![]() |
PIDUINO
|
OptionParser manages all Options. More...
#include <popl.h>
Public Member Functions | |
OptionParser (std::string description="") | |
OptionParser implementation /////////////////////////////////. | |
virtual | ~OptionParser ()=default |
Destructor. | |
template<typename T , Attribute attribute, typename... Ts> | |
std::shared_ptr< T > | add (Ts &&... params) |
template<typename T , typename... Ts> | |
std::shared_ptr< T > | add (Ts &&... params) |
void | parse (int argc, const char *const argv[]) |
std::string | help (const Attribute &max_attribute=Attribute::optional) const |
std::string | description () const |
const std::vector< Option_ptr > & | options () const |
const std::vector< std::string > & | non_option_args () const |
const std::vector< std::string > & | unknown_options () const |
template<typename T > | |
std::shared_ptr< T > | get_option (const std::string &long_name) const |
template<typename T > | |
std::shared_ptr< T > | get_option (char short_name) const |
Protected Member Functions | |
Option_ptr | find_option (const std::string &long_name) const |
Option_ptr | find_option (char short_name) const |
Protected Attributes | |
std::vector< Option_ptr > | options_ |
std::string | description_ |
std::vector< std::string > | non_option_args_ |
std::vector< std::string > | unknown_options_ |
OptionParser manages all Options.
OptionParser manages all Options Add Options (Option_Type = Value<T>, Implicit<T> or Switch) with "add<Option_Type>(option params)" Call "parse(argc, argv)" to trigger parsing of the options and to fill "non_option_args" and "unknown_options"
|
inlineexplicit |
OptionParser implementation /////////////////////////////////.
Construct the OptionParser
description | used for the help message |
|
virtualdefault |
Destructor.
|
inline |
|
inline |
|
inline |
Get the OptionParser's description
Definition at line 814 of file popl.h.
References description_.
Referenced by Piduino::ConsoleOptionPrinter::print(), and Piduino::GroffOptionPrinter::print().
|
inlineprotected |
Definition at line 843 of file popl.h.
References options_, and Piduino::short_name.
|
inlineprotected |
Definition at line 834 of file popl.h.
References Piduino::long_name, and options_.
Referenced by get_option(), get_option(), and parse().
|
inline |
Get an Option by it's short name
the | Option's short name |
Definition at line 867 of file popl.h.
References find_option(), and Piduino::short_name.
|
inline |
Get an Option by it's long name
the | Option's long name |
Definition at line 853 of file popl.h.
References find_option(), and Piduino::long_name.
|
inline |
Produce a help message
max_attribute | show options up to this level (optional, advanced, expert) |
Definition at line 983 of file popl.h.
References Piduino::ConsoleOptionPrinter::print().
|
inline |
Get command line arguments without option e.g. "-i 5 hello" => hello e.g. "-i 5 -- from here non option args" => "from", "here", "non", "option", "args"
Definition at line 824 of file popl.h.
References non_option_args_.
|
inline |
Get all options that where added with "add"
Definition at line 819 of file popl.h.
References options_.
Referenced by Piduino::ConsoleOptionPrinter::print(), and Piduino::GroffOptionPrinter::print().
|
inline |
Parse the command line into the added Options
argc | command line argument count |
argv | command line arguments |
from here on only non opt args
long option arg
short option arg
use the rest of the current argument as optarg
or the next arg
use the rest of the current argument as optarg
Definition at line 880 of file popl.h.
References find_option(), Piduino::inactive, Piduino::long_name, Piduino::invalid_option::missing_option, Piduino::no, non_option_args_, Piduino::optional, options_, Piduino::required, Piduino::short_name, and unknown_options_.
|
inline |
Get unknown command options e.g. '–some_unknown_option="hello"'
Definition at line 829 of file popl.h.
References unknown_options_.
|
protected |
Definition at line 358 of file popl.h.
Referenced by description().
|
protected |
Definition at line 359 of file popl.h.
Referenced by non_option_args(), and parse().
|
protected |
Definition at line 357 of file popl.h.
Referenced by add(), find_option(), find_option(), options(), and parse().
|
protected |
Definition at line 360 of file popl.h.
Referenced by parse(), and unknown_options().