WvStreams
Public Types | Public Member Functions | List of all members
WvArgs Class Reference

WvArgs - Sane command-line argument processing for WvStreams. More...

#include <wvargs.h>

Public Types

enum  flags_t { NO_EXIT_ON_ERRORS , FLAGS_SIZE , NO_EXIT_ON_ERRORS , FLAGS_SIZE }
 These flags control the behaviour of WvArgs. More...
 
enum  flags_t { NO_EXIT_ON_ERRORS , FLAGS_SIZE , NO_EXIT_ON_ERRORS , FLAGS_SIZE }
 These flags control the behaviour of WvArgs. More...
 
typedef wv::function< bool(void *)> NoArgCallback
 The callback type used for switches that do not take a parameter.
 
typedef wv::function< bool(WvStringParm, void *)> ArgCallback
 The callback type used for switches that take a parameter It returns true if the switch was parsed correctly.
 
typedef wv::function< bool(void *)> NoArgCallback
 The callback type used for switches that do not take a parameter.
 
typedef wv::function< bool(WvStringParm, void *)> ArgCallback
 The callback type used for switches that take a parameter It returns true if the switch was parsed correctly.
 

Public Member Functions

bool process (int argc, char **argv, WvStringList *remaining_args=NULL)
 Process the command line arguments passed to main() using the options provided through calls to add_option(..).
 
void set_version (WvStringParm version)
 Set the –version string.
 
void set_email (WvStringParm email)
 Set the e-mail address for bug reports.
 
void set_help_header (WvStringParm header)
 Set the introductory help message, printed at the beginning of –help.
 
void set_help_footer (WvStringParm footer)
 Set the descriptive help message, printed at the end of –help.
 
void print_usage (int argc, char **argv)
 Output the short usage message based on the provided options.
 
void print_help (int argc, char **argv)
 Output the long usage message based on the provided options.
 
void add_set_bool_option (char short_option, WvStringParm long_option, WvStringParm desc, bool &val)
 Add a boolean option, which, when specified, sets the specified boolean variable to true.
 
void add_reset_bool_option (char short_option, WvStringParm long_option, WvStringParm desc, bool &val)
 Add a boolean option, which, when spefied, sets the specified boolean variable to false.
 
void add_flip_bool_option (char short_option, WvStringParm long_option, WvStringParm desc, bool &val)
 Add a boolean option, which, when spefied, changes the value of the boolean variable from false to true or from true to false.
 
void add_option (char short_option, WvStringParm long_option, WvStringParm desc, WvStringParm arg_desc, int &val)
 Add a switch that takes an integer argument.
 
void add_option (char short_option, WvStringParm long_option, WvStringParm desc, WvStringParm arg_desc, long &val)
 Add a switch that takes a long argument.
 
void add_option (char short_option, WvStringParm long_option, WvStringParm desc, WvStringParm arg_desc, float &val)
 Add a switch that takes a float argument.
 
void add_option (char short_option, WvStringParm long_option, WvStringParm desc, WvStringParm arg_desc, double &val)
 Add a switch that takes a double argument.
 
void add_option (char short_option, WvStringParm long_option, WvStringParm desc, WvStringParm arg_desc, WvString &val)
 Add a switch that takes a string argument.
 
void add_option (char short_option, WvStringParm long_option, WvStringParm desc, WvStringParm arg_desc, WvStringList &val)
 Add a switch that takes a string argument; the argument is appended to a string list.
 
void add_option (char short_option, WvStringParm long_option, WvStringParm desc, NoArgCallback cb, void *ud=NULL)
 Add a switch which does not take an argument which invokes a callback when it is specified.
 
void add_option (char short_option, WvStringParm long_option, WvStringParm desc, WvStringParm arg_desc, ArgCallback cb, void *ud=NULL)
 Add a switch which takes an argument which invokes a callback when it is specified.
 
void add_required_arg (WvStringParm desc, bool multiple=false)
 Add a required argument to the list of parameters.
 
