Added support for bool in ArgumentParser::Parameter.

Added support for using Input::read(...) methods using ArgumentParser::Paramter
to adapter to multiple paramter types.
This commit is contained in:
Robert Osfield
2007-09-19 15:29:57 +00:00
parent cf69352873
commit 7ea3632dfc
6 changed files with 253 additions and 0 deletions

View File

@@ -33,6 +33,7 @@ class OSG_EXPORT ArgumentParser
public:
enum ParameterType
{
BOOL_PARAMETER,
FLOAT_PARAMETER,
DOUBLE_PARAMETER,
INT_PARAMETER,
@@ -42,6 +43,7 @@ class OSG_EXPORT ArgumentParser
union ValueUnion
{
bool* _bool;
float* _float;
double* _double;
int* _int;
@@ -49,6 +51,8 @@ class OSG_EXPORT ArgumentParser
std::string* _string;
};
Parameter(bool& value) { _type = BOOL_PARAMETER; _value._bool = &value; }
Parameter(float& value) { _type = FLOAT_PARAMETER; _value._float = &value; }
Parameter(double& value) { _type = DOUBLE_PARAMETER; _value._double = &value; }
@@ -83,6 +87,9 @@ class OSG_EXPORT ArgumentParser
/** Return true if specified parameter is a number. */
static bool isNumber(const char* str);
/** Return true if specified parameter is a bool. */
static bool isBool(const char* str);
public:
ArgumentParser(int* argc,char **argv);