A general purpose command-line argument parser.  
 More...
#include <ArgumentParser.h>
|  | 
|  | ArgumentParser (const std::string &title) | 
|  | Construct an argument parser.  More... 
 | 
|  | 
| void | parseArgs (int argc, const char **argv) | 
|  | Parses a list of strings given in the C style. Throws std::exception if parsing fails.  More... 
 | 
|  | 
| void | parse (const std::vector< std::string > &args) | 
|  | Parses a list of strings. Throws std::exception if parsing fails.  More... 
 | 
|  | 
| void | addOptionalIntArgument (const std::string &name, const std::string &description, int defaultValue) | 
|  | Specify an integer argument that can be given on the command line.  More... 
 | 
|  | 
| void | addOptionalFloatArgument (const std::string &name, const std::string &description, double defaultValue) | 
|  | Specify a floating-point argument that can be given on the command line.  More... 
 | 
|  | 
| void | addOptionalStringArgument (const std::string &name, const std::string &description, const std::string &defaultValue) | 
|  | Specify a string argument that can be given on the command line.  More... 
 | 
|  | 
| void | addOptionalFlag (const std::string &name, const std::string &description) | 
|  | Specify a boolean flag that can be given on the command line.  More... 
 | 
|  | 
| std::string | getUsage () const | 
|  | Gets a string that describes the current set of options we expect.  More... 
 | 
|  | 
| bool | receivedArgument (const std::string &name) const | 
|  | Gets whether a named argument was parsed on the command-line arguments.  More... 
 | 
|  | 
| int | getIntArgument (const std::string &name) const | 
|  | Retrieves the value of a named integer argument.  More... 
 | 
|  | 
| double | getFloatArgument (const std::string &name) const | 
|  | Retrieves the value of a named floating-point argument.  More... 
 | 
|  | 
| std::string | getStringArgument (const std::string &name) const | 
|  | Retrieves the value of a named string argument.  More... 
 | 
|  | 
A general purpose command-line argument parser. 
      
        
          | malmo::ArgumentParser::ArgumentParser | ( | const std::string & | title | ) |  | 
      
 
Construct an argument parser. 
- Parameters
- 
  
    | title | The title of the program to display. |  
 
 
 
      
        
          | void malmo::ArgumentParser::addOptionalFlag | ( | const std::string & | name, | 
        
          |  |  | const std::string & | description | 
        
          |  | ) |  |  | 
      
 
Specify a boolean flag that can be given on the command line. 
- Parameters
- 
  
    | name | The name of the flag. To be given as "--name" |  | description | The explanation of the flag that can be printed out. |  
 
 
 
      
        
          | void malmo::ArgumentParser::addOptionalFloatArgument | ( | const std::string & | name, | 
        
          |  |  | const std::string & | description, | 
        
          |  |  | double | defaultValue | 
        
          |  | ) |  |  | 
      
 
Specify a floating-point argument that can be given on the command line. 
- Parameters
- 
  
    | name | The name of the argument. To be given as "--name <value>" |  | description | The explanation of the argument that can be printed out. |  | defaultValue | The value that this argument should have if not given on the command line. |  
 
 
 
      
        
          | void malmo::ArgumentParser::addOptionalIntArgument | ( | const std::string & | name, | 
        
          |  |  | const std::string & | description, | 
        
          |  |  | int | defaultValue | 
        
          |  | ) |  |  | 
      
 
Specify an integer argument that can be given on the command line. 
- Parameters
- 
  
    | name | The name of the argument. To be given as "--name <value>" |  | description | The explanation of the argument that can be printed out. |  | defaultValue | The value that this argument should have if not given on the command line. |  
 
 
 
      
        
          | void malmo::ArgumentParser::addOptionalStringArgument | ( | const std::string & | name, | 
        
          |  |  | const std::string & | description, | 
        
          |  |  | const std::string & | defaultValue | 
        
          |  | ) |  |  | 
      
 
Specify a string argument that can be given on the command line. 
- Parameters
- 
  
    | name | The name of the argument. To be given as "--name <value>" |  | description | The explanation of the argument that can be printed out. |  | defaultValue | The value that this argument should have if not given on the command line. |  
 
 
 
      
        
          | double malmo::ArgumentParser::getFloatArgument | ( | const std::string & | name | ) | const | 
      
 
Retrieves the value of a named floating-point argument. 
- Parameters
- 
  
    | name | The name of the argument. |  
 
- Returns
- The value of the named argument. 
 
 
      
        
          | int malmo::ArgumentParser::getIntArgument | ( | const std::string & | name | ) | const | 
      
 
Retrieves the value of a named integer argument. 
- Parameters
- 
  
    | name | The name of the argument. |  
 
- Returns
- The value of the named argument. 
 
 
      
        
          | std::string malmo::ArgumentParser::getStringArgument | ( | const std::string & | name | ) | const | 
      
 
Retrieves the value of a named string argument. 
- Parameters
- 
  
    | name | The name of the argument. |  
 
- Returns
- The value of the named argument. 
 
 
      
        
          | std::string malmo::ArgumentParser::getUsage | ( |  | ) | const | 
      
 
Gets a string that describes the current set of options we expect. 
- Returns
- The usage string, for displaying. 
 
 
      
        
          | void malmo::ArgumentParser::parse | ( | const std::vector< std::string > & | args | ) |  | 
      
 
Parses a list of strings. Throws std::exception if parsing fails. 
In C++: takes a std::vector<std::string>. In Python: takes a list of strings. In Lua: takes a table of strings. 
- Parameters
- 
  
    | args | The arguments to parse. |  
 
 
 
      
        
          | void malmo::ArgumentParser::parseArgs | ( | int | argc, | 
        
          |  |  | const char ** | argv | 
        
          |  | ) |  |  | 
      
 
Parses a list of strings given in the C style. Throws std::exception if parsing fails. 
Available in C++ only. In other languages use the parse function instead. 
- Parameters
- 
  
    | argc | The number of arguments. |  | argv | The arguments to parse. |  
 
- See also
- parse() 
 
 
      
        
          | bool malmo::ArgumentParser::receivedArgument | ( | const std::string & | name | ) | const | 
      
 
Gets whether a named argument was parsed on the command-line arguments. 
- Parameters
- 
  
    | name | The name of the argument. |  
 
- Returns
- True if the named argument was received. 
 
 
The documentation for this class was generated from the following file: