Open CASCADE Technology
7.5.0
|
Command parser. More...
#include <ViewerTest_CmdParser.hxx>
Public Member Functions | |
ViewerTest_CmdParser (const std::string &theDescription=std::string()) | |
Initializes help option. More... | |
void | SetDescription (const std::string &theDescription) |
Sets description for command. More... | |
ViewerTest_CommandOptionKey | AddOption (const std::string &theOptionNames, const std::string &theOptionDescription=std::string()) |
Adds option to available option list. Several names may be provided if separated with '|'. More... | |
void | PrintHelp () const |
Prints help message based on provided command and options descriptions. More... | |
void | Parse (Standard_Integer theArgsNb, const char *const *theArgVec) |
Parses argument list (skips the command name); assigns local arguments to each option. More... | |
std::string | GetOptionNameByKey (ViewerTest_CommandOptionKey theOptionKey) const |
Gets an option name by its access key. More... | |
ViewerTest_CommandOptionKeySet | GetUsedOptions () const |
Gets a set of used options. More... | |
bool | HasNoOption () const |
Tests if there were no command line options provided. More... | |
bool | HasUnnamedOption () const |
Tests if the unnamed command line option was provided. More... | |
bool | HasOnlyUnnamedOption () const |
Tests if only unnamed command line option was provided. More... | |
bool | HasOption (const std::string &theOptionName, std::size_t theMandatoryArgsNb=0, bool isFatal=Standard_False) const |
Checks if option was used with given minimal number of arguments. Prints error message if isFatal flag was set. More... | |
bool | HasOption (ViewerTest_CommandOptionKey theOptionKey, std::size_t theMandatoryArgsNb=0, bool isFatal=Standard_False) const |
Checks if option was used with given minimal number of arguments. Prints error message if isFatal flag was set. More... | |
Standard_Integer | GetNumberOfOptionArguments (const std::string &theOptionName) const |
Gets a number of option arguments. More... | |
Standard_Integer | GetNumberOfOptionArguments (ViewerTest_CommandOptionKey theOptionKey) const |
Gets a number of option arguments. More... | |
bool | Arg (const std::string &theOptionName, Standard_Integer theArgumentIndex, std::string &theOptionArgument) const |
Accesses local argument of option 'theOptionName' with index 'theArgumentIndex'. More... | |
bool | Arg (ViewerTest_CommandOptionKey theOptionKey, Standard_Integer theArgumentIndex, std::string &theOptionArgument) const |
Accesses a local argument with the index 'theArgumentIndex' of the option with the key 'theOptionKey'. More... | |
std::string | Arg (const std::string &theOptionName, Standard_Integer theArgumentIndex) const |
Accesses local argument of option 'theOptionName' with index 'theArgumentIndex'. More... | |
std::string | Arg (ViewerTest_CommandOptionKey theOptionKey, Standard_Integer theArgumentIndex) const |
Accesses a local argument with the index 'theArgumentIndex' of the option with the key 'theOptionKey'. More... | |
Graphic3d_Vec3 | ArgVec3f (const std::string &theOptionName, const Standard_Integer theArgumentIndex=0) const |
Graphic3d_Vec3d | ArgVec3d (const std::string &theOptionName, const Standard_Integer theArgumentIndex=0) const |
gp_Vec | ArgVec (const std::string &theOptionName, const Standard_Integer theArgumentIndex=0) const |
gp_Pnt | ArgPnt (const std::string &theOptionName, const Standard_Integer theArgumentIndex=0) const |
Standard_Real | ArgDouble (const std::string &theOptionName, const Standard_Integer theArgumentIndex=0) const |
Standard_ShortReal | ArgFloat (const std::string &theOptionName, const Standard_Integer theArgumentIndex=0) const |
Standard_Integer | ArgInt (const std::string &theOptionName, const Standard_Integer theArgumentIndex=0) const |
bool | ArgBool (const std::string &theOptionName, const Standard_Integer theArgumentIndex=0) const |
template<typename TheColor > | |
bool | ArgColor (const std::string &theOptionName, Standard_Integer &theArgumentIndex, TheColor &theColor) const |
Interprets arguments of the option 'theOptionName' with the index 'theArgumentIndex' as an RGB(A) color object. More... | |
template<typename TheColor > | |
bool | ArgColor (ViewerTest_CommandOptionKey theOptionKey, Standard_Integer &theArgumentIndex, TheColor &theColor) const |
Interprets arguments of the option with the key 'theOptionKey' as an RGB(A) color object. More... | |
Static Public Attributes | |
static const std::size_t | THE_UNNAMED_COMMAND_OPTION_KEY |
The key of the unnamed command option. More... | |
static const std::size_t | THE_HELP_COMMAND_OPTION_KEY |
The key of the help command option. More... | |
Command parser.
ViewerTest_CmdParser::ViewerTest_CmdParser | ( | const std::string & | theDescription = std::string() | ) |
Initializes help option.
theDescription | the description of the command |
ViewerTest_CommandOptionKey ViewerTest_CmdParser::AddOption | ( | const std::string & | theOptionNames, |
const std::string & | theOptionDescription = std::string() |
||
) |
Adds option to available option list. Several names may be provided if separated with '|'.
theOptionNames | the list of possible option names separated with '|' (the first name is main, the other names are aliases) |
theOptionDescription | the description of the option |
bool ViewerTest_CmdParser::Arg | ( | const std::string & | theOptionName, |
Standard_Integer | theArgumentIndex, | ||
std::string & | theOptionArgument | ||
) | const |
Accesses local argument of option 'theOptionName' with index 'theArgumentIndex'.
theOptionName | the name of the option which argument is to be accessed |
theArgumentIndex | the index of an accessed argument |
theOptionArgument | an argument of the option with the given name |
bool ViewerTest_CmdParser::Arg | ( | ViewerTest_CommandOptionKey | theOptionKey, |
Standard_Integer | theArgumentIndex, | ||
std::string & | theOptionArgument | ||
) | const |
Accesses a local argument with the index 'theArgumentIndex' of the option with the key 'theOptionKey'.
theOptionKey | the access key of the option which argument is to be accessed |
theArgumentIndex | the index of an accessed argument |
theOptionArgument | an argument of the option with the given key |
std::string ViewerTest_CmdParser::Arg | ( | const std::string & | theOptionName, |
Standard_Integer | theArgumentIndex | ||
) | const |
Accesses local argument of option 'theOptionName' with index 'theArgumentIndex'.
theOptionName | the name of the option which argument is to be accessed |
theArgumentIndex | the index of an accessed argument |
std::string ViewerTest_CmdParser::Arg | ( | ViewerTest_CommandOptionKey | theOptionKey, |
Standard_Integer | theArgumentIndex | ||
) | const |
Accesses a local argument with the index 'theArgumentIndex' of the option with the key 'theOptionKey'.
theOptionKey | the access key of the option which argument is to be accessed |
theArgumentIndex | the index of an accessed argument |
bool ViewerTest_CmdParser::ArgBool | ( | const std::string & | theOptionName, |
const Standard_Integer | theArgumentIndex = 0 |
||
) | const |
bool ViewerTest_CmdParser::ArgColor | ( | const std::string & | theOptionName, |
Standard_Integer & | theArgumentIndex, | ||
TheColor & | theColor | ||
) | const |
Interprets arguments of the option 'theOptionName' with the index 'theArgumentIndex' as an RGB(A) color object.
theColor | the type of a resulting RGB(A) color object |
theOptionName | the name of the option which arguments are to be interpreted |
theArgumentIndex | the index of the first argument to be interpreted (will be promoted to the next argument after the block of interpreted arguments) |
theColor | a color that is an interpretation of argument(s) of the option with the given name |
bool ViewerTest_CmdParser::ArgColor | ( | ViewerTest_CommandOptionKey | theOptionKey, |
Standard_Integer & | theArgumentIndex, | ||
TheColor & | theColor | ||
) | const |
Interprets arguments of the option with the key 'theOptionKey' as an RGB(A) color object.
theColor | the type of a resulting RGB(A) color object |
theOptionKey | the access key of the option which arguments are to be interpreted |
theArgumentIndex | the index of the first argument to be interpreted (will be promoted to the next argument after the block of interpreted arguments) |
theColor | a color that is an interpretation of argument(s) of the option with the given name |
Standard_Real ViewerTest_CmdParser::ArgDouble | ( | const std::string & | theOptionName, |
const Standard_Integer | theArgumentIndex = 0 |
||
) | const |
Standard_ShortReal ViewerTest_CmdParser::ArgFloat | ( | const std::string & | theOptionName, |
const Standard_Integer | theArgumentIndex = 0 |
||
) | const |
Standard_Integer ViewerTest_CmdParser::ArgInt | ( | const std::string & | theOptionName, |
const Standard_Integer | theArgumentIndex = 0 |
||
) | const |
gp_Pnt ViewerTest_CmdParser::ArgPnt | ( | const std::string & | theOptionName, |
const Standard_Integer | theArgumentIndex = 0 |
||
) | const |
gp_Vec ViewerTest_CmdParser::ArgVec | ( | const std::string & | theOptionName, |
const Standard_Integer | theArgumentIndex = 0 |
||
) | const |
Graphic3d_Vec3d ViewerTest_CmdParser::ArgVec3d | ( | const std::string & | theOptionName, |
const Standard_Integer | theArgumentIndex = 0 |
||
) | const |
Graphic3d_Vec3 ViewerTest_CmdParser::ArgVec3f | ( | const std::string & | theOptionName, |
const Standard_Integer | theArgumentIndex = 0 |
||
) | const |
Standard_Integer ViewerTest_CmdParser::GetNumberOfOptionArguments | ( | const std::string & | theOptionName | ) | const |
Gets a number of option arguments.
theOptionName | the name of the option |
Standard_Integer ViewerTest_CmdParser::GetNumberOfOptionArguments | ( | ViewerTest_CommandOptionKey | theOptionKey | ) | const |
Gets a number of option arguments.
theOptionKey | the access key of the option |
std::string ViewerTest_CmdParser::GetOptionNameByKey | ( | ViewerTest_CommandOptionKey | theOptionKey | ) | const |
Gets an option name by its access key.
theOptionKey | the access key of the option which name is to be found a name of the option with the given access key |
ViewerTest_CommandOptionKeySet ViewerTest_CmdParser::GetUsedOptions | ( | ) | const |
Gets a set of used options.
bool ViewerTest_CmdParser::HasNoOption | ( | ) | const |
Tests if there were no command line options provided.
bool ViewerTest_CmdParser::HasOnlyUnnamedOption | ( | ) | const |
Tests if only unnamed command line option was provided.
bool ViewerTest_CmdParser::HasOption | ( | const std::string & | theOptionName, |
std::size_t | theMandatoryArgsNb = 0 , |
||
bool | isFatal = Standard_False |
||
) | const |
Checks if option was used with given minimal number of arguments. Prints error message if isFatal flag was set.
theOptionName | the name of the option to be checked |
theMandatoryArgsNb | the number of mandatory arguments |
isFatal | the flag that controls printing of an error message |
bool ViewerTest_CmdParser::HasOption | ( | ViewerTest_CommandOptionKey | theOptionKey, |
std::size_t | theMandatoryArgsNb = 0 , |
||
bool | isFatal = Standard_False |
||
) | const |
Checks if option was used with given minimal number of arguments. Prints error message if isFatal flag was set.
theOptionKey | the access key of the option to be checked |
theMandatoryArgsNb | the number of mandatory arguments |
isFatal | the flag that controls printing of an error message |
bool ViewerTest_CmdParser::HasUnnamedOption | ( | ) | const |
Tests if the unnamed command line option was provided.
void ViewerTest_CmdParser::Parse | ( | Standard_Integer | theArgsNb, |
const char *const * | theArgVec | ||
) |
Parses argument list (skips the command name); assigns local arguments to each option.
void ViewerTest_CmdParser::PrintHelp | ( | ) | const |
Prints help message based on provided command and options descriptions.
|
inline |
Sets description for command.
|
static |
The key of the help command option.
|
static |
The key of the unnamed command option.