00001 00002 #ifndef __SKYPE_STRING_LIST_H 00003 #define __SKYPE_STRING_LIST_H 00004 00005 #include "skype-string.h" 00006 #include <skype-thread.h> 00007 00008 /*! \class SEStringList skype-string-list.h "skype-string-list.h" 00009 * \brief SEStringList represents a list of strings (SEString objects). 00010 * 00011 * The operator [] is supported, which can be used to go through the list. 00012 */ 00013 class SEStringList 00014 { 00015 public: 00016 /** Creates an empty list of strings. */ 00017 SEStringList(); 00018 /** Constructs an implicitly shared copy of sl. */ 00019 SEStringList(const SEStringList& sl); 00020 /** Destroys the list and frees the data if this is the last reference to the list. */ 00021 ~SEStringList(); 00022 00023 /** \cond INTERNAL */ 00024 protected: 00025 class Element; 00026 class Data; 00027 Data* d; 00028 SEString empty; 00029 /** \endcond */ 00030 00031 public: 00032 /** Appends a string at the end of the list. */ 00033 void push_back(const SEString& str) { 00034 append(str); 00035 } 00036 /** Appends a string at the end of the list. */ 00037 SEStringList& append(const SEString& str); 00038 /** Removes the first element from the list and returns it. */ 00039 SEString peek(); 00040 /** Returns the size of the list. */ 00041 size_t size() const; 00042 /** Returns the string specified by its index. */ 00043 SEString operator[](size_t n); 00044 /** Returns a string reference specified by its index. */ 00045 const SEString &operator[](size_t n) const; 00046 /** Assigns a shallow copy of sl to this list and returns a reference to it. 00047 * This is very fast because the list isn't actually copied. 00048 */ 00049 SEStringList& operator=(const SEStringList& sl); 00050 /** Creates a string out of the list of strings by joining them. 00051 * \param sep String to use as a separator between each joined string. 00052 * \param escape_args Should the parameters be escaped before joining them. 00053 */ 00054 SEString join(const SEString& sep, bool escape_args = true) const; 00055 /** Splits a string in a list of string using the separaror sep. */ 00056 static SEStringList split(const SEString& str, char sep, char esc = '\\'); 00057 00058 bool contains(const SEString& val); 00059 bool remove_val(const SEString& val); 00060 bool remove_pos(const unsigned int pos); 00061 int find_pos(const SEString& val); 00062 00063 void resize(const unsigned int new_size); 00064 void clear(); 00065 /** \cond INTERNAL */ 00066 protected: 00067 void init(); 00068 void d_ref(); 00069 void d_unref(); 00070 void detach(); 00071 /** \endcond */ 00072 }; 00073 00074 #endif // __SKYPE_STRING_LIST_H
(c) Skype Technologies S.A. Confidential/Proprietary
Last updated: Fri Jan 27 2012