ArgParser Class Reference
[Miscellaneous Tools]


Detailed Description

Command line arguments parser #include <lemon/arg_parser.h>

List of all members.

Classes

class  RefType
 Magic type for operator[]. More...

Public Member Functions

 ArgParser (int argc, const char **argv)
 
ArgParserintOption (const std::string &name, const std::string &help, int value=0, bool obl=false)
 Add a new integer type option.
ArgParserdoubleOption (const std::string &name, const std::string &help, double value=0, bool obl=false)
 Add a new floating type option.
ArgParserboolOption (const std::string &name, const std::string &help, bool value=false, bool obl=false)
 Add a new bool type option.
ArgParserstringOption (const std::string &name, const std::string &help, std::string value="", bool obl=false)
 Add a new string type option.
ArgParserfuncOption (const std::string &name, const std::string &help, void(*func)(void *), void *data)
 Bind a function to an option.
ArgParserother (const std::string &name, const std::string &help="")
 Give help string for non-parsed arguments.
std::vector< std::string > & files ()
 Non option type arguments.
const std::string & commandName ()
 Give back the command name (the 0th argument).
ArgParserparse ()
 Start the parsing process.
ArgParserrun ()
 Synonym for parse().
bool given (std::string op)
 Check if an opion has been given to the command.
RefType operator[] (const std::string &n)
 Give back the value of an option.
Options with an external strorage.
Using this functions, the value of the option will be directly written into a variable once the option appears in the command line.

ArgParserrefOption (const std::string &name, const std::string &help, int &ref, bool obl=false)
 Add a new integer type option with a storage reference.
ArgParserrefOption (const std::string &name, const std::string &help, double &ref, bool obl=false)
 Add a new floating type option with a storage reference.
ArgParserrefOption (const std::string &name, const std::string &help, bool &ref, bool obl=false)
 Add a new bool type option with a storage reference.
ArgParserrefOption (const std::string &name, const std::string &help, std::string &ref, bool obl=false)
 Add a new string type option with a storage reference.
Option Groups and Synonyms
ArgParseroptionGroup (const std::string &group, const std::string &opt)
 Boundle some options into a group.
ArgParseronlyOneGroup (const std::string &group)
 Make the members of a group exclusive.
ArgParsermandatoryGroup (const std::string &group)
 Make a group mandatory.
ArgParsersynonym (const std::string &syn, const std::string &opt)
 Create synonym to an option.


Member Function Documentation

ArgParser & intOption ( const std::string &  name,
const std::string &  help,
int  value = 0,
bool  obl = false 
)

Parameters:
name The name of the option. The leading '-' must be omitted.
help A help string.
Return values:
value The value of the argument will be written to this variable.
Parameters:
obl Indicate if the option is mandatory.

ArgParser & doubleOption ( const std::string &  name,
const std::string &  help,
double  value = 0,
bool  obl = false 
)

Parameters:
name The name of the option. The leading '-' must be omitted.
help A help string.
Return values:
value The value of the argument will be written to this variable.
Parameters:
obl Indicate if the option is mandatory.

ArgParser & boolOption ( const std::string &  name,
const std::string &  help,
bool  value = false,
bool  obl = false 
)

Parameters:
name The name of the option. The leading '-' must be omitted.
help A help string.
Return values:
value The value of the argument will be written to this variable.
Parameters:
obl Indicate if the option is mandatory.

ArgParser & stringOption ( const std::string &  name,
const std::string &  help,
std::string  value = "",
bool  obl = false 
)

Parameters:
name The name of the option. The leading '-' must be omitted.
help A help string.
Return values:
value The value of the argument will be written to this variable.
Parameters:
obl Indicate if the option is mandatory.

ArgParser & funcOption ( const std::string &  name,
const std::string &  help,
void(*)(void *)  func,
void *  data 
)

Parameters:
name The name of the option. The leading '-' must be omitted.
help A help string.
Return values:
func The function to be called when the option is given. It must be of type "void f(void *)"
Parameters:
data Data to be passed to func

ArgParser & refOption ( const std::string &  name,
const std::string &  help,
int &  ref,
bool  obl = false 
)

Parameters:
name The name of the option. The leading '-' must be omitted.
help A help string.
Return values:
ref The value of the argument will be written to this variable.
Parameters:
obl Indicate if the option is mandatory.

ArgParser & refOption ( const std::string &  name,
const std::string &  help,
double &  ref,
bool  obl = false 
)

Parameters:
name The name of the option. The leading '-' must be omitted.
help A help string.
Return values:
ref The value of the argument will be written to this variable.
Parameters:
obl Indicate if the option is mandatory.

ArgParser & refOption ( const std::string &  name,
const std::string &  help,
bool &  ref,
bool  obl = false 
)

Parameters:
name The name of the option. The leading '-' must be omitted.
help A help string.
Return values:
ref The value of the argument will be written to this variable.
Parameters:
obl Indicate if the option is mandatory.

ArgParser & refOption ( const std::string &  name,
const std::string &  help,
std::string &  ref,
bool  obl = false 
)

Parameters:
name The name of the option. The leading '-' must be omitted.
help A help string.
Return values:
ref The value of the argument will be written to this variable.
Parameters:
obl Indicate if the option is mandatory.

ArgParser & optionGroup ( const std::string &  group,
const std::string &  opt 
)

You can group some option by calling this function repeatedly for each option to be grupped with the same groupname.

Parameters:
group The group name
opt The option name

ArgParser & onlyOneGroup ( const std::string &  group  ) 

If you call this function for a group, than at most one of them can be given at the same time

ArgParser & mandatoryGroup ( const std::string &  group  ) 

Using this function, at least one of the members of group must be given.

ArgParser & synonym ( const std::string &  syn,
const std::string &  opt 
)

With this function you can create a sysnonym called sys of the option opt.

ArgParser & other ( const std::string &  name,
const std::string &  help = "" 
)

With this function you can give help string for non-parsed arguments. the parameter name will be printed in the short usage line, while help gives a more detailed description.

std::vector<std::string>& files (  )  [inline]

Gives back a reference to a vector consisting of the program arguments not starting with a '-' character.

RefType operator[] ( const std::string &  n  )  [inline]

Give back the value of an option

See also:
RefType


Generated on Thu Jun 4 04:03:17 2009 for LEMON by  doxygen 1.5.9