arg_router  1.4.0
C++ command line argument parsing and routing
arg_router::parsing::parse_target Class Reference

#include <arg_router/parsing/parse_target.hpp>

Public Member Functions

template<typename Node , typename... Parents>
 parse_target (vector< token_type > tokens, const Node &node, const Parents &... parents) noexcept
 
template<typename Node , typename... Parents>
 parse_target (const Node &node, const Parents &... parents) noexcept
 
vector< token_type > & tokens () noexcept
 
const vector< token_type > & tokens () const noexcept
 
vector< parse_target > & sub_targets () noexcept
 
const vector< parse_target > & sub_targets () const noexcept
 
 operator bool () const noexcept
 
std::size_t node_type () const noexcept
 
void add_sub_target (parse_target target)
 
void tokens (vector< token_type > tokens)
 
utility::unsafe_any operator() ()
 

Detailed Description

A parse target i.e. a target node optionally with tokens for parsing.

This type is the result of a pre-parse phase, and is used to trigger a parse of the given tokens (optional) on the target node. Sub-targets can also be attached allowing a node to trigger the parse of other nodes e.g. mode-like types.

The target can only be invoked once, invoking a second or more time is a no-op.

Definition at line 28 of file parse_target.hpp.

Constructor & Destructor Documentation

◆ parse_target() [1/2]

template<typename Node , typename... Parents>
arg_router::parsing::parse_target::parse_target ( vector< token_type tokens,
const Node &  node,
const Parents &...  parents 
)
inlinenoexcept

Constructor.

Template Parameters
NodeTarget node type
ParentsPack of parent tree nodes in ascending ancestry order
Parameters
tokensTokens to be parsed by node, not including any label token
nodeTarget node instance
parentsParents of node

Definition at line 41 of file parse_target.hpp.

◆ parse_target() [2/2]

template<typename Node , typename... Parents>
arg_router::parsing::parse_target::parse_target ( const Node &  node,
const Parents &...  parents 
)
inlineexplicitnoexcept

No token constructor.

Template Parameters
NodeTarget node type
ParentsPack of parent tree nodes in ascending ancestry order
Parameters
nodeTarget node instance
parentsParents of node

Definition at line 66 of file parse_target.hpp.

Member Function Documentation

◆ add_sub_target()

void arg_router::parsing::parse_target::add_sub_target ( parse_target  target)
inline

Append a sub-target.

The tokens of target are appended to this target.

Parameters
targetSub-target

Definition at line 113 of file parse_target.hpp.

◆ node_type()

std::size_t arg_router::parsing::parse_target::node_type ( ) const
inlinenoexcept

Returns the hash code for the target node.

Returns
Target node hash code

Definition at line 106 of file parse_target.hpp.

◆ operator bool()

arg_router::parsing::parse_target::operator bool ( ) const
inlineexplicitnoexcept

Bool conversion operator.

Returns
True if target is invocable (i.e. trigger a parse)

Definition at line 100 of file parse_target.hpp.

◆ operator()()

utility::unsafe_any arg_router::parsing::parse_target::operator() ( )
inline

Trigger the parse of this target.

Returns
Parse result or empty

Definition at line 125 of file parse_target.hpp.

◆ sub_targets() [1/2]

const vector<parse_target>& arg_router::parsing::parse_target::sub_targets ( ) const
inlinenoexcept

Const overload.

Returns
Sub-targets reference

Definition at line 94 of file parse_target.hpp.

◆ sub_targets() [2/2]

vector<parse_target>& arg_router::parsing::parse_target::sub_targets ( )
inlinenoexcept

The sub-targets associated with this target.

Returns
Sub-targets reference

Definition at line 88 of file parse_target.hpp.

◆ tokens() [1/3]

const vector<token_type>& arg_router::parsing::parse_target::tokens ( ) const
inlinenoexcept

Const overload.

Returns
Tokens reference

Definition at line 82 of file parse_target.hpp.

◆ tokens() [2/3]

vector<token_type>& arg_router::parsing::parse_target::tokens ( )
inlinenoexcept

The tokens associated with this target.

Returns
Tokens reference

Definition at line 76 of file parse_target.hpp.

◆ tokens() [3/3]

void arg_router::parsing::parse_target::tokens ( vector< token_type tokens)
inline

Set the tokens for this node.

Parameters
tokensNew tokens

Definition at line 119 of file parse_target.hpp.


The documentation for this class was generated from the following file: