CPP-AP 2.7.0
Command-line argument parser for C++20
Loading...
Searching...
No Matches
ap::detail Namespace Reference

Classes

class  argument_base
 Argument class interface. More...
 
class  argument_descriptor
 A structure used to represent an argument's description. More...
 
struct  argument_name
 Structure holding the argument's name. More...
 
struct  argument_token
 Structure representing a single command-line argument token. More...
 
struct  parameter_descriptor
 A structure used to represent an argument's parameter description. More...
 

Concepts

concept  c_readable
 The concept is satisfied when T overloads the std::istream operator >>.
 
concept  c_trivially_readable
 The concept is satisfied when T can be constructed from const std::string&.
 
concept  c_writable
 The concept is satisfied when T overloads the std::ostream operator <<.
 
concept  c_arithmetic
 The concept is satisfied when T is an arithmetic type.
 
concept  c_argument_value_type
 The concept is used to verify the validity of the arguments' value types.
 
concept  c_one_of
 Validates that T is the same as one of the types defined by Types.
 
concept  c_valid_type
 Concept that enforces is_valid_type_v.
 
concept  c_range_of
 Validates that R is a range of type T (ignoring the cvref attributes).
 
concept  c_sized_range_of
 Validates that R is a sized range of type T (ignoring the cvref attributes).
 

Typedefs

template<typename T >
using uptr_opt_t = std::optional< std::reference_wrapper< std::unique_ptr< T > > >
 

Enumerations

enum class  argument_name_discriminator : bool { n_primary , n_secondary }
 Argument name member discriminator. More...
 
enum class  type_validator : bool { same , convertible }
 Specifies the type validation rule. More...
 

Functions

void add_default_argument (const argument::default_positional arg_discriminator, argument_parser &arg_parser) noexcept
 Adds a predefined/default positional argument to the parser.
 
void add_default_argument (const argument::default_optional arg_discriminator, argument_parser &arg_parser) noexcept
 Adds a predefined/default optional argument to the parser.
 
template<c_argument_value_type T>
bool is_valid_choice (const T &value, const std::vector< T > &choices) noexcept
 Checks if the provided choice is valid for the given set of choices.
 
template<c_writable T>
std::string as_string (const T &value) noexcept
 Converts a value to std::string.
 
bool contains_whitespaces (std::string_view str) noexcept
 Checks whether a string contains any whitespace characters.
 
template<std::ranges::range R>
requires (c_writable<std::ranges::range_value_t<R>>)
std::string join (const R &range, const std::string_view delimiter=", ")
 Joins elements of a range into a single string with a delimiter.
 
template<typename T >
constexpr std::string_view get_demangled_type_name ()
 

Variables

template<typename T , typename U , type_validator TV>
constexpr bool is_valid_type_v = false
 Checks if two types satisfy a given type_validator rule.
 

Typedef Documentation

◆ uptr_opt_t

template<typename T >
using ap::detail::uptr_opt_t = typedef std::optional<std::reference_wrapper<std::unique_ptr<T> >>

Definition at line 16 of file typing_utility.hpp.

Enumeration Type Documentation

◆ argument_name_discriminator

enum class ap::detail::argument_name_discriminator : bool
strong

Argument name member discriminator.

This discriminator type is used in the argument initializing methods of the argument_parser class.

Enumerator
n_primary 

Represents the primary name (used with a long flag prefix –).

n_secondary 

Represents the secondary name (used with a short flag prefix –).

Definition at line 144 of file argument_name.hpp.

◆ type_validator

enum class ap::detail::type_validator : bool
strong

Specifies the type validation rule.

Enumerator
same 

Exact type match.

convertible 

Implicit conversion allowed.

Definition at line 63 of file concepts.hpp.

Function Documentation

◆ add_default_argument() [1/2]

void ap::detail::add_default_argument ( const argument::default_optional  arg_discriminator,
argument_parser arg_parser 
)
inlinenoexcept

Adds a predefined/default optional argument to the parser.

Parameters
arg_discriminatorThe default argument discriminator.
arg_parserThe argument parser to which the argument will be added.

Definition at line 1145 of file argument_parser.hpp.

◆ add_default_argument() [2/2]

void ap::detail::add_default_argument ( const argument::default_positional  arg_discriminator,
argument_parser arg_parser 
)
inlinenoexcept

Adds a predefined/default positional argument to the parser.

Parameters
arg_discriminatorThe default argument discriminator.
arg_parserThe argument parser to which the argument will be added.

Definition at line 1124 of file argument_parser.hpp.

◆ as_string()

template<c_writable T>
std::string ap::detail::as_string ( const T &  value)
noexcept

Converts a value to std::string.

Template Parameters
TThe value type (must satisfy the ap::detail::c_writable concept).
Parameters
valueThe value to convert.

Definition at line 26 of file str_utility.hpp.

◆ contains_whitespaces()

bool ap::detail::contains_whitespaces ( std::string_view  str)
inlinenoexcept

Checks whether a string contains any whitespace characters.

Definition at line 33 of file str_utility.hpp.

◆ get_demangled_type_name()

template<typename T >
constexpr std::string_view ap::detail::get_demangled_type_name ( )
constexpr

Definition at line 19 of file typing_utility.hpp.

◆ is_valid_choice()

template<c_argument_value_type T>
bool ap::detail::is_valid_choice ( const T &  value,
const std::vector< T > &  choices 
)
noexcept

Checks if the provided choice is valid for the given set of choices.

Parameters
valueA value, the validity of which is to be checked.
choicesThe set against which the choice validity will be checked.
Returns
true if the choice is valid, false otherwise.
Todo:
replace with std::ranges::contains after transition to C++23

Definition at line 120 of file argument_base.hpp.

◆ join()

template<std::ranges::range R>
requires (c_writable<std::ranges::range_value_t<R>>)
std::string ap::detail::join ( const R &  range,
const std::string_view  delimiter = ", " 
)

Joins elements of a range into a single string with a delimiter.

Template Parameters
RThe type of the value range. The value type of R must satisfy the c_writable concept.
Parameters
rangeThe input range to join.
delimiterThe separator string to insert between elements.
Returns
A single string with all elements joined by the delimiter.
Todo:
Replace with std::views::join after transition to C++23.

Definition at line 47 of file str_utility.hpp.

Variable Documentation

◆ is_valid_type_v

template<typename T , typename U , type_validator TV>
constexpr bool ap::detail::is_valid_type_v = false
inlineconstexpr

Checks if two types satisfy a given type_validator rule.

The primary template of the is_valid_type_v helper variable, which does not perform any logic and defaults to false.

Template Parameters
TThe type to check.
UThe type to check agains.
TVThe validation rule.

Definition at line 79 of file concepts.hpp.