1 #ifndef _KVI_KVS_VARIANTLIST_H_ 2 #define _KVI_KVS_VARIANTLIST_H_ 3 //============================================================================= 4 // 5 // File : KviKvsVariantList.h 6 // Creation date : Sat 11 Oct 2003 02:20:51 by Szymon Stefanek 7 // 8 // This file is part of the KVIrc IRC client distribution 9 // Copyright (C) 2003-2010 Szymon Stefanek <pragma at kvirc dot net> 10 // 11 // This program is FREE software. You can redistribute it and/or 12 // modify it under the terms of the GNU General Public License 13 // as published by the Free Software Foundation; either version 2 14 // of the License, or (at your option) any later version. 15 // 16 // This program is distributed in the HOPE that it will be USEFUL, 17 // but WITHOUT ANY WARRANTY; without even the implied warranty of 18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 19 // See the GNU General Public License for more details. 20 // 21 // You should have received a copy of the GNU General Public License 22 // along with this program. If not, write to the Free Software Foundation, 23 // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 24 // 25 //============================================================================= 26 27 /** 28 * \file KviKvsVariantList.h 29 * \author Szymon Stefanek 30 * \brief Parser class to handle variant variables lists 31 */ 32 33 #include "kvi_settings.h" 34 #include "KviPointerList.h" 35 #include "KviKvsVariant.h" 36 37 /** 38 * \class KviKvsVariantList 39 * \brief Class to handle variant variables lists 40 */ 41 class KVIRC_API KviKvsVariantList 42 { 43 public: 44 /** 45 * \brief Constructs the KviKvsVariantList object 46 * \return KviKvsVariantList 47 */ 48 KviKvsVariantList(); 49 50 /** 51 * \brief Constructs the KviKvsVariantList object 52 * \param pV1 The first element's list 53 * \return KviKvsVariantList 54 */ 55 KviKvsVariantList(KviKvsVariant * pV1); 56 57 /** 58 * \brief Constructs the KviKvsVariantList object 59 * \param pV1 The first element's list 60 * \param pV2 The second element's list 61 * \return KviKvsVariantList 62 */ 63 KviKvsVariantList(KviKvsVariant * pV1, KviKvsVariant * pV2); 64 65 /** 66 * \brief Constructs the KviKvsVariantList object 67 * \param pV1 The first element's list 68 * \param pV2 The second element's list 69 * \param pV3 The third element's list 70 * \return KviKvsVariantList 71 */ 72 KviKvsVariantList(KviKvsVariant * pV1, KviKvsVariant * pV2, KviKvsVariant * pV3); 73 74 /** 75 * \brief Constructs the KviKvsVariantList object 76 * \param pV1 The first element's list 77 * \param pV2 The second element's list 78 * \param pV3 The third element's list 79 * \param pV4 The fourth element's list 80 * \return KviKvsVariantList 81 */ 82 KviKvsVariantList(KviKvsVariant * pV1, KviKvsVariant * pV2, KviKvsVariant * pV3, KviKvsVariant * pV4); 83 84 /** 85 * \brief Constructs the KviKvsVariantList object 86 * \param pV1 The first element's list 87 * \param pV2 The second element's list 88 * \param pV3 The third element's list 89 * \param pV4 The fourth element's list 90 * \param pV5 The fifth element's list 91 * \return KviKvsVariantList 92 */ 93 KviKvsVariantList(KviKvsVariant * pV1, KviKvsVariant * pV2, KviKvsVariant * pV3, KviKvsVariant * pV4, KviKvsVariant * pV5); 94 95 /** 96 * \brief Constructs the KviKvsVariantList object 97 * \param pV1 The first element's list 98 * \param pV2 The second element's list 99 * \param pV3 The third element's list 100 * \param pV4 The fourth element's list 101 * \param pV5 The fifth element's list 102 * \param pV6 The sixth element's list 103 * \return KviKvsVariantList 104 */ 105 KviKvsVariantList(KviKvsVariant * pV1, KviKvsVariant * pV2, KviKvsVariant * pV3, KviKvsVariant * pV4, KviKvsVariant * pV5, KviKvsVariant * pV6); 106 107 /** 108 * \brief Constructs the KviKvsVariantList object 109 * \param pV1 The first element's list 110 * \param pV2 The second element's list 111 * \param pV3 The third element's list 112 * \param pV4 The fourth element's list 113 * \param pV5 The fifth element's list 114 * \param pV6 The sixth element's list 115 * \param pV7 The seventh element's list 116 * \return KviKvsVariantList 117 */ 118 KviKvsVariantList(KviKvsVariant * pV1, KviKvsVariant * pV2, KviKvsVariant * pV3, KviKvsVariant * pV4, KviKvsVariant * pV5, KviKvsVariant * pV6, KviKvsVariant * pV7); 119 120 /** 121 * \brief Constructs the KviKvsVariantList object 122 * \param pS1 The first element's list 123 * \return KviKvsVariantList 124 */ 125 KviKvsVariantList(QString * pS1); 126 127 /** 128 * \brief Constructs the KviKvsVariantList object 129 * \param pS1 The first element's list 130 * \param pS2 The second element's list 131 * \return KviKvsVariantList 132 */ 133 KviKvsVariantList(QString * pS1, QString * pS2); 134 135 /** 136 * \brief Constructs the KviKvsVariantList object 137 * \param pS1 The first element's list 138 * \param pS2 The second element's list 139 * \param pS3 The third element's list 140 * \return KviKvsVariantList 141 */ 142 KviKvsVariantList(QString * pS1, QString * pS2, QString * pS3); 143 144 /** 145 * \brief Constructs the KviKvsVariantList object 146 * \param pS1 The first element's list 147 * \param pS2 The second element's list 148 * \param pS3 The third element's list 149 * \param pS4 The fourth element's list 150 * \return KviKvsVariantList 151 */ 152 KviKvsVariantList(QString * pS1, QString * pS2, QString * pS3, QString * pS4); 153 154 /** 155 * \brief Constructs the KviKvsVariantList object 156 * \param pS1 The first element's list 157 * \param pS2 The second element's list 158 * \param pS3 The third element's list 159 * \param pS4 The fourth element's list 160 * \param pS5 The fifth element's list 161 * \return KviKvsVariantList 162 */ 163 KviKvsVariantList(QString * pS1, QString * pS2, QString * pS3, QString * pS4, QString * pS5); 164 165 /** 166 * \brief Constructs the KviKvsVariantList object 167 * \param pS1 The first element's list 168 * \param pS2 The second element's list 169 * \param pS3 The third element's list 170 * \param pS4 The fourth element's list 171 * \param pS5 The fifth element's list 172 * \param pS6 The sixth element's list 173 * \return KviKvsVariantList 174 */ 175 KviKvsVariantList(QString * pS1, QString * pS2, QString * pS3, QString * pS4, QString * pS5, QString * pS6); 176 177 /** 178 * \brief Constructs the KviKvsVariantList object 179 * \param pS1 The first element's list 180 * \param pS2 The second element's list 181 * \param pS3 The third element's list 182 * \param pS4 The fourth element's list 183 * \param pS5 The fifth element's list 184 * \param pS6 The sixth element's list 185 * \param pS7 The seventh element's list 186 * \return KviKvsVariantList 187 */ 188 KviKvsVariantList(QString * pS1, QString * pS2, QString * pS3, QString * pS4, QString * pS5, QString * pS6, QString * pS7); 189 190 /** 191 * \brief Constructs the KviKvsVariantList object 192 * \param pSL Pointer to a QStringList 193 * \return KviKvsVariantList 194 */ 195 KviKvsVariantList(QStringList * pSL); 196 197 /** 198 * \brief Destroys the KviKvsVariantList object 199 */ 200 ~KviKvsVariantList(); 201 202 protected: 203 KviPointerList<KviKvsVariant> * m_pList; 204 205 public: 206 /** 207 * \brief Returns the first element of the list 208 * \return KviKvsVariant * 209 */ first()210 KviKvsVariant * first() { return m_pList->first(); }; 211 212 /** 213 * \brief Returns the next element of the list 214 * \return KviKvsVariant * 215 */ next()216 KviKvsVariant * next() { return m_pList->next(); }; 217 218 /** 219 * \brief Returns the element of the list at the given index 220 * \param iIdx The index of the list we want to extract 221 * \return KviKvsVariant * 222 */ at(int iIdx)223 KviKvsVariant * at(int iIdx) { return m_pList->at(iIdx); }; 224 225 /** 226 * \brief Returns the size of the list 227 * \return unsigned int 228 */ count()229 unsigned int count() { return m_pList->count(); }; 230 231 /** 232 * \brief Clears the list 233 * \return void 234 */ clear()235 void clear() { m_pList->clear(); }; 236 237 /** 238 * \brief Appends an element to the list 239 * \param pItem The element to append 240 * \return void 241 */ append(KviKvsVariant * pItem)242 void append(KviKvsVariant * pItem) { m_pList->append(pItem); }; 243 244 /** 245 * \brief Prepends an element to the list 246 * \param pItem The element to prepend 247 * \return void 248 */ prepend(KviKvsVariant * pItem)249 void prepend(KviKvsVariant * pItem) { m_pList->prepend(pItem); }; 250 251 /** 252 * \brief Appends an element to the list 253 * \param szParam The string element to append 254 * \param bEscape Whether the string has to be escaped for KVS 255 * \return void 256 */ 257 void append(const QString & szParam, bool bEscape = false) { m_pList->append(new KviKvsVariant(szParam, bEscape)); }; 258 259 /** 260 * \brief Appends an element to the list 261 * \param iInt The integer element to append 262 * \return void 263 */ append(kvs_int_t iInt)264 void append(kvs_int_t iInt) { m_pList->append(new KviKvsVariant(iInt)); }; 265 266 /** 267 * \brief Appends an element to the list 268 * \param dReal The real element to append 269 * \return void 270 */ append(kvs_real_t dReal)271 void append(kvs_real_t dReal) { m_pList->append(new KviKvsVariant(dReal)); }; 272 273 /** 274 * \brief Appends an element to the list 275 * \param bBoolean The boolean element to append 276 * \return void 277 */ append(bool bBoolean)278 void append(bool bBoolean) { m_pList->append(new KviKvsVariant(bBoolean)); }; 279 280 /** 281 * \brief Appends an element to the list 282 * \param hObject The hObject element to append 283 * \return void 284 */ append(kvs_hobject_t hObject)285 void append(kvs_hobject_t hObject) { m_pList->append(new KviKvsVariant(hObject)); }; 286 287 /** 288 * \brief Appends an element to the list 289 * \param pArray The array element to append 290 * \return void 291 */ append(KviKvsArray * pArray)292 void append(KviKvsArray * pArray) { m_pList->append(new KviKvsVariant(pArray)); }; 293 294 /** 295 * \brief Appends an element to the list 296 * \param pHash The hash element to append 297 * \return void 298 */ append(KviKvsHash * pHash)299 void append(KviKvsHash * pHash) { m_pList->append(new KviKvsVariant(pHash)); }; 300 301 /** 302 * \brief Sets the auto delete flag on the list 303 * \param bAutoDelete Whether the list has to auto delete itself 304 * \return void 305 */ 306 void setAutoDelete(bool bAutoDelete); // this is true by default 307 308 /** 309 * \brief Appends all elements in a single string delimited by spaces 310 * \param szBuffer The buffer where to store the string 311 * \return void 312 */ 313 void allAsString(QString & szBuffer); 314 315 /** 316 * \brief Returns true if there was a first parameter at all 317 * \param szBuffer The buffer where to store the string 318 * \return bool 319 */ 320 bool firstAsString(QString & szBuffer); 321 322 /** 323 * \brief Returns true if there was a next parameter at all 324 * \param szBuffer The buffer where to store the string 325 * \return bool 326 */ 327 bool nextAsString(QString & szBuffer); 328 }; 329 330 #endif // _KVI_KVS_VARIANTLIST_H_ 331