|
@@ -0,0 +1,281 @@
|
|
1
|
+#ifndef cmData_h
|
|
2
|
+#define cmData_h
|
|
3
|
+
|
|
4
|
+#ifdef __cplusplus
|
|
5
|
+extern "C" {
|
|
6
|
+#endif
|
|
7
|
+
|
|
8
|
+ enum
|
|
9
|
+ {
|
|
10
|
+ kOkDtRC = cmOkRC,
|
|
11
|
+ kCvtErrDtRC
|
|
12
|
+ };
|
|
13
|
+
|
|
14
|
+ enum
|
|
15
|
+ {
|
|
16
|
+ kInvalidDtChar = 0xff,
|
|
17
|
+ kInvalidDtUChar = 0xff,
|
|
18
|
+ kInvalidDtShort = 0xffff,
|
|
19
|
+ kInvalidDtUShort = 0xffff,
|
|
20
|
+ kInvalidDtInt = 0xffffffff,
|
|
21
|
+ kInvalidDtUInt = 0xffffffff,
|
|
22
|
+ kInvalidDtLong = 0xffffffff,
|
|
23
|
+ kInvalidDtULong = 0xffffffff,
|
|
24
|
+ };
|
|
25
|
+
|
|
26
|
+ typedef enum
|
|
27
|
+ {
|
|
28
|
+ kInvalidDtId,
|
|
29
|
+
|
|
30
|
+ kNullDtId,
|
|
31
|
+
|
|
32
|
+ kUCharDtId,
|
|
33
|
+ kCharDtId,
|
|
34
|
+ kUShortDtId,
|
|
35
|
+ kShortDtId,
|
|
36
|
+ kUIntDtId,
|
|
37
|
+ kIntDtId,
|
|
38
|
+ kULongDtId,
|
|
39
|
+ kLongDtId,
|
|
40
|
+ kFloatDtId,
|
|
41
|
+ kDoubleDtId,
|
|
42
|
+
|
|
43
|
+ kStrDtId,
|
|
44
|
+ kConstStrDtId,
|
|
45
|
+
|
|
46
|
+ kMinPtrDtId,
|
|
47
|
+ kUCharPtrDtId = kMinPtrDtId, // cnt=array element count
|
|
48
|
+ kCharPtrDtId,
|
|
49
|
+ kUShortPtrDtId,
|
|
50
|
+ kShortPtrDtId,
|
|
51
|
+ kUIntPtrDtId,
|
|
52
|
+ kIntPtrDtId,
|
|
53
|
+ kULongPtrDtId,
|
|
54
|
+ kLongPtrDtId,
|
|
55
|
+ kFloatPtrDtId,
|
|
56
|
+ kDoublePtrDtId,
|
|
57
|
+ kVoidPtrDtId,
|
|
58
|
+ kMaxPtrDtId = kVoidPtrDtId,
|
|
59
|
+
|
|
60
|
+ kMinStructDtId,
|
|
61
|
+ kListDtId = kMinStructDtId, // children nodes are array elements, cnt=child count
|
|
62
|
+ kPairDtId, // key/value pairs, cnt=2, first child is key, second is value
|
|
63
|
+ kRecordDtId, // children nodes are pairs, cnt=pair count
|
|
64
|
+ kMaxStructDtId
|
|
65
|
+
|
|
66
|
+ } cmDataFmtId_t;
|
|
67
|
+
|
|
68
|
+ enum
|
|
69
|
+ {
|
|
70
|
+ kDynObjDtFl = 0x01, // object was dynamically allocated
|
|
71
|
+ kDynPtrDtFl = 0x02 // ptr array was dynamically allocated
|
|
72
|
+ };
|
|
73
|
+
|
|
74
|
+ typedef struct cmData_str
|
|
75
|
+ {
|
|
76
|
+ cmDataFmtId_t tid; // data format id
|
|
77
|
+ unsigned flags; //
|
|
78
|
+ struct cmData_str* parent; // this childs parent
|
|
79
|
+ struct cmData_str* sibling; // this childs sibling
|
|
80
|
+ unsigned allocCnt; // allocated count
|
|
81
|
+ unsigned cnt; // actual count
|
|
82
|
+
|
|
83
|
+ union
|
|
84
|
+ {
|
|
85
|
+ char c;
|
|
86
|
+ unsigned char uc;
|
|
87
|
+ short s;
|
|
88
|
+ unsigned short us;
|
|
89
|
+ int i;
|
|
90
|
+ unsigned int ui;
|
|
91
|
+ long l;
|
|
92
|
+ unsigned long ul;
|
|
93
|
+ float f;
|
|
94
|
+ double d;
|
|
95
|
+
|
|
96
|
+ cmChar_t* z;
|
|
97
|
+ const cmChar_t* cz;
|
|
98
|
+
|
|
99
|
+ void* vp;
|
|
100
|
+
|
|
101
|
+ char* cp;
|
|
102
|
+ unsigned char* ucp;
|
|
103
|
+ short* sp;
|
|
104
|
+ unsigned short* usp;
|
|
105
|
+ int* ip;
|
|
106
|
+ unsigned int* uip;
|
|
107
|
+ long* lp;
|
|
108
|
+ unsigned long* ulp;
|
|
109
|
+ float* fp;
|
|
110
|
+ double* dp;
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+ struct cmData_str* child; // first child (array,record,pair)
|
|
114
|
+ } u;
|
|
115
|
+
|
|
116
|
+ } cmData_t;
|
|
117
|
+
|
|
118
|
+ typedef unsigned cmDtRC_t;
|
|
119
|
+
|
|
120
|
+ // Get the value of an object without conversion.
|
|
121
|
+ // The data type id must match the return type or the
|
|
122
|
+ // conversion must be an automatic C conversion.
|
|
123
|
+ char cmDataChar( const cmData_t* p );
|
|
124
|
+ unsigned char cmDataUChar( const cmData_t* p );
|
|
125
|
+ short cmDataShort( const cmData_t* p );
|
|
126
|
+ unsigned short cmDataUShort( const cmData_t* p );
|
|
127
|
+ int cmDataInt( const cmData_t* p );
|
|
128
|
+ unsigned int cmDataUInt( const cmData_t* p );
|
|
129
|
+ long cmDataLong( const cmData_t* p );
|
|
130
|
+ unsigned long cmDataULong( const cmData_t* p );
|
|
131
|
+ float cmDataFloat( const cmData_t* p );
|
|
132
|
+ double cmDataDouble( const cmData_t* p );
|
|
133
|
+ cmChar_t* cmDataStr( const cmData_t* p );
|
|
134
|
+ const cmChar_t* cmDataConstStr( const cmData_t* p );
|
|
135
|
+ void* cmDataVoidPtr( const cmData_t* p );
|
|
136
|
+ char* cmDataCharPtr( const cmData_t* p );
|
|
137
|
+ unsigned char* cmDataUCharPtr( const cmData_t* p );
|
|
138
|
+ short* cmDataShortPtr( const cmData_t* p );
|
|
139
|
+ unsigned short* cmDataUShortPtr( const cmData_t* p );
|
|
140
|
+ int* cmDataIntPtr( const cmData_t* p );
|
|
141
|
+ unsigned int* cmDataUIntPtr( const cmData_t* p );
|
|
142
|
+ long* cmDataLongPtr( const cmData_t* p );
|
|
143
|
+ unsigned long* cmDataULongPtr( const cmData_t* p );
|
|
144
|
+ float* cmDataFloatPtr( const cmData_t* p );
|
|
145
|
+ double* cmDataDoublePtr( const cmData_t* p );
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+ // Get the value of an object with conversion.
|
|
149
|
+ char cmDataGetChar( const cmData_t* p );
|
|
150
|
+ unsigned char cmDataGetUChar( const cmData_t* p );
|
|
151
|
+ short cmDataGetShort( const cmData_t* p );
|
|
152
|
+ unsigned short cmDataGetUShort( const cmData_t* p );
|
|
153
|
+ int cmDataGetInt( const cmData_t* p );
|
|
154
|
+ unsigned int cmDataGetUInt( const cmData_t* p );
|
|
155
|
+ long cmDataGetLong( const cmData_t* p );
|
|
156
|
+ unsigned long cmDataGetULong( const cmData_t* p );
|
|
157
|
+ float cmDataGetFloat( const cmData_t* p );
|
|
158
|
+ double cmDataGetDouble( const cmData_t* p );
|
|
159
|
+ cmChar_t* cmDataGetStr( const cmData_t* p );
|
|
160
|
+ const cmChar_t* cmDataGetConstStr( const cmData_t* p );
|
|
161
|
+ void* cmDataGetVoidPtr( const cmData_t* p );
|
|
162
|
+ char* cmDataGetCharPtr( const cmData_t* p );
|
|
163
|
+ unsigned char* cmDataGetUCharPtr( const cmData_t* p );
|
|
164
|
+ short* cmDataGetShortPtr( const cmData_t* p );
|
|
165
|
+ unsigned short* cmDataGetUShortPtr( const cmData_t* p );
|
|
166
|
+ int* cmDataGetIntPtr( const cmData_t* p );
|
|
167
|
+ unsigned int* cmDataGetUIntPtr( const cmData_t* p );
|
|
168
|
+ long* cmDataGetLongPtr( const cmData_t* p );
|
|
169
|
+ unsigned long* cmDataGetULongPtr( const cmData_t* p );
|
|
170
|
+ float* cmDataGetFloatPtr( const cmData_t* p );
|
|
171
|
+ double* cmDataGetDoublePtr( const cmData_t* p );
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+ // Set the value of an existing data object.
|
|
175
|
+ void cmDataSetChar( cmData_t* p, char v );
|
|
176
|
+ void cmDataSetUChar( cmData_t* p, unsigned char v );
|
|
177
|
+ void cmDataSetShort( cmData_t* p, short v );
|
|
178
|
+ void cmDataSetUShort( cmData_t* p, unsigned short v );
|
|
179
|
+ void cmDataSetInt( cmData_t* p, int v );
|
|
180
|
+ void cmDataSetUInt( cmData_t* p, unsigned int v );
|
|
181
|
+ void cmDataSetLong( cmData_t* p, long v );
|
|
182
|
+ void cmDataSetULong( cmData_t* p, unsigned long v );
|
|
183
|
+ void cmDataSetFloat( cmData_t* p, float v );
|
|
184
|
+ void cmDataSetDouble( cmData_t* p, double v );
|
|
185
|
+ void cmDataSetStr( cmData_t* p, cmChar_t* s );
|
|
186
|
+ void cmDataSetConstStr( cmData_t* p, const cmChar_t* s );
|
|
187
|
+
|
|
188
|
+ // Set the value of an existing data object to an external array.
|
|
189
|
+ // The array is not copied.
|
|
190
|
+ void cmDataSetVoidPtr( cmData_t* p, void* vp, unsigned cnt );
|
|
191
|
+ void cmDataSetCharPtr( cmData_t* p, char* vp, unsigned cnt );
|
|
192
|
+ void cmDataSetUCharPtr( cmData_t* p, unsigned char* vp, unsigned cnt );
|
|
193
|
+ void cmDataSetShortPtr( cmData_t* p, short* vp, unsigned cnt );
|
|
194
|
+ void cmDataSetUShortPtr( cmData_t* p, unsigned short* vp, unsigned cnt );
|
|
195
|
+ void cmDataSetIntPtr( cmData_t* p, int* vp, unsigned cnt );
|
|
196
|
+ void cmDataSetUIntPtr( cmData_t* p, unsigned int* vp, unsigned cnt );
|
|
197
|
+ void cmDataSetLongPtr( cmData_t* p, long* vp, unsigned cnt );
|
|
198
|
+ void cmDataSetULongPtr( cmData_t* p, unsigned long* vp, unsigned cnt );
|
|
199
|
+ void cmDataSetFloatPtr( cmData_t* p, float* vp, unsigned cnt );
|
|
200
|
+ void cmDataSetDoublePtr( cmData_t* p, double* vp, unsigned cnt );
|
|
201
|
+
|
|
202
|
+ // Set the value of an existing array based data object.
|
|
203
|
+ // Allocate the internal array and copy the array into it.
|
|
204
|
+ void cmDataSetStrAlloc( cmData_t* p, const cmChar_t* s );
|
|
205
|
+ void cmDataSetConstStrAlloc( cmData_t* p, const cmChar_t* s );
|
|
206
|
+ void cmDataSetVoidAllocPtr( cmData_t* p, const void* vp, unsigned cnt );
|
|
207
|
+ void cmDataSetCharAllocPtr( cmData_t* p, const char* vp, unsigned cnt );
|
|
208
|
+ void cmDataSetUCharAllocPtr( cmData_t* p, const unsigned char* vp, unsigned cnt );
|
|
209
|
+ void cmDataSetShortAllocPtr( cmData_t* p, const short* vp, unsigned cnt );
|
|
210
|
+ void cmDataSetUShortAllocPtr( cmData_t* p, const unsigned short* vp, unsigned cnt );
|
|
211
|
+ void cmDataSetIntAllocPtr( cmData_t* p, const int* vp, unsigned cnt );
|
|
212
|
+ void cmDataSetUIntAllocPtr( cmData_t* p, const unsigned int* vp, unsigned cnt );
|
|
213
|
+ void cmDataSetLongAllocPtr( cmData_t* p, const long* vp, unsigned cnt );
|
|
214
|
+ void cmDataSetULongAllocPtr( cmData_t* p, const unsigned long* vp, unsigned cnt );
|
|
215
|
+ void cmDataSetFloatAllocPtr( cmData_t* p, const float* vp, unsigned cnt );
|
|
216
|
+ void cmDataSetDoubleAllocPtr( cmData_t* p, const double* vp, unsigned cnt );
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+ // Dynamically allocate a data object and set it's value.
|
|
220
|
+ cmData_t* cmDataAllocChar( char v );
|
|
221
|
+ cmData_t* cmDataAllocUChar( unsigned char v );
|
|
222
|
+ cmData_t* cmDataAllocShort( short v );
|
|
223
|
+ cmData_t* cmDataAllocUShort( unsigned short v );
|
|
224
|
+ cmData_t* cmDataAllocInt( int v );
|
|
225
|
+ cmData_t* cmDataAllocUInt( unsigned int v );
|
|
226
|
+ cmData_t* cmDataAllocLong( long v );
|
|
227
|
+ cmData_t* cmDataAllocULong( unsigned long v );
|
|
228
|
+ cmData_t* cmDataAllocFloat( float v );
|
|
229
|
+ cmData_t* cmDataAllocDouble( double v );
|
|
230
|
+ cmData_t* cmDataAllocStr( cmChar_t* str );
|
|
231
|
+ cmData_t* cmDataAllocConstStr( const cmChar_t* str );
|
|
232
|
+
|
|
233
|
+ // Dynamically allocate a data object and set its array value to an external
|
|
234
|
+ // array. The data is not copied.
|
|
235
|
+ cmData_t* cmDataAllocVoidPtr( const void* v, unsigned cnt );
|
|
236
|
+ cmData_t* cmDataAllocCharPtr( const char* v, unsigned cnt );
|
|
237
|
+ cmData_t* cmDataAllocUCharPtr( const unsigned char* v, unsigned cnt );
|
|
238
|
+ cmData_t* cmDataAllocShortPtr( const short* v, unsigned cnt );
|
|
239
|
+ cmData_t* cmDataAllocUShortPtr( const unsigned short* v, unsigned cnt );
|
|
240
|
+ cmData_t* cmDataAllocIntPtr( const int* v, unsigned cnt );
|
|
241
|
+ cmData_t* cmDataAllocUIntPtr( const unsigned int* v, unsigned cnt );
|
|
242
|
+ cmData_t* cmDataAllocLongPtr( const long* v, unsigned cnt );
|
|
243
|
+ cmData_t* cmDataAllocULongPtr( const unsigned long* v, unsigned cnt );
|
|
244
|
+ cmData_t* cmDataAllocFloatPtr( const float* v, unsigned cnt );
|
|
245
|
+ cmData_t* cmDataAllocDoublePtr( const double* v, unsigned cnt );
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+ // Dynamically allocate a data object and its array value.
|
|
249
|
+ // v[cnt] is copied into the allocated array.
|
|
250
|
+ cmData_t* cmDataVoidAllocPtr( const void* v, unsigned cnt );
|
|
251
|
+ cmData_t* cmDataCharAllocPtr( const char* v, unsigned cnt );
|
|
252
|
+ cmData_t* cmDataUCharAllocPtr( const unsigned char* v, unsigned cnt );
|
|
253
|
+ cmData_t* cmDataShortAllocPtr( const short* v, unsigned cnt );
|
|
254
|
+ cmData_t* cmDataUShortAllocPtr( const unsigned short* v, unsigned cnt );
|
|
255
|
+ cmData_t* cmDataIntAllocPtr( const int* v, unsigned cnt );
|
|
256
|
+ cmData_t* cmDataUIntAllocPtr( const unsigned int* v, unsigned cnt );
|
|
257
|
+ cmData_t* cmDataLongAllocPtr( const long* v, unsigned cnt );
|
|
258
|
+ cmData_t* cmDataULongAllocPtr( const unsigned long* v, unsigned cnt );
|
|
259
|
+ cmData_t* cmDataFloatAllocPtr( const float* v, unsigned cnt );
|
|
260
|
+ cmData_t* cmDataDoubleAllocPtr( const double* v, unsigned cnt );
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+ void cmDataFree( cmData_t* p );
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+ unsigned cmDataSerializeByteCount( const cmData_t* p );
|
|
268
|
+ cmDtRC_t cmDataSerialize( const cmData_t* p, void* buf, unsigned bufByteCnt );
|
|
269
|
+ cmDtRC_t cmDataDeserialize( const void* buf, unsigned bufByteCnt, cmData_t** pp );
|
|
270
|
+
|
|
271
|
+ void cmDataPrint( const cmData_t* p, cmRpt_t* rpt );
|
|
272
|
+
|
|
273
|
+ void cmDataTest( cmCtx_t* ctx );
|
|
274
|
+
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+#ifdef __cplusplus
|
|
278
|
+}
|
|
279
|
+#endif
|
|
280
|
+
|
|
281
|
+#endif
|