WarpTwin
Documentation for WarpTwin models and classes.
Loading...
Searching...
No Matches
warptwin::ArgParser Class Reference

Class to parse arguments from the command line in any language. More...

#include <ArgParser.h>

Public Member Functions

 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.

Detailed Description

Class to parse arguments from the command line in any language.

Constructor & Destructor Documentation

◆ ArgParser()

warptwin::ArgParser::ArgParser ( )
inline

Default constructor for the arg parser – sets name to "args".

◆ ~ArgParser()

warptwin::ArgParser::~ArgParser ( )
inline

Member Function Documentation

◆ 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
nameThe name of the argument to add
valThe 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
nameThe name of the argument to add
valThe 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
nameThe name of the argument to add
valThe 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
nameThe arg to get
valThe 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
nameThe arg to get
valThe 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
nameThe arg to get
valThe 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
nameThe arg to get
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
argcC++ argc input
argvC++ 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
argsA 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