Przeglądaj źródła

cmPrefs.c/h Renamed 'Scalar' func's., Fixed bug in cmPrefsCreateXXX()

master
kevin 12 lat temu
rodzic
commit
67f462a501
2 zmienionych plików z 118 dodań i 47 usunięć
  1. 85
    30
      cmPrefs.c
  2. 33
    17
      cmPrefs.h

+ 85
- 30
cmPrefs.c Wyświetl plik

@@ -290,7 +290,7 @@ cmPrRC_t cmPrefsInitialize( cmPrH_t* hp, const cmChar_t* fn, cmPrefsOnChangeFunc
290 290
       goto errLabel;
291 291
     }
292 292
 
293
-    if( cmJsonCreateObject( p->jsH, NULL ) != kOkJsRC )
293
+    if( cmJsonCreateObject( p->jsH, NULL ) == NULL )
294 294
     {
295 295
       rc = cmErrMsg(&p->err,kJsonFailPrRC,"The JSON root object could not be created.");
296 296
       goto errLabel;
@@ -335,6 +335,12 @@ cmPrRC_t cmPrefsFinalize(   cmPrH_t* hp )
335 335
 bool cmPrefsIsValid( cmPrH_t h )
336 336
 { return h.h != NULL; }
337 337
 
338
+const cmChar_t* cmPrefsFileName( cmPrH_t h )
339
+{
340
+  cmPr_t* p = _cmPrefsHandleToPtr(h);
341
+  return p->fn;
342
+}
343
+
338 344
 cmPrRC_t cmPrefsRC( cmPrH_t h)
339 345
 { return cmErrLastRC(&_cmPrefsHandleToPtr(h)->err); }
340 346
 
@@ -665,7 +671,7 @@ const cmChar_t* cmPrefsStringDef( cmPrH_t h, const cmChar_t* pathStr, const cmCh
665 671
 }
666 672
 
667 673
 
668
-cmPrRC_t        cmPrefsScalarBool(   cmPrH_t h, const cmChar_t* pathStr, bool*            retValPtr )
674
+cmPrRC_t        cmPrefsBoolRc(   cmPrH_t h, const cmChar_t* pathStr, bool*            retValPtr )
669 675
 {
670 676
   unsigned id;
671 677
   if((id = cmPrefsId(h,pathStr,true)) == cmInvalidId )
@@ -675,7 +681,7 @@ cmPrRC_t        cmPrefsScalarBool(   cmPrH_t h, const cmChar_t* pathStr, bool*
675 681
   return cmPrefsGetBool(h,id,retValPtr,&n); 
676 682
 }
677 683
 
678
-cmPrRC_t        cmPrefsScalarUInt(   cmPrH_t h, const cmChar_t* pathStr, unsigned*        retValPtr )
684
+cmPrRC_t        cmPrefsUIntRc(   cmPrH_t h, const cmChar_t* pathStr, unsigned*        retValPtr )
679 685
 {
680 686
   unsigned id;
681 687
   unsigned n = 1;
@@ -691,7 +697,7 @@ cmPrRC_t        cmPrefsScalarUInt(   cmPrH_t h, const cmChar_t* pathStr, unsigne
691 697
   return rc;
692 698
 }
693 699
 
694
-cmPrRC_t        cmPrefsScalarInt(    cmPrH_t h, const cmChar_t* pathStr, int*             retValPtr )
700
+cmPrRC_t        cmPrefsIntRc(    cmPrH_t h, const cmChar_t* pathStr, int*             retValPtr )
695 701
 {
696 702
   unsigned id;
697 703
   if((id = cmPrefsId(h,pathStr,true)) == cmInvalidId )
@@ -701,7 +707,7 @@ cmPrRC_t        cmPrefsScalarInt(    cmPrH_t h, const cmChar_t* pathStr, int*
701 707
   return cmPrefsGetInt(h,id,retValPtr,&n); 
702 708
 }
703 709
 
704
-cmPrRC_t        cmPrefsScalarFloat(  cmPrH_t h, const cmChar_t* pathStr, float*           retValPtr )
710
+cmPrRC_t        cmPrefsFloatRc(  cmPrH_t h, const cmChar_t* pathStr, float*           retValPtr )
705 711
 {
706 712
   unsigned id;
707 713
   unsigned n = 1;
@@ -717,7 +723,7 @@ cmPrRC_t        cmPrefsScalarFloat(  cmPrH_t h, const cmChar_t* pathStr, float*
717 723
   return rc;
718 724
 }
719 725
 
720
-cmPrRC_t        cmPrefsScalarReal(   cmPrH_t h, const cmChar_t* pathStr, double*          retValPtr )
726
+cmPrRC_t        cmPrefsRealRc(   cmPrH_t h, const cmChar_t* pathStr, double*          retValPtr )
721 727
 {
722 728
   unsigned id;
723 729
   if((id = cmPrefsId(h,pathStr,true)) == cmInvalidId )
@@ -727,7 +733,7 @@ cmPrRC_t        cmPrefsScalarReal(   cmPrH_t h, const cmChar_t* pathStr, double*
727 733
   return cmPrefsGetReal(h,id,retValPtr,&n); 
728 734
 }
729 735
 
730
-cmPrRC_t        cmPrefsScalarString( cmPrH_t h, const cmChar_t* pathStr, const cmChar_t** retValPtr ) 
736
+cmPrRC_t        cmPrefsStringRc( cmPrH_t h, const cmChar_t* pathStr, const cmChar_t** retValPtr ) 
731 737
 {
732 738
   unsigned id;
733 739
   if((id = cmPrefsId(h,pathStr,true)) == cmInvalidId )
@@ -996,30 +1002,71 @@ cmPrRC_t _cmPrefsSetValues( cmPrH_t h, unsigned id, const bool* bvp, const int*
996 1002
   return _cmPrefsSetValues2( p, np, bvp, ivp, rvp, svp, eleCntPtr );
997 1003
 }
998 1004
 
999
-cmPrRC_t cmPrefsSetBool(   cmPrH_t h, unsigned id, const bool*   vp, const unsigned* eleCntPtr )
1005
+cmPrRC_t cmPrefsSetBoolArray(   cmPrH_t h, unsigned id, const bool*   vp, const unsigned* eleCntPtr )
1000 1006
 { return _cmPrefsSetValues(h, id, vp, NULL, NULL, NULL, eleCntPtr ); }
1001 1007
 
1002
-cmPrRC_t cmPrefsSetInt(    cmPrH_t h, unsigned id, const int*    vp, const unsigned* eleCntPtr )
1008
+cmPrRC_t cmPrefsSetIntArray(    cmPrH_t h, unsigned id, const int*    vp, const unsigned* eleCntPtr )
1003 1009
 { return _cmPrefsSetValues(h, id, NULL, vp, NULL, NULL, eleCntPtr ); }
1004 1010
 
1005
-cmPrRC_t cmPrefsSetReal(   cmPrH_t h, unsigned id, const double* vp, const unsigned* eleCntPtr )
1011
+cmPrRC_t cmPrefsSetRealArray(   cmPrH_t h, unsigned id, const double* vp, const unsigned* eleCntPtr )
1006 1012
 { return _cmPrefsSetValues(h, id, NULL, NULL, vp, NULL, eleCntPtr ); }
1007 1013
 
1008
-cmPrRC_t cmPrefsSetString( cmPrH_t h, unsigned id, const cmChar_t**   vp, const unsigned* eleCntPtr )
1014
+cmPrRC_t cmPrefsSetStringArray( cmPrH_t h, unsigned id, const cmChar_t**   vp, const unsigned* eleCntPtr )
1009 1015
 { return _cmPrefsSetValues(h, id, NULL, NULL, NULL, vp, eleCntPtr ); }
1010 1016
 
1011 1017
 
1012
-cmPrRC_t cmPrefsSetScalarBool(   cmPrH_t h, const cmChar_t* pathStr, bool val )
1018
+cmPrRC_t cmPrefsSetBool(   cmPrH_t h, unsigned id, bool val )
1019
+{
1020
+  unsigned n = 1;
1021
+  return cmPrefsSetBoolArray(h,id,&val,&n);
1022
+}
1023
+
1024
+cmPrRC_t cmPrefsSetUInt(   cmPrH_t h, unsigned id, unsigned val )
1025
+{
1026
+  unsigned n = 1;
1027
+  int ival = (int)val;
1028
+  return cmPrefsSetIntArray(h,id,&ival,&n);
1029
+}
1030
+
1031
+cmPrRC_t cmPrefsSetInt(    cmPrH_t h, unsigned id, int val )
1032
+{
1033
+  unsigned n = 1;
1034
+  return cmPrefsSetIntArray(h,id,&val,&n);
1035
+}
1036
+
1037
+cmPrRC_t cmPrefsSetFloat(  cmPrH_t h, unsigned id, float val )
1038
+{
1039
+  unsigned n = 1;
1040
+  double dval = val;
1041
+  return cmPrefsSetRealArray(h,id,&dval,&n);
1042
+}
1043
+
1044
+cmPrRC_t cmPrefsSetReal( cmPrH_t h, unsigned id, double val )
1045
+{
1046
+  unsigned n = 1;
1047
+  return cmPrefsSetRealArray(h,id,&val,&n);
1048
+}
1049
+
1050
+cmPrRC_t cmPrefsSetString( cmPrH_t h, unsigned id, const cmChar_t* val )
1051
+{
1052
+  unsigned n = 1;
1053
+  return cmPrefsSetStringArray(h,id,&val,&n);
1054
+}
1055
+
1056
+
1057
+
1058
+
1059
+cmPrRC_t cmPrefsPathSetBool(   cmPrH_t h, const cmChar_t* pathStr, bool val )
1013 1060
 {
1014 1061
   unsigned id;
1015 1062
   unsigned n = 1;
1016 1063
   if((id = cmPrefsId(h,pathStr,true)) == cmInvalidId )
1017 1064
     return kVarNotFoundPrRC;
1018 1065
 
1019
-  return cmPrefsSetBool(h,id,&val,&n);
1066
+  return cmPrefsSetBoolArray(h,id,&val,&n);
1020 1067
 }
1021 1068
 
1022
-cmPrRC_t cmPrefsSetScalarUInt(   cmPrH_t h, const cmChar_t* pathStr, unsigned val )
1069
+cmPrRC_t cmPrefsPathSetUInt(   cmPrH_t h, const cmChar_t* pathStr, unsigned val )
1023 1070
 {
1024 1071
   unsigned id;
1025 1072
   unsigned n = 1;
@@ -1027,20 +1074,20 @@ cmPrRC_t cmPrefsSetScalarUInt(   cmPrH_t h, const cmChar_t* pathStr, unsigned va
1027 1074
     return kVarNotFoundPrRC;
1028 1075
 
1029 1076
   int ival = (int)val;
1030
-  return cmPrefsSetInt(h,id,&ival,&n);
1077
+  return cmPrefsSetIntArray(h,id,&ival,&n);
1031 1078
 }
1032 1079
 
1033
-cmPrRC_t cmPrefsSetScalarInt(    cmPrH_t h, const cmChar_t* pathStr, int val )
1080
+cmPrRC_t cmPrefsPathSetInt(    cmPrH_t h, const cmChar_t* pathStr, int val )
1034 1081
 {
1035 1082
   unsigned id;
1036 1083
   unsigned n = 1;
1037 1084
   if((id = cmPrefsId(h,pathStr,true)) == cmInvalidId )
1038 1085
     return kVarNotFoundPrRC;
1039 1086
 
1040
-  return cmPrefsSetInt(h,id,&val,&n);
1087
+  return cmPrefsSetIntArray(h,id,&val,&n);
1041 1088
 }
1042 1089
 
1043
-cmPrRC_t cmPrefsSetScalarFloat(  cmPrH_t h, const cmChar_t* pathStr, float val )
1090
+cmPrRC_t cmPrefsPathSetFloat(  cmPrH_t h, const cmChar_t* pathStr, float val )
1044 1091
 {
1045 1092
   unsigned id;
1046 1093
   unsigned n = 1;
@@ -1048,27 +1095,27 @@ cmPrRC_t cmPrefsSetScalarFloat(  cmPrH_t h, const cmChar_t* pathStr, float val )
1048 1095
     return kVarNotFoundPrRC;
1049 1096
 
1050 1097
   double dval = val;
1051
-  return cmPrefsSetReal(h,id,&dval,&n);
1098
+  return cmPrefsSetRealArray(h,id,&dval,&n);
1052 1099
 }
1053 1100
 
1054
-cmPrRC_t cmPrefsSetScalarReal( cmPrH_t h, const cmChar_t* pathStr, double val )
1101
+cmPrRC_t cmPrefsPathSetReal( cmPrH_t h, const cmChar_t* pathStr, double val )
1055 1102
 {
1056 1103
   unsigned id;
1057 1104
   unsigned n = 1;
1058 1105
   if((id = cmPrefsId(h,pathStr,true)) == cmInvalidId )
1059 1106
     return kVarNotFoundPrRC;
1060 1107
 
1061
-  return cmPrefsSetReal(h,id,&val,&n);
1108
+  return cmPrefsSetRealArray(h,id,&val,&n);
1062 1109
 }
1063 1110
 
1064
-cmPrRC_t cmPrefsSetScalarString( cmPrH_t h, const cmChar_t* pathStr, const cmChar_t* val )
1111
+cmPrRC_t cmPrefsPathSetString( cmPrH_t h, const cmChar_t* pathStr, const cmChar_t* val )
1065 1112
 {
1066 1113
   unsigned id;
1067 1114
   unsigned n = 1;
1068 1115
   if((id = cmPrefsId(h,pathStr,true)) == cmInvalidId )
1069 1116
     return kVarNotFoundPrRC;
1070 1117
 
1071
-  return cmPrefsSetString(h,id,&val,&n);
1118
+  return cmPrefsSetStringArray(h,id,&val,&n);
1072 1119
 }
1073 1120
 
1074 1121
 
@@ -1168,7 +1215,7 @@ cmPrRC_t  _cmPrefsCreateJsonNode(
1168 1215
   }
1169 1216
 
1170 1217
   // we have followed 'pathString' to the last node which already
1171
-  // exists in the JSON tree - now we must new JSON nodes to reflect 
1218
+  // exists in the JSON tree - now we must create new JSON nodes to reflect 
1172 1219
   // the remaining path elements
1173 1220
   for(; i<pathCnt; ++i)
1174 1221
   {
@@ -1225,23 +1272,31 @@ cmPrRC_t  _cmPrefsCreateJsonNode(
1225 1272
 
1226 1273
     }
1227 1274
 
1275
+    unsigned nxtId = p->id;
1276
+
1228 1277
     // create a pref node to associate with this new level
1229
-    if((pnp = _cmPrefsCreateNode(p, jsPairNodePtr, pnp->pathPtr )) == NULL )
1278
+    if((pnp = _cmPrefsCreateNode(p, jsPairNodePtr, pnp==NULL ? NULL : pnp->pathPtr )) == NULL )
1230 1279
     {
1231 1280
       rc = cmErrMsg(&p->err,kNodeCreateFailPrRC,"Creation failed for the '%s' element of the preference node '%s'.",cmStringNullGuard(pathEleStr),cmStringNullGuard(pathString));
1232 1281
       goto errLabel;
1233 1282
     }
1234 1283
 
1284
+    // always leave internal nodes with id=cmInvalidId, leaf node id's will be set below
1285
+    p->id   = nxtId;
1286
+    pnp->id = cmInvalidId;
1287
+
1235 1288
     pathEleStr += strlen(pathEleStr) + 1;
1236 1289
   }
1237 1290
 
1238 1291
   assert( pnp != NULL );
1239 1292
 
1240 1293
   // if an preference variable 'id' was given then set it here
1241
-  if( id != cmInvalidId )
1294
+  if( id == cmInvalidId )
1295
+    pnp->id = _cmPrefsCalcNextAvailId(p);
1296
+  else
1242 1297
   {
1243 1298
     if( _cmPrefsIdToNodePtr(p, id, false ) != NULL )
1244
-      cmErrWarnMsg(&p->err,kDuplicateIdPrRC,"The preference variable id '%i' is used by multiple preference variables including '%s'.",cmStringNullGuard(pathString));
1299
+      cmErrWarnMsg(&p->err,kDuplicateIdPrRC,"The preference variable id '%i' is used by multiple preference variables including '%s'.",id,cmStringNullGuard(pathString));
1245 1300
   
1246 1301
     pnp->id = id;
1247 1302
   }
@@ -1462,19 +1517,19 @@ void _cmPrintNodes( const cmPrNode_t* np )
1462 1517
   
1463 1518
   sr = 44100;
1464 1519
   n  = 1;
1465
-  cmPrefsSetInt(h, cmPrefsId(h,"cfg/srate",true), &sr, &n);
1520
+  cmPrefsSetIntArray(h, cmPrefsId(h,"cfg/srate",true), &sr, &n);
1466 1521
   cmPrefsGetInt(h, cmPrefsId(h,"cfg/chNames/array",true), &sr, &n );
1467 1522
   printf("sr:%i %i\n",sr,n);
1468 1523
  
1469 1524
   int sarr[] = {10,11,12,13 };
1470 1525
   n = sizeof(sarr)/sizeof(sarr[0]);
1471
-  cmPrefsSetInt(h, cmPrefsId(h,"cfg/chNames/array",true), sarr, &n);
1526
+  cmPrefsSetIntArray(h, cmPrefsId(h,"cfg/chNames/array",true), sarr, &n);
1472 1527
   cmPrefsGetInt(h, cmPrefsId(h,"cfg/chNames/array",true), sarr, &n );
1473 1528
   printf("array:%i %i %i %i n=%i\n",sarr[0],sarr[1],sarr[2],sarr[3],n);
1474 1529
 
1475 1530
   int tarr[] = {20,21 };
1476 1531
   n = sizeof(tarr)/sizeof(tarr[0]);
1477
-  cmPrefsSetInt(h, cmPrefsId(h,"cfg/chNames/array",true), tarr, &n);
1532
+  cmPrefsSetIntArray(h, cmPrefsId(h,"cfg/chNames/array",true), tarr, &n);
1478 1533
   cmPrefsGetInt(h, cmPrefsId(h,"cfg/chNames/array",true), tarr, &n );
1479 1534
   printf("array:%i %i  n=%i\n",tarr[0],tarr[1],n);
1480 1535
 

+ 33
- 17
cmPrefs.h Wyświetl plik

@@ -34,6 +34,8 @@ extern "C" {
34 34
 
35 35
   bool cmPrefsIsValid( cmPrH_t h );
36 36
 
37
+  const cmChar_t* cmPrefsFileName( cmPrH_t h );
38
+
37 39
   // Return last RC.
38 40
   cmPrRC_t cmPrefsRC( cmPrH_t h);
39 41
 
@@ -52,6 +54,7 @@ extern "C" {
52 54
 
53 55
   // On input *'eleCntPtr' must contain the number of elements in the buffer pointed to by 'vp'.
54 56
   // On return *'eleCntPtr' contains the actuall number of elements returned by the function.
57
+  // Set *eleCntPtr to 1 for scalar a values.
55 58
   cmPrRC_t cmPrefsGetBool(   cmPrH_t h, unsigned id, bool*            vp, unsigned* eleCntPtr );
56 59
   cmPrRC_t cmPrefsGetInt(    cmPrH_t h, unsigned id, int*             vp, unsigned* eleCntPtr );
57 60
   cmPrRC_t cmPrefsGetReal(   cmPrH_t h, unsigned id, double*          vp, unsigned* eleCntPtr );
@@ -76,12 +79,12 @@ extern "C" {
76 79
   const cmChar_t* cmPrefsStringDef( cmPrH_t h, const cmChar_t* pathStr, const cmChar_t* dfltVal ); 
77 80
 
78 81
   // Get a scalar value. 
79
-  cmPrRC_t        cmPrefsScalarBool(   cmPrH_t h, const cmChar_t* pathStr, bool*            retValPtr );
80
-  cmPrRC_t        cmPrefsScalarUInt(   cmPrH_t h, const cmChar_t* pathStr, unsigned*        retValPtr );
81
-  cmPrRC_t        cmPrefsScalarInt(    cmPrH_t h, const cmChar_t* pathStr, int*             retValPtr );
82
-  cmPrRC_t        cmPrefsScalarFloat(  cmPrH_t h, const cmChar_t* pathStr, float*           retValPtr );
83
-  cmPrRC_t        cmPrefsScalarReal(   cmPrH_t h, const cmChar_t* pathStr, double*          retValPtr );
84
-  cmPrRC_t        cmPrefsScalarString( cmPrH_t h, const cmChar_t* pathStr, const cmChar_t** retValPtr ); 
82
+  cmPrRC_t        cmPrefsBoolRc(   cmPrH_t h, const cmChar_t* pathStr, bool*            retValPtr );
83
+  cmPrRC_t        cmPrefsUIntRc(   cmPrH_t h, const cmChar_t* pathStr, unsigned*        retValPtr );
84
+  cmPrRC_t        cmPrefsIntRc(    cmPrH_t h, const cmChar_t* pathStr, int*             retValPtr );
85
+  cmPrRC_t        cmPrefsFloatRc(  cmPrH_t h, const cmChar_t* pathStr, float*           retValPtr );
86
+  cmPrRC_t        cmPrefsRealRc(   cmPrH_t h, const cmChar_t* pathStr, double*          retValPtr );
87
+  cmPrRC_t        cmPrefsStringRc( cmPrH_t h, const cmChar_t* pathStr, const cmChar_t** retValPtr ); 
85 88
 
86 89
 
87 90
   // Simplified array interface - check cmPrefsRC() for errors
@@ -108,17 +111,24 @@ extern "C" {
108 111
   // 3) For  scalar (non-array) variables *eleCntPtr must be set to 1.
109 112
   //
110 113
 
111
-  cmPrRC_t cmPrefsSetBool(   cmPrH_t h, unsigned id, const bool*      vp, const unsigned* eleCntPtr );
112
-  cmPrRC_t cmPrefsSetInt(    cmPrH_t h, unsigned id, const int*       vp, const unsigned* eleCntPtr );
113
-  cmPrRC_t cmPrefsSetReal(   cmPrH_t h, unsigned id, const double*    vp, const unsigned* eleCntPtr );
114
-  cmPrRC_t cmPrefsSetString( cmPrH_t h, unsigned id, const cmChar_t** vp, const unsigned* eleCntPtr );
115
-
116
-  cmPrRC_t cmPrefsSetScalarBool(   cmPrH_t h, const cmChar_t* pathStr, bool     val );
117
-  cmPrRC_t cmPrefsSetScalarUInt(   cmPrH_t h, const cmChar_t* pathStr, unsigned val );
118
-  cmPrRC_t cmPrefsSetScalarInt(    cmPrH_t h, const cmChar_t* pathStr, int      val );
119
-  cmPrRC_t cmPrefsSetScalarFloat(  cmPrH_t h, const cmChar_t* pathStr, float    val );
120
-  cmPrRC_t cmPrefsSetScalarReal(   cmPrH_t h, const cmChar_t* pathStr, double   val );
121
-  cmPrRC_t cmPrefsSetScalarString( cmPrH_t h, const cmChar_t* pathStr, const cmChar_t* val );
114
+  cmPrRC_t cmPrefsSetBoolArray(   cmPrH_t h, unsigned id, const bool*      vp, const unsigned* eleCntPtr );
115
+  cmPrRC_t cmPrefsSetIntArray(    cmPrH_t h, unsigned id, const int*       vp, const unsigned* eleCntPtr );
116
+  cmPrRC_t cmPrefsSetRealArray(   cmPrH_t h, unsigned id, const double*    vp, const unsigned* eleCntPtr );
117
+  cmPrRC_t cmPrefsSetStringArray( cmPrH_t h, unsigned id, const cmChar_t** vp, const unsigned* eleCntPtr );
118
+
119
+  cmPrRC_t cmPrefsSetBool(   cmPrH_t h, unsigned id, bool     val );
120
+  cmPrRC_t cmPrefsSetUInt(   cmPrH_t h, unsigned id, unsigned val );
121
+  cmPrRC_t cmPrefsSetInt(    cmPrH_t h, unsigned id, int      val );
122
+  cmPrRC_t cmPrefsSetFloat(  cmPrH_t h, unsigned id, float    val );
123
+  cmPrRC_t cmPrefsSetReal(   cmPrH_t h, unsigned id, double   val );
124
+  cmPrRC_t cmPrefsSetString( cmPrH_t h, unsigned id, const cmChar_t* val );
125
+
126
+  cmPrRC_t cmPrefsPathSetBool(   cmPrH_t h, const cmChar_t* pathStr, bool     val );
127
+  cmPrRC_t cmPrefsPathSetUInt(   cmPrH_t h, const cmChar_t* pathStr, unsigned val );
128
+  cmPrRC_t cmPrefsPathSetInt(    cmPrH_t h, const cmChar_t* pathStr, int      val );
129
+  cmPrRC_t cmPrefsPathSetFloat(  cmPrH_t h, const cmChar_t* pathStr, float    val );
130
+  cmPrRC_t cmPrefsPathSetReal(   cmPrH_t h, const cmChar_t* pathStr, double   val );
131
+  cmPrRC_t cmPrefsPathSetString( cmPrH_t h, const cmChar_t* pathStr, const cmChar_t* val );
122 132
 
123 133
   // Create a new preference variable and set it's value to 'val'.
124 134
   // If a variable with the same path and type already exists and kForceValuePrFl is set then update it's value to 'val'.
@@ -126,6 +136,10 @@ extern "C" {
126 136
   //
127 137
   // If a variable with the same path but a different type exists then an error is returned.
128 138
   // 
139
+  // The 'id' argument is optional.  If 'id' is set to cmInvalidId then the
140
+  // variable will be automatically assigned an id.  The value of the
141
+  // automatically assigned id can be found from the path string
142
+  // via cmPrefsId()
129 143
 
130 144
   // Set kForceValuePrFl 
131 145
   enum { kForceValuePrFl=0x01 };
@@ -144,6 +158,8 @@ extern "C" {
144 158
   cmPrRC_t cmPrefsCreateStringArray( cmPrH_t h, unsigned id, const cmChar_t* pathStr, unsigned flags, const cmChar_t** val, unsigned eleCnt );
145 159
 
146 160
   bool     cmPrefsIsDirty( cmPrH_t h );
161
+
162
+  // If 'fn' is NULL then the filename passed in cmPrefsInitialize() is used.
147 163
   cmPrRC_t cmPrefsWrite( cmPrH_t h, const cmChar_t* fn );
148 164
 
149 165
 

Ładowanie…
Anuluj
Zapisz