INGOR
|
Structure for parsing command line arguments. More...
#include <util/ytParseArgs.h>
Public Member Functions | |
ytParseArgs * | ytParseArgs_new () |
Creates a new ytParseArgs instance. | |
void | ytParseArgs_delete (ytParseArgs *this) |
Deletes the ytParseArgs instance. | |
void | ytParseArgs_addString (ytParseArgs *this, const char *key, char **arg) |
Adds a key that takes a string (char * ) value. | |
void | ytParseArgs_addStringOpt (ytParseArgs *this, const char *key, char **arg) |
Adds a key that takes a string (char * ) value. The value can be omitted. | |
void | ytParseArgs_addInt (ytParseArgs *this, const char *key, int *arg) |
Adds a key that takes an int value. | |
void | ytParseArgs_addDouble (ytParseArgs *this, const char *key, double *arg) |
Adds a key that takes a double value. | |
void | ytParseArgs_addOn (ytParseArgs *this, const char *key, int *arg) |
Adds a key that sets an int value of 1 if it exists. | |
void | ytParseArgs_addOff (ytParseArgs *this, const char *key, int *arg) |
Adds a key that sets an int value of 0 if it exists. | |
void | ytParseArgs_addOnOff (ytParseArgs *this, const char *key, int *arg) |
Adds a key that sets an int value of 0 or 1. | |
void | ytParseArgs_addIntArray (ytParseArgs *this, const char *key, ytIntArray **arg) |
Adds a key that sets an integer array to a ytIntArray instance. | |
void | ytParseArgs_addStrArray (ytParseArgs *this, const char *key, ytStrArray **arg) |
Adds a key that sets a string array to a ytStrArray instance. | |
void | ytParseArgs_addStrArrayAdd (ytParseArgs *this, const char *key, ytStrArray **arg) |
Adds a key that adds a string to a ytStrArray instance. | |
void | ytParseArgs_addDoubleArray (ytParseArgs *this, const char *key, ytDoubleArray **arg) |
Adds a key that sets a double array to a ytDoubleArray instance. | |
void | ytParseArgs_addKeyValues (ytParseArgs *this, const char *key, ytKeyValues **arg) |
Adds a key that accepts key=value style values as ytKeyValues. | |
void | ytParseArgs_addKeyValuesArray (ytParseArgs *this, const char *key, ytArray **arg) |
Adds a key that accepts key=value style values as a ytKeyValues instance and adds them to the ytArray instance. | |
void | ytParseArgs_addFunc (ytParseArgs *this, const char *key, void(*f)()) |
Adds a key that calls the specified function. | |
void | ytParseArgs_addFunc3 (ytParseArgs *this, const char *key, void(*f)(const char *, const char *, void *), void *arg) |
Adds a key that calls the specified function with its argument. | |
void | ytParseArgs_addNone (ytParseArgs *this, const char *key) |
Adds a key to ignore. | |
int | ytParseArgs_set (ytParseArgs *parser, int argc, char **argv) |
Parses command line arguments. | |
int | ytParseArgs_setKV (ytParseArgs *parser, const ytKeyValues *kv, int opt) |
Sets values in the variables from the ytKeyValues instance. | |
ytKeyValues * | ytParseArgs_genKV (int argc, char **argv, const char *defKey) |
Generates ytKeyValues instance from command line arguments. | |
void | ytParseArgs_verbose (ytParseArgs *this, int e) |
Sets the verbose level. | |
Related Symbols | |
(Note that these are not member symbols.) | |
#define | ytParseArgs_DEFAULT_KEY |
Default key for an argument without a key. | |
#define | ytParseArgs_OPT_ERROR |
Specifies to stop if the action is not registered. | |
#define | ytParseArgs_OPT_WARNING |
Specifies to put a warning message if the action is not registered. | |
#define | ytParseArgs_OPT_IGNORE |
Specifies to ignore if the action is not registered. | |
#define | ytPA_int(this, key, arg) |
Short Macro. | |
#define | ytPA_double(this, key, arg) |
Short Macro. | |
#define | ytPA_str(this, key, arg) |
Short Macro. | |
Structure for parsing command line arguments.
Specify the array of this structure as the first argument of ytParseArgs_set(). The field ParseArgs::key of the last element of the array has to be NULL to represent the end of the array.
void ytParseArgs_addDouble | ( | ytParseArgs * | this, |
const char * | key, | ||
double * | arg ) |
Adds a key that takes a double
value.
this | |
key | key of this argument. |
arg | pointer to the variable to be set by this argument. |
void ytParseArgs_addDoubleArray | ( | ytParseArgs * | this, |
const char * | key, | ||
ytDoubleArray ** | arg ) |
Adds a key that sets a double array to a ytDoubleArray instance.
If the arg points to NULL, then it automatically allocates a new ytDoubleArray instance.
this | |
key | key of this argument. |
arg | pointer to the variable to be set by this argument. |
void ytParseArgs_addFunc | ( | ytParseArgs * | this, |
const char * | key, | ||
void(* | f )() ) |
Adds a key that calls the specified function.
this | |
key | |
f |
void ytParseArgs_addFunc3 | ( | ytParseArgs * | this, |
const char * | key, | ||
void(* | f )(const char *, const char *, void *), | ||
void * | arg ) |
Adds a key that calls the specified function with its argument.
key is copied.
this | |
key | |
f |
void ytParseArgs_addInt | ( | ytParseArgs * | this, |
const char * | key, | ||
int * | arg ) |
Adds a key that takes an int
value.
this | |
key | key of this argument. |
arg | pointer to the variable to be set by this argument. |
void ytParseArgs_addIntArray | ( | ytParseArgs * | this, |
const char * | key, | ||
ytIntArray ** | arg ) |
Adds a key that sets an integer array to a ytIntArray instance.
If the arg points to NULL, then it automatically allocates a new ytIntArray instance.
this | |
key | key of this argument. |
arg | pointer to the variable to be set by this argument. |
void ytParseArgs_addKeyValues | ( | ytParseArgs * | this, |
const char * | key, | ||
ytKeyValues ** | arg ) |
Adds a key that accepts key=value style values as ytKeyValues.
this | |
key | |
arg |
void ytParseArgs_addKeyValuesArray | ( | ytParseArgs * | this, |
const char * | key, | ||
ytArray ** | arg ) |
Adds a key that accepts key=value style values as a ytKeyValues instance and adds them to the ytArray instance.
this | |
key | |
arg |
void ytParseArgs_addNone | ( | ytParseArgs * | this, |
const char * | key ) |
Adds a key to ignore.
this | |
key |
void ytParseArgs_addOff | ( | ytParseArgs * | this, |
const char * | key, | ||
int * | arg ) |
Adds a key that sets an int
value of 0 if it exists.
this | |
key | key of this argument. |
arg | pointer to the variable to be set by this argument. |
void ytParseArgs_addOn | ( | ytParseArgs * | this, |
const char * | key, | ||
int * | arg ) |
Adds a key that sets an int
value of 1 if it exists.
this | |
key | key of this argument. |
arg | pointer to the variable to be set by this argument. |
void ytParseArgs_addOnOff | ( | ytParseArgs * | this, |
const char * | key, | ||
int * | arg ) |
Adds a key that sets an int
value of 0 or 1.
If a value on
, 1
, true
, t
, or yes
is given, an integer 1 is set to the given variable.
If a value off
, 0
, false
, f
, or no
is given, an integer 0 is set to the given variable.
this | |
key | key of this argument. |
arg | pointer to the variable to be set by this argument. |
void ytParseArgs_addStrArray | ( | ytParseArgs * | this, |
const char * | key, | ||
ytStrArray ** | arg ) |
Adds a key that sets a string array to a ytStrArray instance.
If the arg points to NULL, then it automatically allocates a new ytStrArray instance.
this | |
key | key of this argument. |
arg | pointer to the variable to be set by this argument. |
void ytParseArgs_addStrArrayAdd | ( | ytParseArgs * | this, |
const char * | key, | ||
ytStrArray ** | arg ) |
Adds a key that adds a string to a ytStrArray instance.
If the arg points to NULL, then it automatically allocates a new ytStrArray instance.
this | |
key | key of this argument. |
arg | pointer to the variable to be set by this argument. |
void ytParseArgs_delete | ( | ytParseArgs * | this | ) |
Deletes the ytParseArgs instance.
This releases all memory managed by this instance.
this | ytParserArgs to delete. |
ytKeyValues * ytParseArgs_genKV | ( | int | argc, |
char ** | argv, | ||
const char * | defKey ) |
Generates ytKeyValues instance from command line arguments.
This is a simple parser for command line arguments. This converts "-x y
" or "--x y
" in the command line arguments into a key-value pair of "x
" and "y
".
argc | the number of arguments in argv. |
argv | array of command line arguments. |
int ytParseArgs_set | ( | ytParseArgs * | parser, |
int | argc, | ||
char ** | argv ) |
Parses command line arguments.
Command line arguments are generally tokenized or split into particular arguments by white space characters. However, this parser treats tokens or arguments ending with a comma (,
) and/or an equal letter (=
) and its subsequent arguments as a single token or argument.
parser | ytParseArgs instance. |
argc | Number of arguments in argv, which is passed by main(). |
argv | Array of arguments passed by main(). |
int ytParseArgs_setKV | ( | ytParseArgs * | parser, |
const ytKeyValues * | kv, | ||
int | opt ) |
Sets values in the variables from the ytKeyValues instance.
parser | |
kv | |
opt | ytParseArgs_OPT_ERROR, ytParseArgs_OPT_IGNORE, or ytParseArgs_OPT_WARNING. |
|
related |
Short Macro.
|
related |
Short Macro.
|
related |
Short Macro.