Ver código fonte

cmData.h/c Initialize Add

master
kpl 11 anos atrás
pai
commit
e25c92802e
2 arquivos alterados com 317 adições e 173 exclusões
  1. 181
    134
      cmData.c
  2. 136
    39
      cmData.h

+ 181
- 134
cmData.c Ver arquivo

@@ -1,17 +1,28 @@
1
+#include "cmGlobal.h"
2
+#include "cmRpt.h"
3
+#include "cmErr.h"
4
+#include "cmCtx.h"
1 5
 #include "cmData.h"
2
-
6
+#include "cmMem.h"
7
+#include "cmMallocDebug.h"
3 8
 
4 9
 cmDtRC_t _cmDataErrNo = kOkDtRC;
5 10
 
11
+typedef struct
12
+{
13
+  cmDataFmtId_t tid;
14
+  unsigned      cnt;
15
+} cmDataSerialHdr_t;
16
+
6 17
 void _cmDataFreeArray( cmData_t* p )
7 18
 {
8 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 26
   p->cnt = 0;
16 27
 }
17 28
 
@@ -22,9 +33,10 @@ void _cmDataFree( cmData_t* p )
22 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 40
   switch( p->tid )
29 41
   {
30 42
     case kInvalidDtId:   return 0;
@@ -54,38 +66,41 @@ unsigned _cmDataByteCount( cmData_t* p )
54 66
     case kFloatPtrDtId:  return n + p->cnt * sizeof(float);
55 67
     case kDoublePtrDtId: return n + p->cnt * sizeof(double);
56 68
     case kVoidPtrDtId:   return n + p->cnt * sizeof(char);
69
+
70
+    default:
71
+      return n;
57 72
   }
58 73
   assert(0);
59 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 101
 unsigned char   cmDataGetUChar(     const cmData_t* p )
