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'.
XmlNodeParent ()
 One step up the DOM.
const XmlNodeParent () const
const XmlNodeFirstChild () const
 The first child of this node. Will be null if there are no children.
XmlNodeFirstChild ()
const XmlNodeFirstChild (const char *value) const
 The first child of this node with the matching 'value'. Will be null if none found.
XmlNodeFirstChild (const char *value)
 The first child of this node with the matching 'value'. Will be null if none found.
const XmlNodeLastChild () const
XmlNodeLastChild ()
 The last child of this node. Will be null if there are no children.
const XmlNodeLastChild (const char *value) const
XmlNodeLastChild (const char *value)
 The last child of this node matching 'value'. Will be null if there are no children.
const XmlNodeFirstChild (const String &_value) const
 LDK::String form.
XmlNodeFirstChild (const String &_value)
 LDK::String form.
const XmlNodeLastChild (const String &_value) const
 LDK::String form.
XmlNodeLastChild (const String &_value)
 LDK::String form.
const XmlNodeIterateChildren (const XmlNode *previous) const
XmlNodeIterateChildren (XmlNode *previous)
const XmlNodeIterateChildren (const char *value, const XmlNode *previous) const
 This flavor of IterateChildren searches for children with a particular 'value'.
XmlNodeIterateChildren (const char *value, XmlNode *previous)
const XmlNodeIterateChildren (const String &_value, const XmlNode *previous) const
 LDK::String form.
XmlNodeIterateChildren (const String &_value, XmlNode *previous)
 LDK::String form.
XmlNodeInsertEndChild (const XmlNode &addThis)
XmlNodeLinkEndChild (XmlNode *addThis)
XmlNodeInsertBeforeChild (XmlNode *beforeThis, const XmlNode &addThis)
XmlNodeInsertAfterChild (XmlNode *afterThis, const XmlNode &addThis)
XmlNodeReplaceChild (XmlNode *replaceThis, const XmlNode &withThis)
bool RemoveChild (XmlNode *removeThis)
 Delete a child of this node.
const XmlNodePreviousSibling () const
 Navigate to a sibling node.
XmlNodePreviousSibling ()
const XmlNodePreviousSibling (const char *) const
 Navigate to a sibling node.
XmlNodePreviousSibling (const char *)
const XmlNodePreviousSibling (const String &_value) const
 LDK::String form.
XmlNodePreviousSibling (const String &_value)
 LDK::String form.
const XmlNodeNextSibling (const String &_value) const
 LDK::String form.
XmlNodeNextSibling (const String &_value)
 LDK::String form.
const XmlNodeNextSibling () const
 Navigate to a sibling node.
XmlNodeNextSibling ()
const XmlNodeNextSibling (const char *) const
 Navigate to a sibling node with the given 'value'.
XmlNodeNextSibling (const char *)
const XmlElementNextSiblingElement () const
XmlElementNextSiblingElement ()
const XmlElementNextSiblingElement (const char *) const
XmlElementNextSiblingElement (const char *)
const XmlElementNextSiblingElement (const String &_value) const
 LDK::String form.
XmlElementNextSiblingElement (const String &_value)
 LDK::String form.
const XmlElementFirstChildElement () const
 Convenience function to get through elements.
XmlElementFirstChildElement ()
const XmlElementFirstChildElement (const char *value) const
 Convenience function to get through elements.
XmlElementFirstChildElement (const char *value)
const XmlElementFirstChildElement (const String &_value) const
 LDK::String form.
XmlElementFirstChildElement (const String &_value)
 LDK::String form.
virtual int Type () const
const XmlDocumentGetDocument () const
XmlDocumentGetDocument ()
bool NoChildren () const
 Returns true if this node has no children.
const XmlDocumentToDocument () const
 Cast to a more defined type. Will return null not of the requested type.
const XmlElementToElement () const
 Cast to a more defined type. Will return null not of the requested type.
const XmlCommentToComment () const
 Cast to a more defined type. Will return null not of the requested type.
const XmlUnknownToUnknown () const
 Cast to a more defined type. Will return null not of the requested type.
const XmlTextToText () const
 Cast to a more defined type. Will return null not of the requested type.
const XmlDeclarationToDeclaration () const
 Cast to a more defined type. Will return null not of the requested type.
XmlDocumentToDocument ()
 Cast to a more defined type. Will return null not of the requested type.
XmlElementToElement ()
 Cast to a more defined type. Will return null not of the requested type.
XmlCommentToComment ()
 Cast to a more defined type. Will return null not of the requested type.
XmlUnknownToUnknown ()
 Cast to a more defined type. Will return null not of the requested type.
XmlTextToText ()
 Cast to a more defined type. Will return null not of the requested type.
XmlDeclarationToDeclaration ()
 Cast to a more defined type. Will return null not of the requested type.
virtual XmlNodeClone () const=0

Protected Member Functions

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

Protected Attributes

XmlNodeparent
NodeType type
XmlNodefirstChild
XmlNodelastChild
LDKXML_STRING value
XmlNodeprev
XmlNodenext

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