|
template<typename T , enable_if_t<!std::is_integral< T >::value||(sizeof(T)<=1U), detail::enabler > = detail::dummy> |
Option * | default_flag_modifiers (Option *opt) |
| helper functions for adding in appropriate flag modifiers for add_flag
|
|
std::string | convert_arg_for_ini (const std::string &arg, char stringQuote='"', char characterQuote = '\'') |
|
std::string | ini_join (const std::vector< std::string > &args, char sepChar=',', char arrayStart='[', char arrayEnd=']', char stringQuote='"', char characterQuote = '\'') |
| Comma separated join, adds quotes if needed.
|
|
std::vector< std::string > | generate_parents (const std::string §ion, std::string &name, char parentSeparator) |
|
void | checkParentSegments (std::vector< ConfigItem > &output, const std::string ¤tSection, char parentSeparator) |
| assuming non default segments do a check on the close and open of the segments in a configItem structure
|
|
bool | split_short (const std::string ¤t, std::string &name, std::string &rest) |
|
bool | split_long (const std::string ¤t, std::string &name, std::string &value) |
|
bool | split_windows_style (const std::string ¤t, std::string &name, std::string &value) |
|
std::vector< std::string > | split_names (std::string current) |
|
std::vector< std::pair< std::string, std::string > > | get_default_flag_values (const std::string &str) |
| extract default flag values either {def} or starting with a !
|
|
std::tuple< std::vector< std::string >, std::vector< std::string >, std::string > | get_names (const std::vector< std::string > &input) |
| Get a vector of short names, one of long names, and a single name.
|
|
std::vector< std::string > | split (const std::string &s, char delim) |
| Split a string by a delim.
|
|
template<typename T > |
std::string | join (const T &v, std::string delim=",") |
| Simple function to join a string.
|
|
template<typename T , typename Callable , typename = typename std::enable_if<!std::is_constructible<std::string, Callable>::value>::type> |
std::string | join (const T &v, Callable func, std::string delim=",") |
| Simple function to join a string from processed elements.
|
|
template<typename T > |
std::string | rjoin (const T &v, std::string delim=",") |
| Join a string in reverse order.
|
|
std::string & | ltrim (std::string &str) |
| Trim whitespace from left of string.
|
|
std::string & | ltrim (std::string &str, const std::string &filter) |
| Trim anything from left of string.
|
|
std::string & | rtrim (std::string &str) |
| Trim whitespace from right of string.
|
|
std::string & | rtrim (std::string &str, const std::string &filter) |
| Trim anything from right of string.
|
|
std::string & | trim (std::string &str) |
| Trim whitespace from string.
|
|
std::string & | trim (std::string &str, const std::string filter) |
| Trim anything from string.
|
|
std::string | trim_copy (const std::string &str) |
| Make a copy of the string and then trim it.
|
|
std::string & | remove_quotes (std::string &str) |
| remove quotes at the front and back of a string either '"' or '\''
|
|
std::string | fix_newlines (const std::string &leader, std::string input) |
|
std::string | trim_copy (const std::string &str, const std::string &filter) |
| Make a copy of the string and then trim it, any filter string can be used (any char in string is filtered)
|
|
std::ostream & | format_help (std::ostream &out, std::string name, const std::string &description, std::size_t wid) |
| Print a two part "help" string.
|
|
std::ostream & | format_aliases (std::ostream &out, const std::vector< std::string > &aliases, std::size_t wid) |
| Print subcommand aliases.
|
|
template<typename T > |
bool | valid_first_char (T c) |
|
template<typename T > |
bool | valid_later_char (T c) |
| Verify following characters of an option.
|
|
bool | valid_name_string (const std::string &str) |
| Verify an option/subcommand name.
|
|
bool | valid_alias_name_string (const std::string &str) |
| Verify an app name.
|
|
bool | is_separator (const std::string &str) |
| check if a string is a container segment separator (empty or "%%")
|
|
bool | isalpha (const std::string &str) |
| Verify that str consists of letters only.
|
|
std::string | to_lower (std::string str) |
| Return a lower case version of a string.
|
|
std::string | remove_underscore (std::string str) |
| remove underscores from a string
|
|
std::string | find_and_replace (std::string str, std::string from, std::string to) |
| Find and replace a substring with another substring.
|
|
bool | has_default_flag_values (const std::string &flags) |
| check if the flag definitions has possible false flags
|
|
void | remove_default_flag_values (std::string &flags) |
|
std::ptrdiff_t | find_member (std::string name, const std::vector< std::string > names, bool ignore_case=false, bool ignore_underscore=false) |
| Check if a string is a member of a list of strings and optionally ignore case or ignore underscores.
|
|
template<typename Callable > |
std::string | find_and_modify (std::string str, std::string trigger, Callable modify) |
|
| trim (str) |
|
| while (!str.empty()) |
|
template<typename T , enable_if_t< is_istreamable< T >::value, detail::enabler > = detail::dummy> |
bool | from_stream (const std::string &istring, T &obj) |
| Templated operation to get a value from a stream.
|
|
template<typename T , enable_if_t< std::is_convertible< T, std::string >::value, detail::enabler > = detail::dummy> |
auto | to_string (T &&value) -> decltype(std::forward< T >(value)) |
| Convert an object to a string (directly forward if this can become a string)
|
|
template<typename T , enable_if_t< std::is_constructible< std::string, T >::value &&!std::is_convertible< T, std::string >::value, detail::enabler > = detail::dummy> |
std::string | to_string (const T &value) |
| Construct a string from the object.
|
|
template<typename T , enable_if_t<!std::is_convertible< std::string, T >::value &&!std::is_constructible< std::string, T >::value &&is_ostreamable< T >::value, detail::enabler > = detail::dummy> |
std::string | to_string (T &&value) |
| Convert an object to a string (streaming must be supported for that type)
|
|
template<typename T1 , typename T2 , typename T , enable_if_t< std::is_same< T1, T2 >::value, detail::enabler > = detail::dummy> |
auto | checked_to_string (T &&value) -> decltype(to_string(std::forward< T >(value))) |
| special template overload
|
|
template<typename T1 , typename T2 , typename T , enable_if_t<!std::is_same< T1, T2 >::value, detail::enabler > = detail::dummy> |
std::string | checked_to_string (T &&) |
| special template overload
|
|
template<typename T , enable_if_t< std::is_arithmetic< T >::value, detail::enabler > = detail::dummy> |
std::string | value_string (const T &value) |
| get a string as a convertible value for arithmetic types
|
|
template<typename T , enable_if_t<!std::is_enum< T >::value &&!std::is_arithmetic< T >::value, detail::enabler > = detail::dummy> |
auto | value_string (const T &value) -> decltype(to_string(value)) |
| for other types just use the regular to_string function
|
|
template<typename T , std::size_t I> |
constexpr std::enable_if< I==type_count_base< T >::value, int >::type | tuple_type_size () |
| 0 if the index > tuple size
|
|
template<typename T , std::size_t I> |
constexpr std::enable_if< I< type_count_base< T >::value, int >::type tuple_type_size() { return subtype_count< typename std::tuple_element< I, T >::type >::value+tuple_type_size< T, I+1 >();}template< typename T > struct type_count< T, typename std::enable_if< is_tuple_like< T >::value >::type > { static constexpr int value{tuple_type_size< T, 0 >()};};template< typename T > struct subtype_count { static constexpr int value{is_mutable_container< T >::value ? expected_max_vector_size :type_count< T >::value};};template< typename T, typename Enable=void > struct type_count_min { static const int value{0};};template< typename T >struct type_count_min< T, typename std::enable_if<!is_mutable_container< T >::value &&!is_tuple_like< T >::value &&!is_wrapper< T >::value &&!is_complex< T >::value &&!std::is_void< T >::value >::type > { static constexpr int value{type_count< T >::value};};template< typename T > struct type_count_min< T, typename std::enable_if< is_complex< T >::value >::type > { static constexpr int value{1};};template< typename T >struct type_count_min< T, typename std::enable_if< is_wrapper< T >::value &&!is_complex< T >::value &&!is_tuple_like< T >::value >::type > { static constexpr int value{subtype_count_min< typename T::value_type >::value};};template< typename T, std::size_t I >constexpr typename std::enable_if< I==type_count_base< T >::value, int >::type tuple_type_size_min() { return 0;}template< typename T, std::size_t I > constexpr typename std::enable_if< I< type_count_base< T >::value, int >::type tuple_type_size_min() { return subtype_count_min< typename std::tuple_element< I, T >::type >::value+tuple_type_size_min< T, I+1 >();}template< typename T > struct type_count_min< T, typename std::enable_if< is_tuple_like< T >::value >::type > { static constexpr int value{tuple_type_size_min< T, 0 >()};};template< typename T > struct subtype_count_min { static constexpr int value{is_mutable_container< T >::value ?((type_count< T >::value< expected_max_vector_size) ? type_count< T >::value :0) :type_count_min< T >::value};};template< typename T, typename Enable=void > struct expected_count { static const int value{0};};template< typename T >struct expected_count< T, typename std::enable_if<!is_mutable_container< T >::value &&!is_wrapper< T >::value &&!std::is_void< T >::value >::type > { static constexpr int value{1};};template< typename T > struct expected_count< T, typename std::enable_if< is_mutable_container< T >::value >::type > { static constexpr int value{expected_max_vector_size};};template< typename T >struct expected_count< T, typename std::enable_if<!is_mutable_container< T >::value &&is_wrapper< T >::value >::type > { static constexpr int value{expected_count< typename T::value_type >::value};};enum class object_category :int { char_value=1, integral_value=2, unsigned_integral=4, enumeration=6, boolean_value=8, floating_point=10, number_constructible=12, double_constructible=14, integer_constructible=16, string_assignable=23, string_constructible=24, other=45, wrapper_value=50, complex_number=60, tuple_value=70, container_value=80,};template< typename T, typename Enable=void > struct classify_object { static constexpr object_category value{object_category::other};};template< typename T >struct classify_object< T, typename std::enable_if< std::is_integral< T >::value &&!std::is_same< T, char >::value &&std::is_signed< T >::value &&!is_bool< T >::value &&!std::is_enum< T >::value >::type > { static constexpr object_category value{object_category::integral_value};};template< typename T >struct classify_object< T, typename std::enable_if< std::is_integral< T >::value &&std::is_unsigned< T >::value &&!std::is_same< T, char >::value &&!is_bool< T >::value >::type > { static constexpr object_category value{object_category::unsigned_integral};};template< typename T >struct classify_object< T, typename std::enable_if< std::is_same< T, char >::value &&!std::is_enum< T >::value >::type > { static constexpr object_category value{object_category::char_value};};template< typename T > struct classify_object< T, typename std::enable_if< is_bool< T >::value >::type > { static constexpr object_category value{object_category::boolean_value};};template< typename T > struct classify_object< T, typename std::enable_if< std::is_floating_point< T >::value >::type > { static constexpr object_category value{object_category::floating_point};};template< typename T >struct classify_object< T, typename std::enable_if<!std::is_floating_point< T >::value &&!std::is_integral< T >::value &&std::is_assignable< T &, std::string >::value >::type > { static constexpr object_category value{object_category::string_assignable};};template< typename T >struct classify_object< T, typename std::enable_if<!std::is_floating_point< T >::value &&!std::is_integral< T >::value &&!std::is_assignable< T &, std::string >::value &&(type_count< T >::value==1) &&std::is_constructible< T, std::string >::value >::type > { static constexpr object_category value{object_category::string_constructible};};template< typename T > struct classify_object< T, typename std::enable_if< std::is_enum< T >::value >::type > { static constexpr object_category value{object_category::enumeration};};template< typename T > struct classify_object< T, typename std::enable_if< is_complex< T >::value >::type > { static constexpr object_category value{object_category::complex_number};};template< typename T > struct uncommon_type { using type=typename std::conditional<!std::is_floating_point< T >::value &&!std::is_integral< T >::value &&!std::is_assignable< T &, std::string >::value &&!std::is_constructible< T, std::string >::value &&!is_complex< T >::value &&!is_mutable_container< T >::value &&!std::is_enum< T >::value, std::true_type, std::false_type >::type;static constexpr bool value=type::value;};template< typename T >struct classify_object< T, typename std::enable_if<(!is_mutable_container< T >::value &&is_wrapper< T >::value &&!is_tuple_like< T >::value &&uncommon_type< T >::value)>::type > { static constexpr object_category value{object_category::wrapper_value};};template< typename T >struct classify_object< T, typename std::enable_if< uncommon_type< T >::value &&type_count< T >::value==1 &&!is_wrapper< T >::value &&is_direct_constructible< T, double >::value &&is_direct_constructible< T, int >::value >::type > { static constexpr object_category value{object_category::number_constructible};};template< typename T >struct classify_object< T, typename std::enable_if< uncommon_type< T >::value &&type_count< T >::value==1 &&!is_wrapper< T >::value &&!is_direct_constructible< T, double >::value &&is_direct_constructible< T, int >::value >::type > { static constexpr object_category value{object_category::integer_constructible};};template< typename T >struct classify_object< T, typename std::enable_if< uncommon_type< T >::value &&type_count< T >::value==1 &&!is_wrapper< T >::value &&is_direct_constructible< T, double >::value &&!is_direct_constructible< T, int >::value >::type > { static constexpr object_category value{object_category::double_constructible};};template< typename T >struct classify_object< T, typename std::enable_if< is_tuple_like< T >::value &&((type_count< T >::value >=2 &&!is_wrapper< T >::value)||(uncommon_type< T >::value &&!is_direct_constructible< T, double >::value &&!is_direct_constructible< T, int >::value))>::type > { static constexpr object_category value{object_category::tuple_value};};template< typename T > struct classify_object< T, typename std::enable_if< is_mutable_container< T >::value >::type > { static constexpr object_category value{object_category::container_value};};template< typename T, enable_if_t< classify_object< T >::value==object_category::char_value, detail::enabler >=detail::dummy >constexpr const char *type_name() { return "CHAR";}template< typename T, enable_if_t< classify_object< T >::value==object_category::integral_value||classify_object< T >::value==object_category::integer_constructible, detail::enabler >=detail::dummy >constexpr const char *type_name() { return "INT";}template< typename T, enable_if_t< classify_object< T >::value==object_category::unsigned_integral, detail::enabler >=detail::dummy >constexpr const char *type_name() { return "UINT";}template< typename T, enable_if_t< classify_object< T >::value==object_category::floating_point||classify_object< T >::value==object_category::number_constructible||classify_object< T >::value==object_category::double_constructible, detail::enabler >=detail::dummy >constexpr const char *type_name() { return "FLOAT";}template< typename T, enable_if_t< classify_object< T >::value==object_category::enumeration, detail::enabler >=detail::dummy >constexpr const char *type_name() { return "ENUM";}template< typename T, enable_if_t< classify_object< T >::value==object_category::boolean_value, detail::enabler >=detail::dummy >constexpr const char *type_name() { return "BOOLEAN";}template< typename T, enable_if_t< classify_object< T >::value==object_category::complex_number, detail::enabler >=detail::dummy >constexpr const char *type_name() { return "COMPLEX";}template< typename T, enable_if_t< classify_object< T >::value >=object_category::string_assignable &&classify_object< T >::value<=object_category::other, detail::enabler >=detail::dummy >constexpr const char *type_name() { return "TEXT";}template< typename T, enable_if_t< classify_object< T >::value==object_category::tuple_value &&type_count_base< T >::value >=2, detail::enabler >=detail::dummy >std::string type_name();template< typename T, enable_if_t< classify_object< T >::value==object_category::container_value||classify_object< T >::value==object_category::wrapper_value, detail::enabler >=detail::dummy >std::string type_name();template< typename T, enable_if_t< classify_object< T >::value==object_category::tuple_value &&type_count_base< T >::value==1, detail::enabler >=detail::dummy >inline std::string type_name() { return type_name< typename std::decay< typename std::tuple_element< 0, T >::type >::type >();}template< typename T, std::size_t I >inline typename std::enable_if< I==type_count_base< T >::value, std::string >::type tuple_name() { return std::string{};}template< typename T, std::size_t I >inline typename std::enable_if<(I< type_count_base< T >::value), std::string >::type tuple_name() { std::string str=std::string(type_name< typename std::decay< typename std::tuple_element< I, T >::type >::type >())+','+tuple_name< T, I+1 >();if(str.back()==',') str.pop_back();return str;}template< typename T, enable_if_t< classify_object< T >::value==object_category::tuple_value &&type_count_base< T >::value >=2, detail::enabler > >inline std::string type_name() { auto tname=std::string(1, '[')+tuple_name< T, 0 >();tname.push_back(']');return tname;}template< typename T, enable_if_t< classify_object< T >::value==object_category::container_value||classify_object< T >::value==object_category::wrapper_value, detail::enabler > >inline std::string type_name() { return type_name< typename T::value_type >();}template< typename T, enable_if_t< std::is_unsigned< T >::value, detail::enabler >=detail::dummy >bool integral_conversion(const std::string &input, T &output) noexcept { if(input.empty()) { return false;} char *val=nullptr;std::uint64_t output_ll=std::strtoull(input.c_str(), &val, 0);output=static_cast< T >(output_ll);if(val==(input.c_str()+input.size()) &&static_cast< std::uint64_t >(output)==output_ll) { return true;} val=nullptr;std::int64_t output_sll=std::strtoll(input.c_str(), &val, 0);if(val==(input.c_str()+input.size())) { output=(output_sll< 0) ? static_cast< T >(0) | return (static_cast< std::int64_t >(output)==output_sll) |
| Recursively generate the tuple type name.
|
|
template<typename T , enable_if_t< std::is_signed< T >::value, detail::enabler > = detail::dummy> |
bool | integral_conversion (const std::string &input, T &output) noexcept |
| Convert to a signed integral.
|
|
std::int64_t | to_flag_value (std::string val) |
| Convert a flag into an integer value typically binary flags.
|
|
template<typename T , enable_if_t< classify_object< T >::value==object_category::integral_value||classify_object< T >::value==object_category::unsigned_integral, detail::enabler > = detail::dummy> |
bool | lexical_cast (const std::string &input, T &output) |
| Integer conversion.
|
|
template<typename AssignTo , typename ConvertTo , enable_if_t< std::is_same< AssignTo, ConvertTo >::value &&(classify_object< AssignTo >::value==object_category::string_assignable||classify_object< AssignTo >::value==object_category::string_constructible), detail::enabler > = detail::dummy> |
bool | lexical_assign (const std::string &input, AssignTo &output) |
| Assign a value through lexical cast operations.
|
|
path_type | check_path (const char *file) noexcept |
| get the type of the path from a file name
|
|
template<typename T , enable_if_t< is_copyable_ptr< typename std::remove_reference< T >::type >::value, detail::enabler > = detail::dummy> |
auto | smart_deref (T value) -> decltype(*value) |
|
template<typename T , enable_if_t<!is_copyable_ptr< typename std::remove_reference< T >::type >::value, detail::enabler > = detail::dummy> |
std::remove_reference< T >::type & | smart_deref (T &value) |
|
template<typename T > |
std::string | generate_set (const T &set) |
| Generate a string representation of a set.
|
|
template<typename T > |
std::string | generate_map (const T &map, bool key_only=false) |
| Generate a string representation of a map.
|
|
template<typename T , typename V , enable_if_t<!has_find< T, V >::value, detail::enabler > = detail::dummy> |
auto | search (const T &set, const V &val) -> std::pair< bool, decltype(std::begin(detail::smart_deref(set)))> |
| A search function.
|
|
template<typename T , typename V > |
auto | search (const T &set, const V &val, const std::function< V(V)> &filter_function) -> std::pair< bool, decltype(std::begin(detail::smart_deref(set)))> |
| A search function with a filter function.
|
|
template<typename T > |
std::enable_if< std::is_signed< T >::value, T >::type | overflowCheck (const T &a, const T &b) |
| Do a check for overflow on signed numbers.
|
|
template<typename T > |
std::enable_if<!std::is_signed< T >::value, T >::type | overflowCheck (const T &a, const T &b) |
| Do a check for overflow on unsigned numbers.
|
|
template<typename T > |
std::enable_if< std::is_integral< T >::value, bool >::type | checked_multiply (T &a, T b) |
| Performs a *= b; if it doesn't cause integer overflow. Returns false otherwise.
|
|
template<typename T > |
std::enable_if< std::is_floating_point< T >::value, bool >::type | checked_multiply (T &a, T b) |
| Performs a *= b; if it doesn't equal infinity. Returns false otherwise.
|
|
std::pair< std::string, std::string > | split_program_name (std::string commandline) |
|