cli11
Loading...
Searching...
No Matches
cli11 Module Reference

Concepts

concept  cli::bool_like
 Matches exactly bool, excluding types merely convertible to it.
concept  cli::shared_ptr_like
 Matches std::shared_ptr, with or without top-level const.
concept  cli::copyable_ptr
 Matches pointer-like types that can be copied freely.
concept  cli::adl_detail::lexical_castable
 Matches types with a lexical_cast overload findable by ADL.
concept  cli::detail::pair_valued
 Matches containers whose elements are pair-like.
concept  cli::detail::direct_constructible
 Matches types brace-constructible from C without narrowing.
concept  cli::detail::ostreamable
 Matches types that can be written to an output stream.
concept  cli::detail::istreamable
 Matches types that can be read from an input stream.
concept  cli::detail::complex_like
 Matches complex-number-like types, by their accessors.
concept  cli::detail::mutable_container
 Matches containers that can be cleared and inserted into.
concept  cli::detail::readable_container
 Matches anything that can be iterated over.
concept  cli::detail::wrapper_like
 Matches types with a nested value_type, such as std::optional.
concept  cli::detail::tuple_like
 Matches types usable with std::tuple_size, excluding complex numbers.
concept  cli::detail::string_convertible
 Matches types implicitly convertible to std::string.
concept  cli::detail::string_buildable
 Matches types a std::string can be constructed from.
concept  cli::detail::plain_object
 Matches types with no string conversion and no stream insertion.
concept  cli::detail::wide_string_guard
 Excludes wide-string conversions when classifying narrow strings.
concept  cli::detail::narrow_string_guard
 Excludes narrow-string conversions when classifying wide strings.
concept  cli::detail::uncommon
 Matches types none of the ordinary categories claim.
concept  cli::detail::char_value_like
 Matches types classified as a single character.
concept  cli::detail::integral_value_like
 Matches types classified as a signed integer.
concept  cli::detail::unsigned_integral_like
 Matches types classified as an unsigned integer.
concept  cli::detail::enumeration_like
 Matches types classified as an enumeration.
concept  cli::detail::boolean_value_like
 Matches types classified as a boolean.
concept  cli::detail::floating_point_like
 Matches types classified as floating point.
concept  cli::detail::number_constructible_like
 Matches types constructible from either int or double.
concept  cli::detail::double_constructible_like
 Matches types constructible from double only.
concept  cli::detail::integer_constructible_like
 Matches types constructible from int only.
concept  cli::detail::string_assignable_like
 Matches types assignable from std::string.
concept  cli::detail::string_constructible_like
 Matches types constructible from std::string.
concept  cli::detail::wstring_assignable_like
 Matches types assignable from std::wstring.
concept  cli::detail::wstring_constructible_like
 Matches types constructible from std::wstring.
concept  cli::detail::other_like
 Matches types that fell through every other classification.
concept  cli::detail::wrapper_value_like
 Matches types classified as a wrapper around a nested type.
concept  cli::detail::complex_number_like
 Matches types classified as a complex number.
concept  cli::detail::tuple_value_like
 Matches types classified as a tuple.
concept  cli::detail::container_value_like
 Matches types classified as a container.
concept  cli::detail::text_like
 Matches every string-like category, plus object_category_t::other.
concept  cli::detail::string_like_category
 Matches the four string-like categories as a group.
concept  cli::detail::has_find
 Matches containers offering their own find.

Classes

class  cli::timer_t
 Measures elapsed wall-clock time from construction. More...
class  cli::auto_timer_t
 A timer_t that reports to std::cout when it goes out of scope. More...
struct  cli::detail::split_result_t
 One argument pulled apart into a name and the text following it. More...
struct  cli::detail::option_names_t
 The names extracted from a name specification, sorted by kind. More...
struct  cli::is_member_type_t< T >
 Maps a type to the one used to store it in a member set. More...
struct  cli::is_member_type_t< const char * >
 Stores string literals as std::string. More...
struct  cli::detail::element_type< T >
 The type a pointer-like type points at, or the type itself. More...
struct  cli::detail::element_type< T >
 Unwraps pointer-like types. More...
struct  cli::detail::element_value_type< T >
 The value_type of a container, seen through any pointer. More...
struct  cli::detail::pair_adaptor< T >
 Uniform access to the halves of a container's element. More...
struct  cli::detail::pair_adaptor< T >
 Adapts containers whose elements really are pairs. More...
struct  cli::detail::type_count_base< T >
 How many values a type consumes, ignoring nesting. More...
struct  cli::detail::type_count_base< T >
 Scalars consume one value. More...
struct  cli::detail::wrapped_type< T, def_t >
 The type inside a wrapper, or a supplied default. More...
struct  cli::detail::wrapped_type< T, def_t >
 Unwraps types with a nested value_type. More...
struct  cli::detail::subtype_count< T >
 Value count of a nested type, treating containers as unbounded. More...
struct  cli::detail::subtype_count_min< T >
 Minimum value count of a nested type. More...
struct  cli::detail::type_count< T >
 How many values a type consumes, counting nested elements. More...
struct  cli::detail::type_count< T >
 Plain scalars consume one value. More...
struct  cli::detail::type_count_min< T >
 The minimum number of values a type will accept. More...
struct  cli::detail::type_count_min< T >
 Plain scalars require their full count. More...
struct  cli::detail::expected_count< T >
 How many separate command-line appearances a type expects. More...
struct  cli::detail::expected_count< T >
 Plain types expect a single appearance. More...
struct  cli::detail::classify_object< T >
 Sorts a type into an object_category_t. More...
struct  cli::detail::classify_object< T >
class  cli::formatter_base_t
 Layout settings and labels shared by every formatter. More...
class  cli::formatter_lambda_t
 A formatter that delegates the whole help page to a callable. More...
class  cli::formatter_t
 The default help formatter. More...
class  cli::validator_t
 A composable check applied to one command-line value. More...
class  cli::file_on_default_path_t
 Finds a file relative to a default directory when it is not found as given. More...
class  cli::range_t
 Requires the value to fall within a closed interval. More...
struct  cli::detail::program_name_t
 A command line split into the program and everything after it. More...
class  cli::error_t
 Base of every exception the library throws. More...
