Main Page   Class Hierarchy   Alphabetical List   Compound List   Compound Members  

util::Properties Class Reference

#include <Properties.h>

Inheritance diagram for util::Properties:

util::Hashtable< std::string, std::string > util::Map< std::string, std::string > util::Iterator< Pair< std::string, std::string > > util::Object util::Object List of all members.

Detailed Description

Properties is a utility class for reading name-value pairs from a stream.

It works by reading the stream line by line and storing the encountered values into itself (Hashtable). It works in two different modes: "relaxed" and "C". In both modes, the first token in every line must be a comment or a keyword. In relaxed mode, everything after the keyword on the same line of input is treated as the key value as such. The keyword may be separated by whitespace(s) or one of the characters '=', '-' and ':'. One-line shell-style comments are recognized. In relaxed mode, the following file would be perfectly valid:

 This is a comment
 firstvalue = 1
 secondvalue : two this commend WILL BE INCLUDED in the value
 thirdvalue three

In C-mode, the keyword must be followed by an equality sign (=), and the sign must be followed by exactly one property value. If the property value contains spaces, it must be quoted with double quotes. Within quoted strings, all C escape sequences are recognized and replaced. In C-mode, comments are recognized also at end of lines. The property values must be separated by a semicolon (;). Endlines between properties are not necessary. In C-mode, previously declared property names can be later substituted to other values by using the standard shell syntax. An example:

 //This is a C-style property file
 firstvalue = 1; secondvalue = two; //ignored comment
 a_substitution = "${firstvalue}+1=2
"; variablename = "firstvalue"; another_substitution= "${$variablename}+2=3";

Public Methods

 Properties (std::istream &in, bool relaxed=true) throw (io::IOException&)

The documentation for this class was generated from the following files:
Documentation generated on 11.09.2003 with Doxygen.
The documentation is copyrighted material.
Copyright © Topi Mäenpää 2003. All rights reserved.