TrueReality  v0.1.1912
trUtil::ArgumentParser Class Reference

A a command line argument parser class that helps to create, manage, and pass commands to other systems. More...

#include <ArgumentParser.h>

Classes

class  Parameter
 

Public Types

enum  ErrorSeverity { ErrorSeverity::BENIGN = osg::ArgumentParser::ErrorSeverity::BENIGN, ErrorSeverity::CRITICAL = osg::ArgumentParser::ErrorSeverity::CRITICAL }
 
using ErrorMessageMap = std::map< std::string, ErrorSeverity >
 

Public Member Functions

 ArgumentParser (int *argc, char **argv)
 Default constructor that takes the argc and argv from the main function for command line parsing. More...
 
 ~ArgumentParser ()
 Destructor. More...
 
osg::ArgumentParser & GetOSGArgumentParser ()
 Gets internal osg argument parser. More...
 
const osg::ArgumentParser & GetOSGArgumentParser () const
 Gets the internal osg argument parser. More...
 
bool IsOption (const char *str) const
 Return true if the specified string is an option in the form -option or –option. More...
 
bool IsString (const char *str) const
 Return true if string is non-NULL and not an option in the form -option or –option. More...
 
bool IsNumber (const char *str) const
 Return true if specified parameter is a number. More...
 
bool IsBool (const char *str) const
 Return true if specified parameter is a bool. More...
 
void SetApplicationUsage (ApplicationUsage *usage)
 Sets application usage. More...
 
ApplicationUsageGetApplicationUsage ()
 Gets application usage. More...
 
const ApplicationUsageGetApplicationUsage () const
 Gets application usage. More...
 
int & GetArgc ()
 Return the argument count. More...
 
char ** GetArgv ()
 Return the argument array. More...
 
std::string GetApplicationName () const
 Return the application name, as specified by argv[0]. More...
 
int Find (const std::string &str) const
 Return the position of an occurrence of a string in the argument list. More...
 
bool IsOption (int pos) const
 Return true if the specified parameter is an option in the form of -option or –option. More...
 
bool IsString (int pos) const
 Return true if the specified parameter is a string not in the form of an option. More...
 
bool IsNumber (int pos) const
 Return true if the specified parameter is a number. More...
 
bool ContainsOptions () const
 Query if this object contains options. More...
 
void Remove (int pos, int num=1)
 Remove one or more arguments from the argv argument list, and decrement the argc respectively. More...
 
bool Match (int pos, const std::string &str) const
 Return true if the specified argument matches the given string. More...
 
bool Read (const std::string &str)
 Search for an occurrence of a string in the argument list. More...
 
bool Read (const std::string &str, Parameter value1)
 Search for an occurrence of a string in the argument list. More...
 
bool Read (const std::string &str, Parameter value1, Parameter value2)
 Search for an occurrence of a string in the argument list. More...
 
bool Read (const std::string &str, Parameter value1, Parameter value2, Parameter value3)
 Search for an occurrence of a string in the argument list. More...
 
bool Read (const std::string &str, Parameter value1, Parameter value2, Parameter value3, Parameter value4)
 Search for an occurrence of a string in the argument list. More...
 
bool Read (const std::string &str, Parameter value1, Parameter value2, Parameter value3, Parameter value4, Parameter value5)
 Search for an occurrence of a string in the argument list. More...
 
bool Read (const std::string &str, Parameter value1, Parameter value2, Parameter value3, Parameter value4, Parameter value5, Parameter value6)
 Search for an occurrence of a string in the argument list. More...
 
bool Read (const std::string &str, Parameter value1, Parameter value2, Parameter value3, Parameter value4, Parameter value5, Parameter value6, Parameter value7)
 Search for an occurrence of a string in the argument list. More...
 
bool Read (const std::string &str, Parameter value1, Parameter value2, Parameter value3, Parameter value4, Parameter value5, Parameter value6, Parameter value7, Parameter value8)
 Search for an occurrence of a string in the argument list. More...
 
bool 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. More...
 
bool Read (int pos, const std::string &str, Parameter value1)
 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. More...
 
bool Read (int pos, const std::string &str, Parameter value1, Parameter value2)
 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. More...
 
bool Read (int pos, const std::string &str, Parameter value1, Parameter value2, Parameter value3)
 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. More...
 
bool Read (int pos, const std::string &str, Parameter value1, Parameter value2, Parameter value3, Parameter value4)
 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. More...
 
bool Read (int pos, const std::string &str, Parameter value1, Parameter value2, Parameter value3, Parameter value4, Parameter value5)
 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. More...
 
bool Read (int pos, const std::string &str, Parameter value1, Parameter value2, Parameter value3, Parameter value4, Parameter value5, Parameter value6)
 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. More...
 
bool Read (int pos, const std::string &str, Parameter value1, Parameter value2, Parameter value3, Parameter value4, Parameter value5, Parameter value6, Parameter value7)
 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. More...
 
bool Read (int pos, const std::string &str, Parameter value1, Parameter value2, Parameter value3, Parameter value4, Parameter value5, Parameter value6, Parameter value7, Parameter value8)
 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. More...
 
bool Errors (ErrorSeverity severity=ErrorSeverity::BENIGN) const
 Return the error flag, true if an error has occurred when reading arguments. More...
 
void ReportError (const std::string &message, ErrorSeverity severity=ErrorSeverity::CRITICAL)
 Report an error message by adding to the ErrorMessageMap. More...
 
void ReportRemainingOptionsAsUnrecognized (ErrorSeverity severity=ErrorSeverity::BENIGN)
 For each remaining option, report it as unrecognized. More...
 
void WriteErrorMessages (std::ostream &output, ErrorSeverity severity=ErrorSeverity::BENIGN)
 Write error messages to the given ostream, if at or above the given severity. More...
 
ApplicationUsage::Type ReadHelpType ()
 This convenience method handles help requests on the command line. More...
 
void SetApplicationName (const std::string &name)
 Sets the Applications Name. More...
 
void SetDescription (const std::string &desc)
 If non-empty, the Description is typically shown by the Help Handler as text on the Help display (which also lists keyboard abbreviations.) More...
 
const std::string & GetDescription () const
 Gets the description. More...
 
void AddUsageExplanation (ApplicationUsage::Type type, const std::string &option, const std::string &explanation)
 Adds an usage explanation. More...
 
void SetCommandLineUsage (const std::string &explanation)
 Sets command line usage. More...
 
const std::string & GetCommandLineUsage () const
 Gets command line usage. More...
 
void AddCommandLineOption (const std::string &option, const std::string &explanation, const std::string &defaultValue="")
 Adds a command line option. More...
 
void SetCommandLineOptions (const ApplicationUsage::UsageMap &usageMap)
 Sets command line options. More...
 
const ApplicationUsage::UsageMapGetCommandLineOptions () const
 Gets command line options. More...
 
void SetCommandLineOptionsDefaults (const ApplicationUsage::UsageMap &usageMap)
 Sets command line options defaults. More...
 
const ApplicationUsage::UsageMapGetCommandLineOptionsDefaults () const
 Gets command line options defaults. More...
 
void AddEnvironmentalVariable (const std::string &option, const std::string &explanation, const std::string &defaultValue="")
 Adds an environmental variable usage explanation. More...
 
void SetEnvironmentalVariables (const ApplicationUsage::UsageMap &usageMap)
 Sets environmental variables usage. More...
 
const ApplicationUsage::UsageMapGetEnvironmentalVariables () const
 Gets environmental variables usage. More...
 
void SetEnvironmentalVariablesDefaults (const ApplicationUsage::UsageMap &usageMap)
 Sets environmental variables usage default usage map. More...
 
const ApplicationUsage::UsageMapGetEnvironmentalVariablesDefaults () const
 Gets environmental variables usage default usage map. More...
 
void AddKeyboardMouseBinding (const std::string &prefix, int key, const std::string &explanation)
 Adds a keyboard mouse binding usage. More...
 
void AddKeyboardMouseBinding (int key, const std::string &explanation)
 
void AddKeyboardMouseBinding (const std::string &option, const std::string &explanation)
 Adds a keyboard mouse binding usage. More...
 
void SetKeyboardMouseBindings (const ApplicationUsage::UsageMap &usageMap)
 Sets keyboard mouse bindings usage. More...
 
const ApplicationUsage::UsageMapGetKeyboardMouseBindings () const
 Gets keyboard mouse bindings usage. More...
 
void GetFormattedString (std::string &str, const ApplicationUsage::UsageMap &usageMap, unsigned int widthOfOutput=80, bool showDefaults=false, const ApplicationUsage::UsageMap &usageMapDef=ApplicationUsage::UsageMap())
 Gets formatted string. More...
 
