|
libmx2 2.2.1
C++20 multimedia and game-engine library (SDL2 / OpenGL / Vulkan)
|
Template command-line argument parser. More...
#include <argz.hpp>
Public Member Functions | |
| ~Argz ()=default | |
| Argz ()=default | |
| Argz (int argc, char **argv) | |
| Construct and immediately ingest argv. | |
| Argz (const Argz< String > &a) | |
| Argz< String > & | operator= (const Argz< String > &a) |
| Argz (Argz< String > &&a) | |
| Argz< String > & | operator= (Argz< String > &&a) |
| Argz< String > & | initArgs (int argc, char **argv) |
| Ingest argc/argv, converting to the target String type. | |
| void | reset () |
| Reset the internal parse cursor to the beginning of argv. | |
| Argz< String > & | addOptionSingle (const int &c, const String &description) |
| Register a flag-only short option (e.g. | |
| Argz< String > & | addOptionSingleValue (const int &c, const String &description) |
| Register a short option that requires a value argument (e.g. | |
| Argz< String > & | addOptionDouble (const int &code, const String &value, const String &description) |
| Register a flag-only long option (e.g. | |
| Argz< String > & | addOptionDoubleValue (const int &code, const String &value, const String &description) |
| Register a long option that requires a value argument (e.g. | |
| int | lookUpCode (const String &value) |
| Look up the integer code registered for a long option name. | |
| int | proc (Argument< String > &a) |
| Advance the cursor and parse the next argument. | |
| template<typename T> | |
| void | help (T &cout) |
| Print all registered options to any ostream-like object. | |
| const size_t | count () const |
Protected Attributes | |
| ArgumentData< String > | arg_data |
| std::unordered_map< int, Argument< String > > | arg_info |
Private Attributes | |
| int | index = 0 |
| int | cindex = 1 |
Template command-line argument parser.
| String | String type satisfying StringType (usually std::string or std::wstring). |
Options are registered with addOption*() before parsing. Call proc() in a loop until it returns -1 to iterate over all arguments.
|
default |
|
default |
Referenced by addOptionDouble(), addOptionDoubleValue(), addOptionSingle(), addOptionSingleValue(), Argz(), Argz(), initArgs(), operator=(), and operator=().
|
inline |
Construct and immediately ingest argv.
Definition at line 153 of file argz.hpp.
References initArgs().
|
inline |
|
inline |
|
inline |
Register a flag-only long option (e.g.
--verbose).
| code | Unique integer code associated with this option. |
| value | Long option name string (without --). |
| description | Help text. |
*this for chaining. Definition at line 254 of file argz.hpp.
References ARG_DOUBLE, arg_info, Argument< String >::arg_letter, Argument< String >::arg_name, Argument< String >::arg_type, Argz(), and Argument< String >::desc.
|
inline |
Register a long option that requires a value argument (e.g.
--output file).
| code | Unique integer code. |
| value | Long option name string. |
| description | Help text. |
*this for chaining. Definition at line 271 of file argz.hpp.
References ARG_DOUBLE_VALUE, arg_info, Argument< String >::arg_letter, Argument< String >::arg_name, Argument< String >::arg_type, Argz(), and Argument< String >::desc.
|
inline |
Register a flag-only short option (e.g.
-v, -h).
| c | Short option character code. |
| description | Help text. |
*this for chaining. Definition at line 223 of file argz.hpp.
References arg_info, Argument< String >::arg_letter, ARG_SINGLE, Argument< String >::arg_type, Argz(), and Argument< String >::desc.
Referenced by proc_args().
|
inline |
Register a short option that requires a value argument (e.g.
-o file).
| c | Short option character code. |
| description | Help text. |
*this for chaining. Definition at line 238 of file argz.hpp.
References arg_info, Argument< String >::arg_letter, ARG_SINGLE_VALUE, Argument< String >::arg_type, Argz(), and Argument< String >::desc.
|
inline |
Print all registered options to any ostream-like object.
| T | Output stream type (e.g. std::ostream, std::wostream). |
| cout | Destination stream. |
Definition at line 443 of file argz.hpp.
References ARG_DOUBLE, ARG_DOUBLE_VALUE, arg_info, ARG_SINGLE, and ARG_SINGLE_VALUE.
Referenced by proc_args().
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Advance the cursor and parse the next argument.
| a | Output: filled with the matched option details. |
'-' for a positional argument; -1 when exhausted. | ArgException<String> | On unrecognised options or missing values. |
Definition at line 301 of file argz.hpp.
References arg_data, ARG_DOUBLE, arg_info, Argument< String >::arg_name, ARG_NONE, ARG_SINGLE, ARG_SINGLE_VALUE, Argument< String >::arg_type, Argument< String >::arg_value, cindex, index, and lookUpCode().
Referenced by proc_args().
|
inline |
Reset the internal parse cursor to the beginning of argv.
Definition at line 212 of file argz.hpp.
Referenced by initArgs().
|
protected |
Definition at line 494 of file argz.hpp.
Referenced by Argz(), Argz(), initArgs(), operator=(), operator=(), and proc().
|
protected |
Definition at line 495 of file argz.hpp.
Referenced by addOptionDouble(), addOptionDoubleValue(), addOptionSingle(), addOptionSingleValue(), Argz(), Argz(), help(), lookUpCode(), operator=(), operator=(), and proc().
|
private |
Definition at line 497 of file argz.hpp.
Referenced by Argz(), Argz(), operator=(), operator=(), proc(), and reset().
|
private |
Definition at line 497 of file argz.hpp.
Referenced by Argz(), Argz(), count(), operator=(), operator=(), proc(), and reset().