class  cli::detail::error_mixin_t< derived_t, base_t >
 Supplies the constructor set every error type shares. More...
class  cli::construction_error_t
 Base of the errors reporting a mistake in how the parser was built. More...
class  cli::incorrect_construction_t
 An option was configured in a way that cannot work. More...
class  cli::bad_name_string_t
 An option, subcommand, or positional name was malformed. More...
class  cli::option_already_added_t
 A name collided with one already registered. More...
class  cli::parse_error_t
 Base of the errors reporting a problem with the command line. More...
class  cli::success_t
 Parsing finished early but successfully; the program should exit cleanly. More...
class  cli::call_for_help_t
 The help flag was given; print help and exit. More...
class  cli::call_for_all_help_t
 The expanded help flag was given; print full help and exit. More...
class  cli::call_for_version_t
 The version flag was given; print the version and exit. More...
class  cli::runtime_error_t
 The program requested a non-zero exit without a parsing problem. More...
class  cli::file_error_t
 A file could not be opened or read. More...
class  cli::conversion_error_t
 A value could not be converted to the option's target type. More...
class  cli::validation_error_t
 A value failed one of the option's validators. More...
class  cli::required_error_t
 A required option or subcommand was not supplied. More...
class  cli::argument_mismatch_t
 An option received the wrong number of values. More...
class  cli::requires_error_t
 An option was used without another it depends on. More...
class  cli::excludes_error_t
 Two mutually exclusive options were used together. More...
class  cli::extras_error_t
 Arguments remained on the command line after parsing finished. More...
class  cli::config_error_t
 A configuration file could not be parsed or applied. More...
class  cli::invalid_error_t
 The parser reached a state it cannot resolve. More...
class  cli::horrible_error_t
 An internal invariant was violated. More...
class  cli::option_not_found_t
 A lookup by name found no matching option. More...
class  cli::option_base_t
 Settings shared by option_t and option_defaults_t. More...
class  cli::option_defaults_t
 The settings newly created options inherit. More...
class  cli::option_t
 One command-line option, flag, or positional argument. More...
class  cli::detail::ipv4_validator_t
 Requires the value to be a legal IPv4 address. More...
class  cli::type_validator_t< desired_t >
 Requires the value to parse as a particular type. More...
class  cli::bound_t
 Clamps the value into a closed interval instead of rejecting it. More...
class  cli::is_member_t
 Requires the value to appear in a set. More...
class  cli::transformer_t
 Rewrites a value through a lookup table, passing unknown values through. More...
class  cli::checked_transformer_t
 Rewrites a value through a lookup table, rejecting unknown values. More...
class  cli::as_number_with_unit_t
 Multiplies a value by a unit factor drawn from a mapping. More...
class  cli::as_size_value_t
 Converts a human-readable size to a byte count. More...
class  cli::detail::permission_validator_t
 Requires the path to exist and carry a given permission. More...
class  cli::file_size_validator_t
 Requires the path to name a file within a size range. More...
class  cli::app_t
 A command-line parser, a subcommand, or an option group. More...
class  cli::option_group_t
 An application specialised for grouping options. More...
struct  cli::detail::app_friend_t
 Grants the test suite access to cli::app_t's protected members. More...
struct  cli::config_item_t
 One entry read from a configuration file. More...
class  cli::config_t
 Interface for converting between an application and a configuration file. More...
class  cli::config_base_t
 A configuration converter for INI and TOML files. More...
class  cli::config_ini_t
 A configuration converter producing standard INI output. More...

Enumerations

enum class  cli::detail::object_category_t : std::uint8_t {
  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 , wstring_assignable = 25 ,
  wstring_constructible = 26 , other = 45 , wrapper_value = 50 , complex_number = 60 ,
  tuple_value = 70 , container_value = 80
}
 The classification buckets a type can fall into. More...
enum class  cli::app_format_mode_t : std::uint8_t { normal , all , sub }
 How much detail a help request wants. More...
enum class  cli::token_t : std::uint8_t { short_ , class_ , return_ , while_ }
 Token kinds. More...
enum class  cli::detail::path_type_t : std::uint8_t { nonexistent , file , directory }
 What a path refers to on disk. More...
enum class  cli::exit_codes_t : int {
  success = 0 , incorrect_construction = 100 , bad_name_string , option_already_added ,
  file_error , conversion_error , validation_error , required_error ,
  requires_error , excludes_error , extras_error , config_error ,
  invalid_error , horrible_error , option_not_found , argument_mismatch ,
  base_class = 127
}
 Process exit codes associated with each error type. More...
enum class  cli::multi_option_policy_t : std::uint8_t {
  reject , take_last , take_first , join ,
  take_all , sum , reverse
}
 What to do when an option is given more values than it expects. More...
enum class  cli::callback_priority_t : std::uint8_t {
  first_pre_help = 0 , first = 1 , pre_requirements_check_pre_help = 2 , pre_requirements_check = 3 ,
  normal_pre_help = 4 , normal = 5 , last_pre_help = 6 , last = 7
}
 When an option's callback runs relative to the others. More...
enum class  cli::detail::permission_t : std::uint8_t { none = 0 , read = 1 , write = 2 , exec = 4 }
 A filesystem permission to check for. More...
enum class  cli::detail::classifier_t : std::uint8_t {
  none , positional_mark , short_ , long_ ,
  windows_style , subcommand , subcommand_terminator
}
 What a single command-line argument looks like. More...
enum class  cli::extras_mode_t : std::uint8_t {
  error = 0 , error_immediately , ignore , assume_single_argument ,
  assume_multiple_arguments , capture
}
 What to do with command-line arguments that match nothing. More...
enum class  cli::config_extras_mode_t : std::uint8_t { error = 0 , ignore , ignore_all , capture }
 What to do with configuration-file entries that match nothing. More...
enum class  cli::prefix_command_mode_t : std::uint8_t { off = 0 , separator_only = 1 , on = 2 }
 When an unrecognised argument should stop parsing entirely. More...
enum class  cli::config_output_mode_t : std::uint8_t { active = 0 , all_defaults , active_subcommand_defaults }
 How much of an application is written out to a configuration file. More...

Typedefs

using cli::custom_validator_t = validator_t
 A validator built from a user-supplied callable.
using cli::results_t = std::vector<std::string>
 The raw strings collected for one option.
