TrueReality  v0.1.1912
trUtil::ApplicationUsage Class Reference

An application usage class for the argument parser. More...

#include <ApplicationUsage.h>

Public Types

enum  Type {
  Type::NO_HELP = osg::ApplicationUsage::NO_HELP, Type::COMMAND_LINE_OPTION = osg::ApplicationUsage::COMMAND_LINE_OPTION, Type::ENVIRONMENTAL_VARIABLE = osg::ApplicationUsage::ENVIRONMENTAL_VARIABLE, Type::KEYBOARD_MOUSE_BINDING = osg::ApplicationUsage::KEYBOARD_MOUSE_BINDING,
  Type::HELP_ALL = KEYBOARD_MOUSE_BINDING | ENVIRONMENTAL_VARIABLE | COMMAND_LINE_OPTION
}
 
using UsageMap = std::map< std::string, std::string >
 The message to command usage map. More...
 

Public Member Functions

 ApplicationUsage ()
 Default constructor. More...
 
 ApplicationUsage (osg::ApplicationUsage *applicationUsage)
 Wraps an osg ApplicationUsage, and uses it as the internal class. More...
 
 ApplicationUsage (const std::string &commandLineUsage)
 Default constructor. More...
 
 ~ApplicationUsage ()
 Destructor. More...
 
void SetApplicationName (const std::string &name)
 Sets the Applications Name. More...
 
const std::string & GetApplicationName () const
 Gets the stored application 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 (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 UsageMap &usageMap)
 Sets command line options. More...
 
const UsageMapGetCommandLineOptions () const
 Gets command line options. More...
 
void SetCommandLineOptionsDefaults (const UsageMap &usageMap)
 Sets command line options defaults. More...
 
const 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 UsageMap &usageMap)
 Sets environmental variables usage. More...
 
const UsageMapGetEnvironmentalVariables () const
 Gets environmental variables usage. More...
 
void SetEnvironmentalVariablesDefaults (const UsageMap &usageMap)
 Sets environmental variables usage default usage map. More...
 
const 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)
 Adds a keyboard mouse binding usage. More...
 
void AddKeyboardMouseBinding (const std::string &option, const std::string &explanation)
 Adds a keyboard mouse binding usage. More...
 
void SetKeyboardMouseBindings (const UsageMap &usageMap)
 Sets keyboard mouse bindings usage. More...
 
const UsageMapGetKeyboardMouseBindings () const
 Gets keyboard mouse bindings usage. More...
 
void GetFormattedString (std::string &str, const UsageMap &um, unsigned int widthOfOutput=80, bool showDefaults=false, const UsageMap &ud=UsageMap())
 Gets formatted string. More...
 
void Write (std::ostream &output, const UsageMap &um, unsigned int widthOfOutput=80, bool showDefaults=false, const UsageMap &ud=UsageMap())
 Writes out all the settings to the screen. More...
 
void Write (std::ostream &output, Type type=Type::COMMAND_LINE_OPTION, unsigned int widthOfOutput=80, bool showDefaults=false)
 Writes. More...
 
void WriteEnvironmentSettings (std::ostream &output)
 Writes out the environment settings. More...
 
 operator osg::ApplicationUsage & ()
 Implicit conversion operator to OSG ApplicationUsage. More...
 
 operator const osg::ApplicationUsage & () const
 Implicit conversion operator to OSG ApplicationUsage. More...
 
 operator osg::ApplicationUsage * ()
 Implicit conversion operator to OSG ApplicationUsage. More...
 
 operator const osg::ApplicationUsage * () const
 

Protected Attributes

osg::ref_ptr< osg::ApplicationUsage > mAppUsage = nullptr
 

Detailed Description

An application usage class for the argument parser.

Definition at line 45 of file ApplicationUsage.h.

Member Typedef Documentation

◆ UsageMap

using trUtil::ApplicationUsage::UsageMap = std::map<std::string, std::string>

The message to command usage map.

Definition at line 50 of file ApplicationUsage.h.

Member Enumeration Documentation

◆ Type

Enumerator
NO_HELP 
COMMAND_LINE_OPTION 
ENVIRONMENTAL_VARIABLE 
KEYBOARD_MOUSE_BINDING 
HELP_ALL 

Definition at line 52 of file ApplicationUsage.h.

Constructor & Destructor Documentation

◆ ApplicationUsage() [1/3]

trUtil::ApplicationUsage::ApplicationUsage ( )

Default constructor.

Definition at line 32 of file ApplicationUsage.cpp.

References mAppUsage.

◆ ApplicationUsage() [2/3]

trUtil::ApplicationUsage::ApplicationUsage ( osg::ApplicationUsage *  applicationUsage)

Wraps an osg ApplicationUsage, and uses it as the internal class.

Parameters
[in,out]applicationUsageThe application usage.

Definition at line 38 of file ApplicationUsage.cpp.

References mAppUsage.

◆ ApplicationUsage() [3/3]

trUtil::ApplicationUsage::ApplicationUsage ( const std::string &  commandLineUsage)

Default constructor.

Parameters
commandLineUsageThe command line usage.

Definition at line 44 of file ApplicationUsage.cpp.

References mAppUsage.

◆ ~ApplicationUsage()

trUtil::ApplicationUsage::~ApplicationUsage ( )

Destructor.

Definition at line 50 of file ApplicationUsage.cpp.

Member Function Documentation

◆ AddCommandLineOption()

void trUtil::ApplicationUsage::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 97 of file ApplicationUsage.cpp.

References mAppUsage.

◆ AddEnvironmentalVariable()

void trUtil::ApplicationUsage::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 127 of file ApplicationUsage.cpp.

References mAppUsage.

◆ AddKeyboardMouseBinding() [1/3]

