syBR::Core::XMLNode Class Reference

XML node class. More...

#include <XML.hpp>

List of all members.

Public Member Functions

 XMLNode (TiXmlElement *pSource)
 Constructor to be used when loading an XML node.
 ~XMLNode ()
 Destructor.
const std::string getName () const
 Get the name of the node.
const bool getAttribute (const std::string &name, std::string &value) const
 Get the value of an attribute.
bool setAttribute (const std::string &name, const std::string &value)
 Set the value of an attribute.
XMLNodegetChild (const unsigned int index) const
 Get a child node.
const unsigned int getChildrenCount () const
 Get the number of child nodes.
XMLNodeaddChild (const std::string &name)
 Add a child node.
const unsigned int getFileLine () const
 Get the line number related to this node in the XML file.

Private Attributes

TiXmlElement * m_pContent
 Content of the node, including attributes and children (TinyXML format).
std::vector< XMLNode * > m_vpChildren
 Children of the node.


Detailed Description

XML node class.

It is used to browse the content of a XML file. Note that an instance of this class must NEVER be manually deleted. Load a XML file by using the XMLFile() class and browse its content by using XMLNode() instances. When done with the XML file, just delete it and it will automatically delete all its XMLNode() children.


Constructor & Destructor Documentation

syBR::Core::XMLNode::XMLNode ( TiXmlElement *  pSource  ) 

Constructor to be used when loading an XML node.

Parameters:
pSource XML element to use as the source content of this node

syBR::Core::XMLNode::~XMLNode (  ) 

Destructor.


Member Function Documentation

const std::string syBR::Core::XMLNode::getName (  )  const

Get the name of the node.

Returns:
Name of the node

const bool syBR::Core::XMLNode::getAttribute ( const std::string &  name,
std::string &  value 
) const

Get the value of an attribute.

Parameters:
name Name of the attribute to retrieve
value Reference to a string who will be replaced the attribute value if the attribute exists
Returns:
One of these
  • true if the attribute exists
  • false otherwise

bool syBR::Core::XMLNode::setAttribute ( const std::string &  name,
const std::string &  value 
)

Set the value of an attribute.

If the attribute does not exist, it will be created. otherwise, the existing value will be replaced.

Parameters:
name Name of the attribute
value Value to set to the attribute
Returns:
One of these
  • true in case of success
  • false otherwise

XMLNode * syBR::Core::XMLNode::getChild ( const unsigned int  index  )  const

Get a child node.

Parameters:
index Zero-based index of the child to retrieve
Returns:
One of these:
  • Pointer to the child node if index < children count
  • NULL otherwise

const unsigned int syBR::Core::XMLNode::getChildrenCount (  )  const

Get the number of child nodes.

Returns:
Children count

XMLNode * syBR::Core::XMLNode::addChild ( const std::string &  name  ) 

Add a child node.

Parameters:
name Name of the child node to add
Returns:
One of these:
  • Pointer to the added child node in case of success
  • NULL otherwise

const unsigned int syBR::Core::XMLNode::getFileLine (  )  const

Get the line number related to this node in the XML file.

Returns:
One of these:
  • Line number in the file
  • 0 if the node has not been initialized


Member Data Documentation

TiXmlElement* syBR::Core::XMLNode::m_pContent [private]

Content of the node, including attributes and children (TinyXML format).

std::vector<XMLNode *> syBR::Core::XMLNode::m_vpChildren [private]

Children of the node.


The documentation for this class was generated from the following files:

Copyright © 2008 by Sebastien Frippiat
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 License.
Last modified Tue Dec 30 17:57:33 2008