void Write (std::ostream &output, const ApplicationUsage::UsageMap &usageMap, unsigned int widthOfOutput=80, bool showDefaults=false, const ApplicationUsage::UsageMap &usageMapDef=ApplicationUsage::UsageMap())
 Writes out all the settings to the screen. More...
 
void Write (std::ostream &output, ApplicationUsage::Type type=ApplicationUsage::Type::COMMAND_LINE_OPTION, unsigned int widthOfOutput=80, bool showDefaults=false)
 Writes. More...
 
void WriteEnvironmentSettings (std::ostream &output)
 Writes out the environment settings. More...
 

Protected Attributes

std::unique_ptr< osg::ArgumentParser > mArgParser
 The argument parser. More...
 
std::unique_ptr< ApplicationUsagemAppUsage
 

Detailed Description

A a command line argument parser class that helps to create, manage, and pass commands to other systems.

Definition at line 47 of file ArgumentParser.h.

Member Typedef Documentation

◆ ErrorMessageMap

Definition at line 57 of file ArgumentParser.h.

Member Enumeration Documentation

◆ ErrorSeverity

Enumerator
BENIGN 
CRITICAL 

Definition at line 51 of file ArgumentParser.h.

Constructor & Destructor Documentation

◆ ArgumentParser()

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

Default constructor that takes the argc and argv from the main function for command line parsing.

Parameters
[in,out]argcIf non-null, the argc.
[in,out]argvIf non-null, the argv.

Definition at line 122 of file ArgumentParser.cpp.

References mAppUsage, and mArgParser.

◆ ~ArgumentParser()

trUtil::ArgumentParser::~ArgumentParser ( )

Destructor.

Definition at line 129 of file ArgumentParser.cpp.

Member Function Documentation

◆ AddCommandLineOption()

void trUtil::ArgumentParser::AddCommandLineOption ( const std::string &  option,
const std::string &  explanation,
const std::string &  defaultValue = "" 
)

Adds a command line option.

Parameters
optionThe option.
explanationThe explanation.
defaultValue(Optional) The default value.

Definition at line 441 of file ArgumentParser.cpp.

References mAppUsage.

◆ AddEnvironmentalVariable()

void trUtil::ArgumentParser::AddEnvironmentalVariable ( const std::string &  option,
const std::string &  explanation,
const std::string &  defaultValue = "" 
)

Adds an environmental variable usage explanation.

Parameters
optionThe option.
explanationThe explanation.
defaultValue(Optional) The default value.

Definition at line 471 of file ArgumentParser.cpp.

References mAppUsage.

◆ AddKeyboardMouseBinding() [1/3]

void trUtil::ArgumentParser::AddKeyboardMouseBinding ( const std::string &  prefix,
int  key,
const std::string &  explanation 
)

Adds a keyboard mouse binding usage.

Parameters
prefixThe prefix.
keyThe key.
explanationThe explanation.

Definition at line 501 of file ArgumentParser.cpp.

References mAppUsage.

◆ AddKeyboardMouseBinding() [2/3]

void trUtil::ArgumentParser::AddKeyboardMouseBinding ( int  key,
const std::string &  explanation 
)

Definition at line 507 of file ArgumentParser.cpp.

References mAppUsage.

◆ AddKeyboardMouseBinding() [3/3]

void trUtil::ArgumentParser::AddKeyboardMouseBinding ( const std::string &  option,
const std::string &  explanation 
)

Adds a keyboard mouse binding usage.

Parameters
optionThe option.
explanationThe explanation.

Definition at line 513 of file ArgumentParser.cpp.

References mAppUsage.

◆ AddUsageExplanation()

void trUtil::ArgumentParser::AddUsageExplanation ( ApplicationUsage::Type  type,
const std::string &  option,
const std::string &  explanation 
)

Adds an usage explanation.

Parameters
typeThe type.
optionThe option.
explanationThe explanation.

Definition at line 423 of file ArgumentParser.cpp.

References mAppUsage.

◆ ContainsOptions()

bool trUtil::ArgumentParser::ContainsOptions ( ) const

Query if this object contains options.

Returns
True if it succeeds, false if it fails.

Definition at line 231 of file ArgumentParser.cpp.

References mArgParser.