void trUtil::ApplicationUsage::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 157 of file ApplicationUsage.cpp.

References mAppUsage.

◆ AddKeyboardMouseBinding() [2/3]

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

Adds a keyboard mouse binding usage.

Parameters
keyThe key.
explanationThe explanation.

Definition at line 163 of file ApplicationUsage.cpp.

References mAppUsage.

◆ AddKeyboardMouseBinding() [3/3]

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

Adds a keyboard mouse binding usage.

Parameters
optionThe option.
explanationThe explanation.

Definition at line 169 of file ApplicationUsage.cpp.

References mAppUsage.

◆ AddUsageExplanation()

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

Adds an usage explanation.

Parameters
typeThe type.
optionThe option.
explanationThe explanation.

Definition at line 79 of file ApplicationUsage.cpp.

References mAppUsage.

◆ GetApplicationName()

const std::string & trUtil::ApplicationUsage::GetApplicationName ( ) const

Gets the stored application name.

Returns
The application name.

Definition at line 61 of file ApplicationUsage.cpp.

References mAppUsage.

◆ GetCommandLineOptions()

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

Gets command line options.

Returns
The command line options.

Definition at line 109 of file ApplicationUsage.cpp.

References mAppUsage.

◆ GetCommandLineOptionsDefaults()

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

Gets command line options defaults.

Returns
The command line options defaults.

Definition at line 121 of file ApplicationUsage.cpp.

References mAppUsage.

◆ GetCommandLineUsage()

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

Gets command line usage.

Returns
The command line usage.

Definition at line 91 of file ApplicationUsage.cpp.

References mAppUsage.

◆ GetDescription()

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

Gets the description.

Returns
The description.

Definition at line 73 of file ApplicationUsage.cpp.

References mAppUsage.

◆ GetEnvironmentalVariables()

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

Gets environmental variables usage.

Returns
The environmental variables.

Definition at line 139 of file ApplicationUsage.cpp.

References mAppUsage.

◆ GetEnvironmentalVariablesDefaults()

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

Gets environmental variables usage default usage map.

Returns
The environmental variables defaults.

Definition at line 151 of file ApplicationUsage.cpp.

References mAppUsage.

◆ GetFormattedString()

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

Gets formatted string.

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

Definition at line 187 of file ApplicationUsage.cpp.

References mAppUsage.

◆ GetKeyboardMouseBindings()

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

Gets keyboard mouse bindings usage.

Returns
The keyboard mouse bindings.

Definition at line 181 of file ApplicationUsage.cpp.

References mAppUsage.

◆ operator const osg::ApplicationUsage &()

trUtil::ApplicationUsage::operator const osg::ApplicationUsage & ( ) const

Implicit conversion operator to OSG ApplicationUsage.

Returns
A const.

Definition at line 217 of file ApplicationUsage.cpp.

References mAppUsage.

◆ operator const osg::ApplicationUsage *()

trUtil::ApplicationUsage::operator const osg::ApplicationUsage * ( ) const

Definition at line 229 of file ApplicationUsage.cpp.

References mAppUsage.

◆ operator osg::ApplicationUsage &()

trUtil::ApplicationUsage::operator osg::ApplicationUsage & ( )

Implicit conversion operator to OSG ApplicationUsage.

Returns
The result of the operation.

Definition at line 211 of file ApplicationUsage.cpp.

References mAppUsage.

◆ operator osg::ApplicationUsage *()

trUtil::ApplicationUsage::operator osg::ApplicationUsage * ( )

Implicit conversion operator to OSG ApplicationUsage.

Returns
The result of the operation.

Definition at line 223 of file ApplicationUsage.cpp.

References mAppUsage.

◆ SetApplicationName()

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

Sets the Applications Name.

It is used in Application description

Parameters
nameThe name.

Definition at line 55 of file ApplicationUsage.cpp.

References mAppUsage.

◆ SetCommandLineOptions()

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

Sets command line options.

Parameters
usageMapThe usage map.

Definition at line 103 of file ApplicationUsage.cpp.

References mAppUsage.

◆ SetCommandLineOptionsDefaults()

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

Sets command line options defaults.

Parameters
usageMapThe usage map.

Definition at line 115 of file ApplicationUsage.cpp.

References mAppUsage.

◆ SetCommandLineUsage()

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

Sets command line usage.

Parameters
explanationThe explanation.

Definition at line 85 of file ApplicationUsage.cpp.

References mAppUsage.

◆ SetDescription()

void trUtil::ApplicationUsage::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 67 of file ApplicationUsage.cpp.

References mAppUsage.

◆ SetEnvironmentalVariables()

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

Sets environmental variables usage.

Parameters
usageMapThe usage map.

Definition at line 133 of file ApplicationUsage.cpp.

References mAppUsage.

◆ SetEnvironmentalVariablesDefaults()

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

Sets environmental variables usage default usage map.

Parameters
usageMapThe usage map.

Definition at line 145 of file ApplicationUsage.cpp.

References mAppUsage.

◆ SetKeyboardMouseBindings()

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

Sets keyboard mouse bindings usage.

Parameters
usageMapThe usage map.

Definition at line 175 of file ApplicationUsage.cpp.

References mAppUsage.

◆ Write() [1/2]

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

Writes out all the settings to the screen.

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

Definition at line 193 of file ApplicationUsage.cpp.

References mAppUsage.

◆ Write() [2/2]

void trUtil::ApplicationUsage::Write ( std::ostream &  output,
Type  type = 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 199 of file ApplicationUsage.cpp.

References mAppUsage.

◆ WriteEnvironmentSettings()

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

Writes out the environment settings.

Parameters
[in,out]outputThe output.

Definition at line 205 of file ApplicationUsage.cpp.

References mAppUsage.

Member Data Documentation

◆ mAppUsage


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