95 lines
1.7 KiB
C++
95 lines
1.7 KiB
C++
/*
|
|
* This file is part of the Owl Positioning System (OwlPS).
|
|
* OwlPS is a project of the University of Franche-Comté
|
|
* (Université de Franche-Comté), France.
|
|
*/
|
|
|
|
|
|
#include "configuration.hh"
|
|
|
|
using namespace std ;
|
|
namespace po = boost::program_options ;
|
|
|
|
|
|
|
|
/* *** Attribute definitions *** */
|
|
|
|
po::variables_map Configuration::configuration ;
|
|
|
|
|
|
|
|
/* *** Read accessors *** */
|
|
|
|
|
|
po::variables_map& Configuration::getw_configuration()
|
|
{
|
|
return configuration ;
|
|
}
|
|
|
|
|
|
bool Configuration::is_configured(const string &key)
|
|
{
|
|
if (configuration.count(key))
|
|
return true ;
|
|
return false ;
|
|
}
|
|
|
|
|
|
const std::string&
|
|
Configuration::string_value(const string &key)
|
|
{
|
|
return configuration[key].as<string>() ;
|
|
}
|
|
|
|
|
|
int Configuration::int_value(const string &key)
|
|
{
|
|
return configuration[key].as<int>() ;
|
|
}
|
|
|
|
|
|
unsigned int Configuration::uint_value(const string &key)
|
|
{
|
|
return configuration[key].as<unsigned int>() ;
|
|
}
|
|
|
|
|
|
float Configuration::float_value(const string &key)
|
|
{
|
|
return configuration[key].as<float>() ;
|
|
}
|
|
|
|
|
|
bool Configuration::bool_value(const string &key)
|
|
{
|
|
return configuration[key].as<bool>() ;
|
|
}
|
|
|
|
|
|
/**
|
|
* @return \em true if the string \em value exists in the vector \em key.
|
|
* @return \em false if \em value is not found in \em key.
|
|
*/
|
|
bool Configuration::
|
|
value_exists_in_string_vector(const string &key, const string &value)
|
|
{
|
|
if (! is_configured(key))
|
|
return false ;
|
|
|
|
vector<string> key_values = configuration[key].as< vector<string> >() ;
|
|
|
|
for (vector<string>::const_iterator i = key_values.begin() ;
|
|
i != key_values.end() ; ++i)
|
|
if (*i == value)
|
|
return true ;
|
|
|
|
return false ;
|
|
}
|
|
|
|
|
|
const vector<string>& Configuration::
|
|
string_vector_value(const string &key)
|
|
{
|
|
return configuration[key].as< vector<string> >() ;
|
|
}
|