KVIrc  4.9.2
DeveloperAPIs
KviKvsParameterProcessor.h
Go to the documentation of this file.
1 #ifndef _KVI_KVS_PARAMETERPROCESSOR_H_
2 #define _KVI_KVS_PARAMETERPROCESSOR_H_
3 //=============================================================================
4 //
5 // File : KviKvsParameterProcessor.h
6 // Creation date : Sun 17 Apr 2005 16:47:09 by Szymon Stefanek
7 //
8 // This file is part of the KVIrc IRC client distribution
9 // Copyright (C) 2005-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 #include "kvi_settings.h"
28 #include "KviKvsTypes.h"
29 
30 class KviKvsHash;
31 class KviKvsArray;
32 class KviKvsArrayCast;
33 class KviKvsVariant;
34 class QStringList;
35 class QByteArray;
36 class QString;
37 
38 // Data type: QString
39 // Default: QString()
41 {
44 };
45 
46 // Data type: kvs_int_t
47 // Default: 0
49 {
52 };
53 
54 // Data type: kvs_uint_t
55 // Default: 0
57 {
60 };
61 
62 // Data type: kvs_real_t
63 // default: 0.0
65 {
68 };
69 
70 // Data type: bool
71 // default: false
73 {
76 };
77 
78 // Data type: KviKvsHash *
79 // default: 0
81 {
83 };
84 
85 // Data type: KviKvsArrayCast
86 // default empty cast
88 {
90 };
91 
92 // Data type: KviKvsVariant *
93 // default: 0
95 {
97 };
98 
99 // Data type: QByteArray
100 // default null string (0)
102 {
105 };
106 
107 // Data type: QStringList
108 // default: list cleared
109 // This eats all the remaining params in the list!
111 {
113 };
114 
115 // Data type: KviKvsVariantList
116 // default: list cleared
117 // This eats all the remaining params in the list!
118 // The list has autodelete set to off since the copies are SHALLOW (as opposed to deep)!
120 {
122 };
123 
124 // Data type: kvs_hobject_t
125 // default: (kvs_hobject_t)0
127 {
129 };
130 
131 // Data type: KviKvsArray *
132 // default 0
134 {
136 };
137 
138 // Data type: ignored
139 #define KVS_PT_IGNORE 15
140 
141 // If omitted, set to default
142 #define KVS_PF_OPTIONAL 1
143 // Valid only for string types: it's the last parameter that eats all the remaining ones
144 #define KVS_PF_APPENDREMAINING 2
145 
146 class KviKvsVariantList;
148 
149 namespace KviKvsParameterProcessor
150 {
152  {
153  public:
154  const char * szName;
155  unsigned char uType;
156  unsigned char uFlags;
157  void * pContainer;
158 
159  public:
160  // KVS_PT_STRING, KVS_PT_NONEMPTYSTRING
161  ParameterFormat(const char * name, KviKvsParameterTypeQString type, unsigned char flags, QString & szBuffer)
162  : szName(name), uType((unsigned char)type), uFlags(flags), pContainer((void *)(&szBuffer)){};
163 
164  // KVS_PT_INTEGER (KVS_PT_INT)
165  ParameterFormat(const char * name, KviKvsParameterTypeKvsIntT type, unsigned char flags, kvs_int_t & iBuffer)
166  : szName(name), uType((unsigned char)type), uFlags(flags), pContainer((void *)(&iBuffer)){};
167 
168  // KVS_PT_UNSIGNEDINTEGER (KVS_PT_UINT)
169  ParameterFormat(const char * name, KviKvsParameterTypeKvsUIntT type, unsigned char flags, kvs_uint_t & uBuffer)
170  : szName(name), uType((unsigned char)type), uFlags(flags), pContainer((void *)(&uBuffer)){};
171 
172  // KVS_PT_DOUBLE (KVS_PT_REAL)
173  ParameterFormat(const char * name, KviKvsParameterTypeKvsRealT type, unsigned char flags, kvs_real_t & dBuffer)
174  : szName(name), uType((unsigned char)type), uFlags(flags), pContainer((void *)(&dBuffer)){};
175 
176  // KVS_PT_BOOL (KVS_PT_BOOLEAN)
177  ParameterFormat(const char * name, KviKvsParameterTypeBool type, unsigned char flags, bool & bBuffer)
178  : szName(name), uType((unsigned char)type), uFlags(flags), pContainer((void *)(&bBuffer)){};
179 
180  // KVS_PT_HASH
181  ParameterFormat(const char * name, KviKvsParameterTypeKviKvsHashPointer type, unsigned char flags, KviKvsHash *& pBuffer)
182  : szName(name), uType((unsigned char)type), uFlags(flags), pContainer((void *)(&pBuffer)){};
183 
184  // KVS_PT_ARRAYCAST
185  ParameterFormat(const char * name, KviKvsParameterTypeKviKvsArrayCast type, unsigned char flags, KviKvsArrayCast & oBuffer)
186  : szName(name), uType((unsigned char)type), uFlags(flags), pContainer((void *)(&oBuffer)){};
187 
188  // KVS_PT_VARIANT
189  ParameterFormat(const char * name, KviKvsParameterTypeKviKvsVariantPointer type, unsigned char flags, KviKvsVariant *& pBuffer)
190  : szName(name), uType((unsigned char)type), uFlags(flags), pContainer((void *)(&pBuffer)){};
191 
192  // KVS_PT_CSTRING, KVS_PT_NONEMPTYCSTRING
193  ParameterFormat(const char * name, KviKvsParameterTypeQByteArray type, unsigned char flags, QByteArray & szBuffer)
194  : szName(name), uType((unsigned char)type), uFlags(flags), pContainer((void *)(&szBuffer)){};
195 
196  // KVS_PT_STRINGLIST
197  ParameterFormat(const char * name, KviKvsParameterTypeQStringList type, unsigned char flags, QStringList & lBuffer)
198  : szName(name), uType((unsigned char)type), uFlags(flags), pContainer((void *)(&lBuffer)){};
199 
200  // KVS_PT_VARIANTLIST
201  ParameterFormat(const char * name, KviKvsParameterTypeKviKvsVariantList type, unsigned char flags, KviKvsVariantList & lBuffer)
202  : szName(name), uType((unsigned char)type), uFlags(flags), pContainer((void *)(&lBuffer)){};
203 
204  // KVS_PT_HOBJECT
205  ParameterFormat(const char * name, KviKvsParameterTypeKvsHObjectT type, unsigned char flags, kvs_hobject_t & hBuffer)
206  : szName(name), uType((unsigned char)type), uFlags(flags), pContainer((void *)(&hBuffer)){};
207 
208  // KVS_PT_ARRAY
209  ParameterFormat(const char * name, KviKvsParameterTypeKviKvsArrayPointer type, unsigned char flags, KviKvsArray *& pBuffer)
210  : szName(name), uType((unsigned char)type), uFlags(flags), pContainer((void *)(&pBuffer)){};
211 
212  // KVS_PT_IGNORE
213  ParameterFormat(const char * name)
214  : szName(name), uType(KVS_PT_IGNORE), uFlags(0), pContainer(NULL) {}
215 
216  // terminator
218  : szName(NULL), uType(KVS_PT_IGNORE), uFlags(0), pContainer(NULL){};
219 
220  //ParameterFormat(const char * n,unsigned char t,unsigned char f,void * p)
221  //: szName(n), uType(t), uFlags(f), pContainer(p) {};
222  };
223 
225 }
226 
227 #define KVS_PARAMETERS_BEGIN(__name) \
228  KviKvsParameterProcessor::ParameterFormat __name[] = {
229 
230 #define KVS_PARAMETERS_END \
231  KviKvsParameterProcessor::ParameterFormat(0) \
232  } \
233  ;
234 
235 //#define KVS_PARAMETER(__name,__type,__flags,__void)
236 // KviKvsParameterProcessor::ParameterFormat(__name,__type,__flags,((void *)(&(__void)))),
237 
238 #define KVS_PARAMETER(__name, __type, __flags, __param) \
239  KviKvsParameterProcessor::ParameterFormat(__name, __type, __flags, __param),
240 
241 #define KVS_PARAMETER_IGNORED(__name) \
242  KviKvsParameterProcessor::ParameterFormat(__name),
243 
244 #endif
ParameterFormat(const char *name, KviKvsParameterTypeKviKvsArrayPointer type, unsigned char flags, KviKvsArray *&pBuffer)
Definition: KviKvsParameterProcessor.h:209
Definition: KviKvsParameterProcessor.h:50
This class defines a new data type which contains variant data.
Definition: KviKvsVariant.h:351
Definition: KviKvsParameterProcessor.h:75
Definition: KviKvsParameterProcessor.h:42
#define KVIRC_API
Definition: kvi_settings.h:128
KviKvsParameterTypeQByteArray
Definition: KviKvsParameterProcessor.h:101
KviKvsParameterTypeKvsHObjectT
Definition: KviKvsParameterProcessor.h:126
unsigned char uFlags
Definition: KviKvsParameterProcessor.h:156
char * NULL
Definition: KviIrcNumericCodes.h:391
Class to handle variant variables lists.
Definition: KviKvsVariantList.h:41
KviKvsParameterTypeKvsRealT
Definition: KviKvsParameterProcessor.h:64
Definition: KviKvsParameterProcessor.h:89
const char * szName
Definition: KviKvsParameterProcessor.h:154
ParameterFormat(const char *name, KviKvsParameterTypeKvsIntT type, unsigned char flags, kvs_int_t &iBuffer)
Definition: KviKvsParameterProcessor.h:165
KviKvsParameterTypeQStringList
Definition: KviKvsParameterProcessor.h:110
ParameterFormat(const char *name, KviKvsParameterTypeKviKvsArrayCast type, unsigned char flags, KviKvsArrayCast &oBuffer)
Definition: KviKvsParameterProcessor.h:185
KviKvsParameterTypeQString
Definition: KviKvsParameterProcessor.h:40
ParameterFormat(const char *name, KviKvsParameterTypeKviKvsHashPointer type, unsigned char flags, KviKvsHash *&pBuffer)
Definition: KviKvsParameterProcessor.h:181
QString type()
Definition: KviRuntimeInfo.cpp:646
Definition: KviKvsParameterProcessor.h:74
Definition: KviKvsParameterProcessor.h:59
This class defines a new data type which contains hash data.
Definition: KviKvsHash.h:47
KviKvsParameterTypeKvsIntT
Definition: KviKvsParameterProcessor.h:48
Definition: KviKvsParameterProcessor.h:82
KviKvsParameterTypeBool
Definition: KviKvsParameterProcessor.h:72
#define KVS_PT_IGNORE
Definition: KviKvsParameterProcessor.h:139
Definition: KviKvsParameterProcessor.h:104
ParameterFormat(const char *name, KviKvsParameterTypeKviKvsVariantList type, unsigned char flags, KviKvsVariantList &lBuffer)
Definition: KviKvsParameterProcessor.h:201
ParameterFormat(const char *name, KviKvsParameterTypeQStringList type, unsigned char flags, QStringList &lBuffer)
Definition: KviKvsParameterProcessor.h:197
Definition: KviKvsParameterProcessor.h:103
Definition: KviKvsParameterProcessor.h:112
ParameterFormat(const char *name, KviKvsParameterTypeQString type, unsigned char flags, QString &szBuffer)
Definition: KviKvsParameterProcessor.h:161
Definition: KviKvsParameterProcessor.h:43
KviKvsParameterTypeKviKvsArrayCast
Definition: KviKvsParameterProcessor.h:87
Definition: KviKvsParameterProcessor.h:151
KviKvsParameterTypeKviKvsArrayPointer
Definition: KviKvsParameterProcessor.h:133
double kvs_real_t
Definition: KviKvsTypes.h:35
void * pContainer
Definition: KviKvsParameterProcessor.h:157
kvi_u64_t kvs_uint_t
Definition: KviKvsTypes.h:34
ParameterFormat(const char *name, KviKvsParameterTypeKvsRealT type, unsigned char flags, kvs_real_t &dBuffer)
Definition: KviKvsParameterProcessor.h:173
Definition: KviKvsRunTimeContext.h:103
KviKvsParameterTypeKviKvsVariantList
Definition: KviKvsParameterProcessor.h:119
ParameterFormat(const char *name, KviKvsParameterTypeQByteArray type, unsigned char flags, QByteArray &szBuffer)
Definition: KviKvsParameterProcessor.h:193
Definition: KviKvsParameterProcessor.h:96
KviKvsParameterTypeKviKvsVariantPointer
Definition: KviKvsParameterProcessor.h:94
ParameterFormat(const char *name, KviKvsParameterTypeKvsUIntT type, unsigned char flags, kvs_uint_t &uBuffer)
Definition: KviKvsParameterProcessor.h:169
QString name()
Definition: KviRuntimeInfo.cpp:655
KviKvsParameterTypeKvsUIntT
Definition: KviKvsParameterProcessor.h:56
This class defines a new data type which contains array data.
Definition: KviKvsArray.h:43
void * kvs_hobject_t
Definition: KviKvsTypes.h:32
Definition: KviKvsParameterProcessor.h:67
ParameterFormat()
Definition: KviKvsParameterProcessor.h:217
char szBuffer[4096]
Definition: winamp.cpp:77
ParameterFormat(const char *name, KviKvsParameterTypeKviKvsVariantPointer type, unsigned char flags, KviKvsVariant *&pBuffer)
Definition: KviKvsParameterProcessor.h:189
Definition: KviKvsParameterProcessor.h:66
This file contains compile time settings.
ParameterFormat(const char *name, KviKvsParameterTypeKvsHObjectT type, unsigned char flags, kvs_hobject_t &hBuffer)
Definition: KviKvsParameterProcessor.h:205
Definition: KviKvsParameterProcessor.h:121
kvi_i64_t kvs_int_t
Definition: KviKvsTypes.h:33
Definition: KviKvsParameterProcessor.h:128
unsigned char uType
Definition: KviKvsParameterProcessor.h:155
bool process(KviKvsVariantList *pVariantList, KviKvsRunTimeContext *pContext, KviKvsParameterProcessor::ParameterFormat *pFmtArray)
Definition: KviKvsParameterProcessor.cpp:136
ParameterFormat(const char *name, KviKvsParameterTypeBool type, unsigned char flags, bool &bBuffer)
Definition: KviKvsParameterProcessor.h:177
Definition: KviKvsParameterProcessor.h:51
ParameterFormat(const char *name)
Definition: KviKvsParameterProcessor.h:213
Definition: KviKvsParameterProcessor.h:135
KviKvsParameterTypeKviKvsHashPointer
Definition: KviKvsParameterProcessor.h:80
Definition: KviKvsParameterProcessor.h:58
Definition: KviKvsArrayCast.h:30