25 #include <boost/program_options.hpp>
27 #include <queso/BoostInputOptionsParser.h>
28 #include <queso/Miscellaneous.h>
35 m_optionsDescription(new boost::program_options::options_description(
"Input options")),
36 m_optionsMap(new boost::program_options::variables_map()),
37 m_scannedInputFile(false)
44 m_optionsDescription(new boost::program_options::options_description(
"Input options")),
45 m_optionsMap(new boost::program_options::variables_map()),
46 m_scannedInputFile(false)
66 boost::program_options::store(
67 boost::program_options::parse_config_file(
80 std::string description)
84 boost::program_options::value<T>()->default_value(defaultValue),
101 value = (*m_optionsMap)[name].as<T>();
116 std::vector<double> tmpVec(0, 0.0);
117 std::string optionValue;
118 this->getOption<std::string>(name, optionValue);
121 for (
unsigned int i = 0; i < tmpVec.size(); i++) {
122 value.insert((
unsigned int) tmpVec[i]);
129 BoostInputOptionsParser::getOption<std::vector<double, std::allocator<double> > >(std::string & name, std::vector<double, std::allocator<double> > & value)
131 if (m_scannedInputFile) {
136 std::string optionValue;
137 this->getOption<std::string>(name, optionValue);
149 template void BoostInputOptionsParser::registerOption<int>(std::string, int, std::string);
150 template void BoostInputOptionsParser::registerOption<unsigned int>(std::string,
unsigned int, std::string);
151 template void BoostInputOptionsParser::registerOption<bool>(std::string, bool, std::string);
152 template void BoostInputOptionsParser::registerOption<double>(std::string, double, std::string);
153 template void BoostInputOptionsParser::registerOption<std::string>(std::string, std::string, std::string);
155 template void BoostInputOptionsParser::getOption<int>(std::string&,
int&);
156 template void BoostInputOptionsParser::getOption<unsigned int>(std::string&,
unsigned int&);
157 template void BoostInputOptionsParser::getOption<double>(std::string&,
double&);
158 template void BoostInputOptionsParser::getOption<bool>(std::string&,
bool&);
159 template void BoostInputOptionsParser::getOption<std::string>(std::string&, std::string&);
160 template void BoostInputOptionsParser::getOption<std::set<unsigned int, std::less<unsigned int>, std::allocator<unsigned int> > >(std::string&, std::set<unsigned int, std::less<unsigned int>, std::allocator<unsigned int> >&);
161 template void BoostInputOptionsParser::getOption<std::vector<unsigned int, std::allocator<unsigned int> > >(std::string&, std::vector<unsigned int, std::allocator<unsigned int> >&);
162 template void BoostInputOptionsParser::getOption<std::vector<double, std::allocator<double> > >(std::string&, std::vector<double, std::allocator<double> >&);
virtual ~BoostInputOptionsParser()
Destructor.
ScopedPtr< boost::program_options::variables_map >::Type m_optionsMap
std::ostream & operator<<(std::ostream &os, const BaseEnvironment &obj)
void scanInputFile()
This is the method that parses the input file.
#define queso_require_msg(asserted, msg)
const std::string & m_filename
void registerOption(std::string name, T defaultValue, std::string description)
Call this to register an option with the parser.
void MiscReadDoublesFromString(const std::string &inputString, std::vector< double > &outputDoubles)
ScopedPtr< boost::program_options::options_description >::Type m_optionsDescription
BoostInputOptionsParser()
Default constructor that sets m_filename to "".
void getOption(std::string &name, T &value)
Get option name from the parser and set value to the parsed value.