5 #ifndef BASE_OPTIONS_UTIL_H_
6 #define BASE_OPTIONS_UTIL_H_
13 #include <boost/program_options.hpp>
19 template <
typename ElementType>
21 const boost::program_options::variables_map &var_map,
22 std::vector<ElementType> &var,
const std::string &val,
23 std::vector<ElementType>*,
bool if_not_defaulted) {
25 if (var_map.count(val) && (!if_not_defaulted ||
26 (if_not_defaulted && !var_map[val].defaulted()))) {
27 std::vector<ElementType> tmp(
28 var_map[val].as<std::vector<ElementType> >());
30 for (
typename std::vector<ElementType>::const_iterator it =
32 it != tmp.end(); it++) {
33 std::stringstream ss(*it);
34 std::copy(std::istream_iterator<ElementType>(ss),
35 std::istream_iterator<ElementType>(),
36 std::back_inserter(var));
43 template <
typename ValueType>
45 const boost::program_options::variables_map &var_map,
47 bool if_not_defaulted) {
49 if (var_map.count(val) && (!if_not_defaulted ||
50 (if_not_defaulted && !var_map[val].defaulted()))) {
57 template <
typename ValueType>
58 bool GetOptValue(
const boost::program_options::variables_map &var_map,
64 template <
typename ValueType>
66 const boost::program_options::variables_map &var_map,
75 #endif // BASE_OPTIONS_UTIL_H_
bool GetOptValueImpl(const boost::program_options::variables_map &var_map, std::vector< ElementType > &var, const std::string &val, std::vector< ElementType > *, bool if_not_defaulted)
bool GetOptValueIfNotDefaulted(const boost::program_options::variables_map &var_map, ValueType &var, const std::string &val)
bool GetOptValue(const boost::program_options::variables_map &var_map, ValueType &var, const std::string &val)