arg_router
1.4.0
C++ command line argument parsing and routing
|
Classes | |
class | dynamic_token_adapter |
class | parse_target |
class | pre_parse_data_base |
class | pre_parse_data |
class | pre_parse_data< Validator, false > |
class | pre_parse_data< Validator, true > |
struct | token_type |
Typedefs | |
using | pre_parse_result = utility::result< pre_parse_action, multi_lang_exception > |
Enumerations | |
enum class | pre_parse_action : std::uint8_t { skip_node , valid_node , skip_node_but_use_sub_targets } |
enum class | prefix_type : std::uint8_t { } |
Functions | |
template<typename T > | |
constexpr bool | match (token_type token) noexcept |
template<typename Node > | |
constexpr token_type | node_token_type () noexcept |
template<typename BaseNode , typename... DerivedAndParents> | |
constexpr auto | clean_node_ancestry_list (const BaseNode &base_node, const DerivedAndParents &... derived_and_parents) |
template<typename Node , typename... Parents> | |
bool | is_runtime_disabled (const Node &node, const Parents &... parents) noexcept |
constexpr std::string_view | to_string (prefix_type prefix) noexcept |
string | to_string (const token_type &token) |
string | to_string (const vector< token_type > &view) |
token_type | get_token_type (std::string_view token) |
template<typename Node > | |
token_type | get_token_type ([[maybe_unused]] const Node &node, std::string_view token) |
template<typename Node > | |
void | unknown_argument_exception (const Node &node, token_type unknown_token) |
Namespace containing types and functions to aid parsing.
using arg_router::parsing::pre_parse_result = typedef utility::result<pre_parse_action, multi_lang_exception> |
Policy-level pre-parse phase result type.
Definition at line 27 of file parsing.hpp.
|
strong |
Owning nodes requested action by a pre-parse implementing policy.
Definition at line 15 of file parsing.hpp.
|
strong |
Enum for the prefix type on a token.
Enumerator | |
---|---|
short_ | Long prefix. |
none | Short prefix. No prefix |
Definition at line 13 of file token_type.hpp.
|
constexpr |
Remove the leading entries from the node ancestry list that are derived from BaseNode.
To allow derived types to call the inherited implementations of the pre-parse and parse stages, we need to clean the multiple leading *this
references that each parent method call will add. Due to the use of policies we can almost guarantee that OOP parents will not be confused with structural parents (i.e. parents in the tree). It is an almost guarantee because someone could create a custom node that allows for identical policies to it's tree parent and then not define a validator rule to prevent this - but I'd consider that to have bigger problems...
This method is used in tree_node, so anything derived from that that uses its inherited pre-parse and parse methods will not need to use this function.
BaseNode | Base node type to be used to find derived types in derived_and_parents |
DerivedAndParents | Pack of (possibly) derived types in descending OOP ancestry order, and then parent tree nodes in ascending ancestry order |
base_node | Base node instance |
derived_and_parents | Derived type and parent node instances |
std::reference_wrapper
Definition at line 105 of file parsing.hpp.
|
inline |
Overload that uses the naming policies of node to control the output.
If the target node is available, this should be the preferred overload.
Node | Target node type |
node | Node instance |
token | Token to analyse |
Definition at line 127 of file token_type.hpp.
|
inline |
Analyse token and return a pair consisting of the prefix type and token stripped of the token.
token | Token to analyse |
Definition at line 103 of file token_type.hpp.
|
noexcept |
Returns true if node or any of its parents are marked as runtime disabled.
Node | Current node type |
Parents | Parent nodes' type |
node | Current node instance |
parents | Parent nodes of node |
Definition at line 133 of file parsing.hpp.
|
constexprnoexcept |
Matches token to T by comparing the token against the long, short, or none name traits.
T | Type providing the long, short, or none name methods |
token | The token to match against |
Definition at line 36 of file parsing.hpp.
|
constexprnoexcept |
Returns the token_type of Node, the long form name is preferred if Node has both short and long form names.
Node | Node type |
Definition at line 68 of file parsing.hpp.
|
inline |
Creates a string representation of token, it effectively recreates the original token on the command line.
token | Token to convert |
Definition at line 74 of file token_type.hpp.
|
inline |
Creates a string representation of view.
view | Processed tokens to convert |
Definition at line 85 of file token_type.hpp.
|
constexprnoexcept |
Creates a string version of prefix.
This uses config::long_prefix and config::short_prefix.
prefix | Prefix type to convert |
Definition at line 25 of file token_type.hpp.
void arg_router::parsing::unknown_argument_exception | ( | const Node & | node, |
token_type | unknown_token | ||
) |
Throws a multi_lang_exception with either a error_code::unknown_argument or a error_code::unknown_argument_with_suggestion if the data is available.
Node | Node type throwing the exception |
node | Node throwing the exception, used as a source for the utility::utf8::closest_matching_child_node(const Node& node, parsing::token_type token) |
unknown_token | The token that caused the exception to be thrown |
Definition at line 20 of file unknown_argument_handling.hpp.