Orxonox
0.0.5 Codename: Arcturus
|
Container class for a command line argument of any type supported by MultiType. More...
#include </home/jenkins/workspace/orxonox_doxygen_trunk/src/libraries/core/commandline/CommandLineParser.h>
Public Member Functions | |
CommandLineArgument (const std::string &name, const MultiType &defaultValue) | |
Constructor initialises both value_ and defaultValue_ with defaultValue. More... | |
~CommandLineArgument () | |
const MultiType & | getDefaultValue () const |
Returns the given default value as type T. More... | |
const std::string & | getInformation () const |
Returns the usage information. More... | |
const std::string & | getName () const |
Returns the name of the argument. More... | |
const std::string & | getShortcut () const |
Returns the shortcut (example: "-p 22" for "--port 22") of the argument. More... | |
const MultiType & | getValue () const |
Returns the actual value of the argument. Can be equal to default value. More... | |
bool | hasDefaultValue () const |
Tells whether the value has been changed by the command line. More... | |
CommandLineArgument & | information (const std::string &usage) |
Sets the option information when displaying orxonox usage. More... | |
CommandLineArgument & | shortcut (const std::string &shortcut) |
Sets the shortcut for the argument. More... | |
Private Member Functions | |
CommandLineArgument (const CommandLineArgument &)=delete | |
CommandLineArgument & | operator= (const CommandLineArgument &)=delete |
void | parse (const std::string &value) |
Parses the value string of a command line argument. More... | |
Private Attributes | |
bool | bHasDefaultValue_ |
Tells whether the value has been changed by the command line. More... | |
MultiType | defaultValue_ |
Default value. Should not be changed. More... | |
std::string | name_ |
Name of the argument. More... | |
std::string | shortcut_ |
Shortcut of the argument. More... | |
std::string | usageInformation_ |
Tells about the usage of this parameter. More... | |
MultiType | value_ |
The actual value. More... | |
Friends | |
class | CommandLineParser |
Container class for a command line argument of any type supported by MultiType.
Whenever you want to have an option specified by a command line switch, you need to first define it with SetCommandLineArgument(name, defaultValue). It is then added to a map and possibly changed when the command line is being parsed. If the option was not given, you can detect this by asking hasDefaultValue().
There is a possibility to define a short cut so you can write "-p 20" instead of "--port 20". Note the difference between "-" and "--"! Also, there is no restriction to the number of strings you add after –name. So "--startVector {2, 4, 5}" is perfectly legal.
Retrieving an argument is possible with the getCommandLineArgument function of the CommandLineParser class. It is a Singleton, but the public interface is static.
|
inline |
Constructor initialises both value_ and defaultValue_ with defaultValue.
|
inline |
|
privatedelete |
|
inline |
Returns the given default value as type T.
|
inline |
Returns the usage information.
|
inline |
Returns the name of the argument.
|
inline |
Returns the shortcut (example: "-p 22" for "--port 22") of the argument.
Evaluates to "" if there is none.
|
inline |
Returns the actual value of the argument. Can be equal to default value.
|
inline |
Tells whether the value has been changed by the command line.
|
inline |
Sets the option information when displaying orxonox usage.
|
privatedelete |
|
private |
Parses the value string of a command line argument.
Parses a value string for a command line argument.
It simply uses convertValue(Output, Input) to do that. Bools are treated specially. That is necessary so that you can have simple command line switches.
|
inline |
Sets the shortcut for the argument.
|
friend |
|
private |
Tells whether the value has been changed by the command line.
|
private |
Default value. Should not be changed.
|
private |
Name of the argument.
|
private |
Shortcut of the argument.
|
private |
Tells about the usage of this parameter.
|
private |
The actual value.