void add_optional_arg (WvStringParm desc, bool multiple=false)
 Add an optional argument to the list of parameters.
 
void remove_option (char short_option)
 Remove an option by specifying its short form.
 
void remove_option (WvStringParm long_option)
 Remove an option by specifying its long form.
 
void remove_all_options ()
 Remove all options.
 
void zap ()
 An alias for remove_all_options()
 
bool get_flag (const flags_t flag) const
 Get and set flags.
 
void set_flag (const flags_t flag, const bool value)
 
bool process (int argc, char **argv, WvStringList *remaining_args=NULL)
 Process the command line arguments passed to main() using the options provided through calls to add_option(..).
 
void set_version (WvStringParm version)
 Set the –version string.
 
void set_email (WvStringParm email)
 Set the e-mail address for bug reports.
 
void set_help_header (WvStringParm header)
 Set the introductory help message, printed at the beginning of –help.
 
void set_help_footer (WvStringParm footer)
 Set the descriptive help message, printed at the end of –help.
 
void print_usage (int argc, char **argv)
 Output the short usage message based on the provided options.
 
void print_help (int argc, char **argv)
 Output the long usage message based on the provided options.
 
void add_set_bool_option (char short_option, WvStringParm long_option, WvStringParm desc, bool &val)
 Add a boolean option, which, when specified, sets the specified boolean variable to true.
 
void add_reset_bool_option (char short_option, WvStringParm long_option, WvStringParm desc, bool &val)
 Add a boolean option, which, when spefied, sets the specified boolean variable to false.
 
void add_flip_bool_option (char short_option, WvStringParm long_option, WvStringParm desc, bool &val)
 Add a boolean option, which, when spefied, changes the value of the boolean variable from false to true or from true to false.
 
void add_option (char short_option, WvStringParm long_option, WvStringParm desc, WvStringParm arg_desc, int &val)
 Add a switch that takes an integer argument.
 
void add_option (char short_option, WvStringParm long_option, WvStringParm desc, WvStringParm arg_desc, long &val)
 Add a switch that takes a long argument.
 
void add_option (char short_option, WvStringParm long_option, WvStringParm desc, WvStringParm arg_desc, float &val)
 Add a switch that takes a float argument.
 
void add_option (char short_option, WvStringParm long_option, WvStringParm desc, WvStringParm arg_desc, double &val)
 Add a switch that takes a double argument.
 
void add_option (char short_option, WvStringParm long_option, WvStringParm desc, WvStringParm arg_desc, WvString &val)
 Add a switch that takes a string argument.
 
void add_option (char short_option, WvStringParm long_option, WvStringParm desc, WvStringParm arg_desc, WvStringList &val)
 Add a switch that takes a string argument; the argument is appended to a string list.
 
void add_option (char short_option, WvStringParm long_option, WvStringParm desc, NoArgCallback cb, void *ud=NULL)
 Add a switch which does not take an argument which invokes a callback when it is specified.
 
void add_option (char short_option, WvStringParm long_option, WvStringParm desc, WvStringParm arg_desc, ArgCallback cb, void *ud=NULL)
 Add a switch which takes an argument which invokes a callback when it is specified.
 
void add_required_arg (WvStringParm desc, bool multiple=false)
 Add a required argument to the list of parameters.
 
void add_optional_arg (WvStringParm desc, bool multiple=false)
 Add an optional argument to the list of parameters.
 
void remove_option (char short_option)
 Remove an option by specifying its short form.
 
void remove_option (WvStringParm long_option)
 Remove an option by specifying its long form.
 
void remove_all_options ()
 Remove all options.
 
void zap ()
 An alias for remove_all_options()
 
bool get_flag (const flags_t flag) const
 Get and set flags.
 
void set_flag (const flags_t flag, const bool value)
 

Detailed Description

WvArgs - Sane command-line argument processing for WvStreams.

WvArgs allows you to specify a series of typed or callback-enabled command-line arguments. Once all of these arguments are specified, the WvArgs::process(..) function can be called to perform the actual argument processing.

Sample usage:

