LDK::XmlNode Class Reference

#include <LDK/XML.h>

Inheritance diagram for LDK::XmlNode:

Inheritance graph
[legend]
Collaboration diagram for LDK::XmlNode:

Collaboration graph
[legend]

Public Types

enum  NodeType {
  DOCUMENT, ELEMENT, COMMENT, UNKNOWN,
  TEXT, DECLARATION, TYPECOUNT
}

Public Member Functions

const char * Value () const
void SetValue (const char *_value)
void SetValue (const String &_value)
 LDK::String form.
void Clear ()
 Delete all the children of this node. Does not affect 'this'.
XmlNode * Parent ()
 One step up the DOM.
const XmlNode * Parent () const
const XmlNode * FirstChild () const
 The first child of this node. Will be null if there are no children.
XmlNode * FirstChild ()
const XmlNode * FirstChild (const char *value) const
 The first child of this node with the matching 'value'. Will be null if none found.
XmlNode * FirstChild (const char *value)
 The first child of this node with the matching 'value'. Will be null if none found.
const XmlNode * LastChild () const
XmlNode * LastChild ()
 The last child of this node. Will be null if there are no children.
const XmlNode * LastChild (const char *value) const
XmlNode * LastChild (const char *value)
 The last child of this node matching 'value'. Will be null if there are no children.
const XmlNode * FirstChild (const String &_value) const
 LDK::String form.
XmlNode * FirstChild (const String &_value)
 LDK::String form.
const XmlNode * LastChild (const String &_value) const
 LDK::String form.
XmlNode * LastChild (const String &_value)
 LDK::String form.
const XmlNode * IterateChildren (const XmlNode *previous) const
XmlNode * IterateChildren (XmlNode *previous)
const XmlNode * IterateChildren (const char *value, const XmlNode *previous) const
 This flavor of IterateChildren searches for children with a particular 'value'.
XmlNode * IterateChildren (const char *value, XmlNode *previous)
const XmlNode * IterateChildren (const String &_value, const XmlNode *previous) const
 LDK::String form.
XmlNode * IterateChildren (const String &_value, XmlNode *previous)
 LDK::String form.
XmlNode * InsertEndChild (const XmlNode &addThis)
XmlNode * LinkEndChild (XmlNode *addThis)
XmlNode * InsertBeforeChild (XmlNode *beforeThis, const XmlNode &addThis)
XmlNode * InsertAfterChild (XmlNode *afterThis, const XmlNode &addThis)
XmlNode * ReplaceChild (XmlNode *replaceThis, const XmlNode &withThis)
bool RemoveChild (XmlNode *removeThis)
 Delete a child of this node.
const XmlNode * PreviousSibling () const
 Navigate to a sibling node.
XmlNode * PreviousSibling ()
const XmlNode * PreviousSibling (const char *) const
 Navigate to a sibling node.
XmlNode * PreviousSibling (const char *)
const XmlNode * PreviousSibling (const String &_value) const
 LDK::String form.
XmlNode * PreviousSibling (const String &_value)
 LDK::String form.
const XmlNode * NextSibling (const String &_value) const
 LDK::String form.
XmlNode * NextSibling (const String &_value)
 LDK::String form.
const XmlNode * NextSibling () const
 Navigate to a sibling node.
XmlNode * NextSibling ()
const XmlNode * NextSibling (const char *) const
 Navigate to a sibling node with the given 'value'.
XmlNode * NextSibling (const char *)
const XmlElement * NextSiblingElement () const
XmlElement * NextSiblingElement ()
const XmlElement * NextSiblingElement (const char *) const
XmlElement * NextSiblingElement (const char *)
const XmlElement * NextSiblingElement (const String &_value) const
 LDK::String form.
XmlElement * NextSiblingElement (const String &_value)
 LDK::String form.
const XmlElement * FirstChildElement () const
 Convenience function to get through elements.
XmlElement * FirstChildElement ()
const XmlElement * FirstChildElement (const char *value) const
 Convenience function to get through elements.
XmlElement * FirstChildElement (const char *value)
const XmlElement * FirstChildElement (const String &_value) const
 LDK::String form.
XmlElement * FirstChildElement (const String &_value)
 LDK::String form.
virtual int Type () const
const XmlDocument * GetDocument () const
XmlDocument * GetDocument ()
bool NoChildren () const
 Returns true if this node has no children.
const XmlDocument * ToDocument () const
 Cast to a more defined type. Will return null not of the requested type.
const XmlElement * ToElement () const
 Cast to a more defined type. Will return null not of the requested type.
const XmlComment * ToComment () const
 Cast to a more defined type. Will return null not of the requested type.
const XmlUnknown * ToUnknown () const
 Cast to a more defined type. Will return null not of the requested type.
const XmlText * ToText () const
 Cast to a more defined type. Will return null not of the requested type.
const XmlDeclaration * ToDeclaration () const
 Cast to a more defined type. Will return null not of the requested type.
XmlDocument * ToDocument ()
 Cast to a more defined type. Will return null not of the requested type.
XmlElement * ToElement ()
 Cast to a more defined type. Will return null not of the requested type.
XmlComment * ToComment ()
 Cast to a more defined type. Will return null not of the requested type.
XmlUnknown * ToUnknown ()
 Cast to a more defined type. Will return null not of the requested type.
XmlText * ToText ()
 Cast to a more defined type. Will return null not of the requested type.
XmlDeclaration * ToDeclaration ()
 Cast to a more defined type. Will return null not of the requested type.
virtual XmlNode * Clone () const=0

Protected Member Functions

 XmlNode (NodeType _type)
