35 #ifndef _CommandLine_H__ 36 #define _CommandLine_H__ 72 : bHasDefaultValue_(true)
74 , value_(defaultValue)
75 , defaultValue_(defaultValue)
89 { this->shortcut_ = shortcut;
return *
this; }
95 { this->usageInformation_ = usage;
return *
this; }
143 { getInstance()._parse(cmdLine); }
151 { *value = (
T)(getArgument(name)->
getValue()); }
153 {
return getArgument(name)->
getValue(); }
160 std::map<std::string, CommandLineArgument*>::const_iterator it = getInstance().cmdLineArgs_.find(name);
161 return !(it == getInstance().cmdLineArgs_.end());
164 static void generateDoc(std::ofstream& file);
std::string shortcut_
Shortcut of the argument.
Definition: CommandLineParser.h:115
static void parse(const std::string &cmdLine)
Parse redirection to internal member method.
Definition: CommandLineParser.h:142
CommandLineParser()
Constructor initialises bFirstTimeParse_ with true.
Definition: CommandLineParser.h:138
const std::string & getInformation() const
Returns the usage information.
Definition: CommandLineParser.h:92
Shared library macros, enums, constants and forward declarations for the core library ...
::std::string string
Definition: gtest-port.h:756
CommandLineArgument & shortcut(const std::string &shortcut)
Sets the shortcut for the argument.
Definition: CommandLineParser.h:88
bool hasDefaultValue() const
Tells whether the value has been changed by the command line.
Definition: CommandLineParser.h:80
const std::string & getName() const
Returns the name of the argument.
Definition: CommandLineParser.h:82
Global interface to command line options.
Definition: CommandLineParser.h:132
MultiType defaultValue_
Default value. Should not be changed.
Definition: CommandLineParser.h:119
std::string usageInformation_
Tells about the usage of this parameter.
Definition: CommandLineParser.h:116
false defaultValue(2, false).argumentCompleter(0
CommandLineArgument & information(const std::string &usage)
Sets the option information when displaying orxonox usage.
Definition: CommandLineParser.h:94
MultiType value_
The actual value.
Definition: CommandLineParser.h:118
Base for singleton classes.
Definition: Singleton.h:114
CommandLineArgument(const std::string &name, const MultiType &defaultValue)
Constructor initialises both value_ and defaultValue_ with defaultValue.
Definition: CommandLineParser.h:71
Die Wagnis Klasse hat die folgenden Aufgaben:
Definition: ApplicationPaths.cc:66
Declaration of the MultiType and some helper constructs.
#define _CoreExport
Definition: CorePrereqs.h:61
The MultiType can hold a value of many possible types and convert them to other types.
Definition: MultiType.h:130
std::map< std::string, CommandLineArgument * > cmdLineArgs_
Holds all pointers to the arguments and serves as a search map by name.
Definition: CommandLineParser.h:182
Definition: InputPrereqs.h:78
static bool existsArgument(const std::string &name)
Definition: CommandLineParser.h:158
const MultiType & getValue() const
Returns the actual value of the argument. Can be equal to default value.
Definition: CommandLineParser.h:98
std::string name_
Name of the argument.
Definition: CommandLineParser.h:114
Definition of the Singleton template that is used as base class for classes that allow only one insta...
static CommandLineParser * singletonPtr_s
Definition: CommandLineParser.h:186
static void getValue(const std::string &name, T *value)
Writes the argument value in the given parameter.
Definition: CommandLineParser.h:150
const std::string & getShortcut() const
Returns the shortcut (example: "-p 22" for "--port 22") of the argument.
Definition: CommandLineParser.h:86
bool bFirstTimeParse_
Tells whether we parsed for the first time.
Definition: CommandLineParser.h:179
~CommandLineArgument()
Definition: CommandLineParser.h:77
internal::String name_
Definition: gtest.cc:2289
std::map< std::string, CommandLineArgument * > cmdLineArgsShortcut_
Search map by shortcut for the arguments.
Definition: CommandLineParser.h:184
Declaration of custom assertion facilities
Container class for a command line argument of any type supported by MultiType.
Definition: CommandLineParser.h:65
static const MultiType & getValue(const std::string &name)
Definition: CommandLineParser.h:152
bool bHasDefaultValue_
Tells whether the value has been changed by the command line.
Definition: CommandLineParser.h:111
const MultiType & getDefaultValue() const
Returns the given default value as type T.
Definition: CommandLineParser.h:100