PixelLightAPI  .
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes
PLCore::XmlNode Class Reference

Abstract XML node. More...

#include <XmlNode.h>

Inheritance diagram for PLCore::XmlNode:
Inheritance graph
[legend]

List of all members.

Public Types

enum  ENodeType {
  Document, Element, Comment, Unknown,
  Text, Declaration, NumOfTypes
}
 The supported types of XML nodes. (All the unsupported types are picked up by 'Unknown'.) More...

Public Member Functions

virtual PLCORE_API ~XmlNode ()
 Destructor.
String GetValue () const
 The meaning of 'value' changes for the specific type of 'XmlNode'.
void SetValue (const String &sValue)
 Changes the value of the node.
PLCORE_API void Clear ()
 Delete all the children of this node.
XmlNodeGetParent ()
 One step up the DOM.
const XmlNodeGetParent () const
XmlNodeGetFirstChild ()
 Returns the first child of this node.
const XmlNodeGetFirstChild () const
PLCORE_API XmlNodeGetFirstChild (const String &sValue)
 Returns the first child of this node with the matching 'value'.
PLCORE_API const XmlNodeGetFirstChild (const String &sValue) const
XmlNodeGetLastChild ()
 Returns the last child of this node.
const XmlNodeGetLastChild () const
PLCORE_API XmlNodeGetLastChild (const String &sValue)
 Returns the last child of this node with the matching 'value'.
PLCORE_API const XmlNodeGetLastChild (const String &sValue) const
XmlNodeIterateChildren (XmlNode *pPrevious)
 An alternate way to walk the children of a node.
const XmlNodeIterateChildren (const XmlNode *pPrevious) const
XmlNodeIterateChildren (const String &sValue, XmlNode *pPrevious)
 This flavor of 'IterateChildren()' searches for children with a particular 'value'.
const XmlNodeIterateChildren (const String &sValue, const XmlNode *pPrevious) const
PLCORE_API XmlNodeInsertEndChild (const XmlNode &cAddThis)
 Add a new node related to this (adds a child past the last child)
PLCORE_API XmlNodeLinkEndChild (XmlNode &cAddThis)
 Add a new node related to this (adds a child past the last child)
PLCORE_API XmlNodeInsertBeforeChild (XmlNode &cBeforeThis, const XmlNode &cAddThis)
 Add a new node related to this (adds a child before the specified child)
PLCORE_API XmlNodeInsertAfterChild (XmlNode &cAfterThis, const XmlNode &cAddThis)
 Add a new node related to this (adds a child after the specified child)
PLCORE_API XmlNodeReplaceChild (XmlNode &cReplaceThis, const XmlNode &cWithThis)
 Replace a child of this node.
PLCORE_API bool RemoveChild (XmlNode &cRemoveThis)
 Delete a child of this node.
XmlNodeGetPreviousSibling ()
 Navigate to a sibling node.
const XmlNodeGetPreviousSibling () const
PLCORE_API XmlNodeGetPreviousSibling (const String &sValue)
 Navigate to a sibling node with the given 'value'.
PLCORE_API const XmlNodeGetPreviousSibling (const String &sValue) const
XmlNodeGetNextSibling ()
 Navigate to a sibling node.
const XmlNodeGetNextSibling () const
PLCORE_API XmlNodeGetNextSibling (const String &sValue)
 Navigate to a sibling node with the given 'value'.
PLCORE_API const XmlNodeGetNextSibling (const String &sValue) const
XmlElementGetNextSiblingElement ()
 Convenience function to get through elements.
PLCORE_API const XmlElementGetNextSiblingElement () const
PLCORE_API XmlElementGetNextSiblingElement (const String &sValue)
 Convenience function to get through elements.
PLCORE_API const XmlElementGetNextSiblingElement (const String &sValue) const
XmlElementGetFirstChildElement ()
 Convenience function to get through elements.
PLCORE_API const XmlElementGetFirstChildElement () const
XmlElementGetFirstChildElement (const String &sValue)
 Convenience function to get through elements.
PLCORE_API const XmlElementGetFirstChildElement (const String &sValue) const
ENodeType GetType () const
 Query the type (as an enumerated value, above) of this node.
XmlDocumentGetDocument ()
 Return a pointer to the document this node lives in.
PLCORE_API const XmlDocumentGetDocument () const
bool NoChildren () const
 Returns true if this node has no children.
XmlDocumentToDocument ()
 Cast functions, will return a null pointer if the given node is not from the requested type.
const XmlDocumentToDocument () const
XmlElementToElement ()
const XmlElementToElement () const
XmlCommentToComment ()
const XmlCommentToComment () const
XmlUnknownToUnknown ()
const XmlUnknownToUnknown () const
XmlTextToText ()
const XmlTextToText () const
XmlDeclarationToDeclaration ()
const XmlDeclarationToDeclaration () const
virtual XmlNodeClone () const =0
 Create an exact duplicate of this node and return it.

Protected Member Functions

 XmlNode (ENodeType nType)
 Constructor.
XmlNodeIdentify (const char *pszData, EEncoding nEncoding)
 Figure out what is at *pszData, and parse it.

Protected Attributes

XmlNodem_pParent
ENodeType m_nType
XmlNodem_pFirstChild
XmlNodem_pLastChild
String m_sValue
XmlNodem_pPreviousSibling
XmlNodem_pNextSibling

Detailed Description

Abstract XML node.


Member Enumeration Documentation

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

Enumerator:
Document 

Document

Element 

Element

Comment 

Comment

Unknown 

Unknown

Text 

Text

Declaration 

Declaration

NumOfTypes 

Number of types


Constructor & Destructor Documentation

virtual PLCORE_API PLCore::XmlNode::~XmlNode ( ) [virtual]

Destructor.

PLCore::XmlNode::XmlNode ( ENodeType  nType) [protected]

Constructor.

Parameters:
[in]nTypeType of the node

Member Function Documentation

String PLCore::XmlNode::GetValue ( ) const [inline]

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

Returns:
Node value
Remarks:
		*    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.
void PLCore::XmlNode::SetValue ( const String sValue) [inline]

Changes the value of the node.

Parameters:
[in]sValueNew node value
See also:
PLCORE_API void PLCore::XmlNode::Clear ( )

Delete all the children of this node.

Note:
  • Does not affect 'this'

One step up the DOM.

Returns:
The parent node, a null pointer on error
const XmlNode * PLCore::XmlNode::GetParent ( ) const [inline]

Returns the first child of this node.

Returns:
The first child of this node, a null pointer if there are no children
const XmlNode * PLCore::XmlNode::GetFirstChild ( ) const [inline]
PLCORE_API XmlNode* PLCore::XmlNode::GetFirstChild ( const String sValue)

Returns the first child of this node with the matching 'value'.

Parameters:
[in]sValueValue to look for
Returns:
The first child of this node with the matching 'value', a null pointer if none found
PLCORE_API const XmlNode* PLCore::XmlNode::GetFirstChild ( const String sValue) const

Returns the last child of this node.

Returns:
The last child of this node, a null pointer if there are no children
const XmlNode * PLCore::XmlNode::GetLastChild ( ) const [inline]
PLCORE_API XmlNode* PLCore::XmlNode::GetLastChild ( const String sValue)

Returns the last child of this node with the matching 'value'.

Parameters:
[in]sValueValue to look for
Returns:
The last child of this node with the matching 'value', a null pointer if none found
PLCORE_API const XmlNode* PLCore::XmlNode::GetLastChild ( const String sValue) const
XmlNode * PLCore::XmlNode::IterateChildren ( XmlNode pPrevious) [inline]

An alternate way to walk the children of a node.

Parameters:
[in]pPreviousPrevious node, if a null pointer the first child node is returned
Returns:
Next node, a null pointer if there's no next node
Remarks:
One way to iterate over nodes is:
		*    for (XmlNode *pChild=pParent->GetFirstChild(); pChild; pChild=Child->GetNextSibling())
		*    

'IterateChildren()' does the same thing with the syntax:

		*    XmlNode *pChild = pParent->IterateChildren(pChild);
		*    while (pChild)
		*    

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

const XmlNode * PLCore::XmlNode::IterateChildren ( const XmlNode pPrevious) const [inline]
XmlNode * PLCore::XmlNode::IterateChildren ( const String sValue,
XmlNode pPrevious 
) [inline]

This flavor of 'IterateChildren()' searches for children with a particular 'value'.

Parameters:
[in]sValueValue to look for
[in]pPreviousPrevious node, if a null pointer the first child node is returned
Returns:
Next node, a null pointer if there's no next node
const XmlNode * PLCore::XmlNode::IterateChildren ( const String sValue,
const XmlNode pPrevious 
) const [inline]
PLCORE_API XmlNode* PLCore::XmlNode::InsertEndChild ( const XmlNode cAddThis)

Add a new node related to this (adds a child past the last child)

Parameters:
[in]cAddThisNode to insert
Returns:
Returns a pointer to the new object or a null pointer if an error occurred
PLCORE_API XmlNode* PLCore::XmlNode::LinkEndChild ( XmlNode cAddThis)

Add a new node related to this (adds a child past the last child)

Parameters:
[in]cAddThisNode to add
Returns:
Pointer to the given 'cAddThis', a null pointer on error (on error, 'cAddThis' will be deleted)
Remarks:
The node to be added is passed by reference, and will be henceforth owned (and deleted) by the XML implementation. 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.
PLCORE_API XmlNode* PLCore::XmlNode::InsertBeforeChild ( XmlNode cBeforeThis,
const XmlNode cAddThis 
)

Add a new node related to this (adds a child before the specified child)

Parameters:
[in]cBeforeThisNode before this insertion
[in]cAddThisNode to insert
Returns:
Returns a pointer to the new object or a null pointer if an error occurred
PLCORE_API XmlNode* PLCore::XmlNode::InsertAfterChild ( XmlNode cAfterThis,
const XmlNode cAddThis 
)

