Dune::ParameterTreeParser Class Reference
[Common (foundation classes)]

Parser for hierarchical configuration filesThis class parses config files into a hierarchical structure. Config files should look like this. More...

#include <dune/common/parametertreeparser.hh>

List of all members.

Static Public Member Functions

static void readINITree (std::istream &in, ParameterTree &pt, bool overwrite)
 parse C++ stream
static void readINITree (std::istream &in, ParameterTree &pt, const std::string srcname="stream", bool overwrite=true)
 parse C++ stream
static void readINITree (std::string file, ParameterTree &pt, bool overwrite=true)
 parse file
static void readOptions (int argc, char *argv[], ParameterTree &pt)
 parse command line

Detailed Description

Parser for hierarchical configuration files

This class parses config files into a hierarchical structure. Config files should look like this.

# this file configures fruit colors in fruitsalad


#these are no fruit but could also appear in fruit salad
honeydewmelon = yellow
watermelon = green

fruit.tropicalfruit.orange = orange

[fruit]
strawberry = red
pomegranate = red

[fruit.pipfruit]
apple = green/red/yellow
pear = green

[fruit.stonefruit]
cherry = red
plum = purple

   

If a '[prefix]' statement appears all following entries use this prefix until the next '[prefix]' statement. Fruitsalads for example contain:

honeydewmelon = yellow
fruit.tropicalfruit.orange = orange
fruit.pipfruit.apple = green/red/yellow
fruit.stonefruit.cherry = red
   

All keys with a common 'prefix.' belong to the same substructure called 'prefix'. Leading and trailing spaces and tabs are removed from the values unless you use single or double quotes around them. Using single or double quotes you can also have multiline values.


Member Function Documentation

void Dune::ParameterTreeParser::readINITree ( std::istream &  in,
ParameterTree pt,
bool  overwrite 
) [static]

parse C++ stream

Parses C++ stream and build hierarchical config structure.

Parameters:
in The stream to parse
overwrite Whether to overwrite already existing values. If false, values in the stream will be ignored if the key is already present.
Note:
This method is identical to parseStream(std::istream&, const std::string&, bool) with the exception that that method allows to give a custom name for the stream.

Referenced by readINITree().

void Dune::ParameterTreeParser::readINITree ( std::istream &  in,
ParameterTree pt,
const std::string  srcname = "stream",
bool  overwrite = true 
) [static]

parse C++ stream

Parses C++ stream and build hierarchical config structure.

Parameters:
in The stream to parse
srcname Name of the configuration source for error messages, "stdin" or a filename.
overwrite Whether to overwrite already existing values. If false, values in the stream will be ignored if the key is already present.

References DUNE_THROW, and Dune::ParameterTree::hasKey().

void Dune::ParameterTreeParser::readINITree ( std::string  file,
ParameterTree pt,
bool  overwrite = true 
) [static]

parse file

Parses file with given name and build hierarchical config structure.

Parameters:
file filename
overwrite Whether to overwrite already existing values. If false, values in the stream will be ignored if the key is already present.

References DUNE_THROW, and readINITree().

void Dune::ParameterTreeParser::readOptions ( int  argc,
char *  argv[],
ParameterTree pt 
) [static]

parse command line

Parses command line options and build hierarchical ParameterTree structure.

Parameters:
argc arg count
argv arg values

The documentation for this class was generated from the following files:

Generated on Fri Apr 29 2011 with Doxygen (ver 1.7.1) [doxygen-log,error-log].