14#ifndef OSG_ARGUMENTPARSER
15#define OSG_ARGUMENTPARSER 1
54 Parameter(
bool& value) { _type = BOOL_PARAMETER; _value._bool = &value; }
56 Parameter(
float& value) { _type = FLOAT_PARAMETER; _value._float = &value; }
58 Parameter(
double& value) { _type = DOUBLE_PARAMETER; _value._double = &value; }
60 Parameter(
int& value) { _type = INT_PARAMETER; _value._int = &value; }
62 Parameter(
unsigned int& value) { _type = UNSIGNED_INT_PARAMETER; _value._uint = &value; }
64 Parameter(std::string& value) { _type = STRING_PARAMETER; _value._string = &value; }
70 bool valid(
const char* str)
const;
105 char**
argv() {
return _argv; }
108 char* operator [] (
int pos) {
return _argv[pos]; }
111 const char* operator [] (
int pos)
const {
return _argv[pos]; }
118 int find(
const std::string& str)
const;
138 bool match(
int pos,
const std::string& str)
const;
142 bool read(
const std::string& str);
156 bool read(
int pos,
const std::string& str);
Definition ApplicationUsage:26
Type
Definition ApplicationUsage:48
Definition ArgumentParser:32
Parameter(float &value)
Definition ArgumentParser:56
Parameter(bool &value)
Definition ArgumentParser:54
bool assign(const char *str)
Parameter(int &value)
Definition ArgumentParser:60
ValueUnion _value
Definition ArgumentParser:76
Parameter(unsigned int &value)
Definition ArgumentParser:62
bool valid(const char *str) const
Parameter(double &value)
Definition ArgumentParser:58
Parameter(std::string &value)
Definition ArgumentParser:64
ParameterType
Definition ArgumentParser:35
@ INT_PARAMETER
Definition ArgumentParser:39
@ DOUBLE_PARAMETER
Definition ArgumentParser:38
@ FLOAT_PARAMETER
Definition ArgumentParser:37
@ BOOL_PARAMETER
Definition ArgumentParser:36
@ UNSIGNED_INT_PARAMETER
Definition ArgumentParser:40
Parameter(const Parameter ¶m)
Definition ArgumentParser:66
ParameterType _type
Definition ArgumentParser:75
Definition ArgumentParser:28
ApplicationUsage::Type readHelpType()
std::string getApplicationName() const
static bool isString(const char *str)
int & argc()
Definition ArgumentParser:102
static bool isOption(const char *str)
void reportRemainingOptionsAsUnrecognized(ErrorSeverity severity=BENIGN)
bool read(const std::string &str)
bool read(int pos, const std::string &str, Parameter value1, Parameter value2, Parameter value3, Parameter value4, Parameter value5)
void writeErrorMessages(std::ostream &output, ErrorSeverity sevrity=BENIGN)
char ** _argv
Definition ArgumentParser:205
bool read(const std::string &str, Parameter value1, Parameter value2, Parameter value3, Parameter value4)
ApplicationUsage * getApplicationUsage()
Definition ArgumentParser:98
bool read(int pos, const std::string &str, Parameter value1, Parameter value2, Parameter value3, Parameter value4, Parameter value5, Parameter value6)
bool isNumber(int pos) const
bool match(int pos, const std::string &str) const
bool read(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(const std::string &str, Parameter value1, Parameter value2)
ErrorMessageMap _errorMessageMap
Definition ArgumentParser:206
bool read(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)
char ** argv()
Definition ArgumentParser:105
bool read(int pos, const std::string &str, Parameter value1, Parameter value2)
const ErrorMessageMap & getErrorMessageMap() const
Definition ArgumentParser:188
bool read(int pos, const std::string &str)
bool read(int pos, const std::string &str, Parameter value1, Parameter value2, Parameter value3, Parameter value4)
bool read(const std::string &str, Parameter value1)
bool read(int pos, const std::string &str, Parameter value1, Parameter value2, Parameter value3, Parameter value4, Parameter value5, Parameter value6, Parameter value7, Parameter value8)
static bool isNumber(const char *str)
const ApplicationUsage * getApplicationUsage() const
Definition ArgumentParser:99
void reportError(const std::string &message, ErrorSeverity severity=CRITICAL)
int find(const std::string &str) const
bool read(int pos, const std::string &str, Parameter value1, Parameter value2, Parameter value3)
bool read(const std::string &str, Parameter value1, Parameter value2, Parameter value3, Parameter value4, Parameter value5, Parameter value6, Parameter value7, Parameter value8)
ErrorMessageMap & getErrorMessageMap()
Definition ArgumentParser:185
ErrorSeverity
Definition ArgumentParser:168
bool isString(int pos) const
bool isOption(int pos) const
bool errors(ErrorSeverity severity=BENIGN) const
bool containsOptions() const
int * _argc
Definition ArgumentParser:204
bool read(const std::string &str, Parameter value1, Parameter value2, Parameter value3, Parameter value4, Parameter value5)
void setApplicationUsage(ApplicationUsage *usage)
Definition ArgumentParser:97
ArgumentParser(int *argc, char **argv)
void remove(int pos, int num=1)
ref_ptr< ApplicationUsage > _usage
Definition ArgumentParser:207
static bool isBool(const char *str)
bool read(const std::string &str, Parameter value1, Parameter value2, Parameter value3)
std::map< std::string, ErrorSeverity > ErrorMessageMap
Definition ArgumentParser:173
author: Julien Valentin 2017 (mp3butcher@hotmail.com)
Definition AlphaFunc:19
#define OSG_EXPORT
Definition osg/Export:39
Definition ArgumentParser:45
bool * _bool
Definition ArgumentParser:46
std::string * _string
Definition ArgumentParser:51
int * _int
Definition ArgumentParser:49
float * _float
Definition ArgumentParser:47
unsigned int * _uint
Definition ArgumentParser:50
double * _double
Definition ArgumentParser:48