6 #ifndef BASE_OPTIONS_UTIL_H_
7 #define BASE_OPTIONS_UTIL_H_
14 #include <boost/program_options.hpp>
20 template <
typename ElementType>
22 const boost::program_options::variables_map &var_map,
23 std::vector<ElementType> &var,
const std::string &val,
24 std::vector<ElementType>*,
bool if_not_defaulted) {
26 if (var_map.count(val) && (!if_not_defaulted ||
27 (if_not_defaulted && !var_map[val].defaulted()))) {
28 std::vector<ElementType> tmp(
29 var_map[val].as<std::vector<ElementType> >());
31 for (
typename std::vector<ElementType>::const_iterator it =
33 it != tmp.end(); it++) {
34 std::stringstream ss(*it);
35 std::copy(std::istream_iterator<ElementType>(ss),
36 std::istream_iterator<ElementType>(),
37 std::back_inserter(var));
44 template <
typename ValueType>
46 const boost::program_options::variables_map &var_map,
48 bool if_not_defaulted) {
50 if (var_map.count(val) && (!if_not_defaulted ||
51 (if_not_defaulted && !var_map[val].defaulted()))) {
58 template <
typename ValueType>
59 bool GetOptValue(
const boost::program_options::variables_map &var_map,
65 template <
typename ValueType>
67 const boost::program_options::variables_map &var_map,
bool GetOptValue(const boost::program_options::variables_map &var_map, ValueType &var, const std::string &val)
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)