◆ Errors()

bool trUtil::ArgumentParser::Errors ( ErrorSeverity  severity = ErrorSeverity::BENIGN) const

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

Parameters
severity(Optional) The severity.
Returns
True if it succeeds, false if it fails.

Definition at line 357 of file ArgumentParser.cpp.

References mArgParser.

◆ Find()

int trUtil::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.

Parameters
strThe string.
Returns
An int.

Definition at line 207 of file ArgumentParser.cpp.

References mArgParser.

◆ GetApplicationName()

std::string trUtil::ArgumentParser::GetApplicationName ( ) const

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

Returns
The application name.

Definition at line 201 of file ArgumentParser.cpp.

References mArgParser.

◆ GetApplicationUsage() [1/2]

ApplicationUsage * trUtil::ArgumentParser::GetApplicationUsage ( )

Gets application usage.

Returns
Null if it fails, else a pointer to an ApplicationUsage.

Definition at line 177 of file ArgumentParser.cpp.

References mAppUsage.

◆ GetApplicationUsage() [2/2]

const ApplicationUsage * trUtil::ArgumentParser::GetApplicationUsage ( ) const

Gets application usage.

Returns
Null if it fails, else the application usage.

Definition at line 183 of file ArgumentParser.cpp.

References mAppUsage.

◆ GetArgc()

int & trUtil::ArgumentParser::GetArgc ( )

Return the argument count.

Returns
The argc.

Definition at line 189 of file ArgumentParser.cpp.

References mArgParser.

◆ GetArgv()

char ** trUtil::ArgumentParser::GetArgv ( )

Return the argument array.

Returns
Null if it fails, else the argv.

Definition at line 195 of file ArgumentParser.cpp.

References mArgParser.

◆ GetCommandLineOptions()

const ApplicationUsage::UsageMap & trUtil::ArgumentParser::GetCommandLineOptions ( ) const

Gets command line options.

Returns
The command line options.

Definition at line 453 of file ArgumentParser.cpp.

References mAppUsage.

◆ GetCommandLineOptionsDefaults()

const ApplicationUsage::UsageMap & trUtil::ArgumentParser::GetCommandLineOptionsDefaults ( ) const

Gets command line options defaults.

Returns
The command line options defaults.

Definition at line 465 of file ArgumentParser.cpp.

References mAppUsage.

◆ GetCommandLineUsage()

const std::string & trUtil::ArgumentParser::GetCommandLineUsage ( ) const

Gets command line usage.

Returns
The command line usage.

Definition at line 435 of file ArgumentParser.cpp.

References mAppUsage.

◆ GetDescription()

const std::string & trUtil::ArgumentParser::GetDescription ( ) const

Gets the description.

Returns
The description.

Definition at line 417 of file ArgumentParser.cpp.

References mAppUsage.

◆ GetEnvironmentalVariables()

const ApplicationUsage::UsageMap & trUtil::ArgumentParser::GetEnvironmentalVariables ( ) const

Gets environmental variables usage.

Returns
The environmental variables.

Definition at line 483 of file ArgumentParser.cpp.

References mAppUsage.

◆ GetEnvironmentalVariablesDefaults()

const ApplicationUsage::UsageMap & trUtil::ArgumentParser::GetEnvironmentalVariablesDefaults ( ) const

Gets environmental variables usage default usage map.

Returns
The environmental variables defaults.

Definition at line 495 of file ArgumentParser.cpp.

References mAppUsage.

◆ GetFormattedString()

void trUtil::ArgumentParser::GetFormattedString ( std::string &  str,
const ApplicationUsage::UsageMap usageMap,
unsigned int  widthOfOutput = 80,
bool  showDefaults = false,
const ApplicationUsage::UsageMap usageMapDef = ApplicationUsage::UsageMap() 
)

Gets formatted string.

Parameters
[in,out]strThe string.
usageMapThe usage map.
widthOfOutput(Optional) Width of the output.
showDefaults(Optional) True to show, false to hide the defaults.
usageMapDef(Optional) The usage map default.

Definition at line 531 of file ArgumentParser.cpp.

References mAppUsage.

◆ GetKeyboardMouseBindings()

const ApplicationUsage::UsageMap & trUtil::ArgumentParser::GetKeyboardMouseBindings ( ) const

Gets keyboard mouse bindings usage.

Returns
The keyboard mouse bindings.

