Nebula
Loading...
Searching...
No Matches
Util::CommandLineArgs Class Reference

#include <commandlineargs.h>

Detailed Description

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 StringGetCmdName () const
 get the command name
 
bool HasArg (const String &arg, const IndexT start=0) const
 return true if arg exists
 
const StringGetString (const String &name, const String &defaultValue="") const
 get string value
 
Util::Array< Util::StringGetStrings (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::vec4GetVec4s (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::mat4GetMat4s (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 StringGetStringAtIndex (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
 

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
 

Private Attributes

Array< Stringargs
 

Constructor & Destructor Documentation

◆ CommandLineArgs() [1/3]

Util::CommandLineArgs::CommandLineArgs ( )

default constructor

◆ CommandLineArgs() [2/3]

Util::CommandLineArgs::CommandLineArgs ( const String & cmdLine)

construct from Win32-style command string

◆ CommandLineArgs() [3/3]

Util::CommandLineArgs::CommandLineArgs ( int argc,
const char ** argv )

construct from posix style command string

Member Function Documentation

◆ AppendCommandString()

void Util::CommandLineArgs::AppendCommandString ( const CommandLineArgs & otherArgs)

append other command string

◆ Error()

void Util::CommandLineArgs::Error ( const String & argName) const
private

put out an error

Put out a missing argument error.

◆ FindArgIndex()

int Util::CommandLineArgs::FindArgIndex ( const String & name,
const IndexT start = 0 ) const
private

find index of argument, fails hard with error msg if not found

Returns index of argument.

Throws an error if argument not found.

◆ GetBool()

bool Util::CommandLineArgs::GetBool ( const String & name,
bool defaultValue = false ) const

get bool value (key=value)

◆ GetBoolAtIndex()

bool Util::CommandLineArgs::GetBoolAtIndex ( IndexT index) const

get bool value at index

◆ GetBoolFlag()

bool Util::CommandLineArgs::GetBoolFlag ( const String & name) const

get bool flag (args only needs to exist to trigger as true)

◆ GetBools()

Util::Array< bool > Util::CommandLineArgs::GetBools ( const String & name,
bool defaultValue = false ) const

get all bool values

◆ GetCmdName()

const String & Util::CommandLineArgs::GetCmdName ( ) const

get the command name

Returns the command name.

◆ GetFloat()

float Util::CommandLineArgs::GetFloat ( const String & name,
float defaultValue = 0.0f ) const

get float value

◆ GetFloatAtIndex()

float Util::CommandLineArgs::GetFloatAtIndex ( IndexT index) const

get float value at index

◆ GetFloats()

Util::Array< float > Util::CommandLineArgs::GetFloats ( const String & name,
float defaultValue = 0.0f ) const

get all float values

◆ GetInt()

int Util::CommandLineArgs::GetInt ( const String & name,
int defaultValue = 0 ) const

get int value

◆ GetIntAtIndex()

int Util::CommandLineArgs::GetIntAtIndex ( IndexT index) const

get int value at index

◆ GetInts()

Util::Array< int > Util::CommandLineArgs::GetInts ( const String & name,
int defaultValue = 0 ) const

get all int values

◆ GetMat4()

mat4 Util::CommandLineArgs::GetMat4 ( const String & name,
const Math::mat4 & defaultValue = Math::mat4() ) const

get mat4 value

◆ GetMat4AtIndex()

mat4 Util::CommandLineArgs::GetMat4AtIndex ( IndexT index) const

get mat4 value at index

◆ GetMat4s()

Util::Array< Math::mat4 > Util::CommandLineArgs::GetMat4s ( const String & name,
const Math::mat4 & defaultValue = Math::mat4() ) const

get all mat4 values

◆ GetNumArgs()

SizeT Util::CommandLineArgs::GetNumArgs ( ) const

get number of arguments (exluding command name)

◆ GetString()

const String & Util::CommandLineArgs::GetString ( const String & name,
const String & defaultValue = "" ) const

get string value

◆ GetStringAtIndex()

const String & Util::CommandLineArgs::GetStringAtIndex ( IndexT index) const

get string argument at index

◆ GetStrings()

Util::Array< Util::String > Util::CommandLineArgs::GetStrings ( const String & name,
const String & defaultValue = "" ) const

get all string values

◆ GetVec4()

vec4 Util::CommandLineArgs::GetVec4 ( const String & name,
const Math::vec4 & defaultValue = Math::vec4() ) const

get vec4 value

◆ GetVec4AtIndex()

vec4 Util::CommandLineArgs::GetVec4AtIndex ( IndexT index) const

get vec4 value at index

◆ GetVec4s()

Util::Array< Math::vec4 > Util::CommandLineArgs::GetVec4s ( const String & name,
const Math::vec4 & defaultValue = Math::vec4() ) const

get all vec4 values

◆ HasArg()

bool Util::CommandLineArgs::HasArg ( const String & arg,
const IndexT start = 0 ) const

return true if arg exists

Returns true if argument exists.

◆ IsEmpty()

bool Util::CommandLineArgs::IsEmpty ( ) const
inline

returns true if the argument list is empty

Member Data Documentation

◆ args

Array<String> Util::CommandLineArgs::args
private

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