cmXml.h/c : Added cmXmlHasChild() and cmXmlNodeDouble().
This commit is contained in:
parent
3c81940892
commit
dd03627898
30
cmXml.c
30
cmXml.c
@ -169,6 +169,7 @@ cmXmlNode_t* _cmXmlNodeAlloc( cmXml_t* p, unsigned flags, const cmChar_t* label,
|
|||||||
if( label != NULL )
|
if( label != NULL )
|
||||||
np->label = cmLhAllocStrN(p->heapH,label,labelN);
|
np->label = cmLhAllocStrN(p->heapH,label,labelN);
|
||||||
|
|
||||||
|
np->line = p->line;
|
||||||
np->flags = flags;
|
np->flags = flags;
|
||||||
|
|
||||||
return np;
|
return np;
|
||||||
@ -992,14 +993,33 @@ cmXmlRC_t cmXmlNodeDouble(const cmXmlNode_t* np, double* retRef, ...)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cmXmlNodeHasChild( const cmXmlNode_t* np, const cmChar_t* label )
|
bool cmXmlNodeHasChildV( const cmXmlNode_t* np, const cmChar_t* label, va_list vl )
|
||||||
{
|
{
|
||||||
const cmXmlNode_t* cnp = np->children;
|
const cmChar_t* str = NULL;
|
||||||
for(; cnp!=NULL; cnp=cnp->sibling)
|
|
||||||
if( cmTextCmp(cnp->label,label) == 0 )
|
|
||||||
return true;
|
|
||||||
|
|
||||||
|
// get next label to match
|
||||||
|
while( (str = va_arg(vl,const cmChar_t*)) == NULL )
|
||||||
|
{
|
||||||
|
np = np->children;
|
||||||
|
for(; np!=NULL; np=np->sibling)
|
||||||
|
if( cmTextCmp(np->label,label) == 0 )
|
||||||
|
break;
|
||||||
|
|
||||||
|
// if the end of the child list was encountered - with no match
|
||||||
|
if( np == NULL )
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool cmXmlNodeHasChild( const cmXmlNode_t* np, const cmChar_t* label, ... )
|
||||||
|
{
|
||||||
|
va_list vl;
|
||||||
|
va_start(vl,label);
|
||||||
|
bool fl = cmXmlNodeHasChildV(np,label,vl);
|
||||||
|
va_end(vl);
|
||||||
|
return fl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
11
cmXml.h
11
cmXml.h
@ -35,6 +35,7 @@ extern "C" {
|
|||||||
|
|
||||||
typedef struct cmXmlNode_str
|
typedef struct cmXmlNode_str
|
||||||
{
|
{
|
||||||
|
unsigned line; // line number
|
||||||
unsigned flags; // See k???XmlFl
|
unsigned flags; // See k???XmlFl
|
||||||
|
|
||||||
const cmChar_t* label; // node label
|
const cmChar_t* label; // node label
|
||||||
@ -69,19 +70,23 @@ extern "C" {
|
|||||||
cmXmlRC_t cmXmlAttrUInt( const cmXmlNode_t* np, const cmChar_t* attrLabel, unsigned* retRef );
|
cmXmlRC_t cmXmlAttrUInt( const cmXmlNode_t* np, const cmChar_t* attrLabel, unsigned* retRef );
|
||||||
|
|
||||||
// Return the data value for a node or attributes.
|
// Return the data value for a node or attributes.
|
||||||
// List Syntax: node-label-0, node-label-1, NULL, attr-label-0 attr-label-1
|
// Terminate node label list with NULL.
|
||||||
const cmChar_t* cmXmlNodeValueV( const cmXmlNode_t* np, va_list vl );
|
const cmChar_t* cmXmlNodeValueV( const cmXmlNode_t* np, va_list vl );
|
||||||
const cmChar_t* cmXmlNodeValue( const cmXmlNode_t* np, ... );
|
const cmChar_t* cmXmlNodeValue( const cmXmlNode_t* np, ... );
|
||||||
|
|
||||||
|
// Terminate node label list with NULL.
|
||||||
cmXmlRC_t cmXmlNodeIntV( const cmXmlNode_t* np, int* retRef, va_list vl );
|
cmXmlRC_t cmXmlNodeIntV( const cmXmlNode_t* np, int* retRef, va_list vl );
|
||||||
cmXmlRC_t cmXmlNodeUIntV( const cmXmlNode_t* np, unsigned* retRef, va_list vl );
|
cmXmlRC_t cmXmlNodeUIntV( const cmXmlNode_t* np, unsigned* retRef, va_list vl );
|
||||||
cmXmlRC_t cmXmlNodeDoubleV( const cmXmlNode_t* np, double* retRef, va_list vl );
|
cmXmlRC_t cmXmlNodeDoubleV( const cmXmlNode_t* np, double* retRef, va_list vl );
|
||||||
|
|
||||||
|
// Terminate node label list with NULL.
|
||||||
cmXmlRC_t cmXmlNodeInt( const cmXmlNode_t* np, int* retRef, ... );
|
cmXmlRC_t cmXmlNodeInt( const cmXmlNode_t* np, int* retRef, ... );
|
||||||
cmXmlRC_t cmXmlNodeUInt( const cmXmlNode_t* np, unsigned* retRef, ... );
|
cmXmlRC_t cmXmlNodeUInt( const cmXmlNode_t* np, unsigned* retRef, ... );
|
||||||
cmXmlRC_t cmXmlNodeDouble(const cmXmlNode_t* np, double* retRef, ...);
|
cmXmlRC_t cmXmlNodeDouble(const cmXmlNode_t* np, double* retRef, ... );
|
||||||
|
|
||||||
bool cmXmlNodeHasChild( const cmXmlNode_t* np, const cmChar_t* label );
|
// Terminate node label list with NULL.
|
||||||
|
bool cmXmlNodeHasChildV(const cmXmlNode_t* np, const cmChar_t* label, va_list vl );
|
||||||
|
bool cmXmlNodeHasChild( const cmXmlNode_t* np, const cmChar_t* label, ... );
|
||||||
|
|
||||||
|
|
||||||
cmXmlRC_t cmXmlTest( cmCtx_t* ctx, const cmChar_t* fn );
|
cmXmlRC_t cmXmlTest( cmCtx_t* ctx, const cmChar_t* fn );
|
||||||
|
Loading…
Reference in New Issue
Block a user