ParseOptionsArguments Class Reference

Class for parsing command line options and arguments. More...

#include <ParseOptionsArguments.h>

List of all members.

Public Types

typedef std::string String
 The string type.

Public Member Functions

Constructors etc.

 ParseOptionsArguments ()
 Default constructor.
 ParseOptionsArguments (const int argc, char *argv[], const char optionPrefix= '-')
 Construct from the command line arguments.
 ~ParseOptionsArguments ()
 Trivial destructor.
Accessors.

const StringgetProgramName () const
 Get the program name.
char getOptionPrefix () const
 Get the option prefix character.
int getNumberOfOptions () const
 Get the number of options (with and without values) remaining.
bool areOptionsEmpty () const
 Return true if there are no more options (with and without values) remaining.
int getNumberOfArguments () const
 Get the number of arguments remaining.
bool areArgumentsEmpty () const
 Return true if there are no more arguments remaining.
Manipulators.

void parse (int argc, char *argv[])
 Parse the options and arguments.
void setOptionPrefix (const char optionPrefix)
 Set the option prefix character.
bool getOption (const String &key)
 Return true if the option was given. Erase the option.
bool getOption (const char key)
 Return true if the option was given. Erase the option.
template<typename T >
bool getOption (const String &key, T *value)
 Return true if the option was given. Set the option value and erase the option.
template<typename T >
bool getOption (const char key, T *value)
 Return true if the option was given. Set the option value and erase the option.
bool getOption (const String &key, String *value)
 Return true if the option was given. Set the option value as a string and erase the option.
String getArgument ()
 Get the current argument and erase it.
template<typename T >
bool getArgument (T *x)
 Get the current argument and erase it.
File I/O.

void printOptions (std::ostream &out) const
 Print any remaining options (with and without values).
void printArguments (std::ostream &out) const
 Print any remaining arguments.

Detailed Description

Class for parsing command line options and arguments.


Member Function Documentation

template<typename T >
bool ParseOptionsArguments::getArgument ( T *  x  )  [inline]

Get the current argument and erase it.

Precondition:
The number of remaining arguments must not be zero.

The object of type T must be able to read its' state from a stream with operator>>().

Returns:
true if the argument could be read.
String ParseOptionsArguments::getArgument (  )  [inline]

Get the current argument and erase it.

Precondition:
The number of remaining arguments must not be zero.
template<typename T >
bool ParseOptionsArguments::getOption ( const char  key,
T *  value 
) [inline]

Return true if the option was given. Set the option value and erase the option.

This is a convenience function for single character option keys.

References getOption().

bool ParseOptionsArguments::getOption ( const char  key  )  [inline]

Return true if the option was given. Erase the option.

This is a convenience function for single character option keys.

References getOption().


The documentation for this class was generated from the following file:
Generated on Thu Jun 30 02:14:52 2016 for Algorithms and Data Structures Package by  doxygen 1.6.3