SettingMap< Key > Class Template Reference

A collection of setting nodes arranged as an associative container. More...

#include <settings.h>

List of all members.

Public Member Functions

 SettingMap (const QDomElement &node, const QString &element, const QString &key)
uint size () const
Settings get (const Key &index) const
Settings insert (const Key &index)
void clear ()

Protected Member Functions

virtual QDomElement node () const

Protected Attributes

QDomElement m_node
QString m_element
QString m_key


Detailed Description

template<typename Key>
class SettingMap< Key >

A collection of setting nodes arranged as an associative container.

A setting map is a collection of setting nodes, all having the same parent node and the same name, and containing an inner node acting as a key. The following is an example of how the configuration node containing a setting map may look like. The element name is "event" and the key name is "name".

 <event>
 <name>click</name>
   <action>action1</action>
 </event>
 <event>
   <name>double-click</name>
   <action>action2</action>
 </event>
 

Other than the key, each element of the map may contain any arbitrarily nested nodes.

To use a map, you simply access its elements by keys using the get member function, which returns a Settings object associated to the specified element.

Elements are cached as an STL map, which is kept in sync with the configuration file, so read operation have the same complexity of the corresponding STL operations (i.e. logarithmic).


Member Function Documentation

template<typename Key>
uint SettingMap< Key >::size (  )  const [inline]

Returns:
The number of elements in the map.

template<typename Key>
Settings SettingMap< Key >::get ( const Key &  index  )  const

Retrieve an element by key.

Parameters:
index The key of the element.
Returns:
The Settings object corresponding to the specified element.

template<typename Key>
Settings SettingMap< Key >::insert ( const Key &  index  ) 

Insert an element into the map.

Parameters:
index The key of the element.
Returns:
An Settings object containing only the specified key. This object can be used to add arbitrary content to the map element.

template<typename Key>
void SettingMap< Key >::clear (  ) 

Clear the map, removing all its elements.


The documentation for this class was generated from the following file:
Generated on Sun Feb 25 17:59:51 2007 for Settings by  doxygen 1.5.1