Thread: [Compbench-devel] CompBenchmarks++/System XML.cpp, 1.2, 1.3 XML.h, 1.3, 1.4
Brought to you by:
xfred
From: Frederic T. <xf...@us...> - 2007-01-21 20:45:14
|
Update of /cvsroot/compbench/CompBenchmarks++/System In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv18838 Modified Files: XML.cpp XML.h Log Message: CBM namespace. Index: XML.h =================================================================== RCS file: /cvsroot/compbench/CompBenchmarks++/System/XML.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** XML.h 18 Jan 2007 18:43:02 -0000 1.3 --- XML.h 21 Jan 2007 20:45:09 -0000 1.4 *************** *** 14,148 **** namespace CBM { ! namespace XML { ! ! /** \brief XML Attribute ! * Internal representation for an XML attribute. ! */ ! class Attribute ! { ! protected: ! std::string name; /*!< Attribute name */ ! std::string value; /*!< Attribute value */ ! public: ! /** Constructor ! * Initialise a new attribute. ! * \param _name Attribute's name ! * \param _value Attribute's value (optional) */ ! Attribute(std::string _name, ! std::string _value = ""); ! /** Get attribute's name ! \return a std::string */ ! virtual std::string Name(void); ! /** Get attribute's value ! \return a std::string */ ! virtual std::string Value(void); ! /** Set attribute's value ! \param _value new value (std::string) ! */ ! virtual void setValue(std::string _value); ! /** Destructor */ ! virtual ~Attribute(); ! }; ! /** \brief XML Node ! * Internal representation of an XML node. ! */ ! class Node ! { ! protected: ! std::vector<Node*> childs; /*!< Child nodes */ ! std::vector<Attribute*> attributes; /*!< Node's attributes */ ! std::string name; /*!< Node's name */ ! std::string value; /*!< Node value */ ! virtual void indent(std::string& str, ! int _indent); ! public: ! /** Constructor ! * Initialise a new node. ! * \param _name Node's name ! * \param _value Node's value (optional) */ ! Node(std::string _name, ! std::string _value = ""); ! /** Get node's name ! \return a std::string */ ! virtual std::string Name(void); ! /** Get node's value ! \return a std::string */ ! virtual std::string Value(void); ! /** Set node's value ! \param _value new value (std::string) ! */ ! virtual void setValue(std::string _value); ! /** Get childs' number ! * \return number of nodes held by current node ! * \sa getChild() */ ! virtual int childNumber(void); ! /** Get a child node according to its index ! * \return A node ! * \sa childNumber() */ ! virtual Node *getChild(int _index); ! /** Get attributes' number ! * \return number of attributes on current node ! * \sa getAttribute() */ ! virtual int attributeNumber(void); ! /** Get an attribute according to its index ! * \return An attribute ! * \sa attributeNumber() */ ! virtual Attribute *getAttribute(int _index); ! /** Add a node into current node ! * \param _child node to add ! * \return node added (_child) ! * \sa addNode() */ ! virtual Node *add(Node *_child); ! /** Add a node into current node ! * \param _name name of the node ! * \param _value value of the node (optional) ! * \return node added (_child) ! * \sa add() */ ! virtual Node *addNode(std::string _name, ! std::string _value = ""); ! /** Add an attribute on current node ! * \param _attribute to add ! * \return attribute added (_attribute) ! * \sa addAttribute() */ ! virtual Attribute *add(Attribute *_attribute); ! /** Add an attribute on current node ! * \param _name name of the attribute ! * \param _value value of the attribute (optional) ! * \return attribute added (_attribute) ! * \sa add() */ ! virtual Attribute *addAttribute(std::string _name, ! std::string _value = ""); ! /** Get textual (XML) representation of the node ! * Build a string corresponding to the XML elements of current node and ! * childs (includes attributes and value). ! * \param _indent Optional indentation level; internal use only. ! * \return string (XML formatted) */ ! virtual std::string str(int _indent = 0); ! virtual ~Node(); ! }; ! } } --- 14,147 ---- namespace CBM { ! /** \brief XML Attribute ! * Internal representation for an XML attribute. ! * \sa XMLNode ! */ ! class XMLAttribute ! { ! protected: ! std::string name; /*!< Attribute name */ ! std::string value; /*!< Attribute value */ ! public: ! /** Constructor ! * Initialise a new attribute. ! * \param _name Attribute's name ! * \param _value Attribute's value (optional) */ ! XMLAttribute(std::string _name, ! std::string _value = ""); ! /** Get attribute's name ! \return a std::string */ ! virtual std::string Name(void); ! /** Get attribute's value ! \return a std::string */ ! virtual std::string Value(void); ! /** Set attribute's value ! \param _value new value (std::string) ! */ ! virtual void setValue(std::string _value); ! /** Destructor */ ! virtual ~XMLAttribute(); ! }; ! /** \brief XML Node ! * Internal representation of an XML node. ! * \sa XMLAttribute ! */ ! class XMLNode ! { ! protected: ! std::vector<XMLNode*> childs; /*!< Child nodes */ ! std::vector<XMLAttribute*> attributes; /*!< Node's attributes */ ! std::string name; /*!< Node's name */ ! std::string value; /*!< Node value */ ! virtual void indent(std::string& str, ! int _indent); ! public: ! /** Constructor ! * Initialise a new node. ! * \param _name Node's name ! * \param _value Node's value (optional) */ ! XMLNode(std::string _name, ! std::string _value = ""); ! /** Get node's name ! \return a std::string */ ! virtual std::string Name(void); ! /** Get node's value ! \return a std::string */ ! virtual std::string Value(void); ! /** Set node's value ! \param _value new value (std::string) ! */ ! virtual void setValue(std::string _value); ! /** Get childs' number ! * \return number of nodes held by current node ! * \sa getChild() */ ! virtual int childNumber(void); ! /** Get a child node according to its index ! * \return A node ! * \sa childNumber() */ ! virtual XMLNode *getChild(int _index); ! /** Get attributes' number ! * \return number of attributes on current node ! * \sa getAttribute() */ ! virtual int attributeNumber(void); ! /** Get an attribute according to its index ! * \return An attribute ! * \sa attributeNumber() */ ! virtual XMLAttribute *getAttribute(int _index); ! /** Add a node into current node ! * \param _child node to add ! * \return node added (_child) ! * \sa addNode() */ ! virtual XMLNode *add(XMLNode *_child); ! /** Add a node into current node ! * \param _name name of the node ! * \param _value value of the node (optional) ! * \return node added (_child) ! * \sa add() */ ! virtual XMLNode *addNode(std::string _name, ! std::string _value = ""); ! /** Add an attribute on current node ! * \param _attribute to add ! * \return attribute added (_attribute) ! * \sa addAttribute() */ ! virtual XMLAttribute *add(XMLAttribute *_attribute); ! /** Add an attribute on current node ! * \param _name name of the attribute ! * \param _value value of the attribute (optional) ! * \return attribute added (_attribute) ! * \sa add() */ ! virtual XMLAttribute *addAttribute(std::string _name, ! std::string _value = ""); ! /** Get textual (XML) representation of the node ! * Build a string corresponding to the XML elements of current node and ! * childs (includes attributes and value). ! * \param _indent Optional indentation level; internal use only. ! * \return string (XML formatted) */ ! virtual std::string str(int _indent = 0); ! virtual ~XMLNode(); ! }; } Index: XML.cpp =================================================================== RCS file: /cvsroot/compbench/CompBenchmarks++/System/XML.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** XML.cpp 18 Jan 2007 18:43:02 -0000 1.2 --- XML.cpp 21 Jan 2007 20:45:09 -0000 1.3 *************** *** 8,15 **** #include <System/XML.h> ! using namespace CBM::XML; ! Attribute::Attribute(std::string _name, ! std::string _value) { name=_name; --- 8,15 ---- #include <System/XML.h> ! using namespace CBM; ! XMLAttribute::XMLAttribute(std::string _name, ! std::string _value) { name=_name; *************** *** 17,40 **** } ! std::string Attribute::Name(void) { return(name); } ! std::string Attribute::Value(void) { return(value); } ! void Attribute::setValue(std::string _value) { value=_value; } ! Attribute::~Attribute() { } ! Node::Node(std::string _name, std::string _value) { --- 17,40 ---- } ! std::string XMLAttribute::Name(void) { return(name); } ! std::string XMLAttribute::Value(void) { return(value); } ! void XMLAttribute::setValue(std::string _value) { value=_value; } ! XMLAttribute::~XMLAttribute() { } ! XMLNode::XMLNode(std::string _name, std::string _value) { *************** *** 43,47 **** } ! void Node::indent(std::string& str, int _indent) { --- 43,47 ---- } ! void XMLNode::indent(std::string& str, int _indent) { *************** *** 50,84 **** } ! std::string Node::Name(void) { return(name); } ! std::string Node::Value(void) { return(value); } ! void Node::setValue(std::string _value) { value=_value; } ! int Node::childNumber(void) { return(childs.size()); } ! Node *Node::getChild(int _index) { return(childs[_index]); } ! int Node::attributeNumber(void) { return(attributes.size()); } ! Attribute *Node::getAttribute(int _index) { return(attributes[_index]); --- 50,84 ---- } ! std::string XMLNode::Name(void) { return(name); } ! std::string XMLNode::Value(void) { return(value); } ! void XMLNode::setValue(std::string _value) { value=_value; } ! int XMLNode::childNumber(void) { return(childs.size()); } ! XMLNode *XMLNode::getChild(int _index) { return(childs[_index]); } ! int XMLNode::attributeNumber(void) { return(attributes.size()); } ! XMLAttribute *XMLNode::getAttribute(int _index) { return(attributes[_index]); *************** *** 86,90 **** ! Node *Node::add(Node *_child) { childs.push_back(_child); --- 86,90 ---- ! XMLNode *XMLNode::add(XMLNode *_child) { childs.push_back(_child); *************** *** 92,104 **** } ! Node *Node::addNode(std::string _name, ! std::string _value) { ! Node *result = new Node(_name, _value); return(add(result)); } ! Attribute *Node::add(Attribute *_attribute) { attributes.push_back(_attribute); --- 92,104 ---- } ! XMLNode *XMLNode::addNode(std::string _name, ! std::string _value) { ! XMLNode *result = new XMLNode(_name, _value); return(add(result)); } ! XMLAttribute *XMLNode::add(XMLAttribute *_attribute) { attributes.push_back(_attribute); *************** *** 106,121 **** } ! Attribute *Node::addAttribute(std::string _name, ! std::string _value) { ! Attribute *result = new Attribute(_name, _value); return(add(result)); } ! std::string Node::str(int _indent) { std::string result; ! Attribute *att; int i; int n_child; --- 106,121 ---- } ! XMLAttribute *XMLNode::addAttribute(std::string _name, ! std::string _value) { ! XMLAttribute *result = new XMLAttribute(_name, _value); return(add(result)); } ! std::string XMLNode::str(int _indent) { std::string result; ! XMLAttribute *att; int i; int n_child; *************** *** 173,177 **** } ! Node::~Node() { } --- 173,177 ---- } ! XMLNode::~XMLNode() { } |