- Main Page
- Related Pages
- Classes
- Files
- Examples

- File List
- File Members

# skype-ptr-dict.h

Go to the documentation of this file.

    00001
    00002 #ifndef __SKYPE_PTR_DICT_H
    00003 #define __SKYPE_PTR_DICT_H
    00004
    00005 #include <stddef.h>
    00006 #include "skype-string.h"
    00007 #include <skype-string-list.h>
    00008 #include <skype-thread.h>
    00009
    00010 /** \class SEPtrDict skype-ptr-dict.h "skype-ptr-dict.h"
    00011  *  \brief SEPtrDict is a dictionary class of pointers associated to strings.
    00012  */
    00013 class SEPtrDict
    00014 {
    00015 public:
    00016         /** Creates an empty dictionary of pointers. */
    00017         SEPtrDict();
    00018         /** Constructs an implicitly shared copy of dict. */
    00019         SEPtrDict(const SEPtrDict& dict);
    00020         /** Destroys the dictionary and frees the data if this is the last reference to it. */
    00021         ~SEPtrDict();
    00022
    00023         /** \cond INTERNAL */
    00024 protected:
    00025         class Element;
    00026         class Data;
    00027         Data* d;
    00028         /** \endcond */
    00029
    00030 public:
    00031         /** Inserts the key with the value into the dictionary.
    00032          * Multiple items can have the same key, they are not overwritten.
    00033          * You can access them with the offset parameter of the find() function.
    00034          * If key is null, nothing is inserted.
    00035          */
    00036         void insert(const SEString& key, const void* new_value);
    00037         /** Finds the specified key in the dictionary.
    00038          * \param key       Key to search.
    00039          * \param offset    When the dictionary contains several entries with the same key,
    00040          *                  use the offset param to indicate which key you want.
    00041          * \return null if the key is not found.
    00042          */
    00043         const void*& find(const SEString& key = "0", unsigned int offset = 0) const;
    00044         /** Assigns a shallow copy of dict to this dictionary and returns a reference to it.
    00045          * This is very fast because the dictionary isn't actually copied.
    00046          */
    00047         SEPtrDict& operator=(const SEPtrDict& dict);
    00048
    00049         /** Returns how many elements are in the dictionary. */
    00050         size_t size() const;
    00051
    00052         /** Use this function to iterate through the dictionary.
    00053          * It doesn't make sense to use this functions outside of an iteration (i.e. a loop).
    00054          * See also keyAt()
    00055          */
    00056         const void*& operator[](size_t i) const;
    00057         /** Use this function to iterate through the dictionary.
    00058          * It doesn't make sense to use this functions outside of an iteration (i.e. a loop).
    00059          * See also operator[]()
    00060          */
    00061         SEString keyAt(size_t i) const;
    00062
    00063         const void*& value(const SEString& key) { return find(key); }
    00064         SEStringList keys();
    00065
    00066         /** \cond INTERNAL */
    00067
    00068 protected:
    00069         void d_ref();
    00070         void d_unref();
    00071         void detach();
    00072         /** \endcond */
    00073 };
    00074
    00075 #endif // __SKYPE_PTR_DICT_H

All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

(c) Skype Technologies S.A. Confidential/Proprietary

Last updated: Fri Jan 27 2012