# # # patch "options.hh" # from [9ca1ad470e21a92ba2c0a0280281c548bb31e013] # to [a1ab6f9b8cd25fcb3338cc78b31d87d9e6df2026] # ============================================================ --- options.hh 9ca1ad470e21a92ba2c0a0280281c548bb31e013 +++ options.hh a1ab6f9b8cd25fcb3338cc78b31d87d9e6df2026 @@ -17,6 +17,7 @@ * as options::. */ +#include #include #include @@ -49,22 +50,30 @@ class enum_string class enum_string { - std::string allowed; + std::vector allowed; + std::string allowed_str; std::string value; public: enum_string() { } - enum_string(std::string const & a) : allowed(a) + enum_string(std::string a) : allowed_str(a) { - size_t x = allowed.find(","); - value = allowed.substr(0, x); + size_t x = a.find(","); + while (x != std::string::npos) + { + allowed.push_back(a.substr(0, x)); + a.erase(0, x + 1); + x = a.find(","); + } + allowed.push_back(a); + I(allowed.size() >= 2); + value = idx(allowed, 0); } void set(std::string const & v) { - if (v.find(",") != std::string::npos - || allowed.find(v) == std::string::npos) + if (std::find(allowed.begin(), allowed.end(), v) == allowed.end()) { throw option::bad_arg_internal((F("must be one of the following: %s") - % allowed).str()); + % allowed_str).str()); } else value = v;