using cli::callback_t = std::function<bool(const results_t &)>
 The callback that turns collected results into a bound value.
using cli::option_ptr_t = std::unique_ptr<option_t>
 Owning handle to an option.
using cli::validator_ptr_t = std::shared_ptr<validator_t>
 Shared handle to a validator.
template<typename T>
using cli::transform_pairs_t = std::vector<std::pair<std::string, T>>
 The default mapping type for the transformers.
using cli::app_ptr_t = std::shared_ptr<app_t>
 Shared handle to an application or subcommand.
using cli::config_toml_t = config_base_t
 The default configuration format, which is TOML.

Functions

auto cli::operator<< (std::ostream &in, const timer_t &timer) -> std::ostream &
 Streams a rendered measurement.
auto cli::narrow (const wchar_t *str, std::size_t str_size) -> std::string
 Converts a wide string to a narrow string.
auto cli::narrow (const std::wstring &str) -> std::string
 Converts a wide string to a narrow string.
auto cli::narrow (const wchar_t *str) -> std::string
 Converts a null-terminated wide string to a narrow string.
auto cli::narrow (std::wstring_view str) -> std::string
 Converts a wide string view to a narrow string.
auto cli::widen (const char *str, std::size_t str_size) -> std::wstring
 Converts a narrow string to a wide string.
auto cli::widen (const std::string &str) -> std::wstring
 Converts a narrow string to a wide string.
auto cli::widen (const char *str) -> std::wstring
 Converts a null-terminated narrow string to a wide string.
auto cli::widen (std::string_view str) -> std::wstring
 Converts a narrow string view to a wide string.
auto cli::to_path (std::string_view str) -> std::filesystem::path
 Builds a filesystem path from a narrow string.
auto cli::detail::split_short (const std::string &current) -> std::optional< split_result_t >
 Splits a short-form argument such as -fvalue.
auto cli::detail::split_long (const std::string &current) -> std::optional< split_result_t >
 Splits a long-form argument such as --file=value.
auto cli::detail::split_windows_style (const std::string &current) -> std::optional< split_result_t >
 Splits a Windows-style argument such as /file:value.
auto cli::detail::split_names (std::string current) -> std::vector< std::string >
 Splits a comma-separated name specification, trimming each entry.
auto cli::detail::get_default_flag_values (const std::string &str) -> std::vector< std::pair< std::string, std::string > >
 Extracts the default values written into a flag specification.
auto cli::detail::get_names (const std::vector< std::string > &input, bool allow_non_standard=false) -> option_names_t
 Sorts a name specification into short, long, and positional names.
template<istreamable T>
auto cli::detail::from_stream (const std::string &istring, T &obj) -> bool
 Reads a value from a string using its stream extraction operator.
template<typename T>
requires (!istreamable<T>)
auto cli::detail::from_stream (const std::string &, T &) -> bool
 Fallback for types with no stream extraction operator.
template<string_convertible T>
auto cli::detail::to_string (T &&value) -> decltype(std::forward< T >(value))
 Renders a value already convertible to a string.
template<typename T>
requires (string_buildable<T> && !string_convertible<T>)
auto cli::detail::to_string (T &&value) -> std::string
 Renders a value a string can be built from.
template<typename T>
requires (!string_convertible<T> && !string_buildable<T> && ostreamable<T>)
auto cli::detail::to_string (T &&value) -> std::string
 Renders a value through its stream insertion operator.
template<typename T>
requires (plain_object<T> && tuple_like<T> && type_count_base_v<T> == 1)
auto cli::detail::to_string (T &&value) -> std::string
 Renders a single-element tuple as its one element.
template<typename T>
requires (plain_object<T> && tuple_like<T> && type_count_base_v<T> >= 2)
auto cli::detail::to_string (T &&value) -> std::string
 Renders a multi-element tuple as a bracketed list.
template<typename T>
requires (plain_object<T> && !readable_container<std::remove_const_t<T>> && !tuple_like<T>)
auto cli::detail::to_string (T &&) -> std::string
 Renders anything with no usable representation as an empty string.
template<typename T>
requires (plain_object<T> && readable_container<T> && !tuple_like<T>)
auto cli::detail::to_string (T &&variable) -> std::string
 Renders a container as a bracketed, comma-separated list.
template<typename T, std::size_t I>
requires (I == type_count_base_v<T>)
auto cli::detail::tuple_value_string (T &&) -> std::string
 Terminates the tuple rendering recursion.
template<typename T, std::size_t I>
requires (I < type_count_base_v<T>)
auto cli::detail::tuple_value_string (T &&value) -> std::string
 Renders tuple elements from index I onward.
template<typename lhs_t, typename rhs_t, typename T>
requires std::same_as<lhs_t, rhs_t>
auto cli::detail::checked_to_string (T &&value) -> decltype(to_string(std::forward< T >(value)))
 Renders a value only when two types agree.
template<typename lhs_t, typename rhs_t, typename T>
requires (!std::same_as<lhs_t, rhs_t>)
auto cli::detail::checked_to_string (T &&) -> std::string
 Renders nothing when the two types differ.
template<typename T>
requires std::is_arithmetic_v<T>
auto cli::detail::value_string (const T &value) -> std::string
 Renders an arithmetic value.
template<typename T>
requires std::is_enum_v<T>
auto cli::detail::value_string (const T &value) -> std::string
 Renders an enumerator as its underlying integer.
template<typename T>
requires (!std::is_enum_v<T> && !std::is_arithmetic_v<T>)
auto cli::detail::value_string (const T &value) -> decltype(to_string(value))
 Renders any other value through to_string.
template<typename T, std::size_t I>
requires (I == type_count_base_v<T>)
constexpr auto cli::detail::tuple_type_size () -> int
 Terminates the tuple size recursion.
template<typename T, std::size_t I>
requires (I < type_count_base_v<T>)
constexpr auto cli::detail::tuple_type_size () -> int
 Sums the value counts of tuple elements from index I onward.
template<typename T, std::size_t I>
requires (I == type_count_base_v<T>)
constexpr auto cli::detail::tuple_type_size_min () -> int
 Terminates the minimum tuple size recursion.
template<typename T, std::size_t I>
requires (I < type_count_base_v<T>)
constexpr auto cli::detail::tuple_type_size_min () -> int
 Sums the minimum counts of tuple elements from index I onward.