Definition at line 525 of file ArgumentParser.cpp.

References mAppUsage.

◆ GetOSGArgumentParser() [1/2]

osg::ArgumentParser & trUtil::ArgumentParser::GetOSGArgumentParser ( )

Gets internal osg argument parser.

Returns
The osg argument parser.

Definition at line 134 of file ArgumentParser.cpp.

References mArgParser.

◆ GetOSGArgumentParser() [2/2]

const osg::ArgumentParser & trUtil::ArgumentParser::GetOSGArgumentParser ( ) const

Gets the internal osg argument parser.

Returns
The osg argument parser.

Definition at line 140 of file ArgumentParser.cpp.

References mArgParser.

◆ IsBool()

bool trUtil::ArgumentParser::IsBool ( const char *  str) const

Return true if specified parameter is a bool.

Parameters
strThe string.
Returns
True if bool, false if not.

Definition at line 164 of file ArgumentParser.cpp.

References mArgParser.

◆ IsNumber() [1/2]

bool trUtil::ArgumentParser::IsNumber ( const char *  str) const

Return true if specified parameter is a number.

Parameters
strThe string.
Returns
True if number, false if not.

Definition at line 158 of file ArgumentParser.cpp.

References mArgParser.

◆ IsNumber() [2/2]

bool trUtil::ArgumentParser::IsNumber ( int  pos) const

Return true if the specified parameter is a number.

Parameters
posThe position.
Returns
True if number, false if not.

Definition at line 225 of file ArgumentParser.cpp.

References mArgParser.

◆ IsOption() [1/2]

bool trUtil::ArgumentParser::IsOption ( const char *  str) const

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

Parameters
strThe string.
Returns
True if option, false if not.

Definition at line 146 of file ArgumentParser.cpp.

References mArgParser.

◆ IsOption() [2/2]

bool trUtil::ArgumentParser::IsOption ( int  pos) const

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

Parameters
posThe position.
Returns
True if option, false if not.

Definition at line 213 of file ArgumentParser.cpp.

References mArgParser.

◆ IsString() [1/2]

bool trUtil::ArgumentParser::IsString ( const char *  str) const

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

Parameters
strThe string.
Returns
True if string, false if not.

Definition at line 152 of file ArgumentParser.cpp.

References mArgParser.

◆ IsString() [2/2]

bool trUtil::ArgumentParser::IsString ( int  pos) const

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

Parameters
posThe position.
Returns
True if string, false if not.

Definition at line 219 of file ArgumentParser.cpp.

References mArgParser.

◆ Match()

bool trUtil::ArgumentParser::Match ( int  pos,
const std::string &  str 
) const

Return true if the specified argument matches the given string.

Parameters
posThe position.
strThe string.
Returns
True if it succeeds, false if it fails.

Definition at line 243 of file ArgumentParser.cpp.

References mArgParser.

◆ Read() [1/18]

bool trUtil::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.

Parameters
strThe String to read.
Returns
True if it succeeds, false if it fails.

Definition at line 249 of file ArgumentParser.cpp.

References mArgParser.

◆ Read() [2/18]

bool trUtil::ArgumentParser::Read ( const std::string &  str,
Parameter  value1 
)

Search for an occurrence of a string in the argument list.

If found, remove that occurrence and return true. Otherwise, return false.

Parameters
strThe String to read.
value1The first value.
Returns
True if it succeeds, false if it fails.

Definition at line 255 of file ArgumentParser.cpp.

References mArgParser.

◆ Read() [3/18]

bool trUtil::ArgumentParser::Read ( const std::string &  str,
Parameter  value1,
Parameter  value2 
)

Search for an occurrence of a string in the argument list.

If found, remove that occurrence and return true. Otherwise, return false.

Parameters
strThe String to read.
value1The first value.
value2The second value.
Returns
True if it succeeds, false if it fails.

Definition at line 261 of file ArgumentParser.cpp.

References mArgParser.

◆ Read() [4/18]

bool trUtil::ArgumentParser::Read ( const std::string &  str,
Parameter  value1,
Parameter  value2,
Parameter  value3 
)

Search for an occurrence of a string in the argument list.

If found, remove that occurrence and return true. Otherwise, return false.

Parameters
strThe String to read.
value1The first value.
value2The second value.
value3The third value.
Returns
True if it succeeds, false if it fails.