Add a new node related to this (adds a child after the specified child)

Parameters:
[in]cAfterThisNode after this insertion
[in]cAddThisNode to insert
Returns:
Returns a pointer to the new object or a null pointer if an error occurred
PLCORE_API XmlNode* PLCore::XmlNode::ReplaceChild ( XmlNode cReplaceThis,
const XmlNode cWithThis 
)

Replace a child of this node.

Parameters:
[in]cReplaceThisNode which should be replaced (on success, destroyed automatically)
[in]cWithThisNew node replacing the old
Returns:
Returns a pointer to the new object or a null pointer if an error occurred
PLCORE_API bool PLCore::XmlNode::RemoveChild ( XmlNode cRemoveThis)

Delete a child of this node.

Parameters:
[in]cRemoveThisNode to remove (on success, destroyed automatically)
Returns:
'true' if all went fine, else 'false'

Navigate to a sibling node.

Returns:
The sibling node, a null pointer if there's no sibling node
const XmlNode * PLCore::XmlNode::GetPreviousSibling ( ) const [inline]
PLCORE_API XmlNode* PLCore::XmlNode::GetPreviousSibling ( const String sValue)

Navigate to a sibling node with the given 'value'.

Parameters:
[in]sValueValue to look for
Returns:
The sibling node, a null pointer if there's no sibling node
PLCORE_API const XmlNode* PLCore::XmlNode::GetPreviousSibling ( const String sValue) const

Navigate to a sibling node.

Returns:
The sibling node, a null pointer if there's no sibling node
const XmlNode * PLCore::XmlNode::GetNextSibling ( ) const [inline]
PLCORE_API XmlNode* PLCore::XmlNode::GetNextSibling ( const String sValue)

Navigate to a sibling node with the given 'value'.

Parameters:
[in]sValueValue to look for
Returns:
The sibling node, a null pointer if there's no sibling node
PLCORE_API const XmlNode* PLCore::XmlNode::GetNextSibling ( const String sValue) const

Convenience function to get through elements.

Remarks:
Calls 'NextSibling()' and 'ToElement()'. Will skip all non-element nodes.
Returns:
Returns a null pointer if there is not another element
PLCORE_API XmlElement* PLCore::XmlNode::GetNextSiblingElement ( const String sValue)

Convenience function to get through elements.

Parameters:
[in]sValueValue to look for
Remarks:
Calls 'NextSibling()' and 'ToElement()'. Will skip all non-element nodes.
Returns:
Returns a null pointer if there is not another element
PLCORE_API const XmlElement* PLCore::XmlNode::GetNextSiblingElement ( const String sValue) const

Convenience function to get through elements.

Returns:
Returns a null pointer if there is not another element

Convenience function to get through elements.

Parameters:
[in]sValueValue to look for
Returns:
Returns a null pointer if there is not another element
PLCORE_API const XmlElement* PLCore::XmlNode::GetFirstChildElement ( const String sValue) const

Query the type (as an enumerated value, above) of this node.

Returns:
Type of this node

Return a pointer to the document this node lives in.

Returns:
Pointer to the document this node lives in, a null pointer if not in a document
PLCORE_API const XmlDocument* PLCore::XmlNode::GetDocument ( ) const
bool PLCore::XmlNode::NoChildren ( ) const [inline]

Returns true if this node has no children.

Returns:
'true' if this node has no children, else 'false'

Cast functions, will return a null pointer if the given node is not from the requested type.

Cast functions.

const XmlDocument * PLCore::XmlNode::ToDocument ( ) const [inline]
const XmlElement * PLCore::XmlNode::ToElement ( ) const [inline]
const XmlComment * PLCore::XmlNode::ToComment ( ) const [inline]
const XmlUnknown * PLCore::XmlNode::ToUnknown ( ) const [inline]
const XmlText * PLCore::XmlNode::ToText ( ) const [inline]
const XmlDeclaration * PLCore::XmlNode::ToDeclaration ( ) const [inline]
virtual XmlNode* PLCore::XmlNode::Clone ( ) const [pure virtual]

Create an exact duplicate of this node and return it.

Returns:
The clone, a null pointer on error
Note:
  • The memory must be deleted by the caller

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

XmlNode* PLCore::XmlNode::Identify ( const char *  pszData,
EEncoding  nEncoding 
) [protected]

Figure out what is at *pszData, and parse it.

Parameters:
[in]pszDataStart position
[in]nEncodingEncoding
Returns:
Returns a null pointer if it is not an XML node, else it returns a created node instance (you're responsible for it's destruction)

Member Data Documentation

Parent node, can be a null pointer

Type of the node

First child, can be a null pointer

Last child, can be a null pointer

Value

Previous sibling, can be a null pointer

Previous sibling, can be a null pointer


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


PixelLight PixelLight 0.9.10-R1
Copyright (C) 2002-2011 by The PixelLight Team
Last modified Fri Dec 23 2011 15:51:17
The content of this PixelLight document is published under the
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported