Class for parsing program arguments.
More...
#include <arg_parser.hpp>
List of all members.
Public Types |
typedef std::list< const char * >
::iterator | iterator |
| | Iterator for the arguments that where not parsed.
|
typedef std::list< const char * >
::const_iterator | const_iterator |
| | ConstIterator for the arguments that where not parse.
|
Public Member Functions |
| void | add (unsigned char flag, const char *str, int *data) |
| | Adds an int option.
|
| void | add (unsigned char flag, const char *str, float *data) |
| | Adds a float option.
|
| void | add (unsigned char flag, const char *str, bool *data) |
| | Adds a bool option.
|
| void | add (unsigned char flag, const char *str, std::string *data) |
| | Adds a string option.
|
| void | add (unsigned char flag, const char *str, const char **data) |
| | Adds a cstring option.
|
| void | add (unsigned char flag, const char *str, option *op) |
| | Adds an user defined option.
|
| void | parse (int argc, const char *argv[]) |
| | Parse the command line arguments using the defined options.
|
| iterator | begin () |
| | Returns an iterator to the first free argument.
|
| const_iterator | begin () const |
| | Returns a const_iterator to the first free argument.
|
| iterator | end () |
| | Returns an Iterator to the end of free arguments list.
|
| const_iterator | end () const |
| | Returns a ConstIterator to the end of free arguments list.
|
| size_t | free_args () const |
| | Return the number of free arguments.
|
| bool | has_free_args () const |
| | Returns whether there are any free arguments.
|
Detailed Description
Class for parsing program arguments.
You register options that individual arguments. It includes some wrapper functions to add options to parse arguments of basic data types.
- See also:
- option
Member Typedef Documentation
ConstIterator for the arguments that where not parse.
Iterator for the arguments that where not parsed.
Member Function Documentation
| void psynth::base::arg_parser::add |
( |
unsigned char |
flag, |
|
|
const char * |
str, |
|
|
int * |
data |
|
) |
| [inline] |
Adds an int option.
- Parameters:
-
| flag | Short version of the option. |
| str | Long version of the option. |
| void psynth::base::arg_parser::add |
( |
unsigned char |
flag, |
|
|
const char * |
str, |
|
|
float * |
data |
|
) |
| [inline] |
Adds a float option.
- Parameters:
-
| flag | Short version of the option. |
| str | Long version of the option. |
| data | Where to store the passed value. |
| void psynth::base::arg_parser::add |
( |
unsigned char |
flag, |
|
|
const char * |
str, |
|
|
std::string * |
data |
|
) |
| [inline] |
Adds a string option.
- Parameters:
-
| flag | Short version of the option. |
| str | Long version of the option. |
| data | Where to store the passed value. |
| void psynth::base::arg_parser::add |
( |
unsigned char |
flag, |
|
|
const char * |
str, |
|
|
const char ** |
data |
|
) |
| [inline] |
Adds a cstring option.
- Parameters:
-
| flag | Short version of the option. |
| str | Long version of the option. |
| data | Where to store the passed value. |
| void psynth::base::arg_parser::add |
( |
unsigned char |
flag, |
|
|
const char * |
str, |
|
|
bool * |
data |
|
) |
| [inline] |
Adds a bool option.
- Parameters:
-
| flag | Short version of the option. |
| str | Long version of the option. |
| data | Where to store the passed value. |
| void psynth::base::arg_parser::add |
( |
unsigned char |
flag, |
|
|
const char * |
str, |
|
|
option * |
op |
|
) |
| |
Adds an user defined option.
If the option is null an empty option is added -produces no result but avoids exceptions.
- Parameters:
-
| flag | Short version of the option. |
| str | Long version of the option. |
| op | The option to associate to and . |
- See also:
- Option
| iterator psynth::base::arg_parser::begin |
( |
| ) |
[inline] |
Returns an iterator to the first free argument.
Returns a const_iterator to the first free argument.
| iterator psynth::base::arg_parser::end |
( |
| ) |
[inline] |
Returns an Iterator to the end of free arguments list.
Returns a ConstIterator to the end of free arguments list.
| size_t psynth::base::arg_parser::free_args |
( |
| ) |
const [inline] |
Return the number of free arguments.
| bool psynth::base::arg_parser::has_free_args |
( |
| ) |
const [inline] |
Returns whether there are any free arguments.
| void psynth::base::arg_parser::parse |
( |
int |
argc, |
|
|
const char * |
argv[] |
|
) |
| |
Parse the command line arguments using the defined options.
Any arguments that had no option associated are added to the free arguments list, which can be later iterated.
- Parameters:
-
| argc | Number of command line arguments. |
| argv | Array of command line arguments. |
- Exceptions:
-
| A | arg_parser_error if there was an option threw an exception, containing the problematic option in the what (). |
The documentation for this class was generated from the following files: