Dictionary Class Reference

This class stores key:value pairs of String data and provides functions to access them. More...

#include <dictionary.h>

Inheritance diagram for Dictionary:
zmm::Object Dictionary_r Session

Public Member Functions

 Dictionary ()
 Constructor, initializes the dictionary.
void put (zmm::String key, zmm::String value)
 Adds a new key:value pair to the dictionary.
zmm::String get (zmm::String key)
 Returns the value for a given key.
int size ()
 Returns the number of elements in the dictinary.
void remove (zmm::String key)
 Deletes a key value pair.
zmm::String encode ()
 Returns an url encoded version of the whole dictionary.
zmm::String encodeSimple ()
 It seems that a lot of devices can not cope with a param=value encoded URL, so we will use a simplified encoding scheme.
void clear ()
 Removes all elements from the dictionary.
void decode (zmm::String url)
 Makes a dictionary out of url encoded data.
void decodeSimple (zmm::String url)
 Makes a dictionary out of simplified url encoded data.
zmm::Ref< Dictionaryclone ()
 Makes a shallow copy of the dictionary.
void merge (zmm::Ref< Dictionary > other)
 Merge dictionary with another dictionary. If keys with the same name already exist, the existing ones will be overwritten.
bool isSubsetOf (zmm::Ref< Dictionary > other)
 returns true if the dictionary is a subset of another dictionary.#
bool equals (zmm::Ref< Dictionary > other)
 checks two dictionaries for equality
zmm::Ref< zmm::Array
< DictionaryElement > > 
getElements ()
void optimize ()
 Frees unnecessary memory.
void retain ()
void release ()
int getRefCount ()

Static Public Member Functions

static void * operator new (size_t size)
static void operator delete (void *ptr)

Protected Member Functions

zmm::String _encode (char sep1, char sep2)
 Allow to specify encoding separators.

Protected Attributes

zmm::Ref< zmm::Array
< DictionaryElement > > 
elements
 Array of DictionaryElements, representing our Dictionary.
mt_atomic_t _ref_count
pthread_mutex_t mutex

Detailed Description

This class stores key:value pairs of String data and provides functions to access them.

Definition at line 65 of file dictionary.h.


Constructor & Destructor Documentation

Dictionary::Dictionary (  ) 

Constructor, initializes the dictionary.

Definition at line 71 of file dictionary.cc.

References elements.

Referenced by clone().


Member Function Documentation

String Dictionary::_encode ( char  sep1,
char  sep2 
) [protected]

Allow to specify encoding separators.

Definition at line 122 of file dictionary.cc.

References elements, and url_escape().

Referenced by encode(), and encodeSimple().

void Dictionary::clear (  ) 

Removes all elements from the dictionary.

Reimplemented in Dictionary_r.

Definition at line 200 of file dictionary.cc.

References elements.

Ref< Dictionary > Dictionary::clone (  ) 

Makes a shallow copy of the dictionary.

Reimplemented in Dictionary_r.

Definition at line 205 of file dictionary.cc.

References Dictionary(), and elements.

Referenced by Dictionary_r::clone().

void Dictionary::decode ( zmm::String  url  ) 

Makes a dictionary out of url encoded data.

Reimplemented in Dictionary_r.

Definition at line 147 of file dictionary.cc.

References zmm::String::c_str(), zmm::String::length(), put(), and url_unescape().

void Dictionary::decodeSimple ( zmm::String  url  ) 

Makes a dictionary out of simplified url encoded data.

Definition at line 174 of file dictionary.cc.

References zmm::String::index(), zmm::String::length(), put(), zmm::String::substring(), and url_unescape().

String Dictionary::encode (  ) 

Returns an url encoded version of the whole dictionary.

Reimplemented in Dictionary_r.

Definition at line 137 of file dictionary.cc.

References _encode().

String Dictionary::encodeSimple (  ) 

It seems that a lot of devices can not cope with a param=value encoded URL, so we will use a simplified encoding scheme.

Definition at line 142 of file dictionary.cc.

References _encode().

bool Dictionary::equals ( zmm::Ref< Dictionary other  ) 

checks two dictionaries for equality

Definition at line 242 of file dictionary.cc.

References isSubsetOf().

String Dictionary::get ( zmm::String  key  ) 

Returns the value for a given key.

Reimplemented in Dictionary_r.

Definition at line 91 of file dictionary.cc.

References elements, and nil.

Ref< Array< DictionaryElement > > Dictionary::getElements (  ) 

Reimplemented in Dictionary_r.

Definition at line 247 of file dictionary.cc.

References elements.

int Object::getRefCount (  )  [inherited]

Definition at line 78 of file object.cc.

References zmm::Object::_ref_count, and atomic_get().

bool Dictionary::isSubsetOf ( zmm::Ref< Dictionary other  ) 

returns true if the dictionary is a subset of another dictionary.#

Definition at line 231 of file dictionary.cc.

References elements.

Referenced by equals().

void Dictionary::merge ( zmm::Ref< Dictionary other  ) 

Merge dictionary with another dictionary. If keys with the same name already exist, the existing ones will be overwritten.

Definition at line 217 of file dictionary.cc.

References nil, and put().

void Object::operator delete ( void *  ptr  )  [static, inherited]

Definition at line 87 of file object.cc.

References FREE.

void * Object::operator new ( size_t  size  )  [static, inherited]

Definition at line 83 of file object.cc.

References MALLOC.

void Dictionary::optimize (  )  [inline]

Frees unnecessary memory.

Reimplemented in Dictionary_r.

Definition at line 121 of file dictionary.h.

References elements.

void Dictionary::put ( zmm::String  key,
zmm::String  value 
)

Adds a new key:value pair to the dictionary.

Reimplemented in Dictionary_r.

Definition at line 76 of file dictionary.cc.

References elements.

Referenced by decode(), decodeSimple(), and merge().

void Object::release (  )  [inherited]
void Dictionary::remove ( zmm::String  key  ) 

Deletes a key value pair.

Reimplemented in Dictionary_r.

Definition at line 109 of file dictionary.cc.

References elements.

void Object::retain (  )  [inherited]
int Dictionary::size (  ) 

Returns the number of elements in the dictinary.

Definition at line 104 of file dictionary.cc.

References elements.


Field Documentation

mt_atomic_t zmm::Object::_ref_count [protected, inherited]

Array of DictionaryElements, representing our Dictionary.

Definition at line 69 of file dictionary.h.

Referenced by _encode(), clear(), clone(), Dictionary(), get(), getElements(), isSubsetOf(), optimize(), put(), remove(), and size().

pthread_mutex_t zmm::Object::mutex [protected, inherited]

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

Generated on Fri Mar 26 20:16:56 2010 for MediaTomb by  doxygen 1.6.1