Rudiments
Public Member Functions | List of all members
commandline Class Reference

Public Member Functions

 commandline (int32_t argc, const char **argv)
 
 ~commandline ()
 
const char * getValue (const char *arg) const
 
const char * getValue (const char *arg, const char *abbr) const
 
bool found (const char *arg) const
 
bool found (const char *arg, const char *abbr) const
 

Detailed Description

The commandline class provides methods for parsing command line arguments.

Constructor & Destructor Documentation

◆ commandline()

commandline::commandline ( int32_t  argc,
const char **  argv 
)

Creates an instance of the commandline class.

◆ ~commandline()

commandline::~commandline ( )

Deletes this instance of the commandline class.

Member Function Documentation

◆ found() [1/2]

bool commandline::found ( const char *  arg) const

Returns true if "-arg", "--arg" or "--arg=value" was found on the command line and false if it was not found.

This is useful for processing command line switches.

◆ found() [2/2]

bool commandline::found ( const char *  arg,
const char *  abbr 
) const

Returns true if the argument or an abbreviated version of it was found on the command line and false if neither were found.

For example, if "arg" is "recursive" and "abbr" is "r" then it returns true if "-recursive", "--recursive", "-r", or "--r" was found on the command line.

This is useful for processing command line switches.

◆ getValue() [1/2]

const char* commandline::getValue ( const char *  arg) const

Looks for either: -arg value or –arg=value on the command line and returns value.

◆ getValue() [2/2]

const char* commandline::getValue ( const char *  arg,
const char *  abbr 
) const

Looks for the argument or an abbreviated version of it on the command line and returns the value.

For example, if "arg" is "name" and "abbr" is "n" then it looks for either:

-name value

or –name=value or -n value or –n==value

on the command line and returns value.

If both "arg" and "abbr" are found then the value for "arg" is returned.