|
@@ -1021,6 +1021,52 @@ unsigned _cmXmlLabelCount( const cmChar_t* firstLabel, va_list vl )
|
1021
|
1021
|
return n;
|
1022
|
1022
|
}
|
1023
|
1023
|
|
|
1024
|
+
|
|
1025
|
+const cmXmlNode_t* _cmXmlNodeHasChildR( const cmXmlNode_t* np, unsigned argIdx, const cmChar_t**argV, unsigned argN, const cmChar_t* attrLabel, const cmChar_t* valueStr)
|
|
1026
|
+{
|
|
1027
|
+ if( argIdx == argN )
|
|
1028
|
+ return NULL;
|
|
1029
|
+
|
|
1030
|
+
|
|
1031
|
+ const cmXmlNode_t* cnp = np->children;
|
|
1032
|
+ for(; cnp!=NULL; cnp=cnp->sibling)
|
|
1033
|
+ if( cmTextCmp(cnp->label,argV[argIdx]) == 0 )
|
|
1034
|
+ {
|
|
1035
|
+ const cmXmlNode_t* tnp = _cmXmlNodeHasChildR(cnp,argIdx+1,argV,argN,attrLabel,valueStr);
|
|
1036
|
+
|
|
1037
|
+ if( attrLabel != NULL )
|
|
1038
|
+ {
|
|
1039
|
+ const cmXmlAttr_t* a;
|
|
1040
|
+ if((a = cmXmlFindAttrib(np,attrLabel)) == NULL )
|
|
1041
|
+ continue;
|
|
1042
|
+
|
|
1043
|
+
|
|
1044
|
+ if( valueStr != NULL )
|
|
1045
|
+ {
|
|
1046
|
+ if( cmTextCmp(a->value,valueStr) != 0 )
|
|
1047
|
+ continue;
|
|
1048
|
+ }
|
|
1049
|
+ }
|
|
1050
|
+
|
|
1051
|
+ if( tnp != NULL )
|
|
1052
|
+ return tnp;
|
|
1053
|
+ }
|
|
1054
|
+
|
|
1055
|
+ return NULL;
|
|
1056
|
+}
|
|
1057
|
+
|
|
1058
|
+const cmXmlNode_t* _cmXmlNodeHasChildV( const cmXmlNode_t* np, const cmChar_t* label, va_list vl, unsigned argN, const cmChar_t* attrLabel, const cmChar_t* valueStr )
|
|
1059
|
+{
|
|
1060
|
+ unsigned i;
|
|
1061
|
+ const cmChar_t* argV[ argN+1 ];
|
|
1062
|
+ argV[0] = label;
|
|
1063
|
+ for(i=1; i<argN+1; ++i)
|
|
1064
|
+ argV[i] = va_arg(vl,const cmChar_t*);
|
|
1065
|
+
|
|
1066
|
+ return _cmXmlNodeHasChildR(np,0,argV,argN,attrLabel,valueStr);
|
|
1067
|
+}
|
|
1068
|
+
|
|
1069
|
+/*
|
1024
|
1070
|
const cmXmlNode_t* _cmXmlNodeHasChildV( const cmXmlNode_t* np, const cmChar_t* label, va_list vl, unsigned argN )
|
1025
|
1071
|
{
|
1026
|
1072
|
unsigned i;
|
|
@@ -1045,10 +1091,11 @@ const cmXmlNode_t* _cmXmlNodeHasChildV( const cmXmlNode_t* np, const cmChar_t*
|
1045
|
1091
|
|
1046
|
1092
|
return np;
|
1047
|
1093
|
}
|
|
1094
|
+*/
|
1048
|
1095
|
|
1049
|
1096
|
bool cmXmlNodeHasChildV( const cmXmlNode_t* np, const cmChar_t* label, va_list vl )
|
1050
|
1097
|
{
|
1051
|
|
- return _cmXmlNodeHasChildV(np,label,vl,_cmXmlLabelCount(label,vl))!=NULL;
|
|
1098
|
+ return _cmXmlNodeHasChildV(np,label,vl,_cmXmlLabelCount(label,vl),NULL,NULL)!=NULL;
|
1052
|
1099
|
}
|
1053
|
1100
|
|
1054
|
1101
|
bool cmXmlNodeHasChild( const cmXmlNode_t* np, const cmChar_t* label, ... )
|
|
@@ -1060,6 +1107,7 @@ bool cmXmlNodeHasChild( const cmXmlNode_t* np, const cmChar_t* label, ... )
|
1060
|
1107
|
return fl;
|
1061
|
1108
|
}
|
1062
|
1109
|
|
|
1110
|
+/*
|
1063
|
1111
|
bool _cmXmlNodeHasChildWithAttrAndValueV( const cmXmlNode_t* np, const cmChar_t* label, va_list vl0, bool valueFl )
|
1064
|
1112
|
{
|
1065
|
1113
|
unsigned argN = _cmXmlLabelCount(label,vl0);
|
|
@@ -1105,6 +1153,48 @@ bool _cmXmlNodeHasChildWithAttrAndValueV( const cmXmlNode_t* np, const cmChar
|
1105
|
1153
|
|
1106
|
1154
|
return true;
|
1107
|
1155
|
}
|
|
1156
|
+*/
|
|
1157
|
+
|
|
1158
|
+bool _cmXmlNodeHasChildWithAttrAndValueV( const cmXmlNode_t* np, const cmChar_t* label, va_list vl0, bool valueFl )
|
|
1159
|
+{
|
|
1160
|
+ unsigned argN = _cmXmlLabelCount(label,vl0);
|
|
1161
|
+ unsigned n = valueFl ? 2 : 1;
|
|
1162
|
+ const cmChar_t* attrLabel = NULL;
|
|
1163
|
+ const cmChar_t* valueStr = NULL;
|
|
1164
|
+ const cmXmlNode_t* cnp = NULL;
|
|
1165
|
+ va_list vl1;
|
|
1166
|
+ unsigned i;
|
|
1167
|
+
|
|
1168
|
+ va_copy(vl1,vl0);
|
|
1169
|
+
|
|
1170
|
+ assert( argN > n-1 ); // an attribute label must be given.
|
|
1171
|
+
|
|
1172
|
+ if( argN <= n-1 )
|
|
1173
|
+ goto errLabel;
|
|
1174
|
+
|
|
1175
|
+ argN -= n;
|
|
1176
|
+
|
|
1177
|
+
|
|
1178
|
+ // advance vl0 to the attribute label
|
|
1179
|
+ for(i=1; i<argN; ++i)
|
|
1180
|
+ {
|
|
1181
|
+ attrLabel = va_arg(vl0,const cmChar_t*);
|
|
1182
|
+ assert( attrLabel != NULL );
|
|
1183
|
+ }
|
|
1184
|
+
|
|
1185
|
+ // get the attr label
|
|
1186
|
+ attrLabel = va_arg(vl0,const cmChar_t*);
|
|
1187
|
+
|
|
1188
|
+ if( valueFl )
|
|
1189
|
+ valueStr = va_arg(vl0,const cmChar_t*);
|
|
1190
|
+
|
|
1191
|
+ cnp = _cmXmlNodeHasChildV(np,label,vl1,argN,attrLabel,valueStr);
|
|
1192
|
+
|
|
1193
|
+ errLabel:
|
|
1194
|
+ va_end(vl1);
|
|
1195
|
+
|
|
1196
|
+ return cnp != NULL;
|
|
1197
|
+ }
|
1108
|
1198
|
|
1109
|
1199
|
bool cmXmlNodeHasChildWithAttrAndValueV( const cmXmlNode_t* np, const cmChar_t* label, va_list vl )
|
1110
|
1200
|
{ return _cmXmlNodeHasChildWithAttrAndValueV(np,label,vl,true); }
|