Home · All Classes · All Namespaces · Modules · Functions · Files |
00001 00023 #ifndef _TelepathyQt4_referenced_handles_h_HEADER_GUARD_ 00024 #define _TelepathyQt4_referenced_handles_h_HEADER_GUARD_ 00025 00026 #ifndef IN_TELEPATHY_QT4_HEADER 00027 #error IN_TELEPATHY_QT4_HEADER 00028 #endif 00029 00030 #include <TelepathyQt4/Constants> 00031 #include <TelepathyQt4/Types> 00032 00033 #ifndef QT_NO_STL 00034 # include <list> 00035 #endif 00036 00037 #include <QList> 00038 #include <QSet> 00039 #include <QSharedDataPointer> 00040 #include <QVector> 00041 00042 namespace Tp 00043 { 00044 00045 class Connection; 00046 00047 class TELEPATHY_QT4_EXPORT ReferencedHandles 00048 { 00049 public: 00050 typedef UIntList::const_iterator const_iterator; 00051 typedef UIntList::ConstIterator ConstIterator; 00052 typedef UIntList::const_pointer const_pointer; 00053 typedef UIntList::const_reference const_reference; 00054 typedef UIntList::difference_type difference_type; 00055 typedef UIntList::pointer pointer; 00056 typedef UIntList::reference reference; 00057 typedef UIntList::size_type size_type; 00058 typedef UIntList::value_type value_type; 00059 00060 ReferencedHandles(); 00061 ReferencedHandles(const ReferencedHandles &other); 00062 ~ReferencedHandles(); 00063 00064 ConnectionPtr connection() const; 00065 HandleType handleType() const; 00066 00067 uint at(int i) const; 00068 00069 inline uint back() const 00070 { 00071 return last(); 00072 } 00073 00074 inline uint first() const 00075 { 00076 return at(0); 00077 } 00078 00079 inline uint front() const 00080 { 00081 return first(); 00082 } 00083 00084 inline uint last() const 00085 { 00086 return at(size() - 1); 00087 } 00088 00089 uint value(int i, uint defaultValue = 0) const; 00090 00091 const_iterator begin() const; 00092 00093 inline const_iterator constBegin() const 00094 { 00095 return begin(); 00096 } 00097 00098 inline const_iterator constEnd() const 00099 { 00100 return end(); 00101 } 00102 00103 const_iterator end() const; 00104 00105 bool contains(uint handle) const; 00106 00107 int count(uint handle) const; 00108 00109 inline int count() const 00110 { 00111 return size(); 00112 } 00113 00114 inline bool empty() const 00115 { 00116 return isEmpty(); 00117 } 00118 00119 inline bool endsWith(uint handle) const 00120 { 00121 return !isEmpty() && last() == handle; 00122 } 00123 00124 int indexOf(uint handle, int from = 0) const; 00125 00126 bool isEmpty() const; 00127 00128 int lastIndexOf(uint handle, int from = -1) const; 00129 00130 inline int length() const 00131 { 00132 return count(); 00133 } 00134 00135 ReferencedHandles mid(int pos, int length = -1) const; 00136 00137 int size() const; 00138 00139 inline bool startsWith(uint handle) const 00140 { 00141 return !isEmpty() && first() == handle; 00142 } 00143 00144 inline void append(const ReferencedHandles& another) 00145 { 00146 *this = *this + another; 00147 } 00148 00149 void clear(); 00150 void move(int from, int to); 00151 00152 inline void pop_back() 00153 { 00154 return removeLast(); 00155 } 00156 00157 inline void pop_front() 00158 { 00159 return removeFirst(); 00160 } 00161 00162 int removeAll(uint handle); 00163 00164 void removeAt(int i); 00165 00166 inline void removeFirst() 00167 { 00168 return removeAt(0); 00169 } 00170 00171 inline void removeLast() 00172 { 00173 return removeAt(size() - 1); 00174 } 00175 00176 bool removeOne(uint handle); 00177 00178 void swap(int i, int j); 00179 00180 uint takeAt(int i); 00181 00182 inline uint takeFirst() 00183 { 00184 return takeAt(0); 00185 } 00186 00187 inline uint takeLast() 00188 { 00189 return takeAt(size() - 1); 00190 } 00191 00192 bool operator!=(const ReferencedHandles& another) const 00193 { 00194 return !(*this == another); 00195 } 00196 00197 bool operator!=(const UIntList& another) const 00198 { 00199 return !(*this == another); 00200 } 00201 00202 ReferencedHandles operator+(const ReferencedHandles& another) const; 00203 00204 inline ReferencedHandles& operator+=(const ReferencedHandles& another) 00205 { 00206 return *this = (*this + another); 00207 } 00208 00209 ReferencedHandles& operator<<(const ReferencedHandles& another) 00210 { 00211 return *this += another; 00212 } 00213 00214 ReferencedHandles& operator=(const ReferencedHandles& another); 00215 00216 bool operator==(const ReferencedHandles& another) const; 00217 bool operator==(const UIntList& list) const; 00218 00219 inline uint operator[](int i) const 00220 { 00221 return at(i); 00222 } 00223 00224 UIntList toList() const; 00225 00226 inline QSet<uint> toSet() const 00227 { 00228 return toList().toSet(); 00229 } 00230 00231 #ifndef QT_NO_STL 00232 inline std::list<uint> toStdList() const 00233 { 00234 return toList().toStdList(); 00235 } 00236 #endif 00237 00238 inline QVector<uint> toVector() const 00239 { 00240 return toList().toVector(); 00241 } 00242 00243 private: 00244 // For access to the "prime" constructor 00245 friend class ContactManager; 00246 friend class PendingContactAttributes; 00247 friend class PendingContacts; 00248 friend class PendingHandles; 00249 00250 TELEPATHY_QT4_NO_EXPORT ReferencedHandles(const ConnectionPtr &connection, 00251 HandleType handleType, const UIntList& handles); 00252 00253 struct Private; 00254 friend struct Private; 00255 QSharedDataPointer<Private> mPriv; 00256 }; 00257 00258 typedef QListIterator<uint> ReferencedHandlesIterator; 00259 00260 } // Tp 00261 00262 Q_DECLARE_METATYPE(Tp::ReferencedHandles); 00263 00264 #endif
Copyright © 2008-2011 Collabora Ltd. and Nokia Corporation | Telepathy-Qt4 0.8.0 |