Definition at line 267 of file ArgumentParser.cpp.

References mArgParser.

◆ Read() [5/18]

bool trUtil::ArgumentParser::Read ( const std::string &  str,
Parameter  value1,
Parameter  value2,
Parameter  value3,
Parameter  value4 
)

Search for an occurrence of a string in the argument list.

If found, remove that occurrence and return true. Otherwise, return false.

Parameters
strThe String to read.
value1The first value.
value2The second value.
value3The third value.
value4The fourth value.
Returns
True if it succeeds, false if it fails.

Definition at line 273 of file ArgumentParser.cpp.

References mArgParser.

◆ Read() [6/18]

bool trUtil::ArgumentParser::Read ( const std::string &  str,
Parameter  value1,
Parameter  value2,
Parameter  value3,
Parameter  value4,
Parameter  value5 
)

Search for an occurrence of a string in the argument list.

If found, remove that occurrence and return true. Otherwise, return false.

Parameters
strThe String to read.
value1The first value.
value2The second value.
value3The third value.
value4The fourth value.
value5The fifth value.
Returns
True if it succeeds, false if it fails.

Definition at line 279 of file ArgumentParser.cpp.

References mArgParser.

◆ Read() [7/18]

bool trUtil::ArgumentParser::Read ( const std::string &  str,
Parameter  value1,
Parameter  value2,
Parameter  value3,
Parameter  value4,
Parameter  value5,
Parameter  value6 
)

Search for an occurrence of a string in the argument list.

If found, remove that occurrence and return true. Otherwise, return false.

Parameters
strThe String to read.
value1The first value.
value2The second value.
value3The third value.
value4The fourth value.
value5The fifth value.
value6The value 6.
Returns
True if it succeeds, false if it fails.

Definition at line 285 of file ArgumentParser.cpp.

References mArgParser.

◆ Read() [8/18]

bool trUtil::ArgumentParser::Read ( const std::string &  str,
Parameter  value1,
Parameter  value2,
Parameter  value3,
Parameter  value4,
Parameter  value5,
Parameter  value6,
Parameter  value7 
)

Search for an occurrence of a string in the argument list.

If found, remove that occurrence and return true. Otherwise, return false.

Parameters
strThe String to read.
value1The first value.
value2The second value.
value3The third value.
value4The fourth value.
value5The fifth value.
value6The value 6.
value7The value 7.
Returns
True if it succeeds, false if it fails.

Definition at line 291 of file ArgumentParser.cpp.

References mArgParser.

◆ Read() [9/18]

bool trUtil::ArgumentParser::Read ( const std::string &  str,
Parameter  value1,
Parameter  value2,
Parameter  value3,
Parameter  value4,
Parameter  value5,
Parameter  value6,
Parameter  value7,
Parameter  value8 
)

Search for an occurrence of a string in the argument list.

If found, remove that occurrence and return true. Otherwise, return false.

Parameters
strThe String to read.
value1The first value.
value2The second value.
value3The third value.
value4The fourth value.
value5The fifth value.
value6The value 6.
value7The value 7.
value8The value 8.
Returns
True if it succeeds, false if it fails.

Definition at line 297 of file ArgumentParser.cpp.

References mArgParser.

◆ Read() [10/18]

bool trUtil::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.

Parameters
posThe position.
strThe string.
Returns
True if it succeeds, false if it fails.

Definition at line 303 of file ArgumentParser.cpp.

References mArgParser.

◆ Read() [11/18]

bool trUtil::ArgumentParser::Read ( int  pos,
const std::string &  str,
Parameter  value1 
)

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.

Parameters
posThe position.
strThe string.
value1The first value.
Returns
True if it succeeds, false if it fails.

Definition at line 309 of file ArgumentParser.cpp.

References mArgParser.

◆ Read() [12/18]

bool trUtil::ArgumentParser::Read ( int  pos,
const std::string &  str,
Parameter  value1,
Parameter  value2 
)

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.

Parameters
posThe position.
strThe string.
value1The first value.
value2The second value.
Returns
True if it succeeds, false if it fails.

Definition at line 315 of file ArgumentParser.cpp.

References mArgParser.

◆ Read() [13/18]

bool trUtil::ArgumentParser::Read ( int  pos,
const std::string &  str,
Parameter  value1,
Parameter  value2,
Parameter  value3 
)

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.

