OSG  3.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
osg::ArgumentParser Class Reference

#include <ArgumentParser.h>

Collaboration diagram for osg::ArgumentParser:
Collaboration graph
[legend]

Classes

class  Parameter
 

Public Types

enum  ErrorSeverity { BENIGN = 0, CRITICAL = 1 }
 
typedef std::map< std::string,
ErrorSeverity
ErrorMessageMap
 

Public Member Functions

 ArgumentParser (int *argc, char **argv)
 
void setApplicationUsage (ApplicationUsage *usage)
 
ApplicationUsagegetApplicationUsage ()
 
const ApplicationUsagegetApplicationUsage () const
 
int & argc ()
 
char ** argv ()
 
char * operator[] (int pos)
 
const char * operator[] (int pos) const
 
std::string getApplicationName () const
 
int find (const std::string &str) const
 
bool isOption (int pos) const
 
bool isString (int pos) const
 
bool isNumber (int pos) const
 
bool containsOptions () const
 
void remove (int pos, int num=1)
 
bool match (int pos, const std::string &str) const
 
bool read (const std::string &str)
 
bool read (const std::string &str, Parameter value1)
 
bool read (const std::string &str, Parameter value1, Parameter value2)
 
bool read (const std::string &str, Parameter value1, Parameter value2, Parameter value3)
 
bool read (const std::string &str, Parameter value1, Parameter value2, Parameter value3, Parameter value4)
 
bool read (const std::string &str, Parameter value1, Parameter value2, Parameter value3, Parameter value4, Parameter value5)
 
bool read (const std::string &str, Parameter value1, Parameter value2, Parameter value3, Parameter value4, Parameter value5, Parameter value6)
 
bool read (const std::string &str, Parameter value1, Parameter value2, Parameter value3, Parameter value4, Parameter value5, Parameter value6, Parameter value7)
 
bool read (const std::string &str, Parameter value1, Parameter value2, Parameter value3, Parameter value4, Parameter value5, Parameter value6, Parameter value7, Parameter value8)
 
bool read (int pos, const std::string &str)
 
bool read (int pos, const std::string &str, Parameter value1)
 
bool read (int pos, const std::string &str, Parameter value1, Parameter value2)
 
bool read (int pos, const std::string &str, Parameter value1, Parameter value2, Parameter value3)
 
bool read (int pos, const std::string &str, Parameter value1, Parameter value2, Parameter value3, Parameter value4)
 
bool read (int pos, const std::string &str, Parameter value1, Parameter value2, Parameter value3, Parameter value4, Parameter value5)
 
bool read (int pos, const std::string &str, Parameter value1, Parameter value2, Parameter value3, Parameter value4, Parameter value5, Parameter value6)
 
bool read (int pos, const std::string &str, Parameter value1, Parameter value2, Parameter value3, Parameter value4, Parameter value5, Parameter value6, Parameter value7)
 
bool read (int pos, const std::string &str, Parameter value1, Parameter value2, Parameter value3, Parameter value4, Parameter value5, Parameter value6, Parameter value7, Parameter value8)
 
bool errors (ErrorSeverity severity=BENIGN) const
 
void reportError (const std::string &message, ErrorSeverity severity=CRITICAL)
 
void reportRemainingOptionsAsUnrecognized (ErrorSeverity severity=BENIGN)
 
ErrorMessageMapgetErrorMessageMap ()
 
const ErrorMessageMapgetErrorMessageMap () const
 
void writeErrorMessages (std::ostream &output, ErrorSeverity sevrity=BENIGN)
 
ApplicationUsage::Type readHelpType ()
 

Static Public Member Functions

static bool isOption (const char *str)
 
static bool isString (const char *str)
 
static bool isNumber (const char *str)
 
static bool isBool (const char *str)
 

Protected Attributes

int * _argc
 
char ** _argv
 
ErrorMessageMap _errorMessageMap
 
ref_ptr< ApplicationUsage_usage
 

Detailed Description

Definition at line 27 of file ArgumentParser.h.

