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

- File List
- File Members

# skype-string-dict.h

Go to the documentation of this file.

    00001
    00002 #ifndef __SKYPE_STRING_DICT_H
    00003 #define __SKYPE_STRING_DICT_H
    00004
    00005 #include <stddef.h>
    00006 #include <skype-thread.h>
    00007 #include "skype-string.h"
    00008
    00009 class SEStringList;
    00010
    00011 /** \class SEStringDict skype-string-dict.h "skype-string-dict.h"
    00012  *  \brief SEStringDict is a dictionary class of strings associated to strings.
    00013  */
    00014 class SEStringDict
    00015 {
    00016 public:
    00017         /** Creates an empty dictionary of string/string. */
    00018         SEStringDict();
    00019         /** Constructs an implicitly shared copy of dict. */
    00020         SEStringDict(const SEStringDict& dict);
    00021         /** Destroys the dictionary and frees the data if this is the last reference to it. */
    00022         ~SEStringDict();
    00023
    00024         /** \cond INTERNAL */
    00025 protected:
    00026         class Element;
    00027         class Data;
    00028         Data* d;
    00029         /** \endcond */
    00030
    00031 public:
    00032         /** Inserts the key with the value into the dictionary.
    00033          * Multiple items can have the same key, they are not overwritten.
    00034          * You can access them with the offset parameter of the find() function.
    00035          * If key is null, nothing is inserted.
    00036          */
    00037         void insert(const SEString& key, const SEString& value);
    00038         /** Finds the specified key in the dictionary.
    00039          * \param key       Key to search.
    00040          *                  Default is to search for 0, which is the most often used key name
    00041          *                  in the Embedded API.
    00042          * \param offset    When the dictionary contains several entries with the same key,
    00043          *                  use the offset param to indicate which key you want.
    00044          * \return null string if the key is not found.
    00045          */
    00046         SEString find(const SEString& key = "0", unsigned int offset = 0) const;
    00047         /** Assigns a shallow copy of dict to this dictionary and returns a reference to it.
    00048          * This is very fast because the dictionary isn't actually copied.
    00049          */
    00050         SEStringDict& operator=(const SEStringDict& dict);
    00051
    00052         /** Returns how many elements are in the dictionary. */
    00053         size_t size() const;
    00054
    00055         /** Use this function to iterate through the dictionary.
    00056          * It doesn't make sense to use this functions outside of an iteration (i.e. a loop).
    00057          * See also keyAt()
    00058          */
    00059         SEString operator[](size_t i) const;
    00060         /** Use this function to iterate through the dictionary.
    00061          * It doesn't make sense to use this functions outside of an iteration (i.e. a loop).
    00062          * See also operator[]()
    00063          */
    00064         SEString keyAt(size_t i) const;
    00065
    00066         /** \cond INTERNAL */
    00067         /** Formats a dictionary according to internal format, i.e. a string with a list
    00068          * of pairs KEY="VALUE" separated by a space.
    00069          */
    00070         SEString format(bool escape_args = true) const;
    00071         /** Creates a list of pairs key-value and parses it with
    00072          * SEStringDict::parse(const SEStringList& str).
    00073          */
    00074         static SEStringDict parse(const SEString& str);
    00075         /** Parses a list of pairs key-value according the internal format, which is
    00076          *      KEY="VALUE"
    00077          * We assume very strict formatting here, any error in the formatting will make
    00078          * the parsing fail.
    00079          * Warning: The value will be null (SEString::isNull() is true) if the key is not present,
    00080          * but also if the value is an empty string.
    00081          */
    00082         static SEStringDict parse(const SEStringList& str);
    00083
    00084         SEString value(const SEString& key) { return find(key); }
    00085
    00086 protected:
    00087         void d_ref();
    00088         void d_unref();
    00089         void detach();
    00090         /** \endcond */
    00091 };
    00092
    00093 #endif // __SKYPE_STRING_DICT_H

All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

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

Last updated: Fri Mar 16 2012