Parameters
posThe position.
strThe string.
value1The first value.
value2The second value.
value3The third value.
Returns
True if it succeeds, false if it fails.

Definition at line 321 of file ArgumentParser.cpp.

References mArgParser.

◆ Read() [14/18]

bool trUtil::ArgumentParser::Read ( int  pos,
const std::string &  str,
Parameter  value1,
Parameter  value2,
Parameter  value3,
Parameter  value4 
)

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.

Parameters
posThe position.
strThe string.
value1The first value.
value2The second value.
value3The third value.
value4The fourth value.
Returns
True if it succeeds, false if it fails.

Definition at line 327 of file ArgumentParser.cpp.

References mArgParser.

◆ Read() [15/18]

bool trUtil::ArgumentParser::Read ( int  pos,
const std::string &  str,
Parameter  value1,
Parameter  value2,
Parameter  value3,
Parameter  value4,
Parameter  value5 
)

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.

Parameters
posThe position.
strThe string.
value1The first value.
value2The second value.
value3The third value.
value4The fourth value.
value5The fifth value.
Returns
True if it succeeds, false if it fails.

Definition at line 333 of file ArgumentParser.cpp.

References mArgParser.

◆ Read() [16/18]

bool trUtil::ArgumentParser::Read ( int  pos,
const std::string &  str,
Parameter  value1,
Parameter  value2,
Parameter  value3,
Parameter  value4,
Parameter  value5,
Parameter  value6 
)

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.

Parameters
posThe position.
strThe string.
value1The first value.
value2The second value.
value3The third value.
value4The fourth value.
value5The fifth value.
value6The sixth value.
Returns
True if it succeeds, false if it fails.

Definition at line 339 of file ArgumentParser.cpp.

References mArgParser.

◆ Read() [17/18]

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

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.

Parameters
posThe position.
strThe string.
value1The first value.
value2The second value.
value3The third value.
value4The fourth value.
value5The fifth value.
value6The sixth value.
value7The seventh value.
Returns
True if it succeeds, false if it fails.

Definition at line 345 of file ArgumentParser.cpp.

References mArgParser.

◆ Read() [18/18]

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

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.

Parameters
posThe position.
strThe string.
value1The first value.
value2The second value.
value3The third value.
value4The fourth value.
value5The fifth value.
value6The sixth value.
value7The seventh value.
value8The eighth value.
Returns
True if it succeeds, false if it fails.

Definition at line 351 of file ArgumentParser.cpp.

References mArgParser.

◆ ReadHelpType()

ApplicationUsage::Type trUtil::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.

Returns
The help type.

Definition at line 381 of file ArgumentParser.cpp.

References trUtil::ApplicationUsage::COMMAND_LINE_OPTION, trUtil::ApplicationUsage::ENVIRONMENTAL_VARIABLE, trUtil::ApplicationUsage::KEYBOARD_MOUSE_BINDING, mArgParser, and trUtil::ApplicationUsage::NO_HELP.

◆ Remove()

void trUtil::ArgumentParser::Remove ( int  pos,
int  num = 1 
)

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

Parameters
posThe position.
num(Optional) Number of.

Definition at line 237 of file ArgumentParser.cpp.

References mArgParser.

◆ ReportError()

void trUtil::ArgumentParser::ReportError ( const std::string &  message,
ErrorSeverity  severity = ErrorSeverity::CRITICAL 
)

Report an error message by adding to the ErrorMessageMap.

Parameters
messageThe message.
severity(Optional) The severity.

Definition at line 363 of file ArgumentParser.cpp.

References mArgParser.

◆ ReportRemainingOptionsAsUnrecognized()

void trUtil::ArgumentParser::ReportRemainingOptionsAsUnrecognized ( ErrorSeverity  severity = ErrorSeverity::BENIGN)

For each remaining option, report it as unrecognized.

Parameters
severity(Optional) The severity.

Definition at line 369 of file ArgumentParser.cpp.

References mArgParser.

◆ SetApplicationName()

void trUtil::ArgumentParser::SetApplicationName ( const std::string &  name)

Sets the Applications Name.

It is used in Application description.

Parameters
nameThe name.

Definition at line 405 of file ArgumentParser.cpp.

References mAppUsage.

◆ SetApplicationUsage()

void trUtil::ArgumentParser::SetApplicationUsage ( ApplicationUsage usage)

Sets application usage.