Member Typedef Documentation

typedef std::map<std::string,ErrorSeverity> osg::ArgumentParser::ErrorMessageMap

Definition at line 173 of file ArgumentParser.h.

Member Enumeration Documentation

Enumerator
BENIGN 
CRITICAL 

Definition at line 167 of file ArgumentParser.h.

Constructor & Destructor Documentation

osg::ArgumentParser::ArgumentParser ( int *  argc,
char **  argv 
)

Member Function Documentation

int& osg::ArgumentParser::argc ( )
inline

Return the argument count.

Definition at line 102 of file ArgumentParser.h.

char** osg::ArgumentParser::argv ( )
inline

Return the argument array.

Definition at line 105 of file ArgumentParser.h.

bool osg::ArgumentParser::containsOptions ( ) const
bool osg::ArgumentParser::errors ( ErrorSeverity  severity = BENIGN) const

Return the error flag, true if an error has occurred when reading arguments.

int osg::ArgumentParser::find ( const std::string &  str) const

Return the position of an occurrence of a string in the argument list. Return -1 if no string is found.

std::string osg::ArgumentParser::getApplicationName ( ) const

Return the application name, as specified by argv[0]

ApplicationUsage* osg::ArgumentParser::getApplicationUsage ( )
inline

Definition at line 98 of file ArgumentParser.h.

const ApplicationUsage* osg::ArgumentParser::getApplicationUsage ( ) const
inline

Definition at line 99 of file ArgumentParser.h.

ErrorMessageMap& osg::ArgumentParser::getErrorMessageMap ( )
inline

Return the error message, if any has occurred.

Definition at line 185 of file ArgumentParser.h.

const ErrorMessageMap& osg::ArgumentParser::getErrorMessageMap ( ) const
inline

Return the error message, if any has occurred.

Definition at line 188 of file ArgumentParser.h.

static bool osg::ArgumentParser::isBool ( const char *  str)
static

Return true if specified parameter is a bool.

static bool osg::ArgumentParser::isNumber ( const char *  str)
static

Return true if specified parameter is a number.

bool osg::ArgumentParser::isNumber ( int  pos) const

Return true if the specified parameter is a number.

static bool osg::ArgumentParser::isOption ( const char *  str)
static

Return true if the specified string is an option in the form -option or –option.

bool osg::ArgumentParser::isOption ( int  pos) const

Return true if the specified parameter is an option in the form of -option or –option.

static bool osg::ArgumentParser::isString ( const char *  str)
static

Return true if string is non-NULL and not an option in the form -option or –option.

bool osg::ArgumentParser::isString ( int  pos) const

Return true if the specified parameter is a string not in the form of an option.

bool osg::ArgumentParser::match ( int  pos,
const std::string &  str 
) const

Return true if the specified argument matches the given string.

char* osg::ArgumentParser::operator[] ( int  pos)
inline

Return the char* argument at the specified position.

Definition at line 108 of file ArgumentParser.h.

const char* osg::ArgumentParser::operator[] ( int  pos) const
inline

Return the const char* argument at the specified position.

Definition at line 111 of file ArgumentParser.h.

bool osg::ArgumentParser::read ( const std::string &  str)

Search for an occurrence of a string in the argument list. If found, remove that occurrence and return true. Otherwise, return false.

