HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
library

Functions

static ArgAction ArgParse::store_true ()
 Return an action that stores 1 into its destination attribute. More...
 
static ArgAction ArgParse::store_false ()
 Return an action that stores 0 into its destination attribute. More...
 
template<typename T >
static ArgAction ArgParse::store_const (const T &value)
 
static ArgAction ArgParse::store_const (const char *value)
 
template<typename T = ustring>
static ArgAction ArgParse::store ()
 
template<typename T = ustring>
static ArgAction ArgParse::append ()
 
static Action ArgParse::do_nothing ()
 

Detailed Description

These are actions provided for convenience. Examples of their use:

ArgParse ap;
...

// Flag, just store 1 if set (default to 0)
ap.add_argument("-v")
  .action(ArgParse::store_true());

// Store 42 if the flag is encountered (default is 1)
ap.add_argument("--foo")
  .defaultval(1)
  .action(ArgParse::store_const(42));

// Take an integer argument and store it
ap.add_argument("--bar")
  .action(ArgParse::store<int>());

// Take 3 floating point arguments, pass default as Color3f.
ap.add_argument("--color")
  .nargs(3)
  .metavar("R G B")
  .action(ArgParse::store<float>)
  .defaultval(Imath::Color3f(0.5f, 0.5f, 0.5f));

// Take a single string argument, but *append* it, so if the
// option appears multiple time, you get a list of strings.
ap.add_argument("-o")
  .action(ArgParse::append());

// Another string appending example, but using a positional
// argument.
ap.add_argument("filename")
  .action(ArgParse::append());

Function Documentation

template<typename T = ustring>
static ArgAction ArgParse::append ( )
inlinestatic

Return an action that appends into its destination attribute the following n command line arguments (where n is the number of additional command line arguments that this option requires).

Definition at line 645 of file argparse.h.

static Action ArgParse::do_nothing ( )
static

Return an action that does nothing. I guess you could use use this for an argument that is obsolete and is still accepted, but no longer has any function.

template<typename T = ustring>
static ArgAction ArgParse::store ( )
inlinestatic

Return an action that stores into its destination attribute the following n command line arguments (where n is the number of additional command line arguments that this option requires).

Definition at line 623 of file argparse.h.

template<typename T >
static ArgAction ArgParse::store_const ( const T value)
inlinestatic

Return an action that stores a constant value into its destination attribute.

Definition at line 606 of file argparse.h.

static ArgAction ArgParse::store_const ( const char *  value)
inlinestatic

Definition at line 613 of file argparse.h.

static ArgAction ArgParse::store_false ( )
static

Return an action that stores 0 into its destination attribute.

static ArgAction ArgParse::store_true ( )
static

Return an action that stores 1 into its destination attribute.