29 mParam =
new osg::ArgumentParser::Parameter(value);
35 mParam =
new osg::ArgumentParser::Parameter(value);
41 mParam =
new osg::ArgumentParser::Parameter(value);
47 mParam =
new osg::ArgumentParser::Parameter(value);
53 mParam =
new osg::ArgumentParser::Parameter(value);
59 mParam =
new osg::ArgumentParser::Parameter(value);
65 mParam =
new osg::ArgumentParser::Parameter(param);
94 return mParam->assign(str);
98 ArgumentParser::Parameter::operator osg::ArgumentParser::Parameter()
const 104 ArgumentParser::Parameter::operator osg::ArgumentParser::Parameter&()
110 ArgumentParser::Parameter::operator
const osg::ArgumentParser::Parameter&()
const 116 ArgumentParser::Parameter::operator osg::ArgumentParser::Parameter*()
124 mArgParser = std::make_unique<osg::ArgumentParser>(argc, argv);
269 return mArgParser->read(str, value1, value2, value3);
275 return mArgParser->read(str, value1, value2, value3, value4);
281 return mArgParser->read(str, value1, value2, value3, value4, value5);
287 return mArgParser->read(str, value1, value2, value3, value4, value5, value6);
293 return mArgParser->read(str, value1, value2, value3, value4, value5, value6, value7);
299 return mArgParser->read(str, value1, value2, value3, value4, value5, value6, value7, value8);
317 return mArgParser->read(pos, str, value1, value2);
323 return mArgParser->read(pos, str, value1, value2, value3);
329 return mArgParser->read(pos, str, value1, value2, value3, value4);
335 return mArgParser->read(pos, str, value1, value2, value3, value4, value5);
341 return mArgParser->read(pos, str, value1, value2, value3, value4, value5, value6);
347 return mArgParser->read(pos, str, value1, value2, value3, value4, value5, value6, value7);
353 return mArgParser->read(pos, str, value1, value2, value3, value4, value5, value6, value7, value8);
359 return mArgParser->errors(static_cast<osg::ArgumentParser::ErrorSeverity>(severity));
365 mArgParser->reportError(message, static_cast<osg::ArgumentParser::ErrorSeverity>(severity));
371 mArgParser->reportRemainingOptionsAsUnrecognized(static_cast<osg::ArgumentParser::ErrorSeverity>(severity));
377 mArgParser->writeErrorMessages(output, static_cast<osg::ArgumentParser::ErrorSeverity>(severity));
383 osg::ApplicationUsage::Type ret =
mArgParser->readHelpType();
387 case osg::ApplicationUsage::NO_HELP:
390 case osg::ApplicationUsage::COMMAND_LINE_OPTION:
393 case osg::ApplicationUsage::ENVIRONMENTAL_VARIABLE:
396 case osg::ApplicationUsage::KEYBOARD_MOUSE_BINDING:
425 mAppUsage->AddUsageExplanation(type, option, explanation);
431 mAppUsage->SetCommandLineUsage(explanation);
443 mAppUsage->AddCommandLineOption(option, explanation, defaultValue);
449 mAppUsage->SetCommandLineOptions(usageMap);
455 return mAppUsage->GetCommandLineOptions();
461 mAppUsage->SetCommandLineOptionsDefaults(usageMap);
467 return mAppUsage->GetCommandLineOptionsDefaults();
473 mAppUsage->AddEnvironmentalVariable(option, explanation, defaultValue);
479 mAppUsage->SetEnvironmentalVariables(usageMap);
485 return mAppUsage->GetEnvironmentalVariables();
491 mAppUsage->SetEnvironmentalVariablesDefaults(usageMap);
497 return mAppUsage->GetEnvironmentalVariablesDefaults();
503 mAppUsage->AddKeyboardMouseBinding(prefix, key, explanation);
509 mAppUsage->AddKeyboardMouseBinding(key, explanation);
515 mAppUsage->AddKeyboardMouseBinding(option, explanation);
521 mAppUsage->SetKeyboardMouseBindings(usageMap);
527 return mAppUsage->GetKeyboardMouseBindings();
533 mAppUsage->GetFormattedString(str, usageMap, widthOfOutput, showDefaults, usageMapDef);
539 mAppUsage->Write(output, usageMap, widthOfOutput, showDefaults, usageMapDef);
545 mAppUsage->Write(output, type, widthOfOutput, showDefaults);
551 mAppUsage->WriteEnvironmentSettings(output);
ApplicationUsage::Type ReadHelpType()
This convenience method handles help requests on the command line.
void ReportError(const std::string &message, ErrorSeverity severity=ErrorSeverity::CRITICAL)
Report an error message by adding to the ErrorMessageMap.
void WriteErrorMessages(std::ostream &output, ErrorSeverity severity=ErrorSeverity::BENIGN)
Write error messages to the given ostream, if at or above the given severity.
void AddKeyboardMouseBinding(const std::string &prefix, int key, const std::string &explanation)
Adds a keyboard mouse binding usage.
const std::string & GetCommandLineUsage() const
Gets command line usage.
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.
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.
bool ContainsOptions() const
Query if this object contains options.
osg::ArgumentParser & GetOSGArgumentParser()
Gets internal osg argument parser.
ApplicationUsage * GetApplicationUsage()
Gets application usage.
const ApplicationUsage::UsageMap & GetCommandLineOptions() const
Gets command line options.
const ApplicationUsage::UsageMap & GetEnvironmentalVariablesDefaults() const
Gets environmental variables usage default usage map.
char ** GetArgv()
Return the argument array.
void AddCommandLineOption(const std::string &option, const std::string &explanation, const std::string &defaultValue="")
Adds a command line option.
const ApplicationUsage::UsageMap & GetCommandLineOptionsDefaults() const
Gets command line options defaults.
bool IsOption(const char *str) const
Return true if the specified string is an option in the form -option or –option. ...
bool IsBool(const char *str) const
Return true if specified parameter is a bool.
~ArgumentParser()
Destructor.
osg::ArgumentParser::Parameter * mParam
void SetCommandLineOptions(const ApplicationUsage::UsageMap &usageMap)
Sets command line options.
void AddEnvironmentalVariable(const std::string &option, const std::string &explanation, const std::string &defaultValue="")
Adds an environmental variable usage explanation.
void WriteEnvironmentSettings(std::ostream &output)
Writes out the environment settings.
bool Match(int pos, const std::string &str) const
Return true if the specified argument matches the given string.
void Remove(int pos, int num=1)
Remove one or more arguments from the argv argument list, and decrement the argc respectively.
void SetCommandLineOptionsDefaults(const ApplicationUsage::UsageMap &usageMap)
Sets command line options defaults.
bool IsString(const char *str) const
Return true if string is non-NULL and not an option in the form -option or –option.
bool IsNumber(const char *str) const
Return true if specified parameter is a number.
const std::string & GetDescription() const
Gets the description.
void SetEnvironmentalVariablesDefaults(const ApplicationUsage::UsageMap &usageMap)
Sets environmental variables usage default usage map.
std::unique_ptr< ApplicationUsage > mAppUsage
const ApplicationUsage::UsageMap & GetEnvironmentalVariables() const
Gets environmental variables usage.
An application usage class for the argument parser.
Parameter(bool &value)
Constructor.
void ReportRemainingOptionsAsUnrecognized(ErrorSeverity severity=ErrorSeverity::BENIGN)
For each remaining option, report it as unrecognized.
void AddUsageExplanation(ApplicationUsage::Type type, const std::string &option, const std::string &explanation)
Adds an usage explanation.
bool Errors(ErrorSeverity severity=ErrorSeverity::BENIGN) const
Return the error flag, true if an error has occurred when reading arguments.
void SetEnvironmentalVariables(const ApplicationUsage::UsageMap &usageMap)
Sets environmental variables usage.
std::string GetApplicationName() const
Return the application name, as specified by argv[0].
bool Assign(const char *str)
Assigns the given string value to the parameter.
std::map< std::string, std::string > UsageMap
The message to command usage map.
Namespace that holds various utility classes for the engine.
void SetDescription(const std::string &desc)
If non-empty, the Description is typically shown by the Help Handler as text on the Help display (whi...
Parameter & operator=(const Parameter ¶m)
Assignment operator.
void SetKeyboardMouseBindings(const ApplicationUsage::UsageMap &usageMap)
Sets keyboard mouse bindings usage.
void SetApplicationUsage(ApplicationUsage *usage)
Sets application usage.
void SetApplicationName(const std::string &name)
Sets the Applications Name.
int Find(const std::string &str) const
Return the position of an occurrence of a string in the argument list.
const ApplicationUsage::UsageMap & GetKeyboardMouseBindings() const
Gets keyboard mouse bindings usage.
bool Read(const std::string &str)
Search for an occurrence of a string in the argument list.
bool Valid(const char *str) const
Checks if this parameter is Valid.
std::unique_ptr< osg::ArgumentParser > mArgParser
The argument parser.
void SetCommandLineUsage(const std::string &explanation)
Sets command line usage.
ArgumentParser(int *argc, char **argv)
Default constructor that takes the argc and argv from the main function for command line parsing...
int & GetArgc()
Return the argument count.