wex
v21.04.0
|
This class offers a command line parser. More...
#include <wex/cmdline.h>
Public Types | |
enum | option_t { FLOAT , INT , STRING } |
Types for command line options. More... | |
typedef std::vector< std::pair< const std::vector< std::string >, std::function< void(bool on)> > > | cmd_switches_t |
Switches: | |
typedef std::vector< std::pair< const std::vector< std::string >, std::pair< option_t, std::function< void(const std::any &any)> > > > | cmd_options_t |
Options: | |
typedef std::pair< const std::pair< const std::string, const std::string >, std::function< void(std::vector< std::string >)> > | cmd_params_t |
Params (currently only string value supported): | |
Public Member Functions | |
cmdline (const cmd_switches_t &s=cmd_switches_t(), const cmd_options_t &o=cmd_options_t(), const cmd_params_t &p=cmd_params_t(), bool add_standard_options=true, const std::string &prefix=std::string()) | |
Default constructor, adds standard options. More... | |
~cmdline () | |
Destructor. | |
bool | parse (data::cmdline &data) |
Parses the command line arguments and invokes callbacks. More... | |
bool | parse_set (data::cmdline &data) const |
Parses the command line arguments and invokes callbacks. More... | |
This class offers a command line parser.
wex::cmdline::cmdline | ( | const cmd_switches_t & | s = cmd_switches_t() , |
const cmd_options_t & | o = cmd_options_t() , |
||
const cmd_params_t & | p = cmd_params_t() , |
||
bool | add_standard_options = true , |
||
const std::string & | prefix = std::string() |
||
) |
Default constructor, adds standard options.
s | switches |
o | options |
p | params |
add_standard_options | add standard options |
prefix | option prefix for all options |
bool wex::cmdline::parse | ( | data::cmdline & | data | ) |
Parses the command line arguments and invokes callbacks.
Returns false if error is found, or exit condition is true.
bool wex::cmdline::parse_set | ( | data::cmdline & | data | ) | const |
Parses the command line arguments and invokes callbacks.
Options are specified according to ex :set specification. [option[=[value]] ...][nooption ...][option? ...][all] Returns false if option was not found.