void CopyTo (XmlNode *target) const
XmlNode * Identify (const char *start, XmlEncoding encoding)
const LDKXML_STRING & SValue () const

Protected Attributes

XmlNode * parent
NodeType type
XmlNode * firstChild
XmlNode * lastChild
LDKXML_STRING value
XmlNode * prev
XmlNode * next

Friends

class LDK_API XmlDocument
class LDK_API XmlElement
LDKXML_OSTREAM & operator<< (LDKXML_OSTREAM &out, const XmlNode &base)

Detailed Description

The parent class for everything in the Document Object Model. (Except for attributes). Nodes have siblings, a parent, and children. A node can be in a document, or stand on its own. The type of a XmlNode can be queried, and it can be cast to its more defined type.

Definition at line 384 of file XML.h.


Member Enumeration Documentation

enum LDK::XmlNode::NodeType

The types of XML nodes supported by TinyXml. (All the unsupported types are picked up by UNKNOWN.)

Definition at line 426 of file XML.h.


Member Function Documentation

const char* LDK::XmlNode::Value (  )  const [inline]

The meaning of 'value' changes for the specific type of XmlNode.

        Document:   filename of the xml file
        Element:    name of the element
        Comment:    the comment text
        Unknown:    the tag contents
        Text:       the text string
        

The subclasses will wrap this function.

Definition at line 451 of file XML.h.

Referenced by LDK::GenericXmlBinding< const char * >::fromXml(), LDK::GenericXmlBinding< T >::fromXml(), LDK::FromXmlChildElement< T, MT >::fromXml(), LDK::StlContainerPtrBinding< T, VecT >::intoXml(), LDK::StlContainerXmlBinding< T, VecT >::intoXml(), and LDK::FromXmlElement< T, MT >::intoXml().

void LDK::XmlNode::SetValue ( const char *  _value  )  [inline]

Changes the value of the node. Defined as:

        Document:   filename of the xml file
        Element:    name of the element
        Comment:    the comment text
        Unknown:    the tag contents
        Text:       the text string
        

Definition at line 462 of file XML.h.

Referenced by LDK::FromXmlElement< T, MT >::intoXml().

const XmlNode* LDK::XmlNode::IterateChildren ( const XmlNode *  previous  )  const

An alternate way to walk the children of a node. One way to iterate over nodes is:

            for( child = parent->FirstChild(); child; child = child->NextSibling() )
        

IterateChildren does the same thing with the syntax:

            child = 0;
            while( child = parent->IterateChildren( child ) )
        

IterateChildren takes the previous child as input and finds the next one. If the previous child is null, it returns the first. IterateChildren will return null when done.

XmlNode* LDK::XmlNode::InsertEndChild ( const XmlNode &  addThis  ) 

Add a new node related to this. Adds a child past the LastChild. Returns a pointer to the new object or NULL if an error occured.

Referenced by LDK::StlContainerPtrBinding< T, VecT >::intoXml(), LDK::StlContainerXmlBinding< T, VecT >::intoXml(), LDK::GenericXmlBinding< const char * >::intoXml(), LDK::GenericXmlBinding< T >::intoXml(), and LDK::FromXmlChildElement< T, MT >::intoXml().

XmlNode* LDK::XmlNode::LinkEndChild ( XmlNode *  addThis  ) 

Add a new node related to this. Adds a child past the LastChild.

NOTE: the node to be added is passed by pointer, and will be henceforth owned (and deleted) by tinyXml. This method is efficient and avoids an extra copy, but should be used with care as it uses a different memory model than the other insert functions.

See also:
InsertEndChild

XmlNode* LDK::XmlNode::InsertBeforeChild ( XmlNode *  beforeThis,
const XmlNode &  addThis 
)

Add a new node related to this. Adds a child before the specified child. Returns a pointer to the new object or NULL if an error occured.

XmlNode* LDK::XmlNode::InsertAfterChild ( XmlNode *  afterThis,
const XmlNode &  addThis 
)

Add a new node related to this. Adds a child after the specified child. Returns a pointer to the new object or NULL if an error occured.

XmlNode* LDK::XmlNode::ReplaceChild ( XmlNode *  replaceThis,
const XmlNode &  withThis 
)

Replace a child of this node. Returns a pointer to the new object or NULL if an error occured.

const XmlElement* LDK::XmlNode::NextSiblingElement (  )  const

Convenience function to get through elements. Calls NextSibling and ToElement. Will skip all non-Element nodes. Returns 0 if there is not another element.

Referenced by LDK::StlContainerXmlBinding< T, VecT >::fromXml(), and LDK::MemberXmlBinding< T >::fromXml().

const XmlElement* LDK::XmlNode::NextSiblingElement ( const char *   )  const

Convenience function to get through elements. Calls NextSibling and ToElement. Will skip all non-Element nodes. Returns 0 if there is not another element.

virtual int LDK::XmlNode::Type (  )  const [inline, virtual]

Query the type (as an enumerated value, above) of this node. The possible types are: DOCUMENT, ELEMENT, COMMENT, UNKNOWN, TEXT, and DECLARATION.

Definition at line 608 of file XML.h.

const XmlDocument* LDK::XmlNode::GetDocument (  )  const

Return a pointer to the Document this node lives in. Returns null if not in a document.

virtual XmlNode* LDK::XmlNode::Clone (  )  const [pure virtual]

Create an exact duplicate of this node and return it. The memory must be deleted by the caller.

Implemented in LDK::XmlElement, LDK::XmlComment, LDK::XmlText, LDK::XmlDeclaration, LDK::XmlUnknown, and LDK::XmlDocument.


The documentation for this class was generated from the following file:
Generated on Fri Aug 17 18:32:28 2007 for LDK by  doxygen 1.5.1