Browse Source

cmData.h/c Initialize Add

master
kpl 11 years ago
parent
commit
e25c92802e
2 changed files with 317 additions and 173 deletions
  1. 181
    134
      cmData.c
  2. 136
    39
      cmData.h

+ 181
- 134
cmData.c View File

1
+#include "cmGlobal.h"
2
+#include "cmRpt.h"
3
+#include "cmErr.h"
4
+#include "cmCtx.h"
1
 #include "cmData.h"
5
 #include "cmData.h"
2
-
6
+#include "cmMem.h"
7
+#include "cmMallocDebug.h"
3
 
8
 
4
 cmDtRC_t _cmDataErrNo = kOkDtRC;
9
 cmDtRC_t _cmDataErrNo = kOkDtRC;
5
 
10
 
11
+typedef struct
12
+{
13
+  cmDataFmtId_t tid;
14
+  unsigned      cnt;
15
+} cmDataSerialHdr_t;
16
+
6
 void _cmDataFreeArray( cmData_t* p )
17
 void _cmDataFreeArray( cmData_t* p )
7
 {
18
 {
8
   if(cmIsFlag(p->flags,kDynPtrDtFl))
19
   if(cmIsFlag(p->flags,kDynPtrDtFl))
9
   {
20
   {
10
-    cmMemFree(p->vp);
11
-    p->vp    = NULL;
12
-    p->flags = cmClrFlag(p->flags,kDynPtrFl);
21
+    cmMemFree(p->u.vp);
22
+    p->u.vp    = NULL;
23
+    p->flags = cmClrFlag(p->flags,kDynPtrDtFl);
13
   }
24
   }
14
-  p->tid = cmInvalidDtId;
25
+  p->tid = kInvalidDtId;
15
   p->cnt = 0;
26
   p->cnt = 0;
16
 }
27
 }
17
 
28
 
22
     cmMemFree(p);
33
     cmMemFree(p);
23
 }
34
 }
24
 
35
 
25
-unsigned _cmDataByteCount( cmData_t* p )
36
+unsigned _cmDataByteCount( const cmData_t* p )
26
 {
37
 {
27
-  unsigned n = sizeof(cmDataSerialHdr_t)
38
+  unsigned n = sizeof(cmDataSerialHdr_t);
39
+
28
   switch( p->tid )
40
   switch( p->tid )
29
   {
41
   {
30
     case kInvalidDtId:   return 0;
42
     case kInvalidDtId:   return 0;
54
     case kFloatPtrDtId:  return n + p->cnt * sizeof(float);
66
     case kFloatPtrDtId:  return n + p->cnt * sizeof(float);
55
     case kDoublePtrDtId: return n + p->cnt * sizeof(double);
67
     case kDoublePtrDtId: return n + p->cnt * sizeof(double);
56
     case kVoidPtrDtId:   return n + p->cnt * sizeof(char);
68
     case kVoidPtrDtId:   return n + p->cnt * sizeof(char);
69
+
70
+    default:
71
+      return n;
57
   }
72
   }
58
   assert(0);
73
   assert(0);
59
   return 0;
74
   return 0;
60
 }
75
 }
61
 
76
 
62
-char            cmDataChar(      const cmData_t* p ) { assert(p->tid==kCharDtId);      p->u.c; }
63
-unsigned char   cmDataUChar(     const cmData_t* p ) { assert(p->tid==kUCharDtId);     p->u.uc; } 
64
-short           cmDataShort(     const cmData_t* p ) { assert(p->tid==kShortDtId);     p->u.s; } 
65
-unsigned short  cmDataUShort(    const cmData_t* p ) { assert(p->tid==kUShortDtId);    p->u.us; } 
66
-int             cmDataInt(       const cmData_t* p ) { assert(p->tid==kIntDtId);       p->u.i; } 
67
-unsigned int    cmDataUInt(      const cmData_t* p ) { assert(p->tid==kUIntDtId);      p->u.ui; } 
68
-long            cmDataLong(      const cmData_t* p ) { assert(p->tid==kLongDtId);      p->u.l; } 
69
-unsigned long   cmDataULong(     const cmData_t* p ) { assert(p->tid==kULongDtId);     p->u.ul; } 
70
-float           cmDataFloat(     const cmData_t* p ) { assert(p->tid==kFloatDtId);     p->u.f; } 
71
-double          cmDataDouble(    const cmData_t* p ) { assert(p->tid==kDoubleDtId);    p->u.d; } 
72
-cmChar_t*       cmDataStr(       const cmData_t* p ) { assert(p->tid==kStrDtId);       p->u.z; } 
73
-const cmChar_t* cmDataConstStr(  const cmData_t* p ) { assert(p->tid==kConstStrDtId);  p->u.cz; } 
74
-void*           cmDataVoidPtr(   const cmData_t* p ) { assert(p->tid==kVoidDtId);      p->u.vp; }
75
-char*           cmDataCharPtr(   const cmData_t* p ) { assert(p->tid==kCharPtrDtId);   p->u.cp; } 
76
-unsigned char*  cmDataUCharPtr(  const cmData_t* p ) { assert(p->tid==kUCharPtrDtId);  p->u.ucp; } 
77
-short*          cmDataShortPtr(  const cmData_t* p ) { assert(p->tid==kShortPtrDtId);  p->u.sp; } 
78
-unsigned short* cmDataUShortPtr( const cmData_t* p ) { assert(p->tid==kUShortPtrDtId); p->u.usp; } 
79
-int*            cmDataIntPtr(    const cmData_t* p ) { assert(p->tid==kIntPtrDtId);    p->u.ip; } 
80
-unsigned int*   cmDataUIntPtr(   const cmData_t* p ) { assert(p->tid==kUIntPtrDtId);   p->u.uip; } 
81
-long*           cmDataLongPtr(   const cmData_t* p ) { assert(p->tid==kLongPtrDtId);   p->u.lp; } 
82
-unsigned long*  cmDataULongPtr(  const cmData_t* p ) { assert(p->tid==kULongPtrDtId);  p->u.ulp; } 
83
-float*          cmDataFloatPtr(  const cmData_t* p ) { assert(p->tid==kFloatPtrDtId);  p->u.fp; } 
84
-double*         cmDataDoublePtr( const cmData_t* p ) { assert(p->tid==kDoublePtrDtId); p->u.dp; } 
77
+char            cmDataChar(      const cmData_t* p ) { assert(p->tid==kCharDtId);      return p->u.c; }
78
+unsigned char   cmDataUChar(     const cmData_t* p ) { assert(p->tid==kUCharDtId);     return p->u.uc; } 
79
+short           cmDataShort(     const cmData_t* p ) { assert(p->tid==kShortDtId);     return p->u.s; } 
80
+unsigned short  cmDataUShort(    const cmData_t* p ) { assert(p->tid==kUShortDtId);    return p->u.us; } 
81
+int             cmDataInt(       const cmData_t* p ) { assert(p->tid==kIntDtId);       return p->u.i; } 
82
+unsigned int    cmDataUInt(      const cmData_t* p ) { assert(p->tid==kUIntDtId);      return p->u.ui; } 
83
+long            cmDataLong(      const cmData_t* p ) { assert(p->tid==kLongDtId);      return p->u.l; } 
84
+unsigned long   cmDataULong(     const cmData_t* p ) { assert(p->tid==kULongDtId);     return p->u.ul; } 
85
+float           cmDataFloat(     const cmData_t* p ) { assert(p->tid==kFloatDtId);     return p->u.f; } 
86
+double          cmDataDouble(    const cmData_t* p ) { assert(p->tid==kDoubleDtId);    return p->u.d; } 
87
+cmChar_t*       cmDataStr(       const cmData_t* p ) { assert(p->tid==kStrDtId);       return p->u.z; } 
88
+const cmChar_t* cmDataConstStr(  const cmData_t* p ) { assert(p->tid==kConstStrDtId);  return p->u.cz; } 
89
+void*           cmDataVoidPtr(   const cmData_t* p ) { assert(p->tid==kVoidPtrDtId);   return p->u.vp; }
90
+char*           cmDataCharPtr(   const cmData_t* p ) { assert(p->tid==kCharPtrDtId);   return p->u.cp; } 
91
+unsigned char*  cmDataUCharPtr(  const cmData_t* p ) { assert(p->tid==kUCharPtrDtId);  return p->u.ucp; } 
92
+short*          cmDataShortPtr(  const cmData_t* p ) { assert(p->tid==kShortPtrDtId);  return p->u.sp; } 
93
+unsigned short* cmDataUShortPtr( const cmData_t* p ) { assert(p->tid==kUShortPtrDtId); return p->u.usp; } 
94
+int*            cmDataIntPtr(    const cmData_t* p ) { assert(p->tid==kIntPtrDtId);    return p->u.ip; } 
95
+unsigned int*   cmDataUIntPtr(   const cmData_t* p ) { assert(p->tid==kUIntPtrDtId);   return p->u.uip; } 
96
+long*           cmDataLongPtr(   const cmData_t* p ) { assert(p->tid==kLongPtrDtId);   return p->u.lp; } 
97
+unsigned long*  cmDataULongPtr(  const cmData_t* p ) { assert(p->tid==kULongPtrDtId);  return p->u.ulp; } 
98
+float*          cmDataFloatPtr(  const cmData_t* p ) { assert(p->tid==kFloatPtrDtId);  return p->u.fp; } 
99
+double*         cmDataDoublePtr( const cmData_t* p ) { assert(p->tid==kDoublePtrDtId); return p->u.dp; } 
85
 
