mirror of
https://github.com/KingDuckZ/dindexer.git
synced 2025-08-12 14:29:50 +00:00
Move ValidationError to commonlib.
This commit is contained in:
parent
986f0c8db3
commit
93a5130cc5
10 changed files with 77 additions and 47 deletions
|
@ -1,4 +1,4 @@
|
|||
project(${bare_name}-delete CXX C)
|
||||
project(${bare_name}-delete CXX)
|
||||
|
||||
add_executable(${PROJECT_NAME}
|
||||
main.cpp
|
||||
|
@ -19,4 +19,3 @@ string(REPLACE "${bare_name}-" "" ACTION_NAME "${PROJECT_NAME}")
|
|||
target_compile_definitions(${PROJECT_NAME}
|
||||
PRIVATE ACTION_NAME="${ACTION_NAME}"
|
||||
)
|
||||
|
||||
|
|
|
@ -25,16 +25,6 @@
|
|||
namespace po = boost::program_options;
|
||||
|
||||
namespace din {
|
||||
ValidationError::ValidationError (const po::validation_error& parOther) :
|
||||
po::validation_error(parOther)
|
||||
{
|
||||
}
|
||||
|
||||
const std::string& ValidationError::raw_value() const {
|
||||
auto it_ret = m_substitutions.find("value");
|
||||
return it_ret->second;
|
||||
}
|
||||
|
||||
bool parse_commandline (int parArgc, char* parArgv[], po::variables_map& parVarMap) {
|
||||
po::options_description set_options(ACTION_NAME " options");
|
||||
set_options.add_options()
|
||||
|
@ -56,7 +46,7 @@ namespace din {
|
|||
po::store(po::command_line_parser(parArgc, parArgv).options(all).positional(pd).run(), parVarMap);
|
||||
}
|
||||
catch (const po::validation_error& err) {
|
||||
throw ValidationError(err);
|
||||
throw dinlib::ValidationError(err);
|
||||
}
|
||||
|
||||
po::notify(parVarMap);
|
||||
|
|
|
@ -18,19 +18,11 @@
|
|||
#ifndef idB6191389C4AD4EE5862CCF1591BE6CE5
|
||||
#define idB6191389C4AD4EE5862CCF1591BE6CE5
|
||||
|
||||
#include <boost/program_options/variables_map.hpp>
|
||||
#include <boost/program_options/errors.hpp>
|
||||
#include "dindexer-common/validationerror.hpp"
|
||||
#include "dindexer-common/mediatypes.hpp"
|
||||
#include <boost/program_options/variables_map.hpp>
|
||||
|
||||
namespace din {
|
||||
class ValidationError : boost::program_options::validation_error {
|
||||
public:
|
||||
explicit ValidationError ( const boost::program_options::validation_error& parOther );
|
||||
~ValidationError ( void ) noexcept = default;
|
||||
|
||||
const std::string& raw_value ( void ) const;
|
||||
};
|
||||
|
||||
bool parse_commandline ( int parArgc, char* parArgv[], boost::program_options::variables_map& parVarMap );
|
||||
} //namespace din
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ int main (int parArgc, char* parArgv[]) {
|
|||
std::cerr << err.what() << "\nUse --help for help" << std::endl;
|
||||
return 2;
|
||||
}
|
||||
catch (const din::ValidationError& err) {
|
||||
catch (const dinlib::ValidationError& err) {
|
||||
std::cerr << "Unrecognized id \"" << err.raw_value() << "\", see --help for usage details\n";
|
||||
return 2;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue