25 #include <queso/config_queso.h>
26 #ifndef QUESO_DISABLE_BOOST_PROGRAM_OPTIONS
27 #include <boost/program_options.hpp>
29 #include <queso/BoostInputOptionsParser.h>
30 #include <queso/Miscellaneous.h>
31 #include <queso/Defines.h>
38 m_optionsDescription(new boost::program_options::options_description(
"Input options")),
39 m_optionsMap(new boost::program_options::variables_map()),
40 m_scannedInputFile(false)
48 m_optionsDescription(new boost::program_options::options_description(
"Input options")),
49 m_optionsMap(new boost::program_options::variables_map()),
50 m_scannedInputFile(false)
72 queso_require_msg(
m_optionsMap,
"m_allOptionsMap variable is NULL");
73 boost::program_options::store(
74 boost::program_options::parse_config_file(
87 const T & defaultValue,
88 const std::string & description)
93 boost::program_options::value<T>()->default_value(defaultValue),
99 const std::string & description)
104 description.c_str());
107 template <
typename T>
113 value = (*m_optionsMap)[name].as<T>();
129 std::vector<double> tmpVec(0, 0.0);
130 std::string optionValue;
131 this->getOption<std::string>(name, optionValue);
134 for (
unsigned int i = 0; i < tmpVec.size(); i++) {
135 value.insert((
unsigned int) tmpVec[i]);
142 BoostInputOptionsParser::getOption<std::vector<double, std::allocator<double> > >(
const std::string & name, std::vector<double, std::allocator<double> > & value)
const
145 if (m_scannedInputFile) {
150 std::string optionValue;
151 this->getOption<std::string>(name, optionValue);
164 template void BoostInputOptionsParser::registerOption<int>(
const std::string &,
const int &,
const std::string &);
165 template void BoostInputOptionsParser::registerOption<unsigned int>(
const std::string &,
const unsigned int &,
const std::string &);
167 template void BoostInputOptionsParser::registerOption<double>(
const std::string &,
const double &,
const std::string &);
168 template void BoostInputOptionsParser::registerOption<std::string>(
const std::string &,
const std::string &,
const std::string &);
170 template void BoostInputOptionsParser::getOption<int>(
const std::string&,
int&)
const;
171 template void BoostInputOptionsParser::getOption<unsigned int>(
const std::string&,
unsigned int&)
const;
172 template void BoostInputOptionsParser::getOption<double>(
const std::string&,
double&)
const;
174 template void BoostInputOptionsParser::getOption<std::string>(
const std::string&, std::string&)
const;
175 template void BoostInputOptionsParser::getOption<std::set<unsigned int, std::less<unsigned int>, std::allocator<unsigned int> > >(
const std::string&, std::set<unsigned int, std::less<unsigned int>, std::allocator<unsigned int> >&)
const;
176 template void BoostInputOptionsParser::getOption<std::vector<unsigned int, std::allocator<unsigned int> > >(
const std::string&, std::vector<unsigned int, std::allocator<unsigned int> >&)
const;
177 template void BoostInputOptionsParser::getOption<std::vector<double, std::allocator<double> > >(
const std::string&, std::vector<double, std::allocator<double> >&)
const;
180 #endif // QUESO_DISABLE_BOOST_PROGRAM_OPTIONS
ScopedPtr< boost::program_options::options_description >::Type m_optionsDescription
BoostInputOptionsParser()
Default constructor that sets m_filename to "".
void getOption(const std::string &name, T &value) const
Get option name from the parser and set value to the parsed value.
std::ostream & operator<<(std::ostream &os, const SequenceStatisticalOptions &obj)
virtual ~BoostInputOptionsParser()
Destructor.
void registerOption(const std::string &name, const T &defaultValue, const std::string &description)
Call this to register an option with the parser.
m_parser getOption< bool >(m_option_computeSolution, m_computeSolution)
void scanInputFile()
This is the method that parses the input file.
SfpOptionsValues::SfpOptionsValues() m_parser registerOption< bool >(m_option_computeSolution, UQ_SFP_COMPUTE_SOLUTION_ODV,"compute solution process")
ScopedPtr< boost::program_options::variables_map >::Type m_optionsMap
void MiscReadDoublesFromString(const std::string &inputString, std::vector< double > &outputDoubles)
const std::string m_filename