template<char_value_like T>
constexpr auto cli::detail::type_name () -> const char *
 Returns the name shown for a character option.
template<typename T>
requires (integral_value_like<T> || integer_constructible_like<T>)
constexpr auto cli::detail::type_name () -> const char *
 Returns the name shown for a signed integer option.
template<unsigned_integral_like T>
constexpr auto cli::detail::type_name () -> const char *
 Returns the name shown for an unsigned integer option.
template<typename T>
requires (floating_point_like<T> || number_constructible_like<T> || double_constructible_like<T>)
constexpr auto cli::detail::type_name () -> const char *
 Returns the name shown for a floating-point option.
template<enumeration_like T>
constexpr auto cli::detail::type_name () -> const char *
 Returns the name shown for an enumeration option.
template<boolean_value_like T>
constexpr auto cli::detail::type_name () -> const char *
 Returns the name shown for a boolean option.
template<complex_number_like T>
constexpr auto cli::detail::type_name () -> const char *
 Returns the name shown for a complex-number option.
template<text_like T>
constexpr auto cli::detail::type_name () -> const char *
 Returns the name shown for a textual option.
template<typename T>
requires (tuple_value_like<T> && type_count_base_v<T> >= 2)
auto cli::detail::type_name () -> std::string
 Returns the bracketed name shown for a multi-element tuple option.
template<typename T>
requires (container_value_like<T> || wrapper_value_like<T>)
auto cli::detail::type_name () -> std::string
 Returns the name of the element type of a container or wrapper.
template<typename T>
requires (tuple_value_like<T> && type_count_base_v<T> == 1)
auto cli::detail::type_name () -> std::string
 Returns the name of a single-element tuple's one element.
template<typename T, std::size_t I>
requires (I == type_count_base_v<T>)
auto cli::detail::tuple_name () -> std::string
 Terminates the tuple name recursion.
template<typename T, std::size_t I>
requires (I < type_count_base_v<T>)
auto cli::detail::tuple_name () -> std::string
 Renders the names of tuple elements from index I onward.
template<typename T>
requires std::is_unsigned_v<T>
auto cli::detail::integral_conversion (const std::string &input, T &output) noexcept -> bool
 Parses an unsigned integer, accepting several notations.
template<typename T>
requires std::is_signed_v<T>
auto cli::detail::integral_conversion (const std::string &input, T &output) noexcept -> bool
 Parses a signed integer, accepting several notations.
auto cli::detail::to_flag_value (std::string val) noexcept -> std::int64_t
 Interprets a string as a tri-state flag value.
auto cli::detail::sum_string_vector (const std::vector< std::string > &values) -> std::string
 Sums a list of values, falling back to concatenation.
auto cli::detail::check_path (std::string_view file) noexcept -> path_type_t
 Reports what a path refers to.
template<typename T>
requires std::is_signed_v<T>
auto cli::detail::overflow_check (const T &a, const T &b) -> bool
 Reports whether multiplying two signed values would overflow.
template<typename T>
requires (!std::is_signed_v<T>)
auto cli::detail::overflow_check (const T &a, const T &b) -> bool
 Reports whether multiplying two unsigned values would overflow.
template<typename T>
requires std::is_integral_v<T>
auto cli::detail::checked_multiply (T &a, T b) -> bool
 Multiplies in place, refusing to overflow.
template<typename T>
requires std::is_floating_point_v<T>
auto cli::detail::checked_multiply (T &a, T b) -> bool
 Multiplies in place, refusing to produce an infinity.
auto cli::detail::split_program_name (std::string commandline) -> program_name_t
 Separates the program name from the rest of a command line.
auto cli::detail::convert_arg_for_ini (const std::string &arg, char string_quote='"', char literal_quote = '\'', bool disable_multi_line = false) -> std::string
 Quotes and escapes one value for writing to a configuration file.
auto cli::detail::ini_join (const std::vector< std::string > &args, char sep_char=',', char array_start='[', char array_end=']', char string_quote='"', char literal_quote = '\'') -> std::string
 Joins values into one configuration entry, quoting as needed.
auto cli::detail::generate_parents (const std::string &section, std::string &name, char parent_separator) -> std::vector< std::string >
 Splits a section path and a name into a list of parent sections.
auto cli::detail::check_parent_segments (std::vector< config_item_t > &output, const std::string &current_section, char parent_separator) -> void
 Emits the section transitions needed before a new section.
auto cli::detail::is_printable (const std::string &test_string) -> bool
 Reports whether a string is safe to write unescaped.
auto cli::detail::has_ml_string (const std::string &full_string, char check) -> bool
 Reports whether a line ends with a triple-quote delimiter.
auto cli::detail::find_matching_config (std::vector< config_item_t > &items, const std::vector< std::string > &parents, const std::string &name, bool full_search) -> std::vector< config_item_t >::iterator
 Finds an entry with a given section path and name.
auto cli::clean_name_string (std::string &name, const std::string &key_chars) -> std::string &
 Quotes a name for writing when it contains anything structural.
template<typename T>
requires std::is_enum_v<T>
auto cli::enums::operator<< (std::ostream &in, const T &item) -> std::ostream &
 Streams any enumeration as its underlying integer value.
auto cli::detail::split (const std::string &s, char delim) -> std::vector< std::string >
 Splits a string on a delimiter.
template<typename T>
auto cli::detail::join (const T &v, std::string_view delim=",") -> std::string
 Joins a range into a delimited string.
template<typename T, typename callable_t>
requires (!std::is_constructible_v<std::string, callable_t>)
auto cli::detail::join (const T &v, callable_t func, std::string_view delim=",") -> std::string
 Joins a range into a delimited string, transforming each element.
template<typename T>
auto cli::detail::rjoin (const T &v, std::string_view delim=",") -> std::string
 Joins a range into a delimited string in reverse order.
auto cli::detail::ltrim (std::string &str) -> std::string &
 Removes leading whitespace in place.
constexpr auto cli::detail::ltrim (std::string &str, std::string_view filter) -> std::string &
 Removes leading characters that appear in filter, in place.
auto cli::detail::rtrim (std::string &str) -> std::string &
 Removes trailing whitespace in place.
