20#include <boost/algorithm/string.hpp>
21#include <boost/algorithm/string/trim_all.hpp>
45 using boost::algorithm::replace_all;
46 using boost::algorithm::starts_with;
47 using boost::algorithm::is_any_of;
48 using boost::algorithm::trim_fill_if;
75 constexpr char SEP_REPLACED =
'_';
78 string opt_name{member_id};
82 trim_fill_if(opt_name,
"", is_any_of(
" \f\n\r\t\v"));
87 if (starts_with(opt_name, M_PFX))
89 opt_name.erase(0, M_PFX.size());
93 replace_all(opt_name, CONCAT_REPLACED, CONCAT_OK);
96 replace_all(opt_name,
string{CONCAT_OK} +
string{M_PFX}, CONCAT_OK);
99 if (sep_replacement != SEP_REPLACED)
101 replace(opt_name.begin(), opt_name.end(), SEP_REPLACED, sep_replacement);
113void validate(boost::any& target,
const std::vector<std::string>& user_strings, path*,
int)
121 using boost::lexical_cast;
122 using boost::bad_lexical_cast;
126 const string& user_string = opts::validators::get_single_string(user_strings);
131 if (!user_string.empty())
138 result_path = lexical_cast<decltype(result_path)>(user_string);
140 catch (
const bad_lexical_cast& exc)
143 (
"Error converting [", user_string,
144 "] to boost::filesystem path. Is there something strange in that string?")};
149 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, char sep_replacement='-')
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 &&... 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.