Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changes between Initial Version and Version 1 of code/doc/CommandLine


Ignore:
Timestamp:
Sep 4, 2008, 7:47:06 PM (16 years ago)
Author:
rgrieder
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • code/doc/CommandLine

    v1 v1  
     1= CommandLine and CommandLineArgument =
     2
     3[[TracNav(TracNav/TOC_Coding)]]
     4
     5These classes serve as a platform to easily declare command line arguments and retrieve them later. By 'later' the code before orxonox starts is being referred which means that we have to declare the possible arguments even before that. I have decided to do it before main via static variable initialisation. [[br]][[br]]
     6
     7== Declaration ==
     8If you would like to retrieve the value of a command line argument, you will have to declare it first anywhere in the source (the macro creates a dummy variable in order allow for code execution via function).
     9{{{
     10namespace orxonox
     11{
     12    SetCommandLineArgument(name, defaultValue).setShortcut('char')
     13        .setInformation(string);
     14}
     15}}}
     16'name' is the argument name (without quotation marks) and defaultValue deduces the type. [[br]]
     17
     18== Retrieving a value ==
     19Getting the values is quite easy via the static interface of the CommandLine class. Use getArgument(name) to retrieve the entire argument including the information whether the default value was used or not (i.e. argument given in command line or not). And use getValue(name, *value) to get the value directly. [[br]]
     20Be careful with the types. If you declare an argument as (int), you will have to retrieve it with an (int)-type variable.
     21
     22== Passing command line parameters ==
     23You can either use full argument names or shortcuts like this: [[br]]
     24{{{ ./orxonox --port 125 }}} or {{{ ./orxonox -p 125 }}} [[br]]
     25Note the difference with "--" and "-".
     26The value after the name or shortcut can be anything that converts to the given type. If the type is boolean and no value is given, it is automatically set to 'true' (so called command line switches).
     27
     28== Usage information ==
     29The user can choose to display information on how to use the arguments or display a list. This information is configured via setInformation(string) when declaring a CommandLineArgument. [[br]]
     30The standard pattern is {{{[--name information]}}}