|
|
@ -45,14 +45,14 @@ Settings::Settings(const int argc, const char* argv[], const char* filename) |
|
|
|
Settings::binaryName = std::string(argv[0]); |
|
|
|
try |
|
|
|
{ |
|
|
|
//! Initially fill description objects and call register callbacks
|
|
|
|
// Initially fill description objects
|
|
|
|
this->initDescriptions(); |
|
|
|
|
|
|
|
//! Take care of positional arguments
|
|
|
|
// Take care of positional arguments
|
|
|
|
Settings::positional.add("trafile", 1); |
|
|
|
Settings::positional.add("labfile", 1); |
|
|
|
|
|
|
|
//! Check module triggers, add corresponding options
|
|
|
|
// Check module triggers, add corresponding options
|
|
|
|
std::map< std::string, std::list< std::string > > options; |
|
|
|
|
|
|
|
for (auto it : Settings::modules) |
|
|
@ -69,10 +69,10 @@ Settings::Settings(const int argc, const char* argv[], const char* filename) |
|
|
|
; |
|
|
|
} |
|
|
|
|
|
|
|
//! Perform first parse run
|
|
|
|
// Perform first parse run
|
|
|
|
this->firstRun(argc, argv, filename); |
|
|
|
|
|
|
|
//! Check module triggers
|
|
|
|
// Check module triggers
|
|
|
|
for (auto it : Settings::modules) |
|
|
|
{ |
|
|
|
std::pair< std::string, std::string > trigger = it.first; |
|
|
@ -87,16 +87,16 @@ Settings::Settings(const int argc, const char* argv[], const char* filename) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//! Stop if help is set
|
|
|
|
// Stop if help is set
|
|
|
|
if ((this->vm.count("help") > 0) || (this->vm.count("help-config") > 0)) |
|
|
|
{ |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
//! Perform second run and call checker callbacks
|
|
|
|
// Perform second run
|
|
|
|
this->secondRun(argc, argv, filename); |
|
|
|
|
|
|
|
//! Finalize parsed options, check for specified requirements
|
|
|
|
// Finalize parsed options, check for specified requirements
|
|
|
|
bpo::notify(this->vm); |
|
|
|
LOG4CPLUS_DEBUG(logger, "Finished loading config."); |
|
|
|
} |
|
|
@ -154,13 +154,11 @@ void Settings::initDescriptions() |
|
|
|
* Perform a sloppy parsing run: parse command line and config file (if |
|
|
|
* given), but allow for unregistered options, do not check requirements |
|
|
|
* from options_description objects, do not check positional arguments. |
|
|
|
* |
|
|
|
* Call all intermediate callbacks afterwards. |
|
|
|
*/ |
|
|
|
void Settings::firstRun(const int argc, const char* argv[], const char* filename) |
|
|
|
{ |
|
|
|
LOG4CPLUS_DEBUG(logger, "Performing first run."); |
|
|
|
//! parse command line
|
|
|
|
// parse command line
|
|
|
|
bpo::store(bpo::command_line_parser(argc, argv).options(*(Settings::desc)).allow_unregistered().run(), this->vm); |
|
|
|
|
|
|
|
/*
|
|
|
@ -180,13 +178,11 @@ void Settings::firstRun(const int argc, const char* argv[], const char* filename |
|
|
|
* Perform the second parser run: parse command line and config file (if |
|
|
|
* given) and check for unregistered options, requirements from |
|
|
|
* options_description objects and positional arguments. |
|
|
|
* |
|
|
|
* Call all checker callbacks afterwards. |
|
|
|
*/ |
|
|
|
void Settings::secondRun(const int argc, const char* argv[], const char* filename) |
|
|
|
{ |
|
|
|
LOG4CPLUS_DEBUG(logger, "Performing second run."); |
|
|
|
//! Parse command line
|
|
|
|
// Parse command line
|
|
|
|
bpo::store(bpo::command_line_parser(argc, argv).options(*(Settings::desc)).positional(this->positional).run(), this->vm); |
|
|
|
/*
|
|
|
|
* load config file if specified |
|
|
|