cli20 0.1.2
A C++20 typed-schema command-line parser
Loading...
Searching...
No Matches
cli::conversion Namespace Reference

Actions that convert a raw std::string_view token to a typed value. More...

Classes

struct  Integer
 Converts a string token to an integral type T using std::from_chars. More...
struct  Floating
 Converts a string token to a floating-point type T using std::from_chars. More...
struct  String
 Converts a string_view token to a std::string by copying. More...
struct  Bool
 Converts a string token to bool. More...
struct  Path
 Converts a string token to std::filesystem::path without filesystem validation. More...
struct  ExistingFile
 Converts a string token to std::filesystem::path, requiring the path to exist and be a regular file. More...
struct  ExistingDirectory
 Converts a string token to std::filesystem::path, requiring the path to exist and be a directory. More...
struct  Choice
 Converts a string token to type T via a user-supplied mapper function. More...
struct  NegatableResult
 Result of the negatable<> conversion. More...
struct  Negatable
 Converts a string token to NegatableResult by detecting a compile-time negation prefix. More...
struct  DefaultMissingValue
 Injects a compile-time default value when an option is invoked as a flag (no value provided). More...

Typedefs

template<class T, auto Mapper>
using Enumeration = Choice<T, Mapper>

Functions

template<std::size_t I>
auto get (NegatableResult &r) -> decltype(auto)
template<std::size_t I>
auto get (const NegatableResult &r) -> decltype(auto)

Variables

template<std::integral T>
constexpr auto integer = Action<Integer<T>{}>{}
template<std::floating_point T>
constexpr auto floating = Action<Floating<T>{}>{}
template<class T, auto Mapper>
constexpr auto choice = Action<Choice<T, Mapper>{}>{}
template<class T, auto Mapper>
constexpr auto enumeration = Action<Enumeration<T, Mapper>{}>{}
template<StringLiteral Prefix>
constexpr auto negatable = Action<Negatable<Prefix>{}>{}
constexpr auto string = Action<String{}>{}
constexpr auto boolean = Action<Bool{}>{}
constexpr auto path = Action<Path{}>{}
constexpr auto existing_file = Action<ExistingFile{}>{}
constexpr auto existing_directory = Action<ExistingDirectory{}>{}
template<StringLiteral Value>
constexpr auto default_missing_value

Detailed Description

Actions that convert a raw std::string_view token to a typed value.

Each action in this namespace transforms the pipeline value from a string representation into a specific C++ type. They are typically placed first in an action pipeline, before validation and pack actions.

Example:

constexpr auto my_action = cli::conversion::integer<int> |
constexpr auto integer
Definition action.hh:921
constexpr auto set_once
Definition action.hh:1877

Typedef Documentation

◆ Enumeration

template<class T, auto Mapper>
using cli::conversion::Enumeration = Choice<T, Mapper>

Definition at line 918 of file action.hh.

Function Documentation

◆ get() [1/2]

template<std::size_t I>
auto cli::conversion::get ( const NegatableResult & r) -> decltype(auto)

Definition at line 2036 of file action.hh.

◆ get() [2/2]

template<std::size_t I>
auto cli::conversion::get ( NegatableResult & r) -> decltype(auto)

Definition at line 2028 of file action.hh.

Variable Documentation

◆ boolean

auto cli::conversion::boolean = Action<Bool{}>{}
inlineconstexpr

Definition at line 979 of file action.hh.

◆ choice

template<class T, auto Mapper>
auto cli::conversion::choice = Action<Choice<T, Mapper>{}>{}
inlineconstexpr

Definition at line 925 of file action.hh.

◆ default_missing_value

template<StringLiteral Value>
auto cli::conversion::default_missing_value
inlineconstexpr
Initial value:
=
A compile-time pipeline of action functions applied sequentially to a parsed token.
Definition action.hh:450

Definition at line 1028 of file action.hh.

◆ enumeration

template<class T, auto Mapper>
auto cli::conversion::enumeration = Action<Enumeration<T, Mapper>{}>{}
inlineconstexpr

Definition at line 927 of file action.hh.

◆ existing_directory

auto cli::conversion::existing_directory = Action<ExistingDirectory{}>{}
inlineconstexpr

Definition at line 982 of file action.hh.

◆ existing_file

auto cli::conversion::existing_file = Action<ExistingFile{}>{}
inlineconstexpr

Definition at line 981 of file action.hh.

◆ floating

template<std::floating_point T>
auto cli::conversion::floating = Action<Floating<T>{}>{}
inlineconstexpr

Definition at line 923 of file action.hh.

◆ integer

template<std::integral T>
auto cli::conversion::integer = Action<Integer<T>{}>{}
inlineconstexpr

Definition at line 921 of file action.hh.

◆ negatable

template<StringLiteral Prefix>
auto cli::conversion::negatable = Action<Negatable<Prefix>{}>{}
inlineconstexpr

Definition at line 977 of file action.hh.

◆ path

auto cli::conversion::path = Action<Path{}>{}
inlineconstexpr

Definition at line 980 of file action.hh.

◆ string

auto cli::conversion::string = Action<String{}>{}
inlineconstexpr

Definition at line 978 of file action.hh.