constexpr auto cli::detail::rtrim (std::string &str, std::string_view filter) -> std::string &
 Removes trailing characters that appear in filter, in place.
auto cli::detail::trim (std::string &str) -> std::string &
 Removes whitespace from both ends, in place.
constexpr auto cli::detail::trim (std::string &str, std::string_view filter) -> std::string &
 Removes characters in filter from both ends, in place.
auto cli::detail::trim_copy (const std::string &str) -> std::string
 Returns a copy with whitespace removed from both ends.
constexpr auto cli::detail::trim_copy (const std::string &str, std::string_view filter) -> std::string
 Returns a copy with characters in filter removed from both ends.
constexpr auto cli::detail::remove_quotes (std::string &str) -> std::string &
 Strips one matched pair of surrounding quotes, in place.
auto cli::detail::fix_newlines (const std::string &leader, std::string input) -> std::string
 Inserts leader after every newline.
auto cli::detail::format_aliases (std::ostream &out, const std::vector< std::string > &aliases, std::size_t wid) -> std::ostream &
 Writes an indented, comma-separated alias list.
template<typename T>
constexpr auto cli::detail::valid_first_char (T c) -> bool
 Tests whether a character may begin an option name.
template<typename T>
constexpr auto cli::detail::valid_later_char (T c) -> bool
 Tests whether a character may appear after the first in an option name.
constexpr auto cli::detail::valid_name_string (const std::string &str) -> bool
 Tests whether a string is a usable option or subcommand name.
constexpr auto cli::detail::valid_alias_name_string (const std::string &str) -> bool
 Tests whether a string is usable as an alias.
constexpr auto cli::detail::is_separator (const std::string &str) -> bool
 Tests whether an argument is a group separator.
auto cli::detail::isalpha (const std::string &str) -> bool
 Tests whether every character is alphabetic in the current locale.
auto cli::detail::to_lower (std::string str) -> std::string
 Returns a lowercased copy, using the current locale.
constexpr auto cli::detail::remove_underscore (std::string str) -> std::string
 Returns a copy with every underscore removed.
auto cli::detail::get_group_separators () -> std::string
 Returns the characters treated as digit-group separators.
constexpr auto cli::detail::find_and_replace (std::string str, std::string_view from, std::string_view to) -> std::string
 Replaces every occurrence of from with to.
constexpr auto cli::detail::has_default_flag_values (const std::string &flags) -> bool
 Tests whether a flag specification carries default values.
constexpr auto cli::detail::remove_default_flag_values (std::string &flags) -> void
 Strips {...} default values and ! negation markers, in place.
auto cli::detail::find_member (std::string name, const std::vector< std::string > &names, bool ignore_case=false, bool ignore_underscore=false) -> std::optional< std::size_t >
 Finds a name in a list, optionally ignoring case and underscores.
template<typename callable_t>
auto cli::detail::find_and_modify (std::string str, std::string_view trigger, callable_t modify) -> std::string
 Repeatedly applies modify at each occurrence of trigger.
constexpr auto cli::detail::has_escapable_character (const std::string &str) -> bool
 Tests whether a string contains a character needing an escape.
constexpr auto cli::detail::add_escaped_characters (const std::string &str) -> std::string
 Returns a copy with backslash escapes applied.
constexpr auto cli::detail::remove_escaped_characters (const std::string &str) -> std::string
 Returns a copy with backslash escapes resolved.
constexpr auto cli::detail::remove_quotes (std::vector< std::string > &args) -> void
 Strips surrounding quotes from every argument, in place.
constexpr auto cli::detail::close_sequence (const std::string &str, std::size_t start, char closure_char) -> std::size_t
 Finds the index closing a quoted or bracketed sequence.
auto cli::detail::split_up (std::string str, char delimiter='\0') -> std::vector< std::string >
 Splits a command line into arguments, respecting quotes and brackets.
constexpr auto cli::detail::escape_detect (std::string &str, std::size_t offset) -> std::size_t
 Neutralises a separator that begins a quoted value.
auto cli::detail::binary_escape_string (const std::string &string_to_escape, bool force=false) -> std::string
 Encodes non-printable characters as a binary-escaped string.
constexpr auto cli::detail::is_binary_escaped_string (const std::string &escaped_string) -> bool
 Tests whether a string carries the binary-escape wrapper.
constexpr auto cli::detail::extract_binary_string (const std::string &escaped_string) -> std::string
 Decodes a binary-escaped string.
constexpr auto cli::detail::process_quoted_string (std::string &str, char string_char='\"', char literal_char = '\'', bool disable_secondary_array_processing = false) -> bool
 Unwraps a quoted, literal, or binary-escaped string in place.
auto cli::detail::get_environment_value (const std::string &env_name) -> std::string
 Reads an environment variable.
auto cli::detail::stream_out_as_paragraph (std::ostream &out, const std::string &text, std::size_t paragraph_width, const std::string &line_prefix="", bool skip_prefix_on_first_line=false) -> std::ostream &
 Writes text word-wrapped to a fixed width, prefixing each line.
template<typename T>
requires copyable_ptr<std::remove_reference_t<T>>
auto cli::detail::smart_deref (T value) -> decltype(*value)
 Dereferences a pointer-like value.
template<typename T>
requires (!copyable_ptr<std::remove_reference_t<T>>)
auto cli::detail::smart_deref (T &value) -> std::remove_reference_t< T > &
 Passes a non-pointer value through unchanged.
template<typename T>
auto cli::detail::generate_set (const T &set) -> std::string
 Renders a set as {a,b,c} for help output.
template<typename T>
auto cli::detail::generate_map (const T &map, bool key_only=false) -> std::string
 Renders a map as {k->v,k->v} for help output.
template<typename T, typename V>
requires (!has_find<T, V>)
auto cli::detail::search (const T &set, const V &val) -> std::pair< bool, decltype(std::begin(detail::smart_deref(set)))>
 Finds a value in a container by scanning it.
template<typename T, typename V>
requires has_find<T, V>
auto cli::detail::search (const T &set, const V &val) -> std::pair< bool, decltype(std::begin(detail::smart_deref(set)))>
 Finds a value in a container using its own find.
template<typename T, typename V>
auto cli::detail::search (const T &set, const V &val, const std::function< V(V)> &filter_function) -> std::pair< bool, decltype(std::begin(detail::smart_deref(set)))>
 Finds a value, comparing through a filter when the direct lookup fails.
