[Compbench-devel] CompBenchmarks++/libcompbenchmarks/Base XML.cpp, 1.2, 1.3 XML.h, 1.2, 1.3
Brought to you by:
xfred
From: Frederic T. <xf...@us...> - 2007-01-24 19:39:24
|
Update of /cvsroot/compbench/CompBenchmarks++/libcompbenchmarks/Base In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv1578 Modified Files: XML.cpp XML.h Log Message: getChild() and getAttribute() by names. Index: XML.h =================================================================== RCS file: /cvsroot/compbench/CompBenchmarks++/libcompbenchmarks/Base/XML.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** XML.h 23 Jan 2007 18:44:18 -0000 1.2 --- XML.h 24 Jan 2007 19:39:18 -0000 1.3 *************** *** 104,107 **** --- 104,111 ---- virtual XMLNode *getChild(int _index); + /** Get a child node according to its name + * \return A node + * \sa getChild() */ + virtual XMLNode *getChild(std::string _name); /** Get attributes' number *************** *** 110,113 **** --- 114,122 ---- virtual int attributeNumber(void); + /** Get an attribute according to its name + * \return An attribute + * \sa getAttribute()() */ + virtual XMLAttribute *getAttribute(std::string _name); + /** Get an attribute according to its index * \return An attribute Index: XML.cpp =================================================================== RCS file: /cvsroot/compbench/CompBenchmarks++/libcompbenchmarks/Base/XML.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** XML.cpp 23 Jan 2007 18:44:18 -0000 1.2 --- XML.cpp 24 Jan 2007 19:39:18 -0000 1.3 *************** *** 8,11 **** --- 8,13 ---- #include <Base/XML.h> + #include <System/System.h> + using namespace CBM; *************** *** 27,30 **** --- 29,33 ---- } + void XMLAttribute::setValue(std::string _value) { *************** *** 85,88 **** --- 88,106 ---- } + XMLNode *XMLNode::getChild(std::string _name) + { + int i; + int n = childNumber(); + XMLNode *N = 0; + + for(i=0; i<n; i++) { + N=getChild(i); + if (N->Name() == _name) + return(N); + } + + return(N); + } + int XMLNode::attributeNumber(void) { *************** *** 90,93 **** --- 108,126 ---- } + XMLAttribute *XMLNode::getAttribute(std::string _name) + { + int i; + int n = attributeNumber(); + XMLAttribute *A = 0; + + for(i=0; i<n; i++) { + A=getAttribute(i); + if (A->Name() == _name) + return(A); + } + + return(A); + } + XMLAttribute *XMLNode::getAttribute(int _index) { |