#include "wvargs.h"
static void callback(void *userdata, WvStringParm value)
{
wvout->print("callback value = %s, userdata = %s\n",
value, (const char *)userdata);
}
int main(int argc, char **argv)
{
WvString str_opt = "default";
bool bool_opt = false;
int num_opt = 0;
WvArgs args;
args.add_option('s', "str", "Pass a string option", "string", str_opt);
args.add_set_bool_option('b', "bool", "Set a boolean option", bool_opt);
args.add_option('n', "num", "Pass a numeric option", "integer", num_opt);
args.add_option('c', "callback", "Callback option",
WvArgs::ArgCallback(callback), (void *)"demo");
WvStringList remaining_args;
args.process(argc, argv, &remaining_args);
wvout->print("str_opt=%s, bool_opt=%s, num_opt=%s\n",
str_opt, bool_opt, num_opt);
WvStringList::Iter i(remaining_args);
for (i.rewind(); i.next(); )
wvout->print("rem: %s\n", *i);
return 0;
}
WvArgs - Sane command-line argument processing for WvStreams.
wv::function< bool(WvStringParm, void *)> ArgCallback
The callback type used for switches that take a parameter It returns true if the switch was parsed co...
bool process(int argc, char **argv, WvStringList *remaining_args=NULL)
Process the command line arguments passed to main() using the options provided through calls to add_o...
Definition wvargs.cc:784
void add_option(char short_option, WvStringParm long_option, WvStringParm desc, WvStringParm arg_desc, int &val)
Add a switch that takes an integer argument.
Definition wvargs.cc:888
void add_set_bool_option(char short_option, WvStringParm long_option, WvStringParm desc, bool &val)
Add a boolean option, which, when specified, sets the specified boolean variable to true.
Definition wvargs.cc:856
A WvFastString acts exactly like a WvString, but can take (const char *) strings without needing to a...
This is a WvList of WvStrings, and is a really handy way to parse strings.
WvString is an implementation of a simple and efficient printable-string class.

!

Definition at line 61 of file debian/libwvstreams-dev/usr/include/wvstreams/wvargs.h.

Member Typedef Documentation

◆ NoArgCallback [1/2]

typedef wv::function<bool(void*)> WvArgs::NoArgCallback

The callback type used for switches that do not take a parameter.

It returns true if the switch was parsed correctly.

Definition at line 69 of file debian/libwvstreams-dev/usr/include/wvstreams/wvargs.h.

◆ ArgCallback [1/2]

typedef wv::function<bool(WvStringParm, void*)> WvArgs::ArgCallback

The callback type used for switches that take a parameter It returns true if the switch was parsed correctly.

Definition at line 74 of file debian/libwvstreams-dev/usr/include/wvstreams/wvargs.h.

◆ NoArgCallback [2/2]

typedef wv::function<bool(void*)> WvArgs::NoArgCallback

The callback type used for switches that do not take a parameter.

It returns true if the switch was parsed correctly.

Definition at line 69 of file include/wvargs.h.

◆ ArgCallback [2/2]

typedef wv::function<bool(WvStringParm, void*)> WvArgs::ArgCallback

The callback type used for switches that take a parameter It returns true if the switch was parsed correctly.

Definition at line 74 of file include/wvargs.h.

Member Enumeration Documentation

◆ flags_t [1/2]

These flags control the behaviour of WvArgs.

By default, they are all set to false.

Definition at line 338 of file debian/libwvstreams-dev/usr/include/wvstreams/wvargs.h.

◆ flags_t [2/2]

These flags control the behaviour of WvArgs.

By default, they are all set to false.

Definition at line 338 of file include/wvargs.h.

Constructor & Destructor Documentation

◆ WvArgs()

WvArgs::WvArgs ( )

Definition at line 771 of file wvargs.cc.

◆ ~WvArgs()

WvArgs::~WvArgs ( )

Definition at line 777 of file wvargs.cc.

Member Function Documentation

◆ process() [1/2]

bool WvArgs::process ( int  argc,
char **  argv,
WvStringList remaining_args = NULL 
)