auto cli::ignore_case (std::string item) -> std::string
 Filter that makes a comparison case-insensitive.
auto cli::ignore_underscore (std::string item) -> std::string
 Filter that makes a comparison ignore underscores.
auto cli::ignore_space (std::string item) -> std::string
 Filter that makes a comparison ignore spaces and tabs.
auto cli::failure_message::simple (const app_t *app, const error_t &e) -> std::string
 Prints a short one-line error message.
auto cli::failure_message::help (const app_t *app, const error_t &e) -> std::string
 Prints the full help text alongside the error.
template<typename T>
requires (!std::is_integral_v<T> || (sizeof(T) <= 1U))
auto cli::detail::default_flag_modifiers (option_t *opt) -> option_t *
 Applies the default settings for a flag bound to a non-counting type.
template<typename T>
requires (std::is_integral_v<T> && (sizeof(T) > 1U))
auto cli::detail::default_flag_modifiers (option_t *opt) -> option_t *
 Applies the default settings for a flag bound to a counting type.
auto cli::trigger_on (app_t *trigger_app, app_t *app_to_enable) -> void
 Enables one subcommand or option group when another is used.
auto cli::trigger_on (app_t *trigger_app, std::vector< app_t * > apps_to_enable) -> void
 Enables several subcommands or option groups when another is used.
auto cli::trigger_off (app_t *trigger_app, app_t *app_to_enable) -> void
 Disables one subcommand or option group when another is used.
auto cli::trigger_off (app_t *trigger_app, std::vector< app_t * > apps_to_enable) -> void
 Disables several subcommands or option groups when another is used.
auto cli::deprecate_option (option_t *opt, const std::string &replacement="") -> void
 Marks an option as deprecated.
auto cli::deprecate_option (app_t *app, const std::string &option_name, const std::string &replacement="") -> void
 Marks a named option as deprecated.
auto cli::deprecate_option (app_t &app, const std::string &option_name, const std::string &replacement="") -> void
 Marks a named option as deprecated.
auto cli::retire_option (app_t *app, option_t *opt) -> void
 Marks an option as retired.
auto cli::retire_option (app_t &app, option_t *opt) -> void
 Marks an option as retired.
auto cli::retire_option (app_t *app, const std::string &option_name) -> void
 Marks a named option as retired.
auto cli::retire_option (app_t &app, const std::string &option_name) -> void
 Marks a named option as retired.
auto cli::detail::maybe_narrow (const char *str) -> const char *
 Passes a narrow string through unchanged.
auto cli::detail::maybe_narrow (const wchar_t *str) -> std::string
 Narrows a wide string.
auto cli::capture_extras (extras_mode_t mode) -> bool
 Reports whether an extras mode keeps unmatched arguments.

Variables

template<typename T>
constexpr int cli::detail::type_count_base_v = type_count_base<T>::value
 Convenience accessor for type_count_base.
template<typename T>
constexpr int cli::detail::type_count_v = type_count<T>::value
 Convenience accessor for type_count.
template<typename T>
constexpr int cli::detail::type_count_min_v = type_count_min<T>::value
 Convenience accessor for type_count_min.
template<typename T>
constexpr int cli::detail::expected_count_v = expected_count<T>::value
 Convenience accessor for expected_count.
template<typename T>
constexpr object_category_t cli::detail::classify_object_v = classify_object<T>::value
 Convenience accessor for classify_object.
constexpr int cli::version_major = 2
 Major component of the library version.
constexpr int cli::version_minor = 6
 Minor component of the library version.
constexpr int cli::version_patch = 2
 Patch component of the library version.
constexpr std::string_view cli::version = "2.6.2"
 Full library version, formatted as "major.minor.patch".
const validator_t cli::existing_file
 Requires the value to name an existing file.
const validator_t cli::existing_directory
 Requires the value to name an existing directory.
const validator_t cli::existing_path
 Requires the value to name something that exists.
const validator_t cli::nonexistent_path
 Requires the value to name something that does not exist.
const validator_t cli::escaped_string
 Resolves quoting and backslash escapes in the value.
const range_t cli::non_negative_number ((std::numeric_limits< double >::max)(), "NONNEGATIVE")
 Requires the value to be zero or greater.
const range_t cli::positive_number ((std::numeric_limits< double >::min)(),(std::numeric_limits< double >::max)(), "POSITIVE")
 Requires the value to be strictly greater than zero.
constexpr std::string_view cli::multiline_literal_quote = R"(''')"
 Opening and closing delimiter for a multi-line literal string.
constexpr std::string_view cli::multiline_string_quote = R"(""")"
 Opening and closing delimiter for a multi-line escaped string.
constexpr int cli::detail::expected_max_vector_size {1 << 29}
 Upper bound on how many values a vector-like option may consume.
const type_validator_t< double > cli::number ("NUMBER")
 Requires the value to parse as a number.
const detail::ipv4_validator_t cli::valid_ipv4
 Requires the value to be a legal IPv4 address.
const detail::permission_validator_t cli::read_permissions (detail::permission_t::read)
 Requires the path to exist and be readable.
const detail::permission_validator_t cli::write_permissions (detail::permission_t::write)
 Requires the path to exist and be writable.
const detail::permission_validator_t cli::exec_permissions (detail::permission_t::exec)
 Requires the path to exist and be executable.
const file_size_validator_t cli::non_empty_file (1, 0)
 Requires the path to name a file that is not empty.

Single-value conversion

lexical_cast turns one command-line token into one value. There is an overload per object_category_t; exactly one is viable for any given type.

template<typename T>
requires (integral_value_like<T> || unsigned_integral_like<T>)
auto cli::detail::lexical_cast (const std::string &input, T &output) -> bool
 Converts a token to an integer.
template<char_value_like T>
auto cli::detail::lexical_cast (const std::string &input, T &output) -> bool
 Converts a token to a character, accepting a numeric code point.
template<boolean_value_like T>
auto cli::detail::lexical_cast (const std::string &input, T &output) -> bool
 Converts a token to a boolean.
template<floating_point_like T>
auto cli::detail::lexical_cast (const std::string &input, T &output) -> bool
 Converts a token to a floating-point value.
