Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

PropRegistry Class Reference

#include <prop_registry.hh>

List of all members.

Public Types

typedef map<string, PropData,
less<string> > 
StorageType
typedef StorageType::iterator iterator
typedef StorageType::const_iterator const_iterator

Public Methods

bool contains (const string &key) const
bool empty () const
iterator begin ()
iterator end ()
const_iterator begin () const
const_iterator end () const
PropDataoperator[] (const string &key)

Private Attributes

StorageType data


Detailed Description

Implements a generael prperty registry. Properties are kept as <key, data> pairs, where data can be a string, an integer value, a float value, a boolean value or a list of such values.

Definition at line 61 of file prop_registry.hh.


Member Typedef Documentation

typedef map< string, PropData, less< string > > PropRegistry::StorageType<string, PropData, less<string> >
 

Definition at line 270 of file prop_registry.hh.

typedef StorageType::iterator PropRegistry::iterator
 

Definition at line 272 of file prop_registry.hh.

typedef StorageType::const_iterator PropRegistry::const_iterator
 

Definition at line 273 of file prop_registry.hh.


Member Function Documentation

bool PropRegistry::contains ( const string & key ) const [inline]
 

Returns true if the iven property is defined.

Definition at line 257 of file prop_registry.hh.

Referenced by Writer::className2cc(), Writer::className2hh(), Writer::fullPath(), and CppCcDriver::run().

bool PropRegistry::empty ( ) const [inline]
 

Returns true if this registry is empty.

Definition at line 265 of file prop_registry.hh.

iterator PropRegistry::begin ( ) [inline]
 

Definition at line 275 of file prop_registry.hh.

Referenced by operator<<().

iterator PropRegistry::end ( ) [inline]
 

Definition at line 280 of file prop_registry.hh.

Referenced by operator<<().

const_iterator PropRegistry::begin ( ) const [inline]
 

Definition at line 285 of file prop_registry.hh.

const_iterator PropRegistry::end ( ) const [inline]
 

Definition at line 290 of file prop_registry.hh.

PropData & PropRegistry::operator[] ( const string & key ) [inline]
 

Allows set/get of properties data. This can e used in several ways:

  • for getting the value of a property:
      string myPropValue = registry["myProp"];
  • for setting the value of a property (a new entry is added if the property did not exist inside the registry; if the entry existed, its value is reset to the new one).
     vector<string> someDirs;
     someDirs.push_back("/");
     someDirs.push_back("/home/alec");
     registry["dirs"] = someDirs;
    The above creates a new entry (if not already presents) and sets its value to a vecotr of strings containing two strings.
  • adding values to a property:
     string anotherOne = "/home/alec/tmp/stuff";
     vector<string> andSomeMore;
     registry["dirs"] << anotherOne;
     registry["dirs"] << andSomeMore;
     registry["more_dirs"] << "and" << "even" << "more" << registry["dirs"];
    The above codes makes use of the "<<" operator of the PropData. Node that on the last line the entry "some_more_dirs" is created "on the fly". Also, the last part of the ilne shows that properties can be appended to each other.
Note:
However, once a property is created, its kind (string/bool/int/float) gets set and an attempt to append some other kind of data via "<<" will fail with a bad_cast exception. The kind of the property can be changed, but only by re-setting it (using the "=" operator).

Definition at line 332 of file prop_registry.hh.


Member Data Documentation

StorageType PropRegistry::data [private]
 

Definition at line 339 of file prop_registry.hh.


The documentation for this class was generated from the following file:
Generated at Tue Jul 9 21:08:04 2002 for CppCC by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001