IS3D::ConfigMap Class Reference

#include <ConfigVal.H>

List of all members.

Static Public Member Functions

static bool readFile (const std::string &filename, Log *log=NULL)
static bool containsKey (const std::string &keyString)
static std::string getValue (const std::string &keyString)
static void set (const std::string &key, const std::string &value)
static void debugPrint ()


Detailed Description

ConfigVal's and config files description:

ConfigVal's are an easy way to access program settings that can be stored in a configuration file. They are all key=value pairs where key and value are both originally std::strings. But, the value string can be easily reinterpreted by any class that overrides the stream >> and << operators. The ConfigVal() function figures out what type to try to convert to by the type of the second parameter to the function. This parameter also specifies the default value to return if the key is not found in the ConfigMap::_map Table.

To use a config file, call ConfigMap::readFile() with the filename of a text file to read. The format of each line of the file should be:

key value

where key has no spaces in it. value is everything after the space until the end of the line, so it can have spaces in it. Any line that *starts* with the character # is a comment and is ignored. A single \ character means cut the line here and continue on the next line. Everything after the \ is ignored and the text on the next line is appended to the text on the current line. You can escape the \ operator with a \ to get a single \ character.

Additionally, any value X appearing inside the special character sequence will be replaced by the value of the environment variable named X. If X is not defined, it will be replaced by a null string. If X takes the form of the path to a file and you're running in Windows under cygwin then X will be automatically converted from the form /cygdrive/c/blah/blah to the more Windows friendly form c:/blah/blah to stay compatible with the Visual C++ compiler.

Additionally, if you put a += after the key and the key has already been defined, then the value is appended to the key's current value. If you don't have the += and the same key is read in from a file, then the new value overwrites the old. For example:

mykey1 value1 mykey1 value2 mykey2 value3 mykey2+= value4

The value of mykey1 will be "value2". The value of mykey2 will be "value3 value4". This class stores the data for the ConfigVal accessor functions Essentially, this is a big associative array std::string's map to std::strings. The ConfigVal function is used to access values and reinterpret them as different types. The key/value pairs can be read in from a file(s), or set manually with the set function.


Member Function Documentation

static bool IS3D::ConfigMap::readFile ( const std::string &  filename,
Log *  log = NULL 
) [static]

static bool IS3D::ConfigMap::containsKey ( const std::string &  keyString  )  [static]

Referenced by IS3D::ConfigVal().

static std::string IS3D::ConfigMap::getValue ( const std::string &  keyString  )  [static]

Referenced by IS3D::ConfigVal().

static void IS3D::ConfigMap::set ( const std::string &  key,
const std::string &  value 
) [static]

static void IS3D::ConfigMap::debugPrint (  )  [static]


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

Generated on Wed Jan 26 06:31:20 2011 for IS3D by  doxygen 1.5.6