Main Page | Alphabetical List | Class List | File List | Class Members

dsr::Argument_helper Class Reference

A helper class for parsing command line arguments. More...

#include <Argument_helper.h>

List of all members.

Public Member Functions

void new_flag (char key, const char *long_name, const char *description, bool &dest)
 Toggle a boolean.

void new_string (const char *arg_description, const char *description, std::string &dest)
 add a string argument

void new_named_string (char key, const char *long_name, const char *arg_description, const char *description, std::string &dest)
 add a string which must have a key.

void new_optional_string (const char *arg_description, const char *description, std::string &dest)
 Add an optional string-- any extra arguments are put in these.

void new_int (const char *arg_description, const char *description, int &dest)
 add an int

void new_named_int (char key, const char *long_name, const char *value_name, const char *description, int &dest)
 Add an int.

void new_optional_int (const char *value_name, const char *description, int &dest)
 Add an optional named int.

void new_double (const char *value_name, const char *description, double &dest)
 Add a named double.

void new_named_double (char key, const char *long_name, const char *value_name, const char *description, double &dest)
 Add a named double.

void new_optional_double (const char *value_name, const char *description, double &dest)
 Add a named double.

void new_char (const char *value_name, const char *description, char &dest)
 Add an char.

void new_named_char (char key, const char *long_name, const char *value_name, const char *description, char &dest)
 Add an optional char.

void new_optional_char (const char *value_name, const char *description, char &dest)
 Add an named char.

void new_unsigned_int (const char *value_name, const char *description, unsigned int &dest)
 Add an unsigned int.

void new_optional_unsigned_int (const char *value_name, const char *description, unsigned int &dest)
 Add an named unsigned int.

void new_named_unsigned_int (char key, const char *long_name, const char *value_name, const char *description, unsigned int &dest)
 Add an optional named unsigned int.

void new_named_string_vector (char key, const char *long_name, const char *value_name, const char *description, std::vector< std::string > &dest)
 add a target which takes a list of strings

void set_string_vector (const char *arg_description, const char *description, std::vector< std::string > &dest)
 add a vector of strings.

void set_author (const char *author)
 Set who wrote the program.

void set_description (const char *descr)
 Set what the program does.

void set_version (float v)
 Set what the version is.

void set_version (const char *str)
void set_name (const char *name)
 Set the name of the program.

void set_build_date (const char *date)
 Set when the program was built.

void process (int argc, const char **argv)
 Process the list of arguments and parse them.

void process (int argc, char **argv)
void write_usage (std::ostream &out) const
 Write how to call the program.

void write_values (std::ostream &out) const
 Write the values of all the possible arguments.


Protected Types

typedef std::map< char, Argument_target * > SMap
typedef std::map< std::string,
Argument_target * > 
LMap
typedef std::vector< Argument_target * > UVect

Protected Member Functions

void new_argument_target (Argument_target *)
void handle_error () const

Protected Attributes

SMap short_names_
LMap long_names_
std::string author_
std::string name_
std::string description_
std::string date_
float version_
bool seen_end_named_
std::vector< Argument_target * > unnamed_arguments_
std::vector< Argument_target * > optional_unnamed_arguments_
std::vector< Argument_target * > all_arguments_
std::string extra_arguments_descr_
std::string extra_arguments_arg_descr_
std::vector< std::string > * extra_arguments_
std::vector< Argument_target
* >::iterator 
current_unnamed_
std::vector< Argument_target
* >::iterator 
current_optional_unnamed_


Detailed Description

A helper class for parsing command line arguments.

This is the only class you need to look at in order to use it.

Definition at line 90 of file Argument_helper.h.


Member Function Documentation

void dsr::Argument_helper::new_named_string_vector char  key,
const char *  long_name,
const char *  value_name,
const char *  description,
std::vector< std::string > &  dest
 

add a target which takes a list of strings

Only named makes sense as the string vector default handles unnamed and optional.

Definition at line 404 of file Argument_helper.cc.

void dsr::Argument_helper::process int  argc,
const char **  argv
 

Process the list of arguments and parse them.

This returns true if all the required arguments are there.

Definition at line 562 of file Argument_helper.cc.

References write_usage().

void dsr::Argument_helper::set_string_vector const char *  arg_description,
const char *  description,
std::vector< std::string > &  dest
 

add a vector of strings.

Any arguments which are not claimed by earlier unnamed arguments or which are named are put here. This means you cannot have a string vector followed by a string.

Definition at line 320 of file Argument_helper.cc.


The documentation for this class was generated from the following files:
Generated on Thu Oct 21 17:29:54 2004 for Argument_helper by doxygen 1.3.6