Argument Parser
[Base Module]

Argument Parser. More...


Classes

class  itpp::Parser
 Argument Parser Class. More...


Detailed Description

Argument Parser.

Author:
Thomas Eriksson and Pal Frenger (Thanks to Svante Signell for valuable input), modifications by Johan Bergman
This class parses strings to variables. The syntax is compatible with Matlab and Octave. It can be used in several different ways. The following test program and test data file gives several examples:

The test program looks as follows:

The data file parser_test_data.txt looks as follows:

Beside the type-specific get methods, like get_int(), there is a templated get method called get(), that can handle all variable types that have an istream operator defined, e.g. Arrays. The get() method takes the variable value as an input/output parameter. If the variable name cannot be found, the old value is kept. Here is an example:

  // Declare and initialize a variable
  Array<ivec> var;
  set_array(var, "{[1] [2 3] [4 5 6]}");

  // Let the Parser p get the variable named my_var_name
  bool my_var_name_was_found = p.get(var, "my_var_name");

In the above example, if my_var_name was not found, var keeps its old value {[1] [2 3] [4 5 6]}. In non-silent mode, the get() method echoes the variable values to the standard output in Matlab/Octave m-file style.


Generated on Tue Jun 2 10:02:14 2009 for mixpp by  doxygen 1.5.8