![]() |
Jetson Inference
DNN Vision Library
|
Command line parser for extracting flags, values, and strings. More...
#include <commandLine.h>
Public Member Functions | |
| commandLine (const int argc, char **argv, const char *extraFlag=NULL) | |
Constructor, takes the command line from main() More... | |
| commandLine (const int argc, char **argv, const char **extraArgs) | |
Constructor, takes the command line from main() More... | |
| bool | GetFlag (const char *argName, bool allowOtherDelimiters=true) const |
| Checks to see whether the specified flag was included on the command line. More... | |
| float | GetFloat (const char *argName, float defaultValue=0.0f, bool allowOtherDelimiters=true) const |
| Get float argument. More... | |
| int | GetInt (const char *argName, int defaultValue=0, bool allowOtherDelimiters=true) const |
| Get integer argument. More... | |
| uint32_t | GetUnsignedInt (const char *argName, uint32_t defaultValue=0, bool allowOtherDelimiters=true) const |
| Get unsigned integer argument. More... | |
| const char * | GetString (const char *argName, const char *defaultValue=NULL, bool allowOtherDelimiters=true) const |
| Get string argument. More... | |
| const char * | GetPosition (unsigned int position, const char *defaultValue=NULL) const |
| Get positional string argument. More... | |
| unsigned int | GetPositionArgs () const |
| Get the number of positional arguments in the command line. More... | |
| void | AddArg (const char *arg) |
| Add an argument to the command line. More... | |
| void | AddArgs (const char **args) |
| Add arguments to the command line. More... | |
| void | AddFlag (const char *flag) |
| Add a flag to the command line. More... | |
| void | Print () const |
| Print out the command line for reference. More... | |
Public Attributes | |
| int | argc |
| The argument count that the object was created with from main() More... | |
| char ** | argv |
| The argument strings that the object was created with from main() More... | |
Command line parser for extracting flags, values, and strings.
| commandLine::commandLine | ( | const int | argc, |
| char ** | argv, | ||
| const char * | extraFlag = NULL |
||
| ) |
Constructor, takes the command line from main()
| commandLine::commandLine | ( | const int | argc, |
| char ** | argv, | ||
| const char ** | extraArgs | ||
| ) |
Constructor, takes the command line from main()
| void commandLine::AddArg | ( | const char * | arg | ) |
Add an argument to the command line.
| void commandLine::AddArgs | ( | const char ** | args | ) |
Add arguments to the command line.
| void commandLine::AddFlag | ( | const char * | flag | ) |
Add a flag to the command line.
| bool commandLine::GetFlag | ( | const char * | argName, |
| bool | allowOtherDelimiters = true |
||
| ) | const |
Checks to see whether the specified flag was included on the command line.
For example, if argv contained --foo, then GetFlag("foo") would return true
| allowOtherDelimiters | if true (default), the argName will be matched against occurances containing either - or _. For example, --foo-bar and --foo_bar would be the same. |
true, if the flag with argName was found false, if the flag with argName was not found | float commandLine::GetFloat | ( | const char * | argName, |
| float | defaultValue = 0.0f, |
||
| bool | allowOtherDelimiters = true |
||
| ) | const |
Get float argument.
For example if argv contained --foo=3.14159, then GetInt("foo") would return 3.14159f
| allowOtherDelimiters | if true (default), the argName will be matched against occurances containing either - or _. For example, --foo-bar and --foo_bar would be the same. |
defaultValue if the argument couldn't be found. (0.0 by default). Otherwise, returns the value of the argument. | int commandLine::GetInt | ( | const char * | argName, |
| int | defaultValue = 0, |
||
| bool | allowOtherDelimiters = true |
||
| ) | const |
Get integer argument.
For example if argv contained --foo=100, then GetInt("foo") would return 100
| allowOtherDelimiters | if true (default), the argName will be matched against occurances containing either - or _. For example, --foo-bar and --foo_bar would be the same. |
defaultValue if the argument couldn't be found (0 by default). Otherwise, returns the value of the argument. | const char* commandLine::GetPosition | ( | unsigned int | position, |
| const char * | defaultValue = NULL |
||
| ) | const |
Get positional string argument.
Positional arguments aren't named, but rather referenced by their index in the list. For example if the command line contained my-program --foo=bar /path/to/my_file.txt, then GetString(0) would return `"/path/to/my_file.txt"
defaultValue if the argument couldn't be found (NULL by default). Otherwise, returns a pointer to the argument value string from the argv array. | unsigned int commandLine::GetPositionArgs | ( | ) | const |
Get the number of positional arguments in the command line.
Positional arguments are those that don't have a name.
| const char* commandLine::GetString | ( | const char * | argName, |
| const char * | defaultValue = NULL, |
||
| bool | allowOtherDelimiters = true |
||
| ) | const |
Get string argument.
For example if argv contained --foo=bar, then GetString("foo") would return "bar"
| allowOtherDelimiters | if true (default), the argName will be matched against occurances containing either - or _. For example, --foo-bar and --foo_bar would be the same. |
defaultValue if the argument couldn't be found (NULL by default). Otherwise, returns a pointer to the argument value string from the argv array. | uint32_t commandLine::GetUnsignedInt | ( | const char * | argName, |
| uint32_t | defaultValue = 0, |
||
| bool | allowOtherDelimiters = true |
||
| ) | const |
Get unsigned integer argument.
For example if argv contained --foo=100, then GetUnsignedInt("foo") would return 100
| allowOtherDelimiters | if true (default), the argName will be matched against occurances containing either - or _. For example, --foo-bar and --foo_bar would be the same. |
defaultValue if the argument couldn't be found, or if the value was negative (0 by default). Otherwise, returns the parsed value. | void commandLine::Print | ( | ) | const |
Print out the command line for reference.
| int commandLine::argc |
The argument count that the object was created with from main()
| char** commandLine::argv |
The argument strings that the object was created with from main()