ENH: Added cmXMLParser::FindAttribute method

This method will help subclasses look for element attributes in their
StartElement methods.
This commit is contained in:
Brad King 2009-02-24 15:43:49 -05:00
parent d033f0d2d1
commit b5db18e723
2 changed files with 20 additions and 0 deletions

View File

@ -180,6 +180,23 @@ int cmXMLParser::IsSpace(char c)
return isspace(c);
}
//----------------------------------------------------------------------------
const char* cmXMLParser::FindAttribute(const char** atts,
const char* attribute)
{
if(atts && attribute)
{
for(const char** a = atts; *a && *(a+1); a += 2)
{
if(strcmp(*a, attribute) == 0)
{
return *(a+1);
}
}
}
return 0;
}
//----------------------------------------------------------------------------
void cmXMLParserStartElement(void* parser, const char *name,
const char **atts)

View File

@ -105,6 +105,9 @@ protected:
//! Send the given c-style string to the XML parser.
int ParseBuffer(const char* buffer);
/** Helps subclasses search for attributes on elements. */
static const char* FindAttribute(const char** atts, const char* attribute);
//! Callbacks for the expat
friend void cmXMLParserStartElement(void*, const char*, const char**);
friend void cmXMLParserEndElement(void*, const char*);