20#include <boost/algorithm/string.hpp>
21#include <boost/algorithm/string/trim_all.hpp>
42 using boost::algorithm::replace_all;
43 using boost::algorithm::starts_with;
44 using boost::algorithm::is_any_of;
45 using boost::algorithm::trim_fill_if;
71 constexpr char SEP_REPLACED =
'_';
72 constexpr char SEP_REPLACEMENT =
'-';
74 string opt_name(member_id);
78 trim_fill_if(opt_name,
"", is_any_of(
" \f\n\r\t\v"));
83 if (starts_with(opt_name, M_PFX))
85 opt_name.erase(0, M_PFX.size());
89 replace_all(opt_name, CONCAT_REPLACED, CONCAT_OK);
92 replace_all(opt_name,
string(CONCAT_OK) +
string(M_PFX), CONCAT_OK);
95 replace(opt_name.begin(), opt_name.end(), SEP_REPLACED, SEP_REPLACEMENT);
106void validate(boost::any& target,
const std::vector<std::string>& user_strings, path*,
int)
114 using boost::lexical_cast;
115 using boost::bad_lexical_cast;
119 const string& user_string = opts::validators::get_single_string(user_strings);
124 if (!user_string.empty())
131 result_path = lexical_cast<decltype(result_path)>(user_string);
133 catch (
const bad_lexical_cast& exc)
136 (
"Error converting [", user_string,
137 "] to boost::filesystem path. Is there something strange in that string?"));
142 target = result_path;
An std::runtime_error (which is an std::exception) that stores an Error_code.
We may add some ADL-based overloads into this namespace outside flow.
void validate(boost::any &target, const std::vector< std::string > &user_values, path *, int)
ADL-based overload of boost.program_options validate() to allow for empty boost::filesystem::path val...
Short-hand for namespace boost::program_options.
Flow module that facilitates configuring modules, such as applications and APIs, via statically and/o...
std::string value_set_member_id_to_opt_name(util::String_view member_id)
Utility, used by FLOW_CFG_OPTION_SET_DECLARE_OPTION() internally but made available as a public API i...
const boost::regex VALUE_SET_MEMBER_ID_TO_OPT_NAME_KEYED_REGEX
An internal constant for value_set_member_id_to_opt_name_keyed().
std::string ostream_op_string(T const &... ostream_args)
Equivalent to ostream_op_to_string() but returns a new string by value instead of writing to the call...
Basic_string_view< char > String_view
Commonly used char-based Basic_string_view. See its doc header.