template<complex_number_like T>
auto cli::detail::lexical_cast (const std::string &input, T &output) -> bool
 Converts a token such as "3+4i" to a complex number.
template<string_assignable_like T>
auto cli::detail::lexical_cast (const std::string &input, T &output) -> bool
 Assigns a token directly to a string-assignable type.
template<string_constructible_like T>
auto cli::detail::lexical_cast (const std::string &input, T &output) -> bool
 Constructs a string-constructible type from a token.
template<wstring_assignable_like T>
auto cli::detail::lexical_cast (const std::string &input, T &output) -> bool
 Widens a token and assigns it.
template<wstring_constructible_like T>
auto cli::detail::lexical_cast (const std::string &input, T &output) -> bool
 Widens a token and constructs from it.
template<enumeration_like T>
auto cli::detail::lexical_cast (const std::string &input, T &output) -> bool
 Converts a token to an enumerator via its underlying type.
template<typename T>
requires (wrapper_value_like<T> && std::is_assignable_v<T &, typename T::value_type>)
auto cli::detail::lexical_cast (const std::string &input, T &output) -> bool
 Converts a token into a wrapper by assigning the inner value.
template<typename T>
requires (wrapper_value_like<T> && !std::is_assignable_v<T &, typename T::value_type> && std::is_assignable_v<T &, T>)
auto cli::detail::lexical_cast (const std::string &input, T &output) -> bool
 Converts a token into a wrapper by rebuilding the wrapper.
template<number_constructible_like T>
auto cli::detail::lexical_cast (const std::string &input, T &output) -> bool
 Converts a token to a type constructible from int or double.
template<integer_constructible_like T>
auto cli::detail::lexical_cast (const std::string &input, T &output) -> bool
 Converts a token to a type constructible from int.
template<double_constructible_like T>
auto cli::detail::lexical_cast (const std::string &input, T &output) -> bool
 Converts a token to a type constructible from double.
template<typename T>
requires (other_like<T> && std::is_assignable_v<T &, int>)
auto cli::detail::lexical_cast (const std::string &input, T &output) -> bool
 Converts a token to an unclassified type assignable from int.
template<typename T>
requires (other_like<T> && !std::is_assignable_v<T &, int> && istreamable<T>)
auto cli::detail::lexical_cast (const std::string &input, T &output) -> bool
 Converts a token to an unclassified type using its >> operator.
template<typename T>
requires (other_like<T> && !std::is_assignable_v<T &, int> && !istreamable<T> && !adl_detail::lexical_castable<T>)
auto cli::detail::lexical_cast (const std::string &, T &) -> bool
 Rejects types with no available conversion.

Assignment

lexical_assign converts a token to convert_to_t and then gets that value into an assign_to_t, which is not always the same type.

template<typename assign_to_t, typename convert_to_t>
requires (std::same_as<assign_to_t, convert_to_t> && string_like_category<assign_to_t>)
auto cli::detail::lexical_assign (const std::string &input, assign_to_t &output) -> bool
 Assigns a token to a string-like destination.
template<typename assign_to_t, typename convert_to_t>
requires (std::same_as<assign_to_t, convert_to_t> && std::is_assignable_v<assign_to_t &, assign_to_t> && !string_like_category
<assign_to_t>)
auto cli::detail::lexical_assign (const std::string &input, assign_to_t &output) -> bool
 Assigns a token to a self-assignable destination.
template<typename assign_to_t, typename convert_to_t>
requires (std::same_as<assign_to_t, convert_to_t> && !std::is_assignable_v<assign_to_t &, assign_to_t> && wrapper_value_like
<assign_to_t>)
auto cli::detail::lexical_assign (const std::string &input, assign_to_t &output) -> bool
 Assigns a token to a wrapper that is not self-assignable.
template<typename assign_to_t, typename convert_to_t>
requires (std::same_as<assign_to_t, convert_to_t> && !std::is_assignable_v<assign_to_t &, assign_to_t> && !wrapper_value_like
<assign_to_t> && std::is_assignable_v<assign_to_t &, int>)
auto cli::detail::lexical_assign (const std::string &input, assign_to_t &output) -> bool
 Assigns a token to a destination reachable only through int.
template<typename assign_to_t, typename convert_to_t>
requires (!std::same_as<assign_to_t, convert_to_t> && std::is_assignable_v<assign_to_t &, convert_to_t &>)
auto cli::detail::lexical_assign (const std::string &input, assign_to_t &output) -> bool
 Converts through an intermediate type, then assigns.
template<typename assign_to_t, typename convert_to_t>
requires (!std::same_as<assign_to_t, convert_to_t> && !std::is_assignable_v<assign_to_t &, convert_to_t &> &&
std::is_move_assignable_v<assign_to_t>)
auto cli::detail::lexical_assign (const std::string &input, assign_to_t &output) -> bool
 Converts through an intermediate type, then constructs.

List conversion

lexical_conversion turns a whole list of tokens into one value, distributing them across tuple elements or container entries as needed.

template<typename assign_to_t, typename convert_to_t>
requires (classify_object_v<convert_to_t> <= object_category_t::other && classify_object_v<assign_to_t>
<= object_category_t::wrapper_value)
auto cli::detail::lexical_conversion (const std::vector< std::string > &strings, assign_to_t &output) -> bool
 Converts a single-value type from the first token.
template<typename assign_to_t, typename convert_to_t>
requires ((type_count_v<assign_to_t> <= 2) && expected_count_v<assign_to_t> == 1 && tuple_like<convert_to_t> && type_count_base_v
<convert_to_t> == 2)
auto cli::detail::lexical_conversion (const std::vector< std::string > &strings, assign_to_t &output) -> bool
 Converts a two-element tuple from up to two tokens.
template<typename assign_to_t, typename convert_to_t>
requires (mutable_container<assign_to_t> && mutable_container<convert_to_t> && type_count_v<convert_to_t> == 1)
auto cli::detail::lexical_conversion (const std::vector< std::string > &strings, assign_to_t &output) -> bool
 Converts a container of single-value elements.
template<typename assign_to_t, typename convert_to_t>
requires complex_like<convert_to_t>
auto cli::detail::lexical_conversion (const std::vector< std::string > &strings, assign_to_t &output) -> bool
 Converts a complex number from one or two tokens.
