|
Nebula
|
#include <commandlineargs.h>
A universal cmd line argument parser.
The command line string must have the form
cmd arg0[=]value0 arg1[=]value1 arg2[=]value2
Public Member Functions | |
| CommandLineArgs () | |
| default constructor | |
| CommandLineArgs (const String &cmdLine) | |
| construct from Win32-style command string | |
| CommandLineArgs (int argc, const char **argv) | |
| construct from posix style command string | |
| const String & | GetCmdName () const |
| get the command name | |
| bool | HasArg (const String &arg, const IndexT start=0) const |
| return true if arg exists | |
| const String & | GetString (const String &name, const String &defaultValue="") const |
| get string value | |
| Util::Array< Util::String > | GetStrings (const String &name, const String &defaultValue="") const |
| get all string values | |
| int | GetInt (const String &name, int defaultValue=0) const |
| get int value | |
| Util::Array< int > | GetInts (const String &name, int defaultValue=0) const |
| get all int values | |
| float | GetFloat (const String &name, float defaultValue=0.0f) const |
| get float value | |
| Util::Array< float > | GetFloats (const String &name, float defaultValue=0.0f) const |
| get all float values | |
| bool | GetBool (const String &name, bool defaultValue=false) const |
| get bool value (key=value) | |
| Util::Array< bool > | GetBools (const String &name, bool defaultValue=false) const |
| get all bool values | |
| bool | GetBoolFlag (const String &name) const |
| get bool flag (args only needs to exist to trigger as true) | |
| Math::vec4 | GetVec4 (const String &name, const Math::vec4 &defaultValue=Math::vec4()) const |
| get vec4 value | |
| Util::Array< Math::vec4 > | GetVec4s (const String &name, const Math::vec4 &defaultValue=Math::vec4()) const |
| get all vec4 values | |
| Math::mat4 | GetMat4 (const String &name, const Math::mat4 &defaultValue=Math::mat4()) const |
| get mat4 value | |
| Util::Array< Math::mat4 > | GetMat4s (const String &name, const Math::mat4 &defaultValue=Math::mat4()) const |
| get all mat4 values | |
| bool | IsEmpty () const |
| returns true if the argument list is empty | |
| SizeT | GetNumArgs () const |
| get number of arguments (exluding command name) | |
| const String & | GetStringAtIndex (IndexT index) const |
| get string argument at index | |
| int | GetIntAtIndex (IndexT index) const |
| get int value at index | |
| float | GetFloatAtIndex (IndexT index) const |
| get float value at index | |
| bool | GetBoolAtIndex (IndexT index) const |
| get bool value at index | |
| Math::vec4 | GetVec4AtIndex (IndexT index) const |
| get vec4 value at index | |
| Math::mat4 | GetMat4AtIndex (IndexT index) const |
| get mat4 value at index | |
| void | AppendCommandString (const CommandLineArgs &otherArgs) |
| append other command string | |
| const Dictionary< String, String > & | GetPairs () const |
| get any key value pairs from args | |
Private Member Functions | |
| void | Error (const String &argName) const |
| put out an error | |
| int | FindArgIndex (const String &argName, const IndexT start=0) const |
| find index of argument, fails hard with error msg if not found | |
| void | ParseIntoGroups (const Array< String > &Tokenized) |
| sort out any explicit key=value arguments into separate structure | |
Private Attributes | |
| Array< String > | args |
| Dictionary< String, String > | keyPairs |
| Util::CommandLineArgs::CommandLineArgs | ( | ) |
default constructor
| Util::CommandLineArgs::CommandLineArgs | ( | const String & | cmdLine | ) |
construct from Win32-style command string
| Util::CommandLineArgs::CommandLineArgs | ( | int | argc, |
| const char ** | argv ) |
construct from posix style command string
| void Util::CommandLineArgs::AppendCommandString | ( | const CommandLineArgs & | otherArgs | ) |
append other command string
|
private |
put out an error
Put out a missing argument error.
|
private |
find index of argument, fails hard with error msg if not found
Returns index of argument.
Throws an error if argument not found.
| bool Util::CommandLineArgs::GetBool | ( | const String & | name, |
| bool | defaultValue = false ) const |
get bool value (key=value)
| bool Util::CommandLineArgs::GetBoolAtIndex | ( | IndexT | index | ) | const |
get bool value at index
| bool Util::CommandLineArgs::GetBoolFlag | ( | const String & | name | ) | const |
get bool flag (args only needs to exist to trigger as true)
| Util::Array< bool > Util::CommandLineArgs::GetBools | ( | const String & | name, |
| bool | defaultValue = false ) const |
get all bool values
| const String & Util::CommandLineArgs::GetCmdName | ( | ) | const |
get the command name
Returns the command name.
| float Util::CommandLineArgs::GetFloat | ( | const String & | name, |
| float | defaultValue = 0.0f ) const |
get float value
| float Util::CommandLineArgs::GetFloatAtIndex | ( | IndexT | index | ) | const |
get float value at index
| Util::Array< float > Util::CommandLineArgs::GetFloats | ( | const String & | name, |
| float | defaultValue = 0.0f ) const |
get all float values
| int Util::CommandLineArgs::GetInt | ( | const String & | name, |
| int | defaultValue = 0 ) const |
get int value
| int Util::CommandLineArgs::GetIntAtIndex | ( | IndexT | index | ) | const |
get int value at index
| Util::Array< int > Util::CommandLineArgs::GetInts | ( | const String & | name, |
| int | defaultValue = 0 ) const |
get all int values
| mat4 Util::CommandLineArgs::GetMat4 | ( | const String & | name, |
| const Math::mat4 & | defaultValue = Math::mat4() ) const |
get mat4 value
| Util::Array< Math::mat4 > Util::CommandLineArgs::GetMat4s | ( | const String & | name, |
| const Math::mat4 & | defaultValue = Math::mat4() ) const |
get all mat4 values
| SizeT Util::CommandLineArgs::GetNumArgs | ( | ) | const |
get number of arguments (exluding command name)
|
inline |
get any key value pairs from args
| const String & Util::CommandLineArgs::GetString | ( | const String & | name, |
| const String & | defaultValue = "" ) const |
get string value
get string argument at index
| Util::Array< Util::String > Util::CommandLineArgs::GetStrings | ( | const String & | name, |
| const String & | defaultValue = "" ) const |
get all string values
| vec4 Util::CommandLineArgs::GetVec4 | ( | const String & | name, |
| const Math::vec4 & | defaultValue = Math::vec4() ) const |
get vec4 value
| Util::Array< Math::vec4 > Util::CommandLineArgs::GetVec4s | ( | const String & | name, |
| const Math::vec4 & | defaultValue = Math::vec4() ) const |
get all vec4 values
return true if arg exists
Returns true if argument exists.
|
inline |
returns true if the argument list is empty
sort out any explicit key=value arguments into separate structure
|
private |