The heavier validators: type checks, set membership, and unit parsing.
More...
import cli11:encoding;
import std;
|
| template<typename T> |
| using | cli::transform_pairs_t = std::vector<std::pair<std::string, T>> |
| | The default mapping type for the transformers.
|
|
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.
|
The heavier validators: type checks, set membership, and unit parsing.
These sit apart from the validators partition because they are templated on the option's type or on a container of allowed values, and because most carry enough machinery to be worth isolating:
Include this partition only if you need them; cli11.cpp re-exports it.
◆ transform_pairs_t
The default mapping type for the transformers.
- Template Parameters
-
◆ permission_t
A filesystem permission to check for.
| Enumerator |
|---|
| none | No permission check.
|
| read | Readable.
|
| write | Writable.
|
| exec | Executable.
|
◆ generate_map()
template<typename T>
| auto cli::detail::generate_map |
( |
const T & | map, |
|
|
bool | key_only = false ) -> std::string |
|
export |
Renders a map as {k->v,k->v} for help output.
- Parameters
-
| map | The map to render. |
| key_only | Render only the keys, omitting the ->value part. |
- Returns
- The rendered map.
◆ generate_set()
template<typename T>
| auto cli::detail::generate_set |
( |
const T & | set | ) |
-> std::string |
|
export |
Renders a set as {a,b,c} for help output.
- Parameters
-
- Returns
- The rendered set.
◆ ignore_case()
| auto cli::ignore_case |
( |
std::string | item | ) |
-> std::string |
|
export |
Filter that makes a comparison case-insensitive.
Pass to cli::is_member_t or one of the transformers.
- Parameters
-
- Returns
- The lowercased value.
◆ ignore_space()
| auto cli::ignore_space |
( |
std::string | item | ) |
-> std::string |
|
export |
Filter that makes a comparison ignore spaces and tabs.
- Parameters
-
- Returns
- The value with spaces and tabs removed.
◆ ignore_underscore()
| auto cli::ignore_underscore |
( |
std::string | item | ) |
-> std::string |
|
export |
Filter that makes a comparison ignore underscores.
- Parameters
-
- Returns
- The value with underscores removed.
◆ search() [1/3]
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)))> |
|
export |
Finds a value in a container using its own find.
- Parameters
-
| set | The container to search. |
| val | The value to look for. |
- Returns
- Whether the value was found, and an iterator to it.
◆ search() [2/3]
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)))> |
|
export |
Finds a value in a container by scanning it.
- Parameters
-
| set | The container to search. |
| val | The value to look for. |
- Returns
- Whether the value was found, and an iterator to it.
◆ search() [3/3]
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)))> |
|
export |
Finds a value, comparing through a filter when the direct lookup fails.
Tries the plain lookup first, since it may be the associative one, and only falls back to scanning with the filter applied to each element.
- Parameters
-
| set | The container to search. |
| val | The value to look for. |
| filter_function | Applied to each element before comparison. |
- Returns
- Whether the value was found, and an iterator to it.
◆ smart_deref() [1/2]
template<typename T>
requires (!copyable_ptr<std::remove_reference_t<T>>)
| auto cli::detail::smart_deref |
( |
T & | value | ) |
-> std::remove_reference_t< T > & |
|
export |
Passes a non-pointer value through unchanged.
- Parameters
-
| value | The value to return. |
- Returns
- A reference to
value.
◆ smart_deref() [2/2]
template<typename T>
requires copyable_ptr<std::remove_reference_t<T>>
| auto cli::detail::smart_deref |
( |
T | value | ) |
-> decltype(*value) |
|
export |
Dereferences a pointer-like value.
Lets the set-membership validators accept either a container or a pointer to one without branching at every use.
- Parameters
-
| value | The pointer to dereference. |
- Returns
- A reference to the pointed-at object.