CPP-ARGON 4.0.0
Command-Line Argument Parser for C++20
Loading...
Searching...
No Matches
Utility

Helper functions, types, concepts, etc. More...

Concepts

concept  argon::action::util::c_value_action_specifier
 The concept is satisfied when AS is a valid value action action specifier.
 
concept  argon::action::util::c_flag_action_specifier
 The concept is satisfied when AS is a valid on-flag action action specifier.
 
concept  argon::action::util::c_action_specifier
 The concept is satisfied when AS is a valid action action specifier.
 
concept  argon::util::c_is_none
 The concept is satisfied when T is argon::none_type.
 
concept  argon::util::c_readable
 The concept is satisfied when T overloads the std::istream operator >>.
 
concept  argon::util::c_trivially_readable
 The concept is satisfied when T can be constructed from const std::string&.
 
concept  argon::util::c_writable
 The concept is satisfied when T overloads the std::ostream operator <<.
 
concept  argon::util::c_arithmetic
 The concept is satisfied when T is an arithmetic type.
 
concept  argon::util::c_argument_value_type
 The concept is used to verify the validity of the arguments' value types.
 
concept  argon::util::c_one_of
 Validates that T is the same as one of the types defined by Types.
 
concept  argon::util::c_valid_type
 Concept that enforces is_valid_type_v.
 
concept  argon::util::c_range_of
 Validates that R is a range of type T (ignoring the cvref qualifiers).
 
concept  argon::util::c_forward_range_of
 Validates that It is a forward iterator of type T (ignoring the cvref qualifiers).
 
concept  argon::util::c_forward_iterator_of
 Validates that It is a forward iterator of type T (ignoring the cvref qualifiers).
 

Classes

struct  argon::action::util::apply_visitor< T >
 A visitor structure used to apply value actions. More...
 

Typedefs

template<c_value_action_specifier AS, argon::util::c_argument_value_type T>
using argon::action::util::callable_type = typename AS::template type< T >
 Template argument action callable type alias.
 

Enumerations

enum class  argon::util::type_validator : bool { argon::util::type_validator::same , argon::util::type_validator::convertible }
 Specifies the type validation rule. More...
 

Functions

template<typename T >
constexpr auto argon::util::any_range_cast_view (const c_range_of< std::any > auto &range)
 Casts a range of std::any to a range of type T.
 
template<c_writable T>
std::string argon::util::as_string (const T &value) noexcept
 Converts a value to std::string.
 
template<std::ranges::range R>
requires (c_writable<std::ranges::range_value_t<R>>)
std::string argon::util::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 argon::util::get_demangled_type_name ()
 Retrieves the demangled name of a type T.
 

Variables

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

Detailed Description

Helper functions, types, concepts, etc.

Typedef Documentation

◆ callable_type

template<c_value_action_specifier AS, argon::util::c_argument_value_type T>
using argon::action::util::callable_type = typedef typename AS::template type<T>

Template argument action callable type alias.

Definition at line 22 of file helpers.hpp.

Enumeration Type Documentation

◆ type_validator

enum class argon::util::type_validator : bool
strong

Specifies the type validation rule.

Enumerator
same 

Exact type match.

convertible 

Implicit conversion allowed.

Definition at line 82 of file concepts.hpp.

Function Documentation

◆ any_range_cast_view()

template<typename T >
constexpr auto argon::util::any_range_cast_view ( const c_range_of< std::any > auto &  range)
constexpr

Casts a range of std::any to a range of type T.

Template Parameters
TThe target type.
Parameters
rangeThe input range of std::any.
Returns
A view representing the casted range of type T.
Exceptions
std::bad_any_castif any element in the input range cannot be cast to type T.

Definition at line 28 of file ranges.hpp.

◆ as_string()

template<c_writable T>
std::string argon::util::as_string ( const T &  value)
noexcept

Converts a value to std::string.

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

Definition at line 27 of file string.hpp.

◆ get_demangled_type_name()

template<typename T >
constexpr std::string_view argon::util::get_demangled_type_name ( )
constexpr

Retrieves the demangled name of a type T.

Template Parameters
TThe type to retrieve the name for.
Returns
A string view representing the demangled name of type T.
Note
- The function uses compiler-specific macros to extract the type name.
- Supported compilers: GCC, Clang, MSVC.

Definition at line 29 of file typing.hpp.

◆ join()

template<std::ranges::range R>
requires (c_writable<std::ranges::range_value_t<R>>)
std::string argon::util::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.
Examples
/home/runner/work/cpp-argon/cpp-argon/include/argon/argument_parser.hpp.

Definition at line 48 of file string.hpp.

Variable Documentation

◆ is_valid_type_v

template<typename T , typename U , type_validator TV>
constexpr bool argon::util::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 99 of file concepts.hpp.