100
 
86
 unsigned char   cmDataGetUChar(     const cmData_t* p )
101
 unsigned char   cmDataGetUChar(     const cmData_t* p )
87
 {
102
 {
88
-  unsigned char v = kInvalidUChar;
103
+  unsigned char v = kInvalidDtUChar;
89
 
104
 
90
   switch( p->tid )
105
   switch( p->tid )
91
   {
106
   {
107
 
122
 
108
 char  cmDataGetChar( const cmData_t* p )
123
 char  cmDataGetChar( const cmData_t* p )
109
 {
124
 {
110
-  char v = kInvalidChar;
125
+  char v = kInvalidDtChar;
111
 
126
 
112
   switch( p->tid )
127
   switch( p->tid )
113
   {
128
   {
129
 
144
 
130
 short           cmDataGetShort(     const cmData_t* p )
145
 short           cmDataGetShort(     const cmData_t* p )
131
 {
146
 {
132
-  short v = kInvalidShort;
147
+  short v = kInvalidDtShort;
133
 
148
 
134
   switch( p->tid )
149
   switch( p->tid )
135
   {
150
   {
153
 
168
 
154
 unsigned short  cmDataGetUShort(    const cmData_t* p )
169
 unsigned short  cmDataGetUShort(    const cmData_t* p )
155
 {
170
 {
156
-  unsigned short v = kInvalidUShort;
171
+  unsigned short v = kInvalidDtUShort;
157
 
172
 
158
   switch( p->tid )
173
   switch( p->tid )
159
   {
174
   {
176
 
191
 
177
 int             cmDataGetInt(       const cmData_t* p )
192
 int             cmDataGetInt(       const cmData_t* p )
178
 {
193
 {
179
-  int v = kInvalidInt;
194
+  int v = kInvalidDtInt;
180
 
195
 
181
   switch( p->tid )
196
   switch( p->tid )
182
   {
197
   {
199
 
214
 
200
 unsigned int    cmDataGetUInt(      const cmData_t* p )
215
 unsigned int    cmDataGetUInt(      const cmData_t* p )
201
 {
216
 {
202
-  unsigned int v = kInvalidUInt;
217
+  unsigned int v = kInvalidDtUInt;
203
 
218
 
204
   switch( p->tid )
219
   switch( p->tid )
205
   {
220
   {
222
 
237
 
223
 long            cmDataGetLong(      const cmData_t* p )
238
 long            cmDataGetLong(      const cmData_t* p )
224
 {
239
 {
225
-  long v = kInvalidLong;
240
+  long v = kInvalidDtLong;
226
 
241
 
227
   switch( p->tid )
242
   switch( p->tid )
228
   {
243
   {
245
 
260
 
246
 unsigned long   cmDataGetULong(     const cmData_t* p )
261
 unsigned long   cmDataGetULong(     const cmData_t* p )
247
 {
262
 {
248
-  unsigned long v = kInvalidULong;
263
+  unsigned long v = kInvalidDtULong;
249
 
264
 
250
   switch( p->tid )
265
   switch( p->tid )
251
   {
266
   {
268
 
283
 
269
 float           cmDataGetFloat(     const cmData_t* p )
284
 float           cmDataGetFloat(     const cmData_t* p )
270
 {
285
 {
271
-  float v = kInvalidChar;
286
+  float v = FLT_MAX;
272
 
287
 
273
   switch( p->tid )
288
   switch( p->tid )
274
   {
289
   {
291
 
306
 
292
 double          cmDataGetDouble(    const cmData_t* p )
307
 double          cmDataGetDouble(    const cmData_t* p )
293
 {
308
 {
294
-  double v = kInvalidChar;
309
+  double v = DBL_MAX;
295
 
310
 
296
   switch( p->tid )
311
   switch( p->tid )
297
   {
312
   {
325
 }
340
 }
326
 
341
 
327
 void*           cmDataGetVoidPtr(   const cmData_t* p )
342
 void*           cmDataGetVoidPtr(   const cmData_t* p )
328
-{ return cmDataVoidPtr(p); }
329
-
330
-void*           cmDataGetVoidPtr(   const cmData_t* p )
331
 {
343
 {
332
   assert( kMinPtrDtId <= p->tid && p->tid <= kMaxPtrDtId );
344
   assert( kMinPtrDtId <= p->tid && p->tid <= kMaxPtrDtId );
333
   return ( kMinPtrDtId <= p->tid && p->tid <= kMaxPtrDtId ) ? p->u.vp : NULL;  
345
   return ( kMinPtrDtId <= p->tid && p->tid <= kMaxPtrDtId ) ? p->u.vp : NULL;  
388
 { return p->tid == kDoublePtrDtId ? p->u.dp : NULL; }
400
 { return p->tid == kDoublePtrDtId ? p->u.dp : NULL; }
389
 
401
 
390
   // Set the value of an existing data object.
402
   // Set the value of an existing data object.
391
-void cmDataSetChar(      cmData_t* p, char v )
403
+cmData_t* cmDataSetChar(      cmData_t* p, char v )
392
 {
404
 {
393
   _cmDataFreeArray(p);
405
   _cmDataFreeArray(p);
394
   p->tid = kCharDtId;
406
   p->tid = kCharDtId;
395
   p->u.c = v;
407
   p->u.c = v;
408
+  return p;
396
 }
409
 }
397
 
410
 
398
-void cmDataSetUChar(     cmData_t* p, unsigned char v )
411
+cmData_t* cmDataSetUChar(     cmData_t* p, unsigned char v )
399
 {
412
 {
400
   _cmDataFreeArray(p);
413
   _cmDataFreeArray(p);
401
   p->tid = kUCharDtId;
414
   p->tid = kUCharDtId;
402
   p->u.uc = v;
415
   p->u.uc = v;
416
+  return p;
403
 }
417
 }
404
 
418
 
405
-void cmDataSetShort(     cmData_t* p, short v )
419
+cmData_t* cmDataSetShort(     cmData_t* p, short v )
406
 {
420
 {
407
   _cmDataFreeArray(p);
421
   _cmDataFreeArray(p);
408
   p->tid = kShortDtId;
422
   p->tid = kShortDtId;
409
   p->u.s = v;
423
   p->u.s = v;
424
+  return p;
410
 }
425
 }
411
-void cmDataSetUShort(    cmData_t* p, unsigned short v )
426
+
427
+cmData_t* cmDataSetUShort(    cmData_t* p, unsigned short v )
412
 {
428
 {
413
   _cmDataFreeArray(p);
429
   _cmDataFreeArray(p);
414
   p->tid = kUShortDtId;
430
   p->tid = kUShortDtId;
415
   p->u.us = v;
431
   p->u.us = v;
432
+  return p;
416
 }
433
 }
417
-void cmDataSetInt(       cmData_t* p, int v )
434
+
435
+cmData_t* cmDataSetInt(       cmData_t* p, int v )
418
 {
436
 {
419
   _cmDataFreeArray(p);
437
   _cmDataFreeArray(p);
420
   p->tid = kCharDtId;
438
   p->tid = kCharDtId;
421
   p->u.c = v;
439
   p->u.c = v;
422
 }
440
 }
423
-void cmDataSetUInt(      cmData_t* p, unsigned int v )
441
+
442
+cmData_t* cmDataSetUInt(      cmData_t* p, unsigned int v )
424
 {
443
 {
425
   _cmDataFreeArray(p);
444
   _cmDataFreeArray(p);
426
   p->tid = kUIntDtId;
445
   p->tid = kUIntDtId;
427
   p->u.ui = v;
446
   p->u.ui = v;
447
+  return p;
428
 }
448
 }
429
-void cmDataSetLong(      cmData_t* p, long v )
449
+
450
+cmData_t* cmDataSetLong(      cmData_t* p, long v )
430
 {
451
 {
431
   _cmDataFreeArray(p);
452
   _cmDataFreeArray(p);
432
   p->tid = kLongDtId;
453
   p->tid = kLongDtId;
433
   p->u.l = v;
454
   p->u.l = v;
434
 }
455
 }
435
-void cmDataSetULong(     cmData_t* p, unsigned long v )
456
+
457
+cmData_t* cmDataSetULong(     cmData_t* p, unsigned long v )
436
 {
458
 {
437
   _cmDataFreeArray(p);
459
   _cmDataFreeArray(p);
438
   p->tid = kULongDtId;
460
   p->tid = kULongDtId;
439
   p->u.ul = v;
461
   p->u.ul = v;
462
+  return p;
440
 }
463
 }
441
-void cmDataSetFloat(     cmData_t* p, float v )
464
+
465
+cmData_t* cmDataSetFloat(     cmData_t* p, float v )
442
 {
466
 {
443
   _cmDataFreeArray(p);
467
   _cmDataFreeArray(p);
444
   p->tid = kFloatDtId;
468
   p->tid = kFloatDtId;
445
   p->u.f = v;
469
   p->u.f = v;
470
+  return p;
446
 }
471
 }
447
-void cmDataSetDouble(    cmData_t* p, double v )
472
+
473
+cmData_t* cmDataSetDouble(    cmData_t* p, double v )
448
 {
474
 {
449
   _cmDataFreeArray(p);
475
   _cmDataFreeArray(p);
450
   p->tid = kDoubleDtId;
476
   p->tid = kDoubleDtId;
451
   p->u.d = v;
477
   p->u.d = v;
478
+  return p;
452
 }
479
 }
453
 
480
 
454
-void cmDataSetStr(       cmData_t* p, cmChar_t* s )
481
+cmData_t* cmDataSetStr(       cmData_t* p, cmChar_t* s )
455
 {
482
 {
456
   _cmDataFreeArray(p);
483
   _cmDataFreeArray(p);
457
   p->tid = kStrDtId;
484
   p->tid = kStrDtId;
458
   p->u.z = s;
485
   p->u.z = s;
486
+  return p;
459
 }
487
 }
460
 
488
 
461
-void cmDataSetConstStr(  cmData_t* p, const cmChar_t* s )
489
+cmData_t* cmDataSetConstStr(  cmData_t* p, const cmChar_t* s )
462
 {
490
 {
463
   _cmDataFreeArray(p);
491
   _cmDataFreeArray(p);
464
   p->tid = kConstStrDtId;
492
   p->tid = kConstStrDtId;
465
   p->u.cz = s;
493
   p->u.cz = s;
494
+  return p;
466
 }
495
 }
467
 
496
 
468
 // Set the value of an existing data object to an external array.
497
 // Set the value of an existing data object to an external array.
469
 // The array is not copied.
498
 // The array is not copied.
470
-void cmDataSetVoidPtr(   cmData_t* p, void* vp,          unsigned cnt )
499
+cmData_t* cmDataSetVoidPtr(   cmData_t* p, void* vp,          unsigned cnt )
471
 {
500
 {
472
-  cmDataSetCharPtr(p,(char*),cnt);  
501
+  cmDataSetCharPtr(p,(char*)vp,cnt);  
502
+  p->tid = kVoidPtrDtId;
503
+  return p;
473
 }
504
 }
474
 
505
 
475
-void cmDataSetCharPtr(   cmData_t* p, char* vp,          unsigned cnt )
506
+cmData_t* cmDataSetCharPtr(   cmData_t* p, char* vp,          unsigned cnt )
476
 {
507
 {
477
   _cmDataFreeArray(p);
508
   _cmDataFreeArray(p);
478
   p->tid  = kCharPtrDtId;
509
   p->tid  = kCharPtrDtId;
479
   p->u.cp = vp;
510
   p->u.cp = vp;
480
   p->cnt  = cnt;
511
   p->cnt  = cnt;
512
+  return p;
481
 }
513
 }
482
 
514
 
483
-void cmDataSetUCharPtr(  cmData_t* p, unsigned char* vp,  unsigned cnt )
515
+cmData_t* cmDataSetUCharPtr(  cmData_t* p, unsigned char* vp,  unsigned cnt )
484
 {
516
 {
485
   _cmDataFreeArray(p);
517
   _cmDataFreeArray(p);
486
   p->tid  = kUCharPtrDtId;
518
   p->tid  = kUCharPtrDtId;
487
   p->u.ucp = vp;
519
   p->u.ucp = vp;
488
   p->cnt  = cnt;
520
   p->cnt  = cnt;
521
+  return p;
489
 }
522
 }
490
 
523
 
491
-void cmDataSetShortPtr(  cmData_t* p, short* vp,          unsigned cnt )
524
+cmData_t* cmDataSetShortPtr(  cmData_t* p, short* vp,          unsigned cnt )
492
 {
525
 {
493
   _cmDataFreeArray(p);
526
   _cmDataFreeArray(p);
494
   p->tid  = kShortPtrDtId;
527
   p->tid  = kShortPtrDtId;
495
   p->u.sp = vp;
528
   p->u.sp = vp;
496
   p->cnt  = cnt;
529
   p->cnt  = cnt;
530
+  return p;
497
 }
531
 }
498
 
532
 
499
-void cmDataSetUShortPtr( cmData_t* p, unsigned short* vp, unsigned cnt )
533
+cmData_t* cmDataSetUShortPtr( cmData_t* p, unsigned short* vp, unsigned cnt )
500
 {
534
 {
501
   _cmDataFreeArray(p);
535
   _cmDataFreeArray(p);
502
   p->tid   = kUShortPtrDtId;
536
   p->tid   = kUShortPtrDtId;
503
   p->u.usp = vp;
537
   p->u.usp = vp;
504
   p->cnt   = cnt;
538
   p->cnt   = cnt;
539
+  return p;
505
 }
540
 }
506
 
541
 
507
-void cmDataSetIntPtr(    cmData_t* p, int* vp,            unsigned cnt )
542
+cmData_t* cmDataSetIntPtr(    cmData_t* p, int* vp,            unsigned cnt )
508
 {
543
 {
509
   _cmDataFreeArray(p);
544
   _cmDataFreeArray(p);
510
   p->tid  = kCharPtrDtId;
545
   p->tid  = kCharPtrDtId;
511
-  p->u.cp = vp;
546
+  p->u.ip = vp;
512
   p->cnt  = cnt;
547
   p->cnt  = cnt;
548
+  return p;
513
 }
549
 }
514
 
550
 
515
-void cmDataSetUIntPtr(   cmData_t* p, unsigned int* vp,   unsigned cnt )
551
+cmData_t* cmDataSetUIntPtr(   cmData_t* p, unsigned int* vp,   unsigned cnt )
516
 {
552
 {
517
   _cmDataFreeArray(p);
553
   _cmDataFreeArray(p);
518
   p->tid   = kUIntPtrDtId;
554
   p->tid   = kUIntPtrDtId;
519
   p->u.uip = vp;
555
   p->u.uip = vp;
520
   p->cnt   = cnt;
556
   p->cnt   = cnt;
557
+  return p;
521
 }
558
 }
522
 
559
 
523
-void cmDataSetLongPtr(   cmData_t* p, long* vp,           unsigned cnt )
560
+cmData_t* cmDataSetLongPtr(   cmData_t* p, long* vp,           unsigned cnt )
524
 {
561
 {
525
   _cmDataFreeArray(p);
562
   _cmDataFreeArray(p);
526
   p->tid  = kLongPtrDtId;
563
   p->tid  = kLongPtrDtId;
527
   p->u.lp = vp;
564
   p->u.lp = vp;
528
   p->cnt  = cnt;
565
   p->cnt  = cnt;
566
+  return p;
529
 }
567
 }
530
 
568
 
531
-void cmDataSetULongPtr(  cmData_t* p, unsigned long* vp,  unsigned cnt )
569
+cmData_t* cmDataSetULongPtr(  cmData_t* p, unsigned long* vp,  unsigned cnt )
532
 {
570
 {
533
   _cmDataFreeArray(p);
571
   _cmDataFreeArray(p);
534
   p->tid   = kULongPtrDtId;
572
   p->tid   = kULongPtrDtId;
535
   p->u.ulp = vp;
573
   p->u.ulp = vp;
536
   p->cnt   = cnt;
574
   p->cnt   = cnt;
575
+  return p;
537
 }
576
 }
538
 
577
 
539
-void cmDataSetFloatPtr(  cmData_t* p, float* vp,          unsigned cnt )
578
+cmData_t* cmDataSetFloatPtr(  cmData_t* p, float* vp,          unsigned cnt )
540
 {
579
 {
541
   _cmDataFreeArray(p);
580
   _cmDataFreeArray(p);
542
   p->tid  = kFloatPtrDtId;
581
   p->tid  = kFloatPtrDtId;
543
   p->u.fp = vp;
582
   p->u.fp = vp;
544
   p->cnt  = cnt;
583
   p->cnt  = cnt;
584
+  return p;
545
 }
585
 }
546
 
586
 
547
-void cmDataSetDoublePtr( cmData_t* p, double* vp,         unsigned cnt )
587
+cmData_t* cmDataSetDoublePtr( cmData_t* p, double* vp,         unsigned cnt )
548
 {
588
 {
549
   _cmDataFreeArray(p);
589
   _cmDataFreeArray(p);
550
   p->tid  = kDoublePtrDtId;
590
   p->tid  = kDoublePtrDtId;
551
   p->u.dp = vp;
591
   p->u.dp = vp;
552
   p->cnt  = cnt;
592
   p->cnt  = cnt;
593
+  return p;
553
 }
594
 }
554
 
595
 
555
 // Set the value of an existing array based data object. 
596
 // Set the value of an existing array based data object. 
556
 // Allocate the internal array and copy the array into it.
597
 // Allocate the internal array and copy the array into it.
557
-void cmDataSetStrAlloc( cmData_t* p, const cmChar_t* s )
598
+cmData_t* cmDataSetStrAlloc( cmData_t* p, const cmChar_t* s )
558
 {
599
 {
559
   if( cmIsFlag(p->flags,kDynPtrDtFl) )
600
   if( cmIsFlag(p->flags,kDynPtrDtFl) )
560
     cmMemResizeStr(p->u.z,s);
601
     cmMemResizeStr(p->u.z,s);
561
   else
602
   else
562
   {
603
   {
563
     _cmDataFreeArray(p);
604
     _cmDataFreeArray(p);
564
-    cmMemAllocStr(p->u.z,s);
605
+    p->u.z = cmMemAllocStr(s);
565
   }
606
   }
566
   p->tid    = kStrDtId;
607
   p->tid    = kStrDtId;
567
   p->flags  = cmSetFlag(p->flags,kDynPtrDtFl);
608
   p->flags  = cmSetFlag(p->flags,kDynPtrDtFl);
609
+  return p;
568
 }
610
 }
569
 
611
 
570
-void cmDataSetConstStrAlloc(  cmData_t* p, const cmChar_t* s )
571
-{ cmDataSetStrAlloc(p,s); }
612
+cmData_t* cmDataSetConstStrAlloc(  cmData_t* p, const cmChar_t* s )
613
+{ return cmDataSetStrAlloc(p,s); }
572
 
614
 
573
-void cmDataSetVoidAllocPtr(   cmData_t* p, const void* vp, unsigned cnt )
574
-{ cmDataSetCharAllocPtr(p,(char*)vp,cnt); }
615
+cmData_t* cmDataSetVoidAllocPtr(   cmData_t* p, const void* vp, unsigned cnt )
616
+{ return cmDataSetCharAllocPtr(p,(char*)vp,cnt); }
575
 
617
 
576
-void cmDataSetCharAllocPtr(  cmData_t* p, const char* vp,  unsigned cnt )
618
+cmData_t* cmDataSetCharAllocPtr(  cmData_t* p, const char* vp,  unsigned cnt )
577
 {
619
 {
578
   if( cmIsFlag(p->flags,kDynPtrDtFl) )
620
   if( cmIsFlag(p->flags,kDynPtrDtFl) )
579
-    cmMemResize(char, p->u.ucp, cnt );
621
+    p->u.cp = cmMemResize(char, p->u.cp, cnt );
580
   else
622
   else
581
   {
623
   {
582
     _cmDataFreeArray(p);
624
     _cmDataFreeArray(p);
583
-    p->u.ucp = cmMemAlloc(char, cnt );
625
+    p->u.cp = cmMemAlloc(char, cnt );
584
   }
626
   }
585
   p->tid   = kCharPtrDtId;
627
   p->tid   = kCharPtrDtId;
586
   p->flags = cmSetFlag(p->flags,kDynPtrDtFl);
628
   p->flags = cmSetFlag(p->flags,kDynPtrDtFl);
629
+  return p;
587
 }
630
 }
588
 
631
 
589
-void cmDataSetUCharAllocPtr(  cmData_t* p, const unsigned char* vp,  unsigned cnt )
632
+cmData_t* cmDataSetUCharAllocPtr(  cmData_t* p, const unsigned char* vp,  unsigned cnt )
590
 {
633
 {
591
   if( cmIsFlag(p->flags,kDynPtrDtFl) )
634
   if( cmIsFlag(p->flags,kDynPtrDtFl) )
592
-    cmMemResize(unsigned char, p->u.ucp, cnt );
635
+    p->u.ucp = cmMemResize(unsigned char, p->u.ucp, cnt );
593
   else
636
   else
594
   {
637
   {
595
     _cmDataFreeArray(p);
638
     _cmDataFreeArray(p);
597
   }
640
   }
598
   p->tid   = kUCharPtrDtId;
641
   p->tid   = kUCharPtrDtId;
599
   p->flags = cmSetFlag(p->flags,kDynPtrDtFl);
642
   p->flags = cmSetFlag(p->flags,kDynPtrDtFl);
643
+  return p;
600
 }
644
 }
601
 
645
 
602
-void cmDataSetShortAllocPtr(  cmData_t* p, const short* vp,          unsigned cnt )
646
+cmData_t* cmDataSetShortAllocPtr(  cmData_t* p, const short* vp,          unsigned cnt )
603
 {
647
 {
604
   if( cmIsFlag(p->flags,kDynPtrDtFl) )
648
   if( cmIsFlag(p->flags,kDynPtrDtFl) )
605
-    cmMemResize(short, p->u.ucp, cnt );
649
+    p->u.sp = cmMemResize(short, p->u.sp, cnt );
606
   else
650
   else
607
   {
651
   {
608
     _cmDataFreeArray(p);
652
     _cmDataFreeArray(p);
609
-    p->u.ucp = cmMemAlloc(short, cnt );
653
+    p->u.sp = cmMemAlloc(short, cnt );
610
   }
654
   }
611
   p->tid   = kShortPtrDtId;
655
   p->tid   = kShortPtrDtId;
612
   p->flags = cmSetFlag(p->flags,kDynPtrDtFl);
656
   p->flags = cmSetFlag(p->flags,kDynPtrDtFl);
657
+  return p;
613
 }
658
 }
614
 
659
 
615
-void cmDataSetUShortAllocPtr( cmData_t* p, const unsigned short* vp, unsigned cnt )
660
+cmData_t* cmDataSetUShortAllocPtr( cmData_t* p, const unsigned short* vp, unsigned cnt )
616
 {
661
 {
617
   if( cmIsFlag(p->flags,kDynPtrDtFl) )
662
   if( cmIsFlag(p->flags,kDynPtrDtFl) )
618
-    cmMemResize(unsigned short, p->u.ucp, cnt );
663
+    p->u.usp = cmMemResize(unsigned short, p->u.usp, cnt );
619
   else
664
   else
620
   {
665
   {
621
     _cmDataFreeArray(p);
666
     _cmDataFreeArray(p);
622
-    p->u.ucp = cmMemAlloc(unsigned short, cnt );
667
+    p->u.usp = cmMemAlloc(unsigned short, cnt );
623
   }
668
   }
624
   p->tid   = kUShortPtrDtId;
669
   p->tid   = kUShortPtrDtId;
625
   p->flags = cmSetFlag(p->flags,kDynPtrDtFl);
670
   p->flags = cmSetFlag(p->flags,kDynPtrDtFl);
626
 }
671
 }
627
 
672
 
628
-void cmDataSetIntAllocPtr(    cmData_t* p, const int* vp,            unsigned cnt )
673
+cmData_t* cmDataSetIntAllocPtr(    cmData_t* p, const int* vp,            unsigned cnt )
629
 {
674
 {
630
   if( cmIsFlag(p->flags,kDynPtrDtFl) )
675
   if( cmIsFlag(p->flags,kDynPtrDtFl) )
631
-    cmMemResize(int, p->u.ucp, cnt );
676
+    p->u.ip = cmMemResize(int, p->u.ip, cnt );
632
   else
677
   else
633
   {
678
   {
634
     _cmDataFreeArray(p);
679
     _cmDataFreeArray(p);
635
-    p->u.ucp = cmMemAlloc(int, cnt );
680
+    p->u.ip = cmMemAlloc(int, cnt );
636
   }
681
   }
637
   p->tid   = kIntPtrDtId;
682
   p->tid   = kIntPtrDtId;
638
   p->flags = cmSetFlag(p->flags,kDynPtrDtFl);
683
   p->flags = cmSetFlag(p->flags,kDynPtrDtFl);
684
+  return p;
639
 }
685
 }
640
 
686
 
641
-void cmDataSetUIntAllocPtr(   cmData_t* p, const unsigned int* vp,   unsigned cnt )
687
+cmData_t* cmDataSetUIntAllocPtr(   cmData_t* p, const unsigned int* vp,   unsigned cnt )
642
 {
688
 {
643
   if( cmIsFlag(p->flags,kDynPtrDtFl) )
689
   if( cmIsFlag(p->flags,kDynPtrDtFl) )
644
-    cmMemResize(unsigned int, p->u.ucp, cnt );
690
+    p->u.uip = cmMemResize(unsigned int, p->u.uip, cnt );
645
   else
691
   else
646
   {
692
   {
647
     _cmDataFreeArray(p);
693
     _cmDataFreeArray(p);
648
-    p->u.ucp = cmMemAlloc(unsigned int, cnt );
694
+    p->u.uip = cmMemAlloc(unsigned int, cnt );
649
   }
695
   }
650
   p->tid   = kUIntPtrDtId;
696
   p->tid   = kUIntPtrDtId;
651
   p->flags = cmSetFlag(p->flags,kDynPtrDtFl);
697
   p->flags = cmSetFlag(p->flags,kDynPtrDtFl);
698
+  return p;
652
 }
699
 }
653
 
700
 
654
 
701
 
655
-void cmDataSetLongAllocPtr(   cmData_t* p, const long* vp,           unsigned cnt )
702
+cmData_t* cmDataSetLongAllocPtr(   cmData_t* p, const long* vp,           unsigned cnt )
656
 {
703
 {
657
   if( cmIsFlag(p->flags,kDynPtrDtFl) )
704
   if( cmIsFlag(p->flags,kDynPtrDtFl) )
658
-    cmMemResize(long, p->u.ucp, cnt );
705
+    p->u.lp = cmMemResize(long, p->u.lp, cnt );
659
   else
706
   else
660
   {
707
   {
661
     _cmDataFreeArray(p);
708
     _cmDataFreeArray(p);
662
-    p->u.ucp = cmMemAlloc(long, cnt );
709
+    p->u.lp = cmMemAlloc(long, cnt );
663
   }
710
   }
664
   p->tid   = kLongPtrDtId;
711
   p->tid   = kLongPtrDtId;
665
   p->flags = cmSetFlag(p->flags,kDynPtrDtFl);
712
   p->flags = cmSetFlag(p->flags,kDynPtrDtFl);
713
+  return p;
666
 }
714
 }
667
 
715
 
668
 
716
 
669
-void cmDataSetULongAllocPtr(  cmData_t* p, const unsigned long* vp,  unsigned cnt )
717
+cmData_t* cmDataSetULongAllocPtr(  cmData_t* p, const unsigned long* vp,  unsigned cnt )
670
 {
718
 {
671
   if( cmIsFlag(p->flags,kDynPtrDtFl) )
719
   if( cmIsFlag(p->flags,kDynPtrDtFl) )
672
-    cmMemResize(unsigned long, p->u.ucp, cnt );
720
+    p->u.ulp = cmMemResize(unsigned long, p->u.ulp, cnt );
673
   else
721
   else
674
   {
722
   {
675
     _cmDataFreeArray(p);
723
     _cmDataFreeArray(p);
676
-    p->u.ucp = cmMemAlloc(unsigned long, cnt );
724
+    p->u.ulp = cmMemAlloc(unsigned long, cnt );
677
   }
725
   }
678
   p->tid   = kULongPtrDtId;
726
   p->tid   = kULongPtrDtId;
679
   p->flags = cmSetFlag(p->flags,kDynPtrDtFl);
727
   p->flags = cmSetFlag(p->flags,kDynPtrDtFl);
728
+  return p;
680
 }
729
 }
681
 
730
 
682
 
731
 
683
-void cmDataSetFloatAllocPtr(  cmData_t* p, const float* vp,          unsigned cnt )
732
+cmData_t* cmDataSetFloatAllocPtr(  cmData_t* p, const float* vp,          unsigned cnt )
684
 {
733
 {
685
   if( cmIsFlag(p->flags,kDynPtrDtFl) )
734
   if( cmIsFlag(p->flags,kDynPtrDtFl) )
686
-    cmMemResize(float, p->u.ucp, cnt );
735
+    p->u.fp = cmMemResize(float, p->u.fp, cnt );
687
   else
736
   else
688
   {
737
   {
689
     _cmDataFreeArray(p);
738
     _cmDataFreeArray(p);
690
-    p->u.ucp = cmMemAlloc(float, cnt );
739
+    p->u.fp = cmMemAlloc(float, cnt );
691
   }
740
   }
692
   p->tid   = kFloatPtrDtId;
741
   p->tid   = kFloatPtrDtId;
693
   p->flags = cmSetFlag(p->flags,kDynPtrDtFl);
742
   p->flags = cmSetFlag(p->flags,kDynPtrDtFl);
743
+  return p;
694
 }
744
 }
695
 
745
 
696
 
746
 
697
-void cmDataSetDoubleAllocPtr( cmData_t* p, const double* vp,         unsigned cnt )
747
+cmData_t* cmDataSetDoubleAllocPtr( cmData_t* p, const double* vp,         unsigned cnt )
698
 {
748
 {
699
   if( cmIsFlag(p->flags,kDynPtrDtFl) )
749
   if( cmIsFlag(p->flags,kDynPtrDtFl) )
700
-    cmMemResize(double, p->u.ucp, cnt );
750
+    p->u.dp = cmMemResize(double, p->u.dp, cnt );
701
   else
751
   else
702
   {
752
   {
703
     _cmDataFreeArray(p);
753
     _cmDataFreeArray(p);
704
-    p->u.ucp = cmMemAlloc(double, cnt );
754
+    p->u.dp = cmMemAlloc(double, cnt );
705
   }
755
   }
706
   p->tid   = kDoublePtrDtId;
756
   p->tid   = kDoublePtrDtId;
707
   p->flags = cmSetFlag(p->flags,kDynPtrDtFl);
757
   p->flags = cmSetFlag(p->flags,kDynPtrDtFl);
758
+  return p;
708
 }
759
 }
709
 
760
 
710
   
761
   
711
 
762
 
712
-  // Dynamically allocate a data object and set it's value.
763
+// Dynamically allocate a data object and set it's value.
713
 cmData_t* cmDataAllocChar(   char v )
764
 cmData_t* cmDataAllocChar(   char v )
714
 {
765
 {
715
   cmData_t* p = cmMemAllocZ(cmData_t,1);
766
   cmData_t* p = cmMemAllocZ(cmData_t,1);
784
 cmData_t* cmDataAllocStr( cmChar_t* str )
835
 cmData_t* cmDataAllocStr( cmChar_t* str )
785
 {
836
 {
786
   cmData_t* p = cmMemAllocZ(cmData_t,1);
837
   cmData_t* p = cmMemAllocZ(cmData_t,1);
787
-  cmDataSetStr(p,v);
838
+  cmDataSetStr(p,str);
788
   return p;
839
   return p;
789
 }
840
 }
790
 
841
 
791
 cmData_t* cmDataAllocConstStr( const cmChar_t* str )
842
 cmData_t* cmDataAllocConstStr( const cmChar_t* str )
792
 {
843
 {
793
   cmData_t* p = cmMemAllocZ(cmData_t,1);
844
   cmData_t* p = cmMemAllocZ(cmData_t,1);
794
-  cmDataSetConstStr(p,v);
845
+  cmDataSetConstStr(p,str);
795
   return p;
846
   return p;
796
 }
847
 }
797
 
848
 
798
 // Dynamically allocate a data object and set its array value to an external
849
 // Dynamically allocate a data object and set its array value to an external
799
 // array. The data is not copied.
850
 // array. The data is not copied.
800
-cmData_t* cmDataAllocVoidPtr(   const void* v,           unsigned cnt );
851
+cmData_t* cmDataAllocVoidPtr(   const void* v,           unsigned cnt )
801
 {
852
 {
802
   cmData_t* p = cmMemAllocZ(cmData_t,1);
853
   cmData_t* p = cmMemAllocZ(cmData_t,1);
803
-  cmDataSetCharPtr(p,(const char*)v,cnt);
854
+  cmDataSetCharPtr(p,(char*)v,cnt);
855
+  p->tid = kVoidPtrDtId;
804
   return p;
856
   return p;
805
 }
857
 }
806
 
858
 
807
 cmData_t* cmDataAllocCharPtr(   const char* v,           unsigned cnt )
859
 cmData_t* cmDataAllocCharPtr(   const char* v,           unsigned cnt )
808
 {
860
 {
809
   cmData_t* p = cmMemAllocZ(cmData_t,1);
861
   cmData_t* p = cmMemAllocZ(cmData_t,1);
810
-  cmDataSetCharPtr(p,v,cnt);
862
+  cmDataSetCharPtr(p,(char*)v,cnt);
811
   return p;
863
   return p;
812
 }
864
 }
813
 
865
 
814
-  cmData_t* cmDataAllocUCharPtr(  const unsigned char* v,  unsigned cnt )
866
+cmData_t* cmDataAllocUCharPtr(  const unsigned char* v,  unsigned cnt )
815
 {
867
 {
816
   cmData_t* p = cmMemAllocZ(cmData_t,1);
868
   cmData_t* p = cmMemAllocZ(cmData_t,1);
817
-  cmDataSetUCharPtr(p,v,cnt);
869
+  cmDataSetUCharPtr(p,(unsigned char*)v,cnt);
818
   return p;
870
   return p;
819
 }
871
 }
820
 
872
 
821
-  cmData_t* cmDataAllocShortPtr(  const short* v,          unsigned cnt )
873
+cmData_t* cmDataAllocShortPtr(  const short* v,          unsigned cnt )
822
 {
874
 {
823
   cmData_t* p = cmMemAllocZ(cmData_t,1);
875
   cmData_t* p = cmMemAllocZ(cmData_t,1);
824
-  cmDataSetShortPtr(p,v,cnt);
876
+  cmDataSetShortPtr(p,(short*)v,cnt);
825
   return p;
877
   return p;
826
 }
878
 }
827
 
879
 
828
-  cmData_t* cmDataAllocUShortPtr( const unsigned short* v, unsigned cnt )
880
+cmData_t* cmDataAllocUShortPtr( const unsigned short* v, unsigned cnt )
829
 {
881
 {
830
   cmData_t* p = cmMemAllocZ(cmData_t,1);
882
   cmData_t* p = cmMemAllocZ(cmData_t,1);
831
-  cmDataSetUShortPtr(p,v,cnt);
883
+  cmDataSetUShortPtr(p,(unsigned short*)v,cnt);
832
   return p;
884
   return p;
833
 }
885
 }
834
 
886
 
835
-  cmData_t* cmDataAllocIntPtr(    const int* v,            unsigned cnt )
887
+cmData_t* cmDataAllocIntPtr(    const int* v,            unsigned cnt )
836
 {
888
 {
837
   cmData_t* p = cmMemAllocZ(cmData_t,1);
889
   cmData_t* p = cmMemAllocZ(cmData_t,1);
838
-  cmDataSetIntPtr(p,v,cnt);
890
+  cmDataSetIntPtr(p,(int*)v,cnt);
839
   return p;
891
   return p;
840
 }
892
 }
841
 
893
 
842
-  cmData_t* cmDataAllocUIntPtr(   const unsigned int* v,   unsigned cnt )
894
+cmData_t* cmDataAllocUIntPtr(   const unsigned int* v,   unsigned cnt )
843
 {
895
 {
844
   cmData_t* p = cmMemAllocZ(cmData_t,1);
896
   cmData_t* p = cmMemAllocZ(cmData_t,1);
845
-  cmDataSetUIntPtr(p,v,cnt);
897
+  cmDataSetUIntPtr(p,(unsigned int*)v,cnt);
846
   return p;
898
   return p;
847
 }
899
 }
848
 
900
 
849
-  cmData_t* cmDataAllocLongPtr(   const long* v,           unsigned cnt )
901
+cmData_t* cmDataAllocLongPtr(   const long* v,           unsigned cnt )
850
 {
902
 {
851
   cmData_t* p = cmMemAllocZ(cmData_t,1);
903
   cmData_t* p = cmMemAllocZ(cmData_t,1);
852
-  cmDataSetLongPtr(p,v,cnt);
904
+  cmDataSetLongPtr(p,(long*)v,cnt);
853
   return p;
905
   return p;
854
 }
906
 }
855
 
907
 
856
-  cmData_t* cmDataAllocULongPtr(  const unsigned long* v,  unsigned cnt )
908
+cmData_t* cmDataAllocULongPtr(  const unsigned long* v,  unsigned cnt )
857
 {
909
 {
858
   cmData_t* p = cmMemAllocZ(cmData_t,1);
910
   cmData_t* p = cmMemAllocZ(cmData_t,1);
859
-  cmDataSetULongPtr(p,v,cnt);
911
+  cmDataSetULongPtr(p,(unsigned long*)v,cnt);
860
   return p;
912
   return p;
861
 }
913
 }
862
 
914
 
863
-  cmData_t* cmDataAllocFloatPtr(  const float* v,          unsigned cnt )
915
+cmData_t* cmDataAllocFloatPtr(  const float* v,          unsigned cnt )
864
 {
916
 {
865
   cmData_t* p = cmMemAllocZ(cmData_t,1);
917
   cmData_t* p = cmMemAllocZ(cmData_t,1);
866
-  cmDataSetFloatPtr(p,v,cnt);
918
+  cmDataSetFloatPtr(p,(float*)v,cnt);
867
   return p;
919
   return p;
868
 }
920
 }
869
 
921
 
870
-  cmData_t* cmDataAllocDoublePtr( const double* v,         unsigned cnt )
922
+cmData_t* cmDataAllocDoublePtr( const double* v,         unsigned cnt )
871
 {
923
 {
872
   cmData_t* p = cmMemAllocZ(cmData_t,1);
924
   cmData_t* p = cmMemAllocZ(cmData_t,1);
873
-  cmDataSetDoublePtr(p,v,cnt);
925
+  cmDataSetDoublePtr(p,(double*)v,cnt);
874
   return p;
926
   return p;
875
 }
927
 }
876
 
928
 
956
 }
1008
 }
957
 
1009
 
958
 
1010
 
959
-void cmDataFree( cmData_t* p )
1011
+void  cmDataFree( cmData_t* p )
960
 {
1012
 {
961
   _cmDataFree(p);
1013
   _cmDataFree(p);
962
 }
1014
 }
969
 
1021
 
970
   // if this data type has a child then calculate it's size
1022
   // if this data type has a child then calculate it's size
971
   if( kMinStructDtId <= p->tid && p->tid <= kMaxStructDtId && p->u.child != NULL )
1023
   if( kMinStructDtId <= p->tid && p->tid <= kMaxStructDtId && p->u.child != NULL )
972
-    bn = cmDataSerializeByteCount(p->child);
1024
+    bn = cmDataSerializeByteCount(p->u.child);
973
   
1025
   
974
   // if this data type has siblings get their type
1026
   // if this data type has siblings get their type
975
   cmData_t* dp = p->u.child;
1027
   cmData_t* dp = p->u.child;
980
   return  _cmDataByteCount(p) + bn;
1032
   return  _cmDataByteCount(p) + bn;
981
 }
1033
 }
982
 
1034
 
983
-typedef struct
984
-{
985
-  cmDataFmtId_t tid;
986
-  unsigned      cnt;
987
-} cmDataSerialHdr_t;
988
 
1035
 
989
 
1036
 
990
 cmDtRC_t cmDataSerialize( const cmData_t* p, void* buf, unsigned bufByteCnt )
1037
 cmDtRC_t cmDataSerialize( const cmData_t* p, void* buf, unsigned bufByteCnt )

+ 136
- 39
cmData.h View File

13
 
13
 
14
   enum
14
   enum
15
   {
15
   {
16
-    kInvalidDtChar  = 0xff,
17
-    kInvalidDtUChar = 0xff,
18
-    kInvalidDtShort = 0xffff,
16
+    kInvalidDtChar   = 0xff,
17
+    kInvalidDtUChar  = 0xff,
18
+    kInvalidDtShort  = 0xffff,
19
     kInvalidDtUShort = 0xffff,
19
     kInvalidDtUShort = 0xffff,
20
     kInvalidDtInt    = 0xffffffff,
20
     kInvalidDtInt    = 0xffffffff,
21
     kInvalidDtUInt   = 0xffffffff,
21
     kInvalidDtUInt   = 0xffffffff,
172
 
172
 
173
 
173
 
174
   // Set the value of an existing data object.
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 );
175
+  cmData_t* cmDataSetChar(      cmData_t* p, char v );
176
+  cmData_t* cmDataSetUChar(     cmData_t* p, unsigned char v );
177
+  cmData_t* cmDataSetShort(     cmData_t* p, short v );
178
+  cmData_t* cmDataSetUShort(    cmData_t* p, unsigned short v );
179
+  cmData_t* cmDataSetInt(       cmData_t* p, int v );
180
+  cmData_t* cmDataSetUInt(      cmData_t* p, unsigned int v );
181
+  cmData_t* cmDataSetLong(      cmData_t* p, long v );
182
+  cmData_t* cmDataSetULong(     cmData_t* p, unsigned long v );
183
+  cmData_t* cmDataSetFloat(     cmData_t* p, float v );
184
+  cmData_t* cmDataSetDouble(    cmData_t* p, double v );
185
+  cmData_t* cmDataSetStr(       cmData_t* p, cmChar_t* s );
186
+  cmData_t* cmDataSetConstStr(  cmData_t* p, const cmChar_t* s );
187
 
187
 
188
   // Set the value of an existing data object to an external array.
188
   // Set the value of an existing data object to an external array.
189
   // The array is not copied.
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 );
190
+  cmData_t* cmDataSetVoidPtr(   cmData_t* p, void* vp,           unsigned cnt );
191
+  cmData_t* cmDataSetCharPtr(   cmData_t* p, char* vp,           unsigned cnt );
192
+  cmData_t* cmDataSetUCharPtr(  cmData_t* p, unsigned char* vp,  unsigned cnt );
193
+  cmData_t* cmDataSetShortPtr(  cmData_t* p, short* vp,          unsigned cnt );
194
+  cmData_t* cmDataSetUShortPtr( cmData_t* p, unsigned short* vp, unsigned cnt );
195
+  cmData_t* cmDataSetIntPtr(    cmData_t* p, int* vp,            unsigned cnt );
196
+  cmData_t* cmDataSetUIntPtr(   cmData_t* p, unsigned int* vp,   unsigned cnt );
197
+  cmData_t* cmDataSetLongPtr(   cmData_t* p, long* vp,           unsigned cnt );
198
+  cmData_t* cmDataSetULongPtr(  cmData_t* p, unsigned long* vp,  unsigned cnt );
199
+  cmData_t* cmDataSetFloatPtr(  cmData_t* p, float* vp,          unsigned cnt );
200
+  cmData_t* cmDataSetDoublePtr( cmData_t* p, double* vp,         unsigned cnt );
201
 
201
 
202
   // Set the value of an existing array based data object. 
202
   // Set the value of an existing array based data object. 
203
   // Allocate the internal array and copy the array into it.
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 );
204
+  cmData_t* cmDataSetStrAlloc(       cmData_t* p, const cmChar_t* s );
205
+  cmData_t* cmDataSetConstStrAlloc(  cmData_t* p, const cmChar_t* s );
206
+  cmData_t* cmDataSetVoidAllocPtr(   cmData_t* p, const void* vp,           unsigned cnt );
207
+  cmData_t* cmDataSetCharAllocPtr(   cmData_t* p, const char* vp,           unsigned cnt );
208
+  cmData_t* cmDataSetUCharAllocPtr(  cmData_t* p, const unsigned char* vp,  unsigned cnt );
209
+  cmData_t* cmDataSetShortAllocPtr(  cmData_t* p, const short* vp,          unsigned cnt );
210
+  cmData_t* cmDataSetUShortAllocPtr( cmData_t* p, const unsigned short* vp, unsigned cnt );
211
+  cmData_t* cmDataSetIntAllocPtr(    cmData_t* p, const int* vp,            unsigned cnt );
212
+  cmData_t* cmDataSetUIntAllocPtr(   cmData_t* p, const unsigned int* vp,   unsigned cnt );
213
+  cmData_t* cmDataSetLongAllocPtr(   cmData_t* p, const long* vp,           unsigned cnt );
214
+
215
+  cmData_t* cmDataSetULongAllocPtr(  cmData_t* p, const unsigned long* vp,  unsigned cnt );
216
+  cmData_t* cmDataSetFloatAllocPtr(  cmData_t* p, const float* vp,          unsigned cnt );
217
+  cmData_t* cmDataSetDoubleAllocPtr( cmData_t* p, const double* vp,         unsigned cnt );
217
   
218
   
218
 
219
 
219
   // Dynamically allocate a data object and set it's value.
220
   // Dynamically allocate a data object and set it's value.
259
   cmData_t* cmDataFloatAllocPtr(  const float* v,          unsigned cnt );
260
   cmData_t* cmDataFloatAllocPtr(  const float* v,          unsigned cnt );
260
   cmData_t* cmDataDoubleAllocPtr( const double* v,         unsigned cnt );
261
   cmData_t* cmDataDoubleAllocPtr( const double* v,         unsigned cnt );
261
 
262
 
263
+  //----------------------------------------------------------------------------
264
+  // Structure related functions
265
+  //
266
+
267
+  // Unlink 'p' from its parents and siblings.
268
+  cmData_t* cmDataUnlink( cmData_t* p );
269
+
270
+  unsigned  cmDataChildCount( cmData_t* p );
271
+  cmData_t* cmDataChild( cmData_t* p, unsigned index );
272
+
273
+  cmData_t* cmDataPrependChild(cmData_t* parent, cmData_t* parent );
274
+  cmData_t* cmDataAppendChild( cmData_t* parent, cmData_t* child );
275
+  cmData_t* cmDataInsertChild( cmData_t* parent, cmData_t* child, unsigned index );
276
+
277
+
278
+  //----------------------------------------------------------------------------
279
+  // Pair related functions
280
+  //
281
+  
282
+  // Get the key/value of a pair
283
+  cmData_t* cmDataPairKey(          cmData_t* p );
284
+  cmData_t* cmDataPairValue(        cmData_t* p );
285
+  
286
+  // Set the key or value of an existing pair node. 
287
+  cmData_t* cmDataPairSetValue(     cmData_t* p, cmData_t* value );
288
+  cmData_t* cmDataPairAllocValue(   cmData_t* p, const cmData_t* value );
289
+
290
+  cmData_t* cmDataPairSetKey(       cmData_t* p, cmData_t* key );
291
+  cmData_t* cmDataPairSetKeyId(     cmData_t* p, unsigned id );
292
+  cmData_t* cmDataPairSetKeyLabel(  cmData_t* p, const cmChar_t* label );
293
+  cmData_t* cmDataPairAllocKey(     cmData_t* p, const cmData_t* key );
294
+
295
+  // Dynamically allocate a pair node 
296
+  cmData_t* cmDataAllocPair(      cmData_t* parent, const cmData_t* key,  const cmData_t* value );
297
+  cmData_t* cmDataAllocPairId(    cmData_t* parent, unsigned  keyId,      cmData_t* value );
298
+  cmData_t* cmDataAllocPairLabel( cmData_t* parent, const cmChar_t label, cmData_t* value );
299
+
300
+  //----------------------------------------------------------------------------
301
+  // List related functions
302
+  //
303
+  
304
+  // Return the count of ele's in the list.
305
+  cmData_t* cmDataListCount(  const cmData_t* p );
306
+
307
+  // Return the ith element in the list.
308
+  cmData_t* cmDataListEle(    const cmData_t* p, unsigned index );
309
+
310
+  cmData_t* cmDataListMake(  cmData_t* parent, cmData_t* p );
311
+  cmData_t* cmDataListAlloc( cmData_t* parent);
312
+
313
+
314
+  // Var-args fmt:
315
+  // <typeId> <value> {<cnt>}
316
+  // scalar types: <value> is literal,<cnt>   is not included
317
+  // ptr    types: <value> is pointer,<cnt>   is element count
318
+  // struct types: <value> is cmData_t, <cnt> is not included
319
+  cmData_t* cmDataListAllocV(cmData_t* parent, va_list vl );
320
+  cmData_t* cmDataListAllocA(cmData_t* parent,  ... );
321
+  
322
+
323
+  cmData_t* cmDataListAppendEle( cmData_t* p, cmData_t* ele );
324
+  cmData_t* cmDataListAppendEleN(cmData_t* p, cmData_t* ele[], unsigned n );
325
+  cmDtRC_t  cmDataListAppendV(   cmData_t* p, va_list vl );
326
+  cmDtRC_t  cmDataListAppend(    cmData_t* p, ... );
327
+
328
+  cmData_t* cmDataListInsertEle( cmData_t* p, unsigned index, cmData_t* ele );
329
+  cmData_t* cmDataListInsertEleN(cmData_t* p, cmData_t* ele[], unsigned n );
330
+  cmDtRC_t  cmDataListInsertV(   cmData_t* p, va_list vl );
331
+  cmDtRC_t  cmDataListInsert(    cmData_t* p, unsigned index, ... );
332
+
333
+ 
334
+  cmData_t* cmDataListUnlink( cmData_t* p, unsigned index );
335
+  cmData_t* cmDataListFree(   cmData_t* p, unsigned index );
336
+
337
+  //----------------------------------------------------------------------------
338
+  // Record related functions
339
+  //
340
+
341
+  // Return count of pairs.
342
+  cmData_t*       cmDataRecdCount(    const cmData_t* p );
343
+
344
+  // Return the ith pair.
345
+  cmData_t*       cmDataRecdEle(      const cmData_t* p, unsigned index );
346
+
347
+  // Return the ith value.
348
+  cmData_t*       cmDataRecdValue(    const cmData_t* p, unsigned index );
349
+
350
+  // Return the ith key
351
+  cmData_t*       cmDataRecdKey(      const cmData_t* p, unsigned index );
352
+  unsigned        cmDataRecdKeyId(    const cmData_t* p, unsigned index );
353
+  const cmChar_t* cmDataRecdKeyLabel( const cmData_t* p, unsigned index );
354
+  
355
+  cmData_t*       cmRecdMake( cmData_t* p );
356
+  cmData_t*       cmRecdAlloc();
357
+  
358
+
262
   
359
   
263
 
360
 
264
   void cmDataFree( cmData_t* p );
361
   void cmDataFree( cmData_t* p );

Loading…
Cancel
Save