Przeglądaj źródła

cmData.h/c : More changes - that won't fully compile.

master
kpl 11 lat temu
rodzic
commit
c809469b62
2 zmienionych plików z 269 dodań i 2055 usunięć
  1. 261
    1709
      cmData.c
  2. 8
    346
      cmData.h

+ 261
- 1709
cmData.c
Plik diff jest za duży
Wyświetl plik


+ 8
- 346
cmData.h Wyświetl plik

@@ -75,7 +75,8 @@ extern "C" {
75 75
     kFloatDtId,      // 10 
76 76
     kDoubleDtId,     // 11 
77 77
     kStrDtId,        // 12 zero terminated string
78
-    kBlobDtId        // 13 application defined raw memory object
78
+    kBlobDtId,       // 13 application defined raw memory object
79
+    kStructDtId      // 14 node is a pair,list, or recd
79 80
   } cmDataTypeId_t;
80 81
 
81 82
 
@@ -425,341 +426,6 @@ extern "C" {
425 426
   cmData_t* cmDataInsertChild( cmData_t* parent, unsigned index, cmData_t* p );
426 427
 
427 428
 
428
-
429
-////////////////////////////////////////////////////////////////////////////////////////////////
430
-////////////////////////////////////////////////////////////////////////////////////////////////
431
-////////////////////////////////////////////////////////////////////////////////////////////////
432
-////////////////////////////////////////////////////////////////////////////////////////////////
433
-
434
-#ifdef NOT_DEF
435
-  typedef enum
436
-  {
437
-    kInvalidDtId,
438
-
439
-    kMinValDtId,
440
-
441
-    kNullDtId = kMinValDtId,
442
-    kUCharDtId,
443
-    kCharDtId,
444
-    kUShortDtId,
445
-    kShortDtId,
446
-    kUIntDtId,
447
-    kIntDtId,
448
-    kULongDtId,
449
-    kLongDtId,
450
-    kFloatDtId,
451
-    kDoubleDtId,
452
-
453
-    kStrDtId,
454
-    kConstStrDtId,
455
-    kMaxValDtId = kConstStrDtId,
456
-
457
-    kMinPtrDtId,
458
-    kUCharPtrDtId = kMinPtrDtId,  // cnt=array element count
459
-    kCharPtrDtId,
460
-    kUShortPtrDtId,
461
-    kShortPtrDtId,
462
-    kUIntPtrDtId,
463
-    kIntPtrDtId,
464
-    kULongPtrDtId,
465
-    kLongPtrDtId,
466
-    kFloatPtrDtId,
467
-    kDoublePtrDtId,
468
-    kVoidPtrDtId,
469
-    kMaxPtrDtId = kVoidPtrDtId,
470
-
471
-    kMinStructDtId,
472
-    kListDtId = kMinStructDtId, // children nodes are array elements, cnt=child count
473
-    kPairDtId,                   // key/value pairs, cnt=2, first child is key, second is value
474
-    kRecordDtId,                 // children nodes are pairs, cnt=pair count
475
-    kMaxStructDtId,
476
-
477
-    kOptArgDtFl = 0x80000000
478
-  } cmDataFmtId_t;
479
-
480
-  enum
481
-  {
482
-    kDynObjDtFl = 0x01,  // object was dynamically allocated
483
-    kDynPtrDtFl = 0x02   // ptr array was dynamically allocated
484
-  };
485
-
486
-  typedef struct cmData_str
487
-  {
488
-    cmDataFmtId_t      tid;       // data format id
489
-    unsigned           flags;     // 
490
-    struct cmData_str* parent;    // this childs parent
491
-    struct cmData_str* sibling;   // this childs left sibling
492
-    unsigned           cnt;       // array ele count
493
-
494
-    union
495
-    {
496
-      char              c;
497
-      unsigned char    uc;
498
-      short             s;
499
-      unsigned short   us;
500
-      int               i;
501
-      unsigned int     ui;
502
-      long              l;
503
-      unsigned long    ul;
504
-      float             f;
505
-      double            d;
506
-
507
-      cmChar_t*         z;
508
-      const cmChar_t*  cz;
509
-
510
-      void*             vp;
511
-
512
-      char*             cp;
513
-      unsigned char*   ucp;
514
-      short*            sp;
515
-      unsigned short*  usp;
516
-      int*              ip;
517
-      unsigned int*    uip;
518
-      long*             lp;
519
-      unsigned long*   ulp;
520
-      float*            fp;
521
-      double*           dp;
522
-
523
-
524
-      struct cmData_str* child; // first child (array,record,pair)
525
-    } u;
526
-  
527
-  } cmData_t;
528
-
529
-  typedef unsigned cmDtRC_t;
530
-
531
-  extern cmData_t cmDataNull;
532
-
533
-  bool cmDataIsValue(  const cmData_t* p );
534
-  bool cmDataIsPtr(    const cmData_t* p );
535
-  bool cmDataIsStruct( const cmData_t* p ); // is a pair,list or record
536
-
537
-
538
-  bool canConvertType( cmDataFmtId_t srcId, cmDataFmtId_t dstId );
539
-  bool willTruncate(   cmDataFmtId_t srcId, cmDataFmtId_t dstId );
540
-  bool canConvertObj(  const cmData_t* srcObj, cmData_t* dstObj );
541
-  bool willTruncateObj(const cmData_t* srcObj, cmData_t* dstObj );
542
-    
543
-  
544
-
545
-  // Get the value of an object without conversion.
546
-  // The data type id must match the return type or the
547
-  // conversion must be an automatic C conversion.
548
-  char            cmDataChar(      const cmData_t* p );
549
-  unsigned char   cmDataUChar(     const cmData_t* p );
550
-  short           cmDataShort(     const cmData_t* p );
551
-  unsigned short  cmDataUShort(    const cmData_t* p );
552
-  int             cmDataInt(       const cmData_t* p );
553
-  unsigned int    cmDataUInt(      const cmData_t* p );
554
-  long            cmDataLong(      const cmData_t* p );
555
-  unsigned long   cmDataULong(     const cmData_t* p );
556
-  float           cmDataFloat(     const cmData_t* p );
557
-  double          cmDataDouble(    const cmData_t* p );
558
-  cmChar_t*       cmDataStr(       const cmData_t* p );
559
-  const cmChar_t* cmDataConstStr(  const cmData_t* p );
560
-  void*           cmDataVoidPtr(   const cmData_t* p );
561
-  char*           cmDataCharPtr(   const cmData_t* p );
562
-  unsigned char*  cmDataUCharPtr(  const cmData_t* p );
563
-  short*          cmDataShortPtr(  const cmData_t* p );
564
-  unsigned short* cmDataUShortPtr( const cmData_t* p );
565
-  int*            cmDataIntPtr(    const cmData_t* p );
566
-  unsigned int*   cmDataUIntPtr(   const cmData_t* p );
567
-  long*           cmDataLongPtr(   const cmData_t* p );
568
-  unsigned long*  cmDataULongPtr(  const cmData_t* p );
569
-  float*          cmDataFloatPtr(  const cmData_t* p );
570
-  double*         cmDataDoublePtr( const cmData_t* p );
571
-
572
-
573
-  // Get the value of an object with conversion.
574
-  cmDtRC_t cmDataGetChar(      const cmData_t* p, char* v );
575
-  cmDtRC_t cmDataGetUChar(     const cmData_t* p, unsigned char* v );
576
-  cmDtRC_t cmDataGetShort(     const cmData_t* p, short* v );
577
-  cmDtRC_t cmDataGetUShort(    const cmData_t* p, unsigned short* v );
578
-  cmDtRC_t cmDataGetInt(       const cmData_t* p, int* v );
579
-  cmDtRC_t cmDataGetUInt(      const cmData_t* p, unsigned int* v );
580
-  cmDtRC_t cmDataGetLong(      const cmData_t* p, long* v );
581
-  cmDtRC_t cmDataGetULong(     const cmData_t* p, unsigned long* v );
582
-  cmDtRC_t cmDataGetFloat(     const cmData_t* p, float* v );
583
-  cmDtRC_t cmDataGetDouble(    const cmData_t* p, double* v );
584
-
585
-  // Returns the pointer - does not copy the data.
586
-  cmDtRC_t cmDataGetStr(       const cmData_t* p, char** v );
587
-  cmDtRC_t cmDataGetConstStr(  const cmData_t* p, const char** v );
588
-  cmDtRC_t cmDataGetVoidPtr(   const cmData_t* p, void** v );
589
-  cmDtRC_t cmDataGetCharPtr(   const cmData_t* p, char** v );
590
-  cmDtRC_t cmDataGetUCharPtr(  const cmData_t* p, unsigned char** v );
591
-  cmDtRC_t cmDataGetShortPtr(  const cmData_t* p, short** v );
592
-  cmDtRC_t cmDataGetUShortPtr( const cmData_t* p, unsigned short** v );
593
-  cmDtRC_t cmDataGetIntPtr(    const cmData_t* p, int** v );
594
-  cmDtRC_t cmDataGetUIntPtr(   const cmData_t* p, unsigned int** v );
595
-  cmDtRC_t cmDataGetLongPtr(   const cmData_t* p, long** v );
596
-  cmDtRC_t cmDataGetULongPtr(  const cmData_t* p, unsigned long** v );
597
-  cmDtRC_t cmDataGetFloatPtr(  const cmData_t* p, float** v );
598
-  cmDtRC_t cmDataGetDoublePtr( const cmData_t* p, double** v );
599
-
600
-
601
-  // Set the value and type of an existing scalar object. 
602
-  // These functions begin by releasing any resources held by *p
603
-  // prior to resetting the type and value of the object.
604
-  cmData_t* cmDataSetNull(      cmData_t* p );
605
-  cmData_t* cmDataSetChar(      cmData_t* p, char v );
606
-  cmData_t* cmDataSetUChar(     cmData_t* p, unsigned char v );
607
-  cmData_t* cmDataSetShort(     cmData_t* p, short v );
608
-  cmData_t* cmDataSetUShort(    cmData_t* p, unsigned short v );
609
-  cmData_t* cmDataSetInt(       cmData_t* p, int v );
610
-  cmData_t* cmDataSetUInt(      cmData_t* p, unsigned int v );
611
-  cmData_t* cmDataSetLong(      cmData_t* p, long v );
612
-  cmData_t* cmDataSetULong(     cmData_t* p, unsigned long v );
613
-  cmData_t* cmDataSetFloat(     cmData_t* p, float v );
614
-  cmData_t* cmDataSetDouble(    cmData_t* p, double v );
615
-  cmData_t* cmDataSetStr(       cmData_t* p, cmChar_t* s );
616
-  cmData_t* cmDataSetConstStr(  cmData_t* p, const cmChar_t* s );
617
-
618
-  // Set the type and value of an existing data object to an external array.
619
-  // These functions begin by releasing any resources help by *p.
620
-  // The array pointed to by 'vp' is not copied or duplicated.
621
-  // 'vp' is simply assigned as the data space for the object and therefore must remain
622
-  // valid for the life of the object.
623
-  cmData_t* cmDataSetVoidPtr(   cmData_t* p, void* vp,           unsigned cnt );
624
-  cmData_t* cmDataSetCharPtr(   cmData_t* p, char* vp,           unsigned cnt );
625
-  cmData_t* cmDataSetUCharPtr(  cmData_t* p, unsigned char* vp,  unsigned cnt );
626
-  cmData_t* cmDataSetShortPtr(  cmData_t* p, short* vp,          unsigned cnt );
627
-  cmData_t* cmDataSetUShortPtr( cmData_t* p, unsigned short* vp, unsigned cnt );
628
-  cmData_t* cmDataSetIntPtr(    cmData_t* p, int* vp,            unsigned cnt );
629
-  cmData_t* cmDataSetUIntPtr(   cmData_t* p, unsigned int* vp,   unsigned cnt );
630
-  cmData_t* cmDataSetLongPtr(   cmData_t* p, long* vp,           unsigned cnt );
631
-  cmData_t* cmDataSetULongPtr(  cmData_t* p, unsigned long* vp,  unsigned cnt );
632
-  cmData_t* cmDataSetFloatPtr(  cmData_t* p, float* vp,          unsigned cnt );
633
-  cmData_t* cmDataSetDoublePtr( cmData_t* p, double* vp,         unsigned cnt );
634
-
635
-  // Set the value of an existing array based data object. 
636
-  // These functions begin by releasing any resources help by *p
637
-  // and then dynamically allocate the internal array and copy 
638
-  // the array data into it.
639
-  cmData_t* cmDataSetStrAllocN(      cmData_t* p, const cmChar_t* s, unsigned charCnt );
640
-  cmData_t* cmDataSetStrAlloc(       cmData_t* p, const cmChar_t* s );
641
-  cmData_t* cmDataSetConstStrAllocN( cmData_t* p, const cmChar_t* s, unsigned charCnt );
642
-  cmData_t* cmDataSetConstStrAlloc(  cmData_t* p, const cmChar_t* s );
643
-  cmData_t* cmDataSetVoidAllocPtr(   cmData_t* p, const void* vp,           unsigned cnt );
644
-  cmData_t* cmDataSetCharAllocPtr(   cmData_t* p, const char* vp,           unsigned cnt );
645
-  cmData_t* cmDataSetUCharAllocPtr(  cmData_t* p, const unsigned char* vp,  unsigned cnt );
646
-  cmData_t* cmDataSetShortAllocPtr(  cmData_t* p, const short* vp,          unsigned cnt );
647
-  cmData_t* cmDataSetUShortAllocPtr( cmData_t* p, const unsigned short* vp, unsigned cnt );
648
-  cmData_t* cmDataSetIntAllocPtr(    cmData_t* p, const int* vp,            unsigned cnt );
649
-  cmData_t* cmDataSetUIntAllocPtr(   cmData_t* p, const unsigned int* vp,   unsigned cnt );
650
-  cmData_t* cmDataSetLongAllocPtr(   cmData_t* p, const long* vp,           unsigned cnt );
651
-  cmData_t* cmDataSetULongAllocPtr(  cmData_t* p, const unsigned long* vp,  unsigned cnt );
652
-  cmData_t* cmDataSetFloatAllocPtr(  cmData_t* p, const float* vp,          unsigned cnt );
653
-  cmData_t* cmDataSetDoubleAllocPtr( cmData_t* p, const double* vp,         unsigned cnt );
654
-  
655
-
656
-  // Dynamically allocate a data object and set it's value.
657
-  cmData_t* cmDataAllocNull(   cmData_t* parent );
658
-  cmData_t* cmDataAllocChar(   cmData_t* parent, char v );
659
-  cmData_t* cmDataAllocUChar(  cmData_t* parent, unsigned char v );
660
-  cmData_t* cmDataAllocShort(  cmData_t* parent, short v );
661
-  cmData_t* cmDataAllocUShort( cmData_t* parent, unsigned short v );
662
-  cmData_t* cmDataAllocInt(    cmData_t* parent, int v );
663
-  cmData_t* cmDataAllocUInt(   cmData_t* parent, unsigned int v );
664
-  cmData_t* cmDataAllocLong(   cmData_t* parent, long v );
665
-  cmData_t* cmDataAllocULong(  cmData_t* parent, unsigned long v );
666
-  cmData_t* cmDataAllocFloat(  cmData_t* parent, float v );
667
-  cmData_t* cmDataAllocDouble( cmData_t* parent, double v );
668
-
669
-  // Dynamically allocate a data object and set its array value to an external
670
-  // array. v[cnt] is assigned as the internal data space for the object and 
671
-  // therefore must remain valid for the life of the object. 
672
-  // See the cmDataXXXAlocPtr() for equivalent functions which dynamically 
673
-  // allocate the intenal data space.
674
-  cmData_t* cmDataAllocStr(       cmData_t* parent, cmChar_t* str );
675
-  cmData_t* cmDataAllocConstStr(  cmData_t* parent, const cmChar_t* str );
676
-  cmData_t* cmDataAllocCharPtr(   cmData_t* parent, char* v,           unsigned cnt );
677
-  cmData_t* cmDataAllocUCharPtr(  cmData_t* parent, unsigned char* v,  unsigned cnt );
678
-  cmData_t* cmDataAllocShortPtr(  cmData_t* parent, short* v,          unsigned cnt );
679
-  cmData_t* cmDataAllocUShortPtr( cmData_t* parent, unsigned short* v, unsigned cnt );
680
-  cmData_t* cmDataAllocIntPtr(    cmData_t* parent, int* v,            unsigned cnt );
681
-  cmData_t* cmDataAllocUIntPtr(   cmData_t* parent, unsigned int* v,   unsigned cnt );
682
-  cmData_t* cmDataAllocLongPtr(   cmData_t* parent, long* v,           unsigned cnt );
683
-  cmData_t* cmDataAllocULongPtr(  cmData_t* parent, unsigned long* v,  unsigned cnt );
684
-  cmData_t* cmDataAllocFloatPtr(  cmData_t* parent, float* v,          unsigned cnt );
685
-  cmData_t* cmDataAllocDoublePtr( cmData_t* parent, double* v,         unsigned cnt );
686
-  cmData_t* cmDataAllocVoidPtr(   cmData_t* parent, void* v,           unsigned cnt );
687
-
688
-
689
-  // Dynamically allocate a data object and its array value.  
690
-  // These functions dynamically allocate the internal array data space
691
-  // and copy v[cnt] into it.
692
-  cmData_t* cmDataStrAlloc(       cmData_t* parent, cmChar_t* str );
693
-  cmData_t* cmDataConstStrAlloc(  cmData_t* parent, const cmChar_t* str );
694
-  cmData_t* cmDataConstStrAllocN( cmData_t* parent, const cmChar_t* str, unsigned charCnt );
695
-  cmData_t* cmDataCharAllocPtr(   cmData_t* parent, const char* v,           unsigned cnt );
696
-  cmData_t* cmDataUCharAllocPtr(  cmData_t* parent, const unsigned char* v,  unsigned cnt );
697
-  cmData_t* cmDataShortAllocPtr(  cmData_t* parent, const short* v,          unsigned cnt );
698
-  cmData_t* cmDataUShortAllocPtr( cmData_t* parent, const unsigned short* v, unsigned cnt );
699
-  cmData_t* cmDataIntAllocPtr(    cmData_t* parent, const int* v,            unsigned cnt );
700
-  cmData_t* cmDataUIntAllocPtr(   cmData_t* parent, const unsigned int* v,   unsigned cnt );
701
-  cmData_t* cmDataLongAllocPtr(   cmData_t* parent, const long* v,           unsigned cnt );
702
-  cmData_t* cmDataULongAllocPtr(  cmData_t* parent, const unsigned long* v,  unsigned cnt );
703
-  cmData_t* cmDataFloatAllocPtr(  cmData_t* parent, const float* v,          unsigned cnt );
704
-  cmData_t* cmDataDoubleAllocPtr( cmData_t* parent, const double* v,         unsigned cnt );
705
-  cmData_t* cmDataVoidAllocPtr(   cmData_t* parent, const void* v,           unsigned cnt );
706
-
707
-  //----------------------------------------------------------------------------
708
-  // Structure related functions
709
-  //
710
-
711
-  // Release an object and any resources held by it.
712
-  // Note the this function does not unlink the object
713
-  // from it's parent.  Use cmDataUnlinkAndFree()
714
-  // to remove a object from it's parent list prior
715
-  // to releasing it.
716
-  void      cmDataFree( cmData_t* p );
717
-
718
-  // Unlink 'p' from its parents and siblings.
719
-  // Asserts if parent is not a structure. 
720
-  // Returns 'p'.
721
-  cmData_t* cmDataUnlink( cmData_t* p );
722
-
723
-  // Wrapper function to cmDataUnlink() and cmDataFree().
724
-  void      cmDataUnlinkAndFree( cmData_t* p );
725
-
726
-  // Replace the 'dst' node with the 'src' node and
727
-  // return 'src'.  This operation does not duplicate
728
-  // 'src' it simply links in 'src' at the location of
729
-  // 'dst' and then unlinks and free's 'dst'.
730
-  cmData_t* cmDataReplace( cmData_t* dst, cmData_t* src );
731
-
732
-  // Return the count of child nodes.
733
-  // 1. Array nodes have one child per array element.
734
-  // 2. List nodes have one child pair.
735
-  // 3. Pair nodes have two children.
736
-  // 4. Leaf nodes have 0 children.
737
-  unsigned  cmDataChildCount( const cmData_t* p );
738
-
739
-  // Returns the ith child of 'p'.
740
-  // Returns NULL if p has no children or index is invalid.
741
-  cmData_t* cmDataChild( cmData_t* p, unsigned index );
742
-
743
-  // Prepend 'p' to 'parents' child list.
744
-  // The source node 'p' is not duplicated  it is simply linked in.
745
-  // 'p' is automatically unlinked prior to being prepended.
746
-  // Returns 'p'. 
747
-  cmData_t* cmDataPrependChild(cmData_t* parent, cmData_t* p );
748
-
749
-  // Append 'p' to the end of 'parent' child list.
750
-  // The source node 'p' is not duplicated it is simply linked in.
751
-  // 'p' is automatically unlinked prior to being appended.
752
-  // Returns 'p'. 
753
-  cmData_t* cmDataAppendChild( cmData_t* parent, cmData_t* p );
754
-
755
-  // Insert 'p' at index.  Index must be in the range: 
756
-  // 0 to cmDataChildCount(parent).
757
-  // The source node 'p' is not duplicated it is simply linked in.
758
-  // 'p' is automatically unlinked prior to being inserted.
759
-  // Returns 'p'.
760
-  cmData_t* cmDataInsertChild( cmData_t* parent, unsigned index, cmData_t* p );
761
-
762
-
763 429
   //----------------------------------------------------------------------------
764 430
   // Pair related functions
765 431
   //
@@ -814,15 +480,15 @@ extern "C" {
814 480
 
815 481
 
816 482
   // Var-args fmt:
817
-  // <typeId> <value> {<cnt>}
483
+  // <contId> {<typeId>} <value> {<cnt>}
818 484
   // scalar types: <value> is literal,<cnt>   is not included
819 485
   //     null has no <value> or <cnt>
820
-  // ptr    types: <value> is pointer,<cnt>   is element count
821
-  // struct types: <value> is cmData_t, <cnt> is not included
486
+  // array  types: <value> is pointer,<cnt>   is element count
487
+  // struct types: <value> is cmData_t, <typeId> and <cnt> is not included
822 488
   // Indicate the end of argument list by setting  <typeId> to kInvalidDtId. 
823 489
   // The memory for array based data types is dynamically allocated.
824
-  cmData_t* cmDataListAllocV(cmData_t* parent, va_list vl );
825
-  cmData_t* cmDataListAllocA(cmData_t* parent,  ... );
490
+  cmRC_t cmDataListAllocV(cmData_t* parent, cmData_t** ref, va_list vl );
491
+  cmRC_t  cmDataListAllocA(cmData_t* parent,  cmData_t** ref, ... );
826 492
   
827 493
   // Returns a ptr to 'ele'.
828 494
   cmData_t* cmDataListAppendEle( cmData_t* p, cmData_t* ele );
@@ -833,9 +499,6 @@ extern "C" {
833 499
   cmData_t* cmDataListInsertEle( cmData_t* p, unsigned index, cmData_t* ele );
834 500
   cmData_t* cmDataListInsertEleN(cmData_t* p, unsigned index, cmData_t* ele[], unsigned n );
835 501
  
836
-  cmData_t* cmDataListUnlink( cmData_t* p, unsigned index );
837
-  cmData_t* cmDataListFree(   cmData_t* p, unsigned index );
838
-
839 502
   //----------------------------------------------------------------------------
840 503
   // Record related functions
841 504
   //
@@ -866,7 +529,7 @@ extern "C" {
866 529
 
867 530
 
868 531
   // Var-args format:
869
-  // <label|id> <typeId>  <value> {<cnt>}
532
+  // <label|id> {<cid>} <typeId>  <value> {<cnt>}
870 533
   // scalar types: <value> is literal,<cnt> is not included
871 534
   // null   type: has no <value> or <cnt>
872 535
   // ptr    types: <value> is pointer,  <cnt> is element count
@@ -918,7 +581,6 @@ extern "C" {
918 581
   void     cmDataPrint( const cmData_t* p, cmRpt_t* rpt );
919 582
   
920 583
   void     cmDataTest( cmCtx_t* ctx );
921
-#endif
922 584
 
923 585
 
924 586
 #ifdef __cplusplus

Ładowanie…
Anuluj
Zapisz