mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-13 16:46:47 +00:00
- fix coverity issues
- clean code and typo in comments
This commit is contained in:
parent
4db91a52eb
commit
b855f77060
|
@ -76,6 +76,21 @@ int FairProgOptions::AddToEnvironmentOptions(const po::options_description& optd
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void FairProgOptions::UseConfigFile(const std::string& filename)
|
||||
{
|
||||
fUseConfigFile = true;
|
||||
if (filename.empty())
|
||||
{
|
||||
fCmdline_options.add_options()
|
||||
("config,c", po::value<std::string>(&fConfigFile)->required(), "Path to configuration file");
|
||||
}
|
||||
else
|
||||
{
|
||||
fConfigFile = filename;
|
||||
}
|
||||
}
|
||||
|
||||
/// //////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// Parser
|
||||
|
||||
|
@ -235,7 +250,7 @@ std::string FairProgOptions::GetStringValue(const std::string& key)
|
|||
}
|
||||
catch(std::exception& e)
|
||||
{
|
||||
MQLOG(ERROR) << "Problem in boost variable map for the key '" << key << "'";
|
||||
MQLOG(ERROR) << "Exception thrown for the key '" << key << "'";
|
||||
MQLOG(ERROR) << e.what();
|
||||
}
|
||||
|
||||
|
@ -243,18 +258,6 @@ std::string FairProgOptions::GetStringValue(const std::string& key)
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
int FairProgOptions::ParseAll(const int argc, char** argv, bool AllowUnregistered)
|
||||
{
|
||||
// //////////////////////////////////
|
||||
// Method to overload.
|
||||
ParseCmdLine(argc,argv,fGenericDesc,fvarmap,AllowUnregistered);
|
||||
PrintOptions();
|
||||
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
|
||||
/// //////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// Print/notify options
|
||||
|
||||
|
|
|
@ -74,39 +74,13 @@ public:
|
|||
int AddToCfgFileOptions(const po::options_description& optdesc, bool visible = true);
|
||||
int AddToEnvironmentOptions(const po::options_description& optdesc);
|
||||
|
||||
void EnableCfgFile(const std::string& filename = "")
|
||||
{
|
||||
fUseConfigFile = true;
|
||||
if (filename.empty())
|
||||
{
|
||||
fCmdline_options.add_options()
|
||||
("config,c", po::value<std::string>(&fConfigFile)->required(), "Path to configuration file");
|
||||
}
|
||||
else
|
||||
{
|
||||
fConfigFile = filename;
|
||||
}
|
||||
}
|
||||
void UseConfigFile(const std::string& filename = "");
|
||||
|
||||
void UseConfigFile(const std::string& filename = "")
|
||||
{
|
||||
fUseConfigFile = true;
|
||||
if (filename.empty())
|
||||
{
|
||||
fCmdline_options.add_options()
|
||||
("config,c", po::value<std::string>(&fConfigFile)->required(), "Path to configuration file");
|
||||
}
|
||||
else
|
||||
{
|
||||
fConfigFile = filename;
|
||||
}
|
||||
}
|
||||
|
||||
// set value corresponding to the key
|
||||
// get value corresponding to the key
|
||||
template<typename T>
|
||||
T GetValue(const std::string& key) const
|
||||
{
|
||||
T val;
|
||||
T val = T();
|
||||
try
|
||||
{
|
||||
if (fvarmap.count(key))
|
||||
|
@ -122,7 +96,7 @@ public:
|
|||
}
|
||||
catch(std::exception& e)
|
||||
{
|
||||
LOG(ERROR) << "Exception thorwn for the key '" << key << "'";
|
||||
LOG(ERROR) << "Exception thrown for the key '" << key << "'";
|
||||
LOG(ERROR) << e.what();
|
||||
this->PrintHelp();
|
||||
}
|
||||
|
@ -132,6 +106,7 @@ public:
|
|||
|
||||
// convert value to string that corresponds to the key
|
||||
std::string GetStringValue(const std::string& key);
|
||||
|
||||
const po::variables_map& GetVarMap() const {return fvarmap;}
|
||||
|
||||
// boost prog options parsers
|
||||
|
@ -172,7 +147,7 @@ protected:
|
|||
std::string fConfigFile;
|
||||
virtual int NotifySwitchOption();
|
||||
|
||||
// UpadateVarMap() and replace() --> to modify the value of variable map after calling po::store
|
||||
// UpadateVarMap() and replace() --> helper functions to modify the value of variable map after calling po::store
|
||||
template<typename T>
|
||||
void UpadateVarMap(const std::string& key, const T& val)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue
Block a user