template<typename assign_to_t, typename convert_to_t>
requires (mutable_container<assign_to_t> && (expected_count_v<convert_to_t> == 1) && (type_count_v<convert_to_t> == 1))
auto cli::detail::lexical_conversion (const std::vector< std::string > &strings, assign_to_t &output) -> bool
 Fills a container, one element per token.
template<typename assign_to_t, typename convert_to_t>
requires (mutable_container<assign_to_t> && mutable_container<convert_to_t> && type_count_base_v<convert_to_t> == 2)
auto cli::detail::lexical_conversion (std::vector< std::string > strings, assign_to_t &output) -> bool
 Converts a container of pairs, consuming tokens two at a time.
template<typename assign_to_t, typename convert_to_t>
requires (mutable_container<assign_to_t> && mutable_container<convert_to_t> && type_count_base_v<convert_to_t> != 2 &&
((type_count_v<convert_to_t> > 2) || (type_count_v<convert_to_t> > type_count_base_v<convert_to_t>)))
auto cli::detail::lexical_conversion (const std::vector< std::string > &strings, assign_to_t &output) -> bool
 Converts a container whose elements consume several tokens each.
template<typename assign_to_t, typename convert_to_t>
requires (tuple_like<assign_to_t> && tuple_like<convert_to_t> && (type_count_base_v<convert_to_t> != type_count_v<convert_to_t> ||
type_count_v<convert_to_t> > 2))
auto cli::detail::lexical_conversion (const std::vector< std::string > &strings, assign_to_t &output) -> bool
 Converts a tuple whose elements are themselves compound.
template<typename assign_to_t, typename convert_to_t>
requires (!tuple_like<assign_to_t> && !mutable_container<assign_to_t> && !wrapper_value_like<convert_to_t> && (mutable_container
<convert_to_t> || type_count_v<convert_to_t> > 2))
auto cli::detail::lexical_conversion (const std::vector< std::string > &strings, assign_to_t &output) -> bool
 Converts a compound source into a scalar destination.
template<typename assign_to_t, typename convert_to_t, std::size_t I>
requires (I >= type_count_base_v<assign_to_t>)
auto cli::detail::tuple_conversion (const std::vector< std::string > &, assign_to_t &) -> bool
 Terminates the tuple conversion recursion.
template<typename assign_to_t, typename convert_to_t>
requires (!mutable_container<convert_to_t> && type_count_v<convert_to_t> == 1)
auto cli::detail::tuple_type_conversion (std::vector< std::string > &strings, assign_to_t &output) -> bool
 Consumes one token for a single-value tuple element.
template<typename assign_to_t, typename convert_to_t>
requires (!mutable_container<convert_to_t> && (type_count_v<convert_to_t> > 1) && type_count_v<convert_to_t> == type_count_min_v
<convert_to_t>)
auto cli::detail::tuple_type_conversion (std::vector< std::string > &strings, assign_to_t &output) -> bool
 Consumes a fixed number of tokens for a compound tuple element.
template<typename assign_to_t, typename convert_to_t>
requires (mutable_container<convert_to_t> || type_count_v<convert_to_t> != type_count_min_v<convert_to_t>)
auto cli::detail::tuple_type_conversion (std::vector< std::string > &strings, assign_to_t &output) -> bool
 Consumes a variable number of tokens, stopping at a separator.
template<typename assign_to_t, typename convert_to_t, std::size_t I>
requires (I < type_count_base_v<assign_to_t>)
auto cli::detail::tuple_conversion (std::vector< std::string > strings, assign_to_t &output) -> bool
 Fills tuple element I, then recurses to the next.
template<typename assign_to_t, typename convert_to_t>
requires (wrapper_value_like<convert_to_t> && std::is_assignable_v<convert_to_t &, convert_to_t>)
auto cli::detail::lexical_conversion (const std::vector< std::string > &strings, assign_to_t &output) -> bool
 Converts into a wrapper that can be rebuilt wholesale.
template<typename assign_to_t, typename convert_to_t>
requires (wrapper_value_like<convert_to_t> && !std::is_assignable_v<assign_to_t &, convert_to_t>)
auto cli::detail::lexical_conversion (const std::vector< std::string > &strings, assign_to_t &output) -> bool
 Converts into the value held by a wrapper.

Files

file  /home/mccakit/desktop/repositories/cli11/src/cli11.cpp
file  /home/mccakit/desktop/repositories/cli11/src/app.cpp
 The application type: the parser itself.
file  /home/mccakit/desktop/repositories/cli11/src/argv.cpp
 Recovery of the original command line on Windows.
file  /home/mccakit/desktop/repositories/cli11/src/config.cpp
 Reading and writing configuration files.
file  /home/mccakit/desktop/repositories/cli11/src/config_fwd.cpp
 Declarations for configuration-file readers and writers.
file  /home/mccakit/desktop/repositories/cli11/src/encoding.cpp
 Conversion between narrow and wide character encodings.
file  /home/mccakit/desktop/repositories/cli11/src/error.cpp
 The exception hierarchy thrown by the library.
file  /home/mccakit/desktop/repositories/cli11/src/extra_validators.cpp
 The heavier validators: type checks, set membership, and unit parsing.
file  /home/mccakit/desktop/repositories/cli11/src/formatter.cpp
 Definitions for the default help formatter.
file  /home/mccakit/desktop/repositories/cli11/src/formatter_fwd.cpp
 Declarations for the help formatters.
file  /home/mccakit/desktop/repositories/cli11/src/option.cpp
 The option type: one command-line option and everything set on it.
file  /home/mccakit/desktop/repositories/cli11/src/split.cpp
 Decomposition of command-line arguments and name specifications.
file  /home/mccakit/desktop/repositories/cli11/src/string_tools.cpp
 Low-level string manipulation shared across the library.
file  /home/mccakit/desktop/repositories/cli11/src/timer.cpp
 Small wall-clock timing helpers.
file  /home/mccakit/desktop/repositories/cli11/src/type_tools.cpp
 Type classification and string conversion.
file  /home/mccakit/desktop/repositories/cli11/src/validators.cpp
 The validator type and the built-in validators.
file  /home/mccakit/desktop/repositories/cli11/src/version.cpp
 Compile-time version information for the cli11 library.