|
@@ -74,6 +74,15 @@ unsigned _cmDataByteCount( const cmData_t* p )
|
74
|
74
|
return 0;
|
75
|
75
|
}
|
76
|
76
|
|
|
77
|
+bool cmIsValue( const cmData_t* p )
|
|
78
|
+{ return kMinValDtId <= p->tid && p->tid <= kMaxValDtId; }
|
|
79
|
+
|
|
80
|
+bool cmIsPtr( const cmData_t* p )
|
|
81
|
+{ return kMinPtrDtId <= p->tid && p->tid <= kMaxPtrDtId; }
|
|
82
|
+
|
|
83
|
+bool cmIsStruct( const cmData_t* p )
|
|
84
|
+{ return kMinStructDtId <= p->tid && p->tid <= kMaxStructDtId; }
|
|
85
|
+
|
77
|
86
|
char cmDataChar( const cmData_t* p ) { assert(p->tid==kCharDtId); return p->u.c; }
|
78
|
87
|
unsigned char cmDataUChar( const cmData_t* p ) { assert(p->tid==kUCharDtId); return p->u.uc; }
|
79
|
88
|
short cmDataShort( const cmData_t* p ) { assert(p->tid==kShortDtId); return p->u.s; }
|
|
@@ -1013,6 +1022,179 @@ void cmDataFree( cmData_t* p )
|
1013
|
1022
|
_cmDataFree(p);
|
1014
|
1023
|
}
|
1015
|
1024
|
|
|
1025
|
+cmData_t* cmDataUnlink( cmData_t* p )
|
|
1026
|
+{
|
|
1027
|
+ if( p->parent == NULL )
|
|
1028
|
+ return p;
|
|
1029
|
+
|
|
1030
|
+ assert( cmDataIsStruct(p->parent) );
|
|
1031
|
+
|
|
1032
|
+ cmData_t* cp = p->u.child;
|
|
1033
|
+ cmData_t* pp = NULL;
|
|
1034
|
+ for(; cp!=NULL; cp=cp->sibling)
|
|
1035
|
+ if( cp == p )
|
|
1036
|
+ {
|
|
1037
|
+ if( pp == NULL )
|
|
1038
|
+ p->parent->u.child = p->sibling;
|
|
1039
|
+ else
|
|
1040
|
+ pp->sibling = cp->sibling;
|
|
1041
|
+ }
|
|
1042
|
+ return p;
|
|
1043
|
+}
|
|
1044
|
+
|
|
1045
|
+unsigned cmDataChildCount( const cmData_t* p )
|
|
1046
|
+{
|
|
1047
|
+ if( !cmDataIsStruct(p) )
|
|
1048
|
+ return 0;
|
|
1049
|
+
|
|
1050
|
+ unsigned n = 0;
|
|
1051
|
+ const cmData_t* cp = p->u.child;
|
|
1052
|
+ for(; cp!=NULL; cp=cp->sibling)
|
|
1053
|
+ ++n;
|
|
1054
|
+
|
|
1055
|
+ return n;
|
|
1056
|
+}
|
|
1057
|
+
|
|
1058
|
+cmData_t* cmDataChild( cmData_t* p, unsigned index )
|
|
1059
|
+{
|
|
1060
|
+ if( !cmDataIsStruct(p) )
|
|
1061
|
+ return NULL;
|
|
1062
|
+
|
|
1063
|
+ unsigned n = 0;
|
|
1064
|
+ cmData_t* cp = p->u.child;
|
|
1065
|
+ for(; cp!=NULL; cp=cp->sibling)
|
|
1066
|
+ {
|
|
1067
|
+ if( n == index )
|
|
1068
|
+ break;
|
|
1069
|
+ ++n;
|
|
1070
|
+ }
|
|
1071
|
+
|
|
1072
|
+ return cp;
|
|
1073
|
+}
|
|
1074
|
+
|
|
1075
|
+cmData_t* cmDataPrependChild(cmData_t* parent, cmData_t* p )
|
|
1076
|
+{
|
|
1077
|
+ assert( cmDataIsStruct(p) );
|
|
1078
|
+
|
|
1079
|
+ p->u.child = parent->u.child;
|
|
1080
|
+ parent->u.child = p;
|
|
1081
|
+ return p;
|
|
1082
|
+}
|
|
1083
|
+
|
|
1084
|
+cmData_t* cmDataAppendChild( cmData_t* parent, cmData_t* p )
|
|
1085
|
+{
|
|
1086
|
+ assert( cmDataIsStruct(p) );
|
|
1087
|
+
|
|
1088
|
+ cmData_t* cp = parent->u.child;
|
|
1089
|
+ if( cp == NULL )
|
|
1090
|
+ parent->u.child = p;
|
|
1091
|
+ else
|
|
1092
|
+ {
|
|
1093
|
+ for(; cp!=NULL; cp=cp->sibling)
|
|
1094
|
+ if( cp->sibling == NULL )
|
|
1095
|
+ {
|
|
1096
|
+ cp->sibling = p;
|
|
1097
|
+ break;
|
|
1098
|
+ }
|
|
1099
|
+ }
|
|
1100
|
+
|
|
1101
|
+ p->sibling = NULL;
|
|
1102
|
+ return p;
|
|
1103
|
+}
|
|
1104
|
+
|
|
1105
|
+cmData_t* cmDataInsertChild( cmData_t* parent, cmData_t* p, unsigned index )
|
|
1106
|
+{
|
|
1107
|
+ if( !cmDataIsStruct(parent) )
|
|
1108
|
+ return NULL;
|
|
1109
|
+
|
|
1110
|
+ unsigned n = 0;
|
|
1111
|
+ cmData_t* cp = parent->u.child;
|
|
1112
|
+ cmData_t* pp = NULL;
|
|
1113
|
+ for(; cp!=NULL; cp=cp->sibling)
|
|
1114
|
+ {
|
|
1115
|
+ if( n == index )
|
|
1116
|
+ {
|
|
1117
|
+ if( pp == NULL )
|
|
1118
|
+ {
|
|
1119
|
+ parent->u.child = p;
|
|
1120
|
+ p->sibling = NULL;
|
|
1121
|
+ }
|
|
1122
|
+ else
|
|
1123
|
+ {
|
|
1124
|
+ p->sibling = pp->sibling;
|
|
1125
|
+ pp->sibling = p;
|
|
1126
|
+ }
|
|
1127
|
+ break;
|
|
1128
|
+
|
|
1129
|
+ }
|
|
1130
|
+ ++n;
|
|
1131
|
+ }
|
|
1132
|
+
|
|
1133
|
+ return p;
|
|
1134
|
+
|
|
1135
|
+}
|
|
1136
|
+
|
|
1137
|
+//----------------------------------------------------------------------------
|
|
1138
|
+
|
|
1139
|
+bool _cmDataPairIsValid( const cmData_t* p )
|
|
1140
|
+{
|
|
1141
|
+ assert( p->tid == kPairDtId );
|
|
1142
|
+
|
|
1143
|
+ const cmData_t* cp = p->u.child;
|
|
1144
|
+ bool fl = cp->u.child == NULL || cp->u.child->sibling == NULL || cp->u.child->sibling->sibling!=NULL;
|
|
1145
|
+ return !fl;
|
|
1146
|
+}
|
|
1147
|
+
|
|
1148
|
+// Get the key/value of a pair
|
|
1149
|
+cmData_t* cmDataPairKey( cmData_t* p )
|
|
1150
|
+{
|
|
1151
|
+ assert( _cmDataPairIsValid(p) );
|
|
1152
|
+ return p->u.child;
|
|
1153
|
+}
|
|
1154
|
+
|
|
1155
|
+cmData_t* cmDataPairValue( cmData_t* p )
|
|
1156
|
+{
|
|
1157
|
+ assert( _cmDataPairIsValid(p) );
|
|
1158
|
+ return p->u.child->sibling;
|
|
1159
|
+}
|
|
1160
|
+
|
|
1161
|
+ // Set the key or value of an existing pair node.
|
|
1162
|
+cmData_t* cmDataPairSetValue( cmData_t* p, cmData_t* value )
|
|
1163
|
+{
|
|
1164
|
+}
|
|
1165
|
+
|
|
1166
|
+cmData_t* cmDataPairAllocValue( cmData_t* p, const cmData_t* value )
|
|
1167
|
+{
|
|
1168
|
+}
|
|
1169
|
+
|
|
1170
|
+cmData_t* cmDataPairSetKey( cmData_t* p, cmData_t* key )
|
|
1171
|
+{
|
|
1172
|
+}
|
|
1173
|
+
|
|
1174
|
+cmData_t* cmDataPairSetKeyId( cmData_t* p, unsigned id )
|
|
1175
|
+{
|
|
1176
|
+}
|
|
1177
|
+
|
|
1178
|
+cmData_t* cmDataPairSetKeyLabel( cmData_t* p, const cmChar_t* label )
|
|
1179
|
+{
|
|
1180
|
+}
|
|
1181
|
+
|
|
1182
|
+cmData_t* cmDataPairAllocKey( cmData_t* p, const cmData_t* key )
|
|
1183
|
+{
|
|
1184
|
+}
|
|
1185
|
+
|
|
1186
|
+// Dynamically allocate a pair node
|
|
1187
|
+cmData_t* cmDataAllocPair( cmData_t* parent, const cmData_t* key, const cmData_t* value )
|
|
1188
|
+{
|
|
1189
|
+}
|
|
1190
|
+
|
|
1191
|
+cmData_t* cmDataAllocPairId( cmData_t* parent, unsigned keyId, cmData_t* value )
|
|
1192
|
+{
|
|
1193
|
+}
|
|
1194
|
+
|
|
1195
|
+cmData_t* cmDataAllocPairLabel( cmData_t* parent, const cmChar_t label, cmData_t* value )
|
|
1196
|
+{
|
|
1197
|
+}
|
1016
|
1198
|
|
1017
|
1199
|
|
1018
|
1200
|
unsigned cmDataSerializeByteCount( const cmData_t* p )
|