bool osg::ArgumentParser::read ( const std::string &  str,
Parameter  value1 
)
bool osg::ArgumentParser::read ( const std::string &  str,
Parameter  value1,
Parameter  value2 
)
bool osg::ArgumentParser::read ( const std::string &  str,
Parameter  value1,
Parameter  value2,
Parameter  value3 
)
bool osg::ArgumentParser::read ( const std::string &  str,
Parameter  value1,
Parameter  value2,
Parameter  value3,
Parameter  value4 
)
bool osg::ArgumentParser::read ( const std::string &  str,
Parameter  value1,
Parameter  value2,
Parameter  value3,
Parameter  value4,
Parameter  value5 
)
bool osg::ArgumentParser::read ( const std::string &  str,
Parameter  value1,
Parameter  value2,
Parameter  value3,
Parameter  value4,
Parameter  value5,
Parameter  value6 
)
bool osg::ArgumentParser::read ( const std::string &  str,
Parameter  value1,
Parameter  value2,
Parameter  value3,
Parameter  value4,
Parameter  value5,
Parameter  value6,
Parameter  value7 
)
bool osg::ArgumentParser::read ( const std::string &  str,
Parameter  value1,
Parameter  value2,
Parameter  value3,
Parameter  value4,
Parameter  value5,
Parameter  value6,
Parameter  value7,
Parameter  value8 
)
bool osg::ArgumentParser::read ( int  pos,
const std::string &  str 
)

If the argument value at the specified position matches the given string, and subsequent parameters are also matched, then set the parameter values, remove the arguments from the list, and return true. Otherwise, return false.

bool osg::ArgumentParser::read ( int  pos,
const std::string &  str,
Parameter  value1 
)
bool osg::ArgumentParser::read ( int  pos,
const std::string &  str,
Parameter  value1,
Parameter  value2 
)
bool osg::ArgumentParser::read ( int  pos,
const std::string &  str,
Parameter  value1,
Parameter  value2,
Parameter  value3 
)
bool osg::ArgumentParser::read ( int  pos,
const std::string &  str,
Parameter  value1,
Parameter  value2,
Parameter  value3,
Parameter  value4 
)
bool osg::ArgumentParser::read ( int  pos,
const std::string &  str,
Parameter  value1,
Parameter  value2,
Parameter  value3,
Parameter  value4,
Parameter  value5 
)
bool osg::ArgumentParser::read ( int  pos,
const std::string &  str,
Parameter  value1,
Parameter  value2,
Parameter  value3,
Parameter  value4,
Parameter  value5,
Parameter  value6 
)
bool osg::ArgumentParser::read ( int  pos,
const std::string &  str,
Parameter  value1,
Parameter  value2,
Parameter  value3,
Parameter  value4,
Parameter  value5,
Parameter  value6,
Parameter  value7 
)
bool osg::ArgumentParser::read ( int  pos,
const std::string &  str,
Parameter  value1,
Parameter  value2,
Parameter  value3,
Parameter  value4,
Parameter  value5,
Parameter  value6,
Parameter  value7,
Parameter  value8 
)
ApplicationUsage::Type osg::ArgumentParser::readHelpType ( )

This convenience method handles help requests on the command line. Return the type(s) of help requested. The return value of this function is suitable for passing into getApplicationUsage()->write(). If ApplicationUsage::NO_HELP is returned then no help commandline option was found on the command line.

void osg::ArgumentParser::remove ( int  pos,
int  num = 1 
)

Remove one or more arguments from the argv argument list, and decrement the argc respectively.

void osg::ArgumentParser::reportError ( const std::string &  message,
ErrorSeverity  severity = CRITICAL 
)

Report an error message by adding to the ErrorMessageMap.

void osg::ArgumentParser::reportRemainingOptionsAsUnrecognized ( ErrorSeverity  severity = BENIGN)

For each remaining option, report it as unrecognized.

void osg::ArgumentParser::setApplicationUsage ( ApplicationUsage usage)
inline

Definition at line 97 of file ArgumentParser.h.

void osg::ArgumentParser::writeErrorMessages ( std::ostream &  output,
ErrorSeverity  sevrity = BENIGN 
)

Write error messages to the given ostream, if at or above the given severity.

Member Data Documentation

int* osg::ArgumentParser::_argc
protected

Definition at line 204 of file ArgumentParser.h.

char** osg::ArgumentParser::_argv
protected

Definition at line 205 of file ArgumentParser.h.

ErrorMessageMap osg::ArgumentParser::_errorMessageMap
protected

Definition at line 206 of file ArgumentParser.h.

ref_ptr<ApplicationUsage> osg::ArgumentParser::_usage
protected

Definition at line 207 of file ArgumentParser.h.


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