dxd - dynax driver framework 3.0.2
cross platform open source driver development framework
Loading...
Searching...
No Matches
dx::parser Class Reference

cmd line parser More...

#include <dx_parser.h>

Inheritance diagram for dx::parser:
Collaboration diagram for dx::parser:

Classes

struct  dispatch
 one command: what it runs, how it reads in the help, and the commands nested under it. A word of parameter consumes the arguments that follow it before this one's own function runs, which is what makes the CLI hierarchical More...

Public Types

typedef std::deque<std::string> args

Public Member Functions

virtual void operator <<(argsargs& argsargs)
virtual void operator <<(const argsargs& argsargs)
 parser(const char* name, const decltype(dictionary)& dictionary= {})
virtual void quiet(const args &= {}) noexcept
virtual ~parser()= default

Protected Member Functions

virtual bool head() const noexcept
virtual void help(argsargs& argsargs)
virtual void help_head() const noexcept
virtual void indent(argsargs& argsargs)
virtual void no_args(const argsargs& argsargs)
auto select(const std::string& id)
virtual void version(const argsargs& argsargs= {})

Static Protected Member Functions

template<typename value_t= int32_t>
static std::optional<value_t> value(argsargs& argsargs)
template<typename value_t= int32_t>
static value_t value(argsargs& argsargs, const char* name)
 the next argument as a number of value_t, which the parameter named requires
template<typename value_t>
static value_t value(argsargs& argsargs, value_t dflt)
 the next argument as a number of value_t, the default where it is none

Protected Attributes

std::map<std::deque<std::string>, dispatch> dictionary
const char* name{}
struct dx::parser:: { ... }  parameter

Detailed Description

cmd line parser

Member Typedef Documentation

◆ args

typedef std::deque<std::string> dx::parser::args

Constructor & Destructor Documentation

◆ parser()

dx::parser::parser(const char* name, const decltype(dictionary)& dictionary= {})
inline
Here is the caller graph for this function:

◆ ~parser()

virtual dx::parser::~parser()
virtualdefault
Here is the call graph for this function:

Member Function Documentation

◆ head()

virtual bool dx::parser::head() const
inlineprotectedvirtualnoexcept

◆ help()

virtual void dx::parser::help(args& args)
inlineprotectedvirtual
Here is the call graph for this function:
Here is the caller graph for this function:

◆ help_head()

virtual void dx::parser::help_head() const
inlineprotectedvirtualnoexcept

Reimplemented in dx::select< parsers_t >, dx::test::driver< super_device_t, device_t, driver_t >, and dx::test::stream::driver< super_device_t, device_t, driver_t >.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ indent()

virtual void dx::parser::indent(args& args)
inlineprotectedvirtual
Here is the call graph for this function:
Here is the caller graph for this function:

◆ no_args()

virtual void dx::parser::no_args(const args& args)
inlineprotectedvirtual
Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator <<() [1/2]

virtual void dx::parser::operator <<(args& args)
inlinevirtual

Reimplemented in dx::install::parser, dx::select< parsers_t >, and dx::test::driver< super_device_t, device_t, driver_t >.

Here is the call graph for this function:

◆ operator <<() [2/2]

virtual void dx::parser::operator <<(const args& args)
inlinevirtual
Here is the caller graph for this function:

◆ quiet()

virtual void dx::parser::quiet(const args&= {})
inlinevirtualnoexcept
Here is the caller graph for this function:

◆ select()

auto dx::parser::select(const std::string& id)
inlineprotected
Here is the call graph for this function:
Here is the caller graph for this function:

◆ value() [1/3]

template<typename value_t= int32_t>
std::optional<value_t> dx::parser::value(args& args)
inlinestaticprotected

the next argument where it is a number of value_t, consumed: $ and 0x hexadecimal, decimal otherwise - none where it is no number or outside value_t

Here is the call graph for this function:
Here is the caller graph for this function:

◆ value() [2/3]

template<typename value_t= int32_t>
value_t dx::parser::value(args& args, const char* name)
inlinestaticprotected

the next argument as a number of value_t, which the parameter named requires

Here is the call graph for this function:

◆ value() [3/3]

template<typename value_t>
value_t dx::parser::value(args& args, value_t dflt)
inlinestaticprotected

the next argument as a number of value_t, the default where it is none

Here is the call graph for this function:

◆ version()

virtual void dx::parser::version(const args& args= {})
inlineprotectedvirtual
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ dictionary

std::map<std::deque<std::string>, dispatch> dx::parser::dictionary
protected
Initial value:
{
{{"--continue", "--no-error", "--ignore", "--ignore-error"},
{[this](args& args) {parameter.error.ignore= true; no_args(args);}, "ignore errors and continue"}},
{{"--indent", "--tab"}, {std::bind(&parser::indent, this, std::placeholders::_1), "set/get indention width and pattern", "[width [pattern]]", {}, {
{{"err", "stderr"}, {[this](args&) {this->parameter.log.err= true;}, "select std error"}},
{{"log", "stdlog"}, {[this](args&) {this->parameter.log.log= true;}, "select std log"}},
{{"out", "stdout"}, {[this](args&) {this->parameter.log.out= true;}, "select std out"}},
}}},
{{"--quiet", "-q"}, {std::bind(&parser::quiet, this, std::placeholders::_1), "quiet!"}},
{{"--version", "-v"}, {std::bind(&parser::version, this, std::placeholders::_1), std::string{"display "}+ name+ " version"}},
}
virtual void indent(args &args)
Definition dx_parser.h:264
virtual void no_args(const args &args)
Definition dx_parser.h:232
const char * name
Definition dx_parser.h:68
std::deque< std::string > args
Definition dx_parser.h:64
struct dx::parser::@046247176025362246310022157273031025265032273157 parameter
virtual void version(const args &args={})
Definition dx_parser.h:287
virtual void quiet(const args &={}) noexcept
Definition dx_parser.h:323

◆ name

const char* dx::parser::name{}
protected

◆ parameter

struct { ... } dx::parser::parameter

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