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