Class to parse arguments from the command line in any language.
More...
#include <ArgParser.h>
|
| | ArgParser () |
| | Default constructor for the arg parser – sets name to "args".
|
| | ~ArgParser () |
| std::string | operator() (const std::string &name) |
| | Function to get the string value of an arg.
|
| int | get (const std::string &name, std::string &val) |
| | Function to get the string value of an arg.
|
| int | get (const std::string &name, double &val) |
| | Function to get the string value of an arg as a double.
|
| int | get (const std::string &name, int &val) |
| | Function to get the string value of an arg as an int.
|
| int | parseArgs (int argc, char *argv[]) |
| | Function to parse argc and argv for string arguments.
|
| int | parseArgs (std::vector< std::string > args) |
| | Function to loop through args and parse for values.
|
| void | addDefaultArgument (const std::string &name, const std::string &val) |
| | Function to add a default argument that can be overridden from the cmd line.
|
| void | addDefaultArgument (const std::string &name, double val) |
| | Function to add a default argument that can be overridden from the cmd line.
|
| void | addDefaultArgument (const std::string &name, int val) |
| | Function to add a default argument that can be overridden from the cmd line.
|
| void | dump () |
| | Function to dump all argument value pairs held in the class.
|
Class to parse arguments from the command line in any language.
◆ ArgParser()
| warptwin::ArgParser::ArgParser |
( |
| ) |
|
|
inline |
Default constructor for the arg parser – sets name to "args".
◆ ~ArgParser()
| warptwin::ArgParser::~ArgParser |
( |
| ) |
|
|
inline |
◆ addDefaultArgument() [1/3]
| void warptwin::ArgParser::addDefaultArgument |
( |
const std::string & | name, |
|
|
const std::string & | val ) |
Function to add a default argument that can be overridden from the cmd line.
- Parameters
-
| name | The name of the argument to add |
| val | The default value |
◆ addDefaultArgument() [2/3]
| void warptwin::ArgParser::addDefaultArgument |
( |
const std::string & | name, |
|
|
double | val ) |
Function to add a default argument that can be overridden from the cmd line.
- Parameters
-
| name | The name of the argument to add |
| val | The default value |
◆ addDefaultArgument() [3/3]
| void warptwin::ArgParser::addDefaultArgument |
( |
const std::string & | name, |
|
|
int | val ) |
Function to add a default argument that can be overridden from the cmd line.
- Parameters
-
| name | The name of the argument to add |
| val | The default value |
◆ dump()
| void warptwin::ArgParser::dump |
( |
| ) |
|
Function to dump all argument value pairs held in the class.
◆ get() [1/3]
| int warptwin::ArgParser::get |
( |
const std::string & | name, |
|
|
double & | val ) |
Function to get the string value of an arg as a double.
- Parameters
-
| name | The arg to get |
| val | The returned value |
- Returns
- The arg as a double value. Will produce error if value can't be cast to double
◆ get() [2/3]
| int warptwin::ArgParser::get |
( |
const std::string & | name, |
|
|
int & | val ) |
Function to get the string value of an arg as an int.
- Parameters
-
| name | The arg to get |
| val | The returned value |
- Returns
- The arg as an int value. Will produce error if value can't be cast to int
◆ get() [3/3]
| int warptwin::ArgParser::get |
( |
const std::string & | name, |
|
|
std::string & | val ) |
Function to get the string value of an arg.
- Parameters
-
| name | The arg to get |
| val | The returned value |
- Returns
- The arg as a string value. Empty string if arg does not exist
◆ operator()()
| std::string warptwin::ArgParser::operator() |
( |
const std::string & | name | ) |
|
|
inline |
Function to get the string value of an arg.
- Parameters
-
- Returns
- The arg as a string value. Empty string if arg does not exist
◆ parseArgs() [1/2]
| int warptwin::ArgParser::parseArgs |
( |
int | argc, |
|
|
char * | argv[] ) |
Function to parse argc and argv for string arguments.
- Parameters
-
| argc | C++ argc input |
| argv | C++ argv input |
- Returns
- Error code corresponding to success/failure
◆ parseArgs() [2/2]
| int warptwin::ArgParser::parseArgs |
( |
std::vector< std::string > | args | ) |
|
Function to loop through args and parse for values.
- Parameters
-
| args | A std::vector of arguments |
- Returns
- Error code corresponding to success/failure
The documentation for this class was generated from the following files:
- /Users/mickey/Documents/Projects/warptwin/cpp/src/simulation/ArgParser.h
- /Users/mickey/Documents/Projects/warptwin/cpp/src/simulation/ArgParser.cpp