#include <src/core/CommandLine.h>
Static Public Member Functions | |
template<class T> | |
static CommandLineArgument & | addArgument (const std::string &name, T defaultValue, bool bCommandLineOnly) |
Adds a new CommandLineArgument to the internal map. Note that only such arguments are actually valid. | |
static void | destroyAllArguments () |
Destroys all command line arguments. This should be called at the end of main. Do not use before that. | |
static bool | existsArgument (const std::string &name) |
static const CommandLineArgument * | getArgument (const std::string &name) |
Retrieves a CommandLineArgument. The method throws an exception if 'name' was not found or the value could not be converted. | |
static std::string | getUsageInformation () |
static MultiType | getValue (const std::string &name) |
template<class T> | |
static void | getValue (const std::string &name, T *value) |
Writes the argument value in the given parameter. | |
static void | parseCommandLine (int argc, char **argv) |
Parse redirection to internal member method. | |
static void | parseFile () |
Private Member Functions | |
void | _parse (const std::vector< std::string > &arguments, bool bParsingFile) |
Reads the command line parses the values of each argument. It is then stored in the corresponding CommandLineArgument. | |
void | _parseCommandLine (int argc, char **argv) |
Parses only the command line for CommandLineArguments. | |
void | _parseFile () |
Parses start.ini (or the file specified with --optionsFile) for CommandLineArguments. | |
void | checkFullArgument (const std::string &name, const std::string &value, bool bParsingFile) |
Parses an argument based on its full name. | |
void | checkShortcut (const std::string &shortcut, const std::string &value, bool bParsingFile) |
Parses an argument based on its shortcut. | |
CommandLine (const CommandLine &instance) | |
Undefined copy constructor. | |
CommandLine () | |
Constructor initialises bFirstTimeParse_ with true. | |
~CommandLine () | |
Destructor destroys all CommandLineArguments with it. | |
Static Private Member Functions | |
static CommandLine & | _getInstance () |
Returns a unique instance (Meyers Singleton). | |
Private Attributes | |
bool | bFirstTimeParse_ |
std::map< std::string, CommandLineArgument * > | cmdLineArgs_ |
Holds all pointers to the arguments and serves as a search map by name. | |
std::map< std::string, CommandLineArgument * > | cmdLineArgsShortcut_ |
Search map by shortcut for the arguments. |
orxonox::CommandLine::CommandLine | ( | ) | [inline, private] |
Constructor initialises bFirstTimeParse_ with true.
orxonox::CommandLine::CommandLine | ( | const CommandLine & | instance | ) | [private] |
Undefined copy constructor.
orxonox::CommandLine::~CommandLine | ( | ) | [private] |
CommandLine & orxonox::CommandLine::_getInstance | ( | ) | [static, private] |
Returns a unique instance (Meyers Singleton).
Referenced by addArgument(), destroyAllArguments(), getArgument(), and getUsageInformation().
void orxonox::CommandLine::_parse | ( | const std::vector< std::string > & | arguments, | |
bool | bParsingFile | |||
) | [private] |
Reads the command line parses the values of each argument. It is then stored in the corresponding CommandLineArgument.
arguments | Vector of space separated strings. |
References bFirstTimeParse_, checkFullArgument(), checkShortcut(), cmdLineArgs_, cmdLineArgsShortcut_, COUT, getUsageInformation(), OrxAssert, orxonox::removeTrailingWhitespaces(), and ThrowException.
Referenced by _parseCommandLine(), and _parseFile().
void orxonox::CommandLine::_parseCommandLine | ( | int | argc, | |
char ** | argv | |||
) | [private] |
void orxonox::CommandLine::_parseFile | ( | ) | [private] |
Parses start.ini (or the file specified with --optionsFile) for CommandLineArguments.
References _parse(), orxonox::Core::getConfigPath(), getValue(), orxonox::removeTrailingWhitespaces(), and orxonox::SubString::size().
CommandLineArgument & orxonox::CommandLine::addArgument | ( | const std::string & | name, | |
T | defaultValue, | |||
bool | bCommandLineOnly | |||
) | [inline, static] |
Adds a new CommandLineArgument to the internal map. Note that only such arguments are actually valid.
name | Name of the argument. Shortcut can be added later. | |
defaultValue | Default value that is used when argument was not given. |
References _getInstance(), orxonox::MT_Type::Bool, cmdLineArgs_, existsArgument(), and OrxAssert.
void orxonox::CommandLine::checkFullArgument | ( | const std::string & | name, | |
const std::string & | value, | |||
bool | bParsingFile | |||
) | [private] |
Parses an argument based on its full name.
name | Full name of the argument | |
value | String containing the value |
References cmdLineArgs_, and ThrowException.
Referenced by _parse().
void orxonox::CommandLine::checkShortcut | ( | const std::string & | shortcut, | |
const std::string & | value, | |||
bool | bParsingFile | |||
) | [private] |
Parses an argument based on its shortcut.
shortcut | Shotcut to the argument | |
value | String containing the value |
References cmdLineArgsShortcut_, and ThrowException.
Referenced by _parse().
void orxonox::CommandLine::destroyAllArguments | ( | ) | [static] |
Destroys all command line arguments. This should be called at the end of main. Do not use before that.
References _getInstance(), and cmdLineArgs_.
Referenced by ~CommandLine(), and orxonox::Core::~Core().
static bool orxonox::CommandLine::existsArgument | ( | const std::string & | name | ) | [inline, static] |
Referenced by addArgument().
const CommandLineArgument * orxonox::CommandLine::getArgument | ( | const std::string & | name | ) | [static] |
Retrieves a CommandLineArgument. The method throws an exception if 'name' was not found or the value could not be converted.
References _getInstance(), cmdLineArgs_, and ThrowException.
Referenced by orxonox::Core::checkDevBuild(), and orxonox::CoreConfiguration::initialise().
std::string orxonox::CommandLine::getUsageInformation | ( | ) | [static] |
static MultiType orxonox::CommandLine::getValue | ( | const std::string & | name | ) | [inline, static] |
static void orxonox::CommandLine::getValue | ( | const std::string & | name, | |
T * | value | |||
) | [inline, static] |
Writes the argument value in the given parameter.
References orxonox::KeyCode::T.
Referenced by _parseFile(), orxonox::GSRoot::activate(), orxonox::GSDedicated::activate(), orxonox::GSClient::activate(), orxonox::Core::checkDevBuild(), orxonox::Core::Core(), orxonox::InputManager::initialise(), and orxonox::CoreConfiguration::initialise().
static void orxonox::CommandLine::parseCommandLine | ( | int | argc, | |
char ** | argv | |||
) | [inline, static] |
static void orxonox::CommandLine::parseFile | ( | ) | [inline, static] |
Referenced by orxonox::Core::Core().
bool orxonox::CommandLine::bFirstTimeParse_ [private] |
std::map<std::string, CommandLineArgument*> orxonox::CommandLine::cmdLineArgs_ [private] |
Holds all pointers to the arguments and serves as a search map by name.
Referenced by _parse(), addArgument(), checkFullArgument(), destroyAllArguments(), getArgument(), and getUsageInformation().
std::map<std::string, CommandLineArgument*> orxonox::CommandLine::cmdLineArgsShortcut_ [private] |