Jetson Inference
DNN Vision Library
commandLine Class Reference

Command line parser class. More...

#include <commandLine.h>

Public Member Functions

 commandLine (const int argc, char **argv)
 Constructor, takes the command line from main() More...
 
bool GetFlag (const char *argName)
 Checks to see whether the specified flag was included on the command line. More...
 
float GetFloat (const char *argName, float defaultValue=0.0f)
 Get float argument. More...
 
int GetInt (const char *argName, int defaultValue=0)
 Get integer argument. More...
 
const char * GetString (const char *argName, const char *defaultValue=NULL)
 Get string argument. More...
 
const char * GetPosition (unsigned int position, const char *defaultValue=NULL)
 Get positional string argument. More...
 
unsigned int GetPositionArgs ()
 Get the number of positional arguments in the command line. More...
 

Protected Attributes

int argc
 
char ** argv
 

Detailed Description

Command line parser class.

Constructor & Destructor Documentation

◆ commandLine()

commandLine::commandLine ( const int  argc,
char **  argv 
)

Constructor, takes the command line from main()

Member Function Documentation

◆ GetFlag()

bool commandLine::GetFlag ( const char *  argName)

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

Returns
true, if the flag with argName was found false, if the flag with argName was not found

◆ GetFloat()

float commandLine::GetFloat ( const char *  argName,
float  defaultValue = 0.0f 
)

Get float argument.

For example if argv contained --foo=3.14159, then GetInt("foo") would return 3.14159f

Returns
defaultValue if the argument couldn't be found. (0.0 by default). Otherwise, returns the value of the argument.

◆ GetInt()

int commandLine::GetInt ( const char *  argName,
int  defaultValue = 0 
)

Get integer argument.

For example if argv contained --foo=100, then GetInt("foo") would return 100

Returns
defaultValue if the argument couldn't be found (0 by default). Otherwise, returns the value of the argument.

◆ GetPosition()

const char* commandLine::GetPosition ( unsigned int  position,
const char *  defaultValue = NULL 
)

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"

Returns
defaultValue if the argument couldn't be found (NULL by default). Otherwise, returns a pointer to the argument value string from the argv array.

◆ GetPositionArgs()

unsigned int commandLine::GetPositionArgs ( )

Get the number of positional arguments in the command line.

Positional arguments are those that don't have a name.

◆ GetString()

const char* commandLine::GetString ( const char *  argName,
const char *  defaultValue = NULL 
)

Get string argument.

For example if argv contained --foo=bar, then GetString("foo") would return "bar"

Returns
defaultValue if the argument couldn't be found (NULL by default). Otherwise, returns a pointer to the argument value string from the argv array.

Member Data Documentation

◆ argc

int commandLine::argc
protected

◆ argv

char** commandLine::argv
protected

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