24 for(
size_t idx = 1; idx < size_t(argc); ++idx)
29 if(key !=
"")
_map[key] = val;
32 else _map[val] = std::string(
"true");
38 inline std::vector<std::string>
validate(
const std::set<std::string>& keywords)
const
40 std::vector<std::string> err;
42 if(!keywords.contains(key.first)) err.push_back(key.first);
47 template<
typename RET>
48 inline RET
get(
const std::string& key)
const
50 if(
_map.contains(key))
return bbm::fromString<RET>(
_map.at(key) );
51 else throw std::runtime_error(std::string(
"Missing required option ") + key);
55 template<
typename RET>
58 if(
_map.contains(key))
return bbm::fromString<RET>(
_map.at(key) );
63 std::map<std::string, std::string>
_map;
concept to check if a type has a valid string_converter.
std::pair< std::string, std::string > split_eq(const std::string &str)
split a string of the form "key = val" in key and value. If no '=', then return an empty key.
Definition: string_util.h:77
Definition: aggregatebsdf.h:29
constexpr auto default_value(T)
Definition: bsdf_attribute.h:37
Helper method for processing strings.
std::map< std::string, std::string > _map
Definition: option.h:63
RET get(const std::string &key, const RET &default_value) const
retrieve an option
Definition: option.h:56
RET get(const std::string &key) const
retrieve an option
Definition: option.h:48
option_parser(int argc, char **argv)
Parse the options from the commandline arguments (argc,argv)
Definition: option.h:22
std::vector< std::string > validate(const std::set< std::string > &keywords) const
check keys in the options are in the set keywords.
Definition: option.h:38