Parameters
[in,out]usageIf non-null, the usage.

Definition at line 170 of file ArgumentParser.cpp.

References mAppUsage, and mArgParser.

◆ SetCommandLineOptions()

void trUtil::ArgumentParser::SetCommandLineOptions ( const ApplicationUsage::UsageMap usageMap)

Sets command line options.

Parameters
usageMapThe usage map.

Definition at line 447 of file ArgumentParser.cpp.

References mAppUsage.

◆ SetCommandLineOptionsDefaults()

void trUtil::ArgumentParser::SetCommandLineOptionsDefaults ( const ApplicationUsage::UsageMap usageMap)

Sets command line options defaults.

Parameters
usageMapThe usage map.

Definition at line 459 of file ArgumentParser.cpp.

References mAppUsage.

◆ SetCommandLineUsage()

void trUtil::ArgumentParser::SetCommandLineUsage ( const std::string &  explanation)

Sets command line usage.

Parameters
explanationThe explanation.

Definition at line 429 of file ArgumentParser.cpp.

References mAppUsage.

◆ SetDescription()

void trUtil::ArgumentParser::SetDescription ( const std::string &  desc)

If non-empty, the Description is typically shown by the Help Handler as text on the Help display (which also lists keyboard abbreviations.)

Parameters
descThe description.

Definition at line 411 of file ArgumentParser.cpp.

References mAppUsage.

◆ SetEnvironmentalVariables()

void trUtil::ArgumentParser::SetEnvironmentalVariables ( const ApplicationUsage::UsageMap usageMap)

Sets environmental variables usage.

Parameters
usageMapThe usage map.

Definition at line 477 of file ArgumentParser.cpp.

References mAppUsage.

◆ SetEnvironmentalVariablesDefaults()

void trUtil::ArgumentParser::SetEnvironmentalVariablesDefaults ( const ApplicationUsage::UsageMap usageMap)

Sets environmental variables usage default usage map.

Parameters
usageMapThe usage map.

Definition at line 489 of file ArgumentParser.cpp.

References mAppUsage.

◆ SetKeyboardMouseBindings()

void trUtil::ArgumentParser::SetKeyboardMouseBindings ( const ApplicationUsage::UsageMap usageMap)

Sets keyboard mouse bindings usage.

Parameters
usageMapThe usage map.

Definition at line 519 of file ArgumentParser.cpp.

References mAppUsage.

◆ Write() [1/2]

void trUtil::ArgumentParser::Write ( std::ostream &  output,
const ApplicationUsage::UsageMap usageMap,
unsigned int  widthOfOutput = 80,
bool  showDefaults = false,
const ApplicationUsage::UsageMap usageMapDef = ApplicationUsage::UsageMap() 
)

Writes out all the settings to the screen.

Parameters
[in,out]outputThe output stream.
usageMapThe usage map.
widthOfOutput(Optional) Width of the output.
showDefaults(Optional) True to show, false to hide the defaults.
usageMapDef(Optional) The ud.

Definition at line 537 of file ArgumentParser.cpp.

References mAppUsage.

◆ Write() [2/2]

void trUtil::ArgumentParser::Write ( std::ostream &  output,
ApplicationUsage::Type  type = ApplicationUsage::Type::COMMAND_LINE_OPTION,
unsigned int  widthOfOutput = 80,
bool  showDefaults = false 
)

Writes.

Parameters
[in,out]outputThe output stream.
type(Optional) The type.
widthOfOutput(Optional) Width of the output.
showDefaults(Optional) True to show, false to hide the defaults.

Definition at line 543 of file ArgumentParser.cpp.

References mAppUsage.

◆ WriteEnvironmentSettings()

void trUtil::ArgumentParser::WriteEnvironmentSettings ( std::ostream &  output)

Writes out the environment settings.

Parameters
[in,out]outputThe output.

Definition at line 549 of file ArgumentParser.cpp.

References mAppUsage.

◆ WriteErrorMessages()

void trUtil::ArgumentParser::WriteErrorMessages ( std::ostream &  output,
ErrorSeverity  severity = ErrorSeverity::BENIGN 
)

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

Parameters
[in,out]outputThe output.
severity(Optional) The severity.

Definition at line 375 of file ArgumentParser.cpp.

References mArgParser.

Member Data Documentation

◆ mAppUsage

◆ mArgParser


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