Public Member Functions | |
const std::vector< std::string > & | getParams () const |
Returns a vector of the actual params. | |
const char * | getParamsRaw () const |
Returns the "raw" command line parameter. |
The CommandLine class is a helper class for extracting the Command line parameters which are being sent into the WinMain/main function.
If you need to retrieve the Command line parameters use this class.
Note!
An object of type CommandLine can be copied and destroyed by anyone but it cannot be constructed by any other means than through the Application::getCommandLine() function!
This means that the ONLY way you can access the Command line parameters is through the Application::getCommandLine() function
But since the Application is a Natural singleton class it should be easy to extract the Command line parameters from anywhere you wish!
Just remember that the constructing of an object (which is being done in the getCommandLine) do come with a bit of overhead! (parsing of the actual params)
So instead of calling the getCommandLine() several times either cache the CommandLine object or cache the return value from the getParams() function of the object!
const std::vector< std::string > & getParams | ( | ) | const |
Returns a vector of the actual params.
You can escape params by embracing them inside " and you can add a " inside a " by adding a ~ (escape character) in front of it.
Note!
The actual " will NOT show up in the param!
Meaning that the param "xyz" will become xyz...
Note!
It will ALWAYS return char * strings and NEVER wchar_t
Use the Ascii2CurrentBuild::doConvert() function if you need to get the parameter transformed into the "current build" type (if UNICODE && _UNICODE is defined UNICODE else ASCII)
Escape characters OUTSIDE a string (surrounded by ") means nothing or will not be specially treated
Redundant spaces OUTSIDE a string will be removed.
Meaning that -h "~~ ~"" testing -t --t~~~ "Thomas~~~~~" hhh" heisann-- ~~ thomas2 thomasHansen..
will become
const char * getParamsRaw | ( | ) | const |
Returns the "raw" command line parameter.
For those of you which MUST have the actual RAW command line parameter you can use this function which will return them as given to the application. Note!
It will ALWAYS return char * and NEVER wchar_t
Use one of the UNICODE converters if you must have it in UNICODE or "CURRENT_BUILD"...