Process the command line arguments passed to main() using the options provided through calls to add_option(..).

If remaining_args is provided, any remaining arguments after the command line switches will be appended to this list.

Definition at line 784 of file wvargs.cc.

Referenced by WvDaemon::run().

◆ set_version()

void WvArgs::set_version ( WvStringParm  version)

Set the –version string.

Definition at line 819 of file wvargs.cc.

◆ set_email()

void WvArgs::set_email ( WvStringParm  email)

Set the e-mail address for bug reports.

Definition at line 825 of file wvargs.cc.

◆ set_help_header()

void WvArgs::set_help_header ( WvStringParm  header)

Set the introductory help message, printed at the beginning of –help.

Definition at line 831 of file wvargs.cc.

◆ set_help_footer()

void WvArgs::set_help_footer ( WvStringParm  footer)

Set the descriptive help message, printed at the end of –help.

Definition at line 837 of file wvargs.cc.

◆ print_usage() [1/2]

void WvArgs::print_usage ( int  argc,
char **  argv 
)

Output the short usage message based on the provided options.

Useful when a bad value is passed as the parameter of a switch.

Definition at line 843 of file wvargs.cc.

◆ print_help()

void WvArgs::print_help ( int  argc,
char **  argv 
)

Output the long usage message based on the provided options.

Definition at line 850 of file wvargs.cc.

◆ add_set_bool_option() [1/2]

void WvArgs::add_set_bool_option ( char  short_option,
WvStringParm  long_option,
WvStringParm  desc,
bool &  val 
)

Add a boolean option, which, when specified, sets the specified boolean variable to true.

Parameters
short_optionThe single-character version of the switch; 0 for none
long_optionThe full-word version of the switch; NULL for none
descThe description of the option; NULL for none
valThe boolean variable to set to true when the switch is specified

Definition at line 856 of file wvargs.cc.

◆ add_reset_bool_option() [1/2]

void WvArgs::add_reset_bool_option ( char  short_option,
WvStringParm  long_option,
WvStringParm  desc,
bool &  val 
)

Add a boolean option, which, when spefied, sets the specified boolean variable to false.

Parameters
short_optionThe single-character version of the switch; 0 for none
long_optionThe full-word version of the switch; NULL for none
descThe description of the option; NULL for none
valThe boolean variable to set to false when the switch is specified

Definition at line 864 of file wvargs.cc.

◆ add_flip_bool_option() [1/2]

void WvArgs::add_flip_bool_option ( char  short_option,
WvStringParm  long_option,
WvStringParm  desc,
bool &  val 
)

Add a boolean option, which, when spefied, changes the value of the boolean variable from false to true or from true to false.

Parameters
short_optionThe single-character version of the switch; 0 for none
long_optionThe full-word version of the switch; NULL for none
descThe description of the option; NULL for none
valThe boolean variable to change when the switch is specified

Definition at line 872 of file wvargs.cc.

◆ add_option() [1/16]

void WvArgs::add_option ( char  short_option,
WvStringParm  long_option,
WvStringParm  desc,
WvStringParm  arg_desc,
int &  val 
)

Add a switch that takes an integer argument.

Parameters
short_optionThe single-character version of the switch; 0 for none
long_optionThe full-word version of the switch; NULL for none
descThe description of the option; NULL for none
arg_descThe (short) description of the argument; NULL for none
valThe integer varible that gets the value of the argument

Definition at line 888 of file wvargs.cc.

◆ add_option() [2/16]

void WvArgs::add_option ( char  short_option,
WvStringParm  long_option,
WvStringParm  desc,
WvStringParm  arg_desc,
long &  val 
)

Add a switch that takes a long argument.

Parameters
short_optionThe single-character version of the switch; 0 for none
long_optionThe full-word version of the switch; NULL for none
descThe description of the option; NULL for none
arg_descThe (short) description of the argument; NULL for none
valThe long varible that gets the value of the argument

Definition at line 896 of file wvargs.cc.