87 102
 {
88
-  unsigned char v = kInvalidUChar;
103
+  unsigned char v = kInvalidDtUChar;
89 104
 
90 105
   switch( p->tid )
91 106
   {
@@ -107,7 +122,7 @@ unsigned char   cmDataGetUChar(     const cmData_t* p )
107 122
 
108 123
 char  cmDataGetChar( const cmData_t* p )
109 124
 {
110
-  char v = kInvalidChar;
125
+  char v = kInvalidDtChar;
111 126
 
112 127
   switch( p->tid )
113 128
   {
@@ -129,7 +144,7 @@ char  cmDataGetChar( const cmData_t* p )
129 144
 
130 145
 short           cmDataGetShort(     const cmData_t* p )
131 146
 {
132
-  short v = kInvalidShort;
147
+  short v = kInvalidDtShort;
133 148
 
134 149
   switch( p->tid )
135 150
   {
@@ -153,7 +168,7 @@ short           cmDataGetShort(     const cmData_t* p )
153 168
 
154 169
 unsigned short  cmDataGetUShort(    const cmData_t* p )
155 170
 {
156
-  unsigned short v = kInvalidUShort;
171
+  unsigned short v = kInvalidDtUShort;
157 172
 
158 173
   switch( p->tid )
159 174
   {
@@ -176,7 +191,7 @@ unsigned short  cmDataGetUShort(    const cmData_t* p )
176 191
 
177 192
 int             cmDataGetInt(       const cmData_t* p )
178 193
 {
179
-  int v = kInvalidInt;
194
+  int v = kInvalidDtInt;
180 195
 
181 196
   switch( p->tid )
182 197
   {
@@ -199,7 +214,7 @@ int             cmDataGetInt(       const cmData_t* p )
199 214
 
200 215
 unsigned int    cmDataGetUInt(      const cmData_t* p )
201 216
 {
202
-  unsigned int v = kInvalidUInt;
217
+  unsigned int v = kInvalidDtUInt;
203 218
 
204 219
   switch( p->tid )
205 220
   {
@@ -222,7 +237,7 @@ unsigned int    cmDataGetUInt(      const cmData_t* p )
222 237
 
223 238
 long            cmDataGetLong(      const cmData_t* p )
224 239
 {
225
-  long v = kInvalidLong;
240
+  long v = kInvalidDtLong;
226 241
 
227 242
   switch( p->tid )
228 243
   {
@@ -245,7 +260,7 @@ long            cmDataGetLong(      const cmData_t* p )
245 260
 
246 261
 unsigned long   cmDataGetULong(     const cmData_t* p )
247 262
 {
248
-  unsigned long v = kInvalidULong;
263
+  unsigned long v = kInvalidDtULong;
249 264
 
250 265
   switch( p->tid )
251 266
   {
@@ -268,7 +283,7 @@ unsigned long   cmDataGetULong(     const cmData_t* p )
268 283
 
269 284
 float           cmDataGetFloat(     const cmData_t* p )
270 285
 {
271
-  float v = kInvalidChar;
286
+  float v = FLT_MAX;
272 287
 
273 288
   switch( p->tid )
274 289
   {
@@ -291,7 +306,7 @@ float           cmDataGetFloat(     const cmData_t* p )
291 306
 
292 307
 double          cmDataGetDouble(    const cmData_t* p )
293 308
 {
294
-  double v = kInvalidChar;
309
+  double v = DBL_MAX;
295 310
 
296 311
   switch( p->tid )
297 312
   {
@@ -325,9 +340,6 @@ const cmChar_t* cmDataGetConstStr(  const cmData_t* p )
325 340
 }
326 341
 
327 342
 void*           cmDataGetVoidPtr(   const cmData_t* p )
328
-{ return cmDataVoidPtr(p); }
329
-
330
-void*           cmDataGetVoidPtr(   const cmData_t* p )
331 343
 {
332 344
   assert( kMinPtrDtId <= p->tid && p->tid <= kMaxPtrDtId );
333 345
   return ( kMinPtrDtId <= p->tid && p->tid <= kMaxPtrDtId ) ? p->u.vp : NULL;  
@@ -388,208 +400,239 @@ double*         cmDataGetDoublePtr( const cmData_t* p )
388 400
 { return p->tid == kDoublePtrDtId ? p->u.dp : NULL; }
389 401
 
390 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 405
   _cmDataFreeArray(p);
394 406
   p->tid = kCharDtId;
395 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 413
   _cmDataFreeArray(p);
401 414
   p->tid = kUCharDtId;
402 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 421
   _cmDataFreeArray(p);
408 422
   p->tid = kShortDtId;
409 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 429
   _cmDataFreeArray(p);
414 430
   p->tid = kUShortDtId;
415 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 437
   _cmDataFreeArray(p);
420 438
   p->tid = kCharDtId;
421 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 444
   _cmDataFreeArray(p);
426 445
   p->tid = kUIntDtId;
427 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 452
   _cmDataFreeArray(p);
432 453
   p->tid = kLongDtId;
433 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 459
   _cmDataFreeArray(p);
438 460
   p->tid = kULongDtId;
439 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 467
   _cmDataFreeArray(p);
444 468
   p->tid = kFloatDtId;
445 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 475
   _cmDataFreeArray(p);
450 476
   p->tid = kDoubleDtId;
451 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 483
   _cmDataFreeArray(p);
457 484
   p->tid = kStrDtId;
458 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 491
   _cmDataFreeArray(p);
464 492
   p->tid = kConstStrDtId;
465 493
   p->u.cz = s;
494
+  return p;
466 495
 }
467 496
 
468 497
 // Set the value of an existing data object to an external array.
469 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 508
   _cmDataFreeArray(p);
478 509
   p->tid  = kCharPtrDtId;
479 510
   p->u.cp = vp;
480 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 517
   _cmDataFreeArray(p);
486 518
   p->tid  = kUCharPtrDtId;
487 519
   p->u.ucp = vp;
488 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 526
   _cmDataFreeArray(p);
494 527
   p->tid  = kShortPtrDtId;
495 528
   p->u.sp = vp;
496 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 535
   _cmDataFreeArray(p);
502 536
   p->tid   = kUShortPtrDtId;
503 537
   p->u.usp = vp;
504 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 544
   _cmDataFreeArray(p);
510 545
   p->tid  = kCharPtrDtId;
511
-  p->u.cp = vp;
546
+  p->u.ip = vp;
512 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 553
   _cmDataFreeArray(p);
518 554
   p->tid   = kUIntPtrDtId;
519 555
   p->u.uip = vp;
520 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 562
   _cmDataFreeArray(p);
526 563
   p->tid  = kLongPtrDtId;
527 564
   p->u.lp = vp;
528 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 571
   _cmDataFreeArray(p);
534 572
   p->tid   = kULongPtrDtId;
535 573
   p->u.ulp = vp;
536 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 580
   _cmDataFreeArray(p);
542 581
   p->tid  = kFloatPtrDtId;
543 582
   p->u.fp = vp;
544 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 589
   _cmDataFreeArray(p);
550 590
   p->tid  = kDoublePtrDtId;
551 591
   p->u.dp = vp;
552 592
   p->cnt  = cnt;
593
+  return p;
553 594
 }
554 595
 
555 596
 // Set the value of an existing array based data object. 
556 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 600
   if( cmIsFlag(p->flags,kDynPtrDtFl) )
560 601
     cmMemResizeStr(p->u.z,s);
561 602
   else
562 603
   {
563 604
     _cmDataFreeArray(p);
564
-    cmMemAllocStr(p->u.z,s);
605
+    p->u.z = cmMemAllocStr(s);
565 606
   }
566 607
   p->tid    = kStrDtId;
567 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 620
   if( cmIsFlag(p->flags,kDynPtrDtFl) )
579
-    cmMemResize(char, p->u.ucp, cnt );
621
+    p->u.cp = cmMemResize(char, p->u.cp, cnt );
580 622
   else
581 623
   {
582 624
     _cmDataFreeArray(p);
583
-    p->u.ucp = cmMemAlloc(char, cnt );
625
+    p->u.cp = cmMemAlloc(char, cnt );
584 626
   }
585 627
   p->tid   = kCharPtrDtId;
586 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 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 636
   else
594 637
   {
595 638
     _cmDataFreeArray(p);
@@ -597,119 +640,127 @@ void cmDataSetUCharAllocPtr(  cmData_t* p, const unsigned char* vp,  unsigned cn
597 640
   }
598 641
   p->tid   = kUCharPtrDtId;
599 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 648
   if( cmIsFlag(p->flags,kDynPtrDtFl) )
605
-    cmMemResize(short, p->u.ucp, cnt );
649
+    p->u.sp = cmMemResize(short, p->u.sp, cnt );
606 650
   else
607 651
   {
608 652
     _cmDataFreeArray(p);
609
-    p->u.ucp = cmMemAlloc(short, cnt );
653
+    p->u.sp = cmMemAlloc(short, cnt );
610 654
   }
611 655
   p->tid   = kShortPtrDtId;
612 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 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 664
   else
620 665
   {
621 666
     _cmDataFreeArray(p);
622
-    p->u.ucp = cmMemAlloc(unsigned short, cnt );
667
+    p->u.usp = cmMemAlloc(unsigned short, cnt );
623 668
   }
624 669
   p->tid   = kUShortPtrDtId;
625 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 675
   if( cmIsFlag(p->flags,kDynPtrDtFl) )
631
-    cmMemResize(int, p->u.ucp, cnt );
676
+    p->u.ip = cmMemResize(int, p->u.ip, cnt );
632 677
   else
633 678
   {
634 679
     _cmDataFreeArray(p);
635
-    p->u.ucp = cmMemAlloc(int, cnt );
680
+    p->u.ip = cmMemAlloc(int, cnt );
636 681
   }
637 682
   p->tid   = kIntPtrDtId;
638 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 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 691
   else
646 692
   {
647 693
     _cmDataFreeArray(p);
648
-    p->u.ucp = cmMemAlloc(unsigned int, cnt );
694
+    p->u.uip = cmMemAlloc(unsigned int, cnt );
649 695
   }
650 696
   p->tid   = kUIntPtrDtId;
651 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 704
   if( cmIsFlag(p->flags,kDynPtrDtFl) )
658
-    cmMemResize(long, p->u.ucp, cnt );
705
+    p->u.lp = cmMemResize(long, p->u.lp, cnt );
659 706
   else
660 707
   {
661 708
     _cmDataFreeArray(p);
662
-    p->u.ucp = cmMemAlloc(long, cnt );
709
+    p->u.lp = cmMemAlloc(long, cnt );
663 710
   }
664 711
   p->tid   = kLongPtrDtId;
665 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 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 721
   else
674 722
   {
675 723
     _cmDataFreeArray(p);
676
-    p->u.ucp = cmMemAlloc(unsigned long, cnt );
724
+    p->u.ulp = cmMemAlloc(unsigned long, cnt );
677 725
   }
678 726
   p->tid   = kULongPtrDtId;
679 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 734
   if( cmIsFlag(p->flags,kDynPtrDtFl) )
686
-    cmMemResize(float, p->u.ucp, cnt );
735
+    p->u.fp = cmMemResize(float, p->u.fp, cnt );
687 736
   else
688 737
   {
689 738
     _cmDataFreeArray(p);
690
-    p->u.ucp = cmMemAlloc(float, cnt );
739
+    p->u.fp = cmMemAlloc(float, cnt );
691 740
   }
692 741
   p->tid   = kFloatPtrDtId;
693 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 749
   if( cmIsFlag(p->flags,kDynPtrDtFl) )
700
-    cmMemResize(double, p->u.ucp, cnt );
750
+    p->u.dp = cmMemResize(double, p->u.dp, cnt );
701 751
   else
702 752
   {
703 753
     _cmDataFreeArray(p);
704
-    p->u.ucp = cmMemAlloc(double, cnt );
754
+    p->u.dp = cmMemAlloc(double, cnt );
705 755
   }
706 756
   p->tid   = kDoublePtrDtId;
707 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 764
 cmData_t* cmDataAllocChar(   char v )
714 765
 {
715 766
   cmData_t* p = cmMemAllocZ(cmData_t,1);
@@ -784,93 +835,94 @@ cmData_t* cmDataAllocDouble( double v )
784 835
 cmData_t* cmDataAllocStr( cmChar_t* str )
785 836
 {
786 837
   cmData_t* p = cmMemAllocZ(cmData_t,1);
787
-  cmDataSetStr(p,v);
838
+  cmDataSetStr(p,str);
788 839
   return p;
789 840
 }
790 841
 
791 842
 cmData_t* cmDataAllocConstStr( const cmChar_t* str )
792 843
 {
793 844
   cmData_t* p = cmMemAllocZ(cmData_t,1);
794
-  cmDataSetConstStr(p,v);
845
+  cmDataSetConstStr(p,str);
795 846
   return p;
796 847
 }
797 848
 
798 849
 // Dynamically allocate a data object and set its array value to an external
799 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 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 856
   return p;
805 857
 }
806 858
 
807 859
 cmData_t* cmDataAllocCharPtr(   const char* v,           unsigned cnt )
808 860
 {
809 861
   cmData_t* p = cmMemAllocZ(cmData_t,1);
810
-  cmDataSetCharPtr(p,v,cnt);
862
+  cmDataSetCharPtr(p,(char*)v,cnt);
811 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 868
   cmData_t* p = cmMemAllocZ(cmData_t,1);
817
-  cmDataSetUCharPtr(p,v,cnt);
869
+  cmDataSetUCharPtr(p,(unsigned char*)v,cnt);
818 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 875
   cmData_t* p = cmMemAllocZ(cmData_t,1);
824
-  cmDataSetShortPtr(p,v,cnt);
876
+  cmDataSetShortPtr(p,(short*)v,cnt);
825 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 882
   cmData_t* p = cmMemAllocZ(cmData_t,1);
831
-  cmDataSetUShortPtr(p,v,cnt);
883
+  cmDataSetUShortPtr(p,(unsigned short*)v,cnt);
832 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 889
   cmData_t* p = cmMemAllocZ(cmData_t,1);
838
-  cmDataSetIntPtr(p,v,cnt);
890
+  cmDataSetIntPtr(p,(int*)v,cnt);
839 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 896
   cmData_t* p = cmMemAllocZ(cmData_t,1);
845
-  cmDataSetUIntPtr(p,v,cnt);
897
+  cmDataSetUIntPtr(p,(unsigned int*)v,cnt);
846 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 903
   cmData_t* p = cmMemAllocZ(cmData_t,1);
852
-  cmDataSetLongPtr(p,v,cnt);
904
+  cmDataSetLongPtr(p,(long*)v,cnt);
853 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 910
   cmData_t* p = cmMemAllocZ(cmData_t,1);
859
-  cmDataSetULongPtr(p,v,cnt);
911
+  cmDataSetULongPtr(p,(unsigned long*)v,cnt);
860 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 917
   cmData_t* p = cmMemAllocZ(cmData_t,1);
866
-  cmDataSetFloatPtr(p,v,cnt);
918
+  cmDataSetFloatPtr(p,(float*)v,cnt);
867 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 924
   cmData_t* p = cmMemAllocZ(cmData_t,1);
873
-  cmDataSetDoublePtr(p,v,cnt);
925
+  cmDataSetDoublePtr(p,(double*)v,cnt);
874 926
   return p;
875 927
 }
876 928
 
@@ -956,7 +1008,7 @@ cmData_t* cmDataDoubleAllocPtr( const double* v,         unsigned cnt )
956 1008
 }
957 1009
 
958 1010
 
959
-void cmDataFree( cmData_t* p )
1011
+void  cmDataFree( cmData_t* p )
960 1012
 {
961 1013
   _cmDataFree(p);
962 1014
 }
@@ -969,7 +1021,7 @@ unsigned cmDataSerializeByteCount( const cmData_t* p )
969 1021
 
970 1022
   // if this data type has a child then calculate it's size
971 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 1026
   // if this data type has siblings get their type
975 1027
   cmData_t* dp = p->u.child;
@@ -980,11 +1032,6 @@ unsigned cmDataSerializeByteCount( const cmData_t* p )
980 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 1037
 cmDtRC_t cmDataSerialize( const cmData_t* p, void* buf, unsigned bufByteCnt )

+ 136
- 39
cmData.h Ver arquivo

@@ -13,9 +13,9 @@ extern "C" {
13 13
 
14 14
   enum
15 15
   {
16
-    kInvalidDtChar  = 0xff,
17
-    kInvalidDtUChar = 0xff,
18
-    kInvalidDtShort = 0xffff,
16
+    kInvalidDtChar   = 0xff,
17
+    kInvalidDtUChar  = 0xff,
18
+    kInvalidDtShort  = 0xffff,
19 19
     kInvalidDtUShort = 0xffff,
20 20
     kInvalidDtInt    = 0xffffffff,
21 21
     kInvalidDtUInt   = 0xffffffff,
@@ -172,48 +172,49 @@ extern "C" {
172 172
 
173 173
 
174 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 188
   // Set the value of an existing data object to an external array.
189 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 202
   // Set the value of an existing array based data object. 
203 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 220
   // Dynamically allocate a data object and set it's value.
@@ -259,6 +260,102 @@ extern "C" {
259 260
   cmData_t* cmDataFloatAllocPtr(  const float* v,          unsigned cnt );
260 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 361
   void cmDataFree( cmData_t* p );

Carregando…
Cancelar
Salvar