◆ add_option() [3/16]

void WvArgs::add_option ( char  short_option,
WvStringParm  long_option,
WvStringParm  desc,
WvStringParm  arg_desc,
float &  val 
)

Add a switch that takes a float argument.

Parameters
short_optionThe single-character version of the switch; 0 for none
long_optionThe full-word version of the switch; NULL for none
descThe description of the option; NULL for none
arg_descThe (short) description of the argument; NULL for none
valThe float varible that gets the value of the argument

Definition at line 904 of file wvargs.cc.

◆ add_option() [4/16]

void WvArgs::add_option ( char  short_option,
WvStringParm  long_option,
WvStringParm  desc,
WvStringParm  arg_desc,
double &  val 
)

Add a switch that takes a double argument.

Parameters
short_optionThe single-character version of the switch; 0 for none
long_optionThe full-word version of the switch; NULL for none
descThe description of the option; NULL for none
arg_descThe (short) description of the argument; NULL for none
valThe double varible that gets the value of the argument

Definition at line 912 of file wvargs.cc.

◆ add_option() [5/16]

void WvArgs::add_option ( char  short_option,
WvStringParm  long_option,
WvStringParm  desc,
WvStringParm  arg_desc,
WvString val 
)

Add a switch that takes a string argument.

Parameters
short_optionThe single-character version of the switch; 0 for none
long_optionThe full-word version of the switch; NULL for none
descThe description of the option; NULL for none
arg_descThe (short) description of the argument; NULL for none
valThe string varible that gets the value of the argument

Definition at line 920 of file wvargs.cc.

◆ add_option() [6/16]

void WvArgs::add_option ( char  short_option,
WvStringParm  long_option,
WvStringParm  desc,
WvStringParm  arg_desc,
WvStringList val 
)

Add a switch that takes a string argument; the argument is appended to a string list.

Parameters
short_optionThe single-character version of the switch; 0 for none
long_optionThe full-word version of the switch; NULL for none
descThe description of the option; NULL for none
arg_descThe (short) description of the argument; NULL for none
valThe string list to which the argument is appended

Definition at line 929 of file wvargs.cc.

◆ add_option() [7/16]

void WvArgs::add_option ( char  short_option,
WvStringParm  long_option,
WvStringParm  desc,
NoArgCallback  cb,
void *  ud = NULL 
)

Add a switch which does not take an argument which invokes a callback when it is specified.

Parameters
short_optionThe single-character version of the switch; 0 for none
long_optionThe full-word version of the switch; NULL for none
descThe description of the option; NULL for none
cbThe callback function to invoke when the switch is encountered
udA generic userdata pointer to pass to the callback

Definition at line 880 of file wvargs.cc.

◆ add_option() [8/16]

void WvArgs::add_option ( char  short_option,
WvStringParm  long_option,
WvStringParm  desc,
WvStringParm  arg_desc,
ArgCallback  cb,
void *  ud = NULL 
)

Add a switch which takes an argument which invokes a callback when it is specified.

Parameters
short_optionThe single-character version of the switch; 0 for none
long_optionThe full-word version of the switch; NULL for none
descThe description of the option; NULL for none
arg_descThe (short) description of the argument; NULL for none
cbThe callback function to invoke when the switch is encountered
udA generic userdata pointer to pass to the callback

Definition at line 938 of file wvargs.cc.

◆ add_required_arg() [1/2]

void WvArgs::add_required_arg ( WvStringParm  desc,
bool  multiple = false 
)

Add a required argument to the list of parameters.

WvArgs will return an error when run if it is not specified.

Parameters
Thedescription of the parameter

Definition at line 966 of file wvargs.cc.

Referenced by add_optional_arg().

◆ add_optional_arg() [1/2]

void WvArgs::add_optional_arg ( WvStringParm  desc,
bool  multiple = false 
)

Add an optional argument to the list of parameters.

Parameters
Thedescription of the parameter

Definition at line 982 of file wvargs.cc.

References add_required_arg().

◆ remove_option() [1/4]

void WvArgs::remove_option ( char  short_option)

Remove an option by specifying its short form.

Note
If an option has both a short and a long form they can only both be removed with two seperate calls to

Definition at line 948 of file wvargs.cc.

◆ remove_option() [2/4]

void WvArgs::remove_option ( WvStringParm  long_option)

Remove an option by specifying its long form.

Note
If an option has both a short and a long form they can only both be removed with two seperate calls to

Definition at line 954 of file wvargs.cc.

◆ remove_all_options()

void WvArgs::remove_all_options ( )

Remove all options.

Definition at line 960 of file wvargs.cc.

Referenced by zap().

◆ zap() [1/2]

void WvArgs::zap ( )
inline

◆ get_flag()

bool WvArgs::get_flag ( const flags_t  flag) const

Get and set flags.

Definition at line 990 of file wvargs.cc.

◆ set_flag()

void WvArgs::set_flag ( const flags_t  flag,
const bool  value 
)

Definition at line 1002 of file wvargs.cc.

◆ process() [2/2]

bool WvArgs::process ( int  argc,
char **  argv,
WvStringList remaining_args = NULL 
)

Process the command line arguments passed to main() using the options provided through calls to add_option(..).

If remaining_args is provided, any remaining arguments after the command line switches will be appended to this list.

◆ print_usage() [2/2]

void WvArgs::print_usage ( int  argc,
char **  argv 
)

Output the short usage message based on the provided options.

Useful when a bad value is passed as the parameter of a switch.

◆ add_set_bool_option() [2/2]

void WvArgs::add_set_bool_option ( char  short_option,
WvStringParm  long_option,
WvStringParm  desc,
bool &  val 
)

Add a boolean option, which, when specified, sets the specified boolean variable to true.

Parameters
short_optionThe single-character version of the switch; 0 for none
long_optionThe full-word version of the switch; NULL for none
descThe description of the option; NULL for none
valThe boolean variable to set to true when the switch is specified

◆ add_reset_bool_option() [2/2]

void WvArgs::add_reset_bool_option ( char  short_option,
WvStringParm  long_option,
WvStringParm  desc,
bool &  val 
)

Add a boolean option, which, when spefied, sets the specified boolean variable to false.

Parameters
short_optionThe single-character version of the switch; 0 for none
long_optionThe full-word version of the switch; NULL for none
descThe description of the option; NULL for none
valThe boolean variable to set to false when the switch is specified

◆ add_flip_bool_option() [2/2]

void WvArgs::add_flip_bool_option ( char  short_option,
WvStringParm  long_option,
WvStringParm  desc,
bool &  val 
)

Add a boolean option, which, when spefied, changes the value of the boolean variable from false to true or from true to false.

Parameters
short_optionThe single-character version of the switch; 0 for none
long_optionThe full-word version of the switch; NULL for none
descThe description of the option; NULL for none
valThe boolean variable to change when the switch is specified

◆ add_option() [9/16]

void WvArgs::add_option ( char  short_option,
WvStringParm  long_option,
WvStringParm  desc,
WvStringParm  arg_desc,
int &  val 
)

Add a switch that takes an integer argument.

Parameters
short_optionThe single-character version of the switch; 0 for none
long_optionThe full-word version of the switch; NULL for none
descThe description of the option; NULL for none
arg_descThe (short) description of the argument; NULL for none
valThe integer varible that gets the value of the argument

◆ add_option() [10/16]

void WvArgs::add_option ( char  short_option,
WvStringParm  long_option,
WvStringParm  desc,
WvStringParm  arg_desc,
long &  val 
)

Add a switch that takes a long argument.

Parameters
short_optionThe single-character version of the switch; 0 for none
long_optionThe full-word version of the switch; NULL for none
descThe description of the option; NULL for none
arg_descThe (short) description of the argument; NULL for none
valThe long varible that gets the value of the argument

◆ add_option() [11/16]

void WvArgs::add_option ( char  short_option,
WvStringParm  long_option,
WvStringParm  desc,
WvStringParm  arg_desc,
float &  val 
)

Add a switch that takes a float argument.

Parameters
short_optionThe single-character version of the switch; 0 for none
long_optionThe full-word version of the switch; NULL for none
descThe description of the option; NULL for none
arg_descThe (short) description of the argument; NULL for none
valThe float varible that gets the value of the argument

◆ add_option() [12/16]

void WvArgs::add_option ( char  short_option,
WvStringParm  long_option,
WvStringParm  desc,
WvStringParm  arg_desc,
double &  val 
)

Add a switch that takes a double argument.

Parameters
short_optionThe single-character version of the switch; 0 for none
long_optionThe full-word version of the switch; NULL for none
descThe description of the option; NULL for none
arg_descThe (short) description of the argument; NULL for none
valThe double varible that gets the value of the argument

◆ add_option() [13/16]

void WvArgs::add_option ( char  short_option,
WvStringParm  long_option,
WvStringParm  desc,
WvStringParm  arg_desc,
WvString val 
)

Add a switch that takes a string argument.

Parameters
short_optionThe single-character version of the switch; 0 for none
long_optionThe full-word version of the switch; NULL for none
descThe description of the option; NULL for none
arg_descThe (short) description of the argument; NULL for none
valThe string varible that gets the value of the argument

◆ add_option() [14/16]

void WvArgs::add_option ( char  short_option,
WvStringParm  long_option,
WvStringParm  desc,
WvStringParm  arg_desc,
WvStringList val 
)

Add a switch that takes a string argument; the argument is appended to a string list.

Parameters
short_optionThe single-character version of the switch; 0 for none
long_optionThe full-word version of the switch; NULL for none
descThe description of the option; NULL for none
arg_descThe (short) description of the argument; NULL for none
valThe string list to which the argument is appended

◆ add_option() [15/16]

void WvArgs::add_option ( char  short_option,
WvStringParm  long_option,
WvStringParm  desc,
NoArgCallback  cb,
void *  ud = NULL 
)

Add a switch which does not take an argument which invokes a callback when it is specified.

Parameters
short_optionThe single-character version of the switch; 0 for none
long_optionThe full-word version of the switch; NULL for none
descThe description of the option; NULL for none
cbThe callback function to invoke when the switch is encountered
udA generic userdata pointer to pass to the callback

◆ add_option() [16/16]

void WvArgs::add_option ( char  short_option,
WvStringParm  long_option,
WvStringParm  desc,
WvStringParm  arg_desc,
ArgCallback  cb,
void *  ud = NULL 
)

Add a switch which takes an argument which invokes a callback when it is specified.

Parameters
short_optionThe single-character version of the switch; 0 for none
long_optionThe full-word version of the switch; NULL for none
descThe description of the option; NULL for none
arg_descThe (short) description of the argument; NULL for none
cbThe callback function to invoke when the switch is encountered
udA generic userdata pointer to pass to the callback

◆ add_required_arg() [2/2]

void WvArgs::add_required_arg ( WvStringParm  desc,
bool  multiple = false 
)

Add a required argument to the list of parameters.

WvArgs will return an error when run if it is not specified.

Parameters
Thedescription of the parameter

◆ add_optional_arg() [2/2]

void WvArgs::add_optional_arg ( WvStringParm  desc,
bool  multiple = false 
)

Add an optional argument to the list of parameters.

Parameters
Thedescription of the parameter

◆ remove_option() [3/4]

void WvArgs::remove_option ( char  short_option)

Remove an option by specifying its short form.

Note
If an option has both a short and a long form they can only both be removed with two seperate calls to

◆ remove_option() [4/4]

void WvArgs::remove_option ( WvStringParm  long_option)

Remove an option by specifying its long form.

Note
If an option has both a short and a long form they can only both be removed with two seperate calls to

◆ zap() [2/2]

void WvArgs::zap ( )
inline

An alias for remove_all_options()

Definition at line 331 of file include/wvargs.h.

References remove_all_options().


The documentation for this class was generated from the following files: