MezzanineEngine 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | Protected Types | Protected Attributes | Friends | List of all members
Mezzanine::XML::Node Class Reference

A light-weight handle for manipulating nodes in DOM tree. More...

#include <node.h>

+ Inheritance diagram for Mezzanine::XML::Node:

Public Types

typedef AttributeIterator attribute_iterator
 An iterator for Attribute members on this Node.
 
typedef NodeIterator iterator
 An iterator for child Nodes that will be easier for members of the std namespace to work with.
 

Public Member Functions

 Node ()
 Default constructor. Constructs an empty node.
 
 Node (NodeStruct *p)
 Constructs node from internal pointer. More...
 
 ~Node ()
 Virtual deconstructor.
 
Attribute AppendAttribute (const Char8 *Name)
 Creates an Attribute and puts it at the end of this Nodes attributes. More...
 
Attribute AppendAttribute (const String &Name)
 Creates an Attribute and puts it at the end of this Nodes attributes. More...
 
Node AppendChild (NodeType Type=NodeElement)
 Creates a Node and makes it a child of this one. More...
 
Node AppendChild (const Char8 *Name)
 Creates an element Node as a child of this Node, with the given name. More...
 
Node AppendChild (const String &Name)
 Creates an element Node as a child of this Node, with the given name. More...
 
Attribute AppendCopy (const Attribute &proto)
 Copies an Attribute and puts the copy at the end of this Nodes attributes. More...
 
Node AppendCopy (const Node &proto)
 Copies a Node and puts the copy at the end of the list of this Nodes Childrem. More...
 
ObjectRange< AttributeIteratorattributes () const
 A range of iterators for just the attributes of this node. More...
 
attribute_iterator attributes_begin () const
 Get an Attribute iterator that references the first Attribute on this Node. More...
 
attribute_iterator attributes_end () const
 Get an Attribute iterator that references the one past the last Attribute on this Node. More...
 
iterator begin () const
 Get a Child node iterator that references the first child Node. More...
 
bool Empty () const
 Is this storing anything at all? More...
 
iterator end () const
 Get a Child node iterator that references one past the last child Node. More...
 
template<typename Predicate >
Attribute FindAttribute (Predicate pred) const
 Search for an Attribute using a function to check each Attribute individually. More...
 
template<typename Predicate >
Node FindChild (Predicate pred) const
 Search for an child ( only direct children ) Node using a function to check each Node individually. More...
 
Node FindChildbyAttribute (const Char8 *Name, const Char8 *AttrName, const Char8 *AttrValue) const
 Find a Node by an Attribute it has. More...
 
Node FindChildbyAttribute (const Char8 *AttrName, const Char8 *AttrValue) const
 Find a Node by an Attribute it has. More...
 
template<typename Predicate >
Node FindNode (Predicate pred) const
 Search for any Node descended from this Node using a function to check each Node individually. More...
 
XPathNodeSet FindNodes (const Char8 *query, XPathVariableSet *variables=0) const
 Select a group of nodes by evaluating an XPath query. More...
 
XPathNodeSet FindNodes (const XPathQuery &query) const
 Select a group of nodes by evaluating an XPath query. More...
 
XPathNode FindSingleNode (const Char8 *query, XPathVariableSet *variables=0) const
 Select single node by evaluating an XPath query. Returns first node from the resulting node set. More...
 
XPathNode FindSingleNode (const XPathQuery &query) const
 Select single node by evaluating an XPath query. Returns first node from the resulting node set. More...
 
Node FirstElementByPath (const Char8 *Path, Char8 delimiter= '/') const
 Search for a node by Path consisting of node names and . or .. elements. More...
 
Attribute GetAttribute (const Char8 *Name) const
 Attempt to get an Attribute on this Node with a given name. More...
 
Node GetChild (const Char8 *Name) const
 Attempt to get a child Node with a given name. More...
 
Node GetChild (const String &Name) const
 Attempt to get a child Node with a given name. More...
 
ObjectRange< NodeIteratorGetChildren () const
 Get an iterator range for this node's children nodes. More...
 
ObjectRange< NamedNodeIteratorGetChildren (const Char8 *Name) const
 Get an iterator range for this a subset of this node's children nodes. More...
 
const Char8GetChildValue () const
 Retrieve the value of this(or a child's) Nodes PCDATA child Node. More...
 
const Char8GetChildValue (const Char8 *Name) const
 Get the PCDATA of a given child. The same a calling "GetChild(Name).ChildValue()". More...
 
Attribute GetFirstAttribute () const
 Get the First Attribute in this Node. More...
 
Node GetFirstChild () const
 Get the first child Node of this Node. More...
 
Attribute GetLastAttribute () const
 Get the Last Attribute in this Node. More...
 
Node GetLastChild () const
 Get the last child Node of this Node. More...
 
Node GetNextSibling () const
 Attempt to retrieve the next sibling of this Node. More...
 
Node GetNextSibling (const Char8 *Name) const
 Like GetNextSibling except that the return will be a null Node or have a matching name. More...
 
Node GetParent () const
 Attempt to retrieve the parent of this Node. More...
 
Node GetPreviousSibling () const
 Attempt to retrieve the prvious sibling of this Node. More...
 
Node GetPreviousSibling (const Char8 *Name) const
 Like GetPreviousSibling except that the return will be a null Node or have a matching name. More...
 
Node GetRoot () const
 Attempt to retrieve the root Node, or the most base Node containing this Node. More...
 
NodeText GetText () const
 Get text object for the current node. More...
 
size_t HashValue () const
 Get hash Value (unique for handles to the same object) More...
 
Attribute InsertAttributeAfter (const Char8 *Name, const Attribute &attr)
 Creates an Attribute and puts it into the list of this Nodes attributes. More...
 
Attribute InsertAttributeBefore (const Char8 *Name, const Attribute &attr)
 Creates an Attribute and puts it into the list of this Nodes attributes. More...
 
Node InsertChildAfter (NodeType Type, const Node &node)
 Creates a Node and makes it a child of this one, and puts at the middle of the Child Nodes. More...
 
Node InsertChildAfter (const Char8 *Name, const Node &node)
 Creates an element Node as a child of this Node, with the given name at the middle of the children. More...
 
Node InsertChildBefore (NodeType Type, const Node &node)
 Creates a Node and makes it a child of this one, and puts at the middle of the Child Nodes. More...
 
Node InsertChildBefore (const Char8 *Name, const Node &node)
 Creates an element Node as a child of this Node, with the given name at the middle of the children. More...
 
Attribute InsertCopyAfter (const Attribute &proto, const Attribute &attr)
 Copies an Attribute and puts the copy into the list of this Nodes attributes. More...
 
Node InsertCopyAfter (const Node &proto, const Node &node)
 Copies a Node and puts the copy in the middle the list of this Nodes Childrem. More...
 
Attribute InsertCopyBefore (const Attribute &proto, const Attribute &attr)
 Copies an Attribute and puts the copy into the list of this Nodes attributes. More...
 
Node InsertCopyBefore (const Node &proto, const Node &node)
 Copies a Node and puts the copy in the middle the list of this Nodes Childrem. More...
 
NodeStruct * InternalObject () const
 Get internal pointer. More...
 
const Char8Name () const
 ptrdiff_tGet the name of this Node. More...
 
ptrdiff_t OffSetDebug () const
 Get node Offset in parsed file/string (in char_t units) for debugging purposes. More...
 
 operator unspecified_bool_type () const
 Used to convert this to a boolean value in a safe way. More...
 
bool operator! () const
 Used to convert this node the opposite of it's normal boolean value. More...
 
bool operator!= (const Node &r) const
 Compares the internal values to check inequality. More...
 
bool operator< (const Node &r) const
 Compares the internal values to check for lessthanness. More...
 
bool operator<= (const Node &r) const
 Compares the internal values to check for inequality and lessthanness. More...
 
bool operator== (const Node &r) const
 Compares the internal values to check equality. More...
 
bool operator> (const Node &r) const
 Compares the internal values to check for greaterthanness. More...
 
bool operator>= (const Node &r) const
 Compares the internal values to check for inequality and greaterthanness. More...
 
String Path (Char8 delimiter= '/') const
 Get the absolute path to this Node. More...
 
Attribute PrependAttribute (const Char8 *Name)
 Creates an Attribute and puts it at the begining of this Nodes attributes. More...
 
Node PrependChild (NodeType Type=NodeElement)
 Creates a Node and makes it a child of this one, and puts at the beginning of the Child Nodes. More...
 
Node PrependChild (const Char8 *Name)
 Creates an element Node as a child of this Node, with the given name at the beginning of the children. More...
 
Node PrependChild (const String &Name)
 Creates an element Node as a child of this Node, with the given name at the beginning of the children. More...
 
Attribute PrependCopy (const Attribute &proto)
 Copies an Attribute and puts the copy at the beginning of this Nodes attributes. More...
 
Node PrependCopy (const Node &proto)
 Copies a Node and puts the copy at the start of the list of this Nodes Childrem. More...
 
void Print (Writer &WriterInstance, const Char8 *indent="\t", unsigned int flags=FormatDefault, Encoding DocumentEncoding=EncodingAuto, unsigned int Depth=0) const
 Output the XML document using a Writer. More...
 
void Print (std::basic_ostream< char, std::char_traits< char > > &os, const Char8 *indent="\t", unsigned int flags=FormatDefault, Encoding DocumentEncoding=EncodingAuto, unsigned int Depth=0) const
 Output the XML document using a Output Stream. More...
 
void Print (std::basic_ostream< wchar_t, std::char_traits< wchar_t > > &os, const Char8 *indent="\t", unsigned int flags=FormatDefault, unsigned int Depth=0) const
 Output the XML document using a Output Stream. More...
 
bool RemoveAttribute (const Attribute &a)
 Remove specified Attribute. More...
 
bool RemoveAttribute (const Char8 *Name)
 Remove Attribute as specified by name. More...
 
bool RemoveChild (const Node &n)
 Remove specified child element. More...
 
bool RemoveChild (const Char8 *Name)
 Remove child element as specified by name. More...
 
bool SetName (const Char8 *rhs)
 Set the name of . More...
 
bool SetName (const String &rhs)
 Set the name of this object. More...
 
bool SetValue (const Char8 *rhs)
 Set the value of this. More...
 
bool Traverse (TreeWalker &walker)
 Perform sophisticated (or whatever) algorithms on this and all descendant Nodes in the XML tree. More...
 
NodeType Type () const
 Identify what kind of Node this is. More...
 
const Char8Value () const
 Get the Value of this Node. More...
 

Protected Types

typedef void(* unspecified_bool_type )(Node ***)
 Used to prevent casting to numerical types acccidentally. More...
 

Protected Attributes

NodeStruct * NodeData
 Stores pointers to the Node data and some metadata. More...
 

Friends

class AttributeIterator
 
class NamedNodeIterator
 
class NodeIterator
 

Detailed Description

A light-weight handle for manipulating nodes in DOM tree.

Definition at line 89 of file node.h.

Member Typedef Documentation

typedef void(* Mezzanine::XML::Node::unspecified_bool_type)(Node ***)
protected

Used to prevent casting to numerical types acccidentally.

Note
Not available in scripting languages because conversion is handled on a per langauge basis.

Definition at line 103 of file node.h.

Constructor & Destructor Documentation

Mezzanine::XML::Node::Node ( NodeStruct *  p)
explicit

Constructs node from internal pointer.

Parameters
pAn internal node pointer.

Member Function Documentation

Attribute Mezzanine::XML::Node::AppendAttribute ( const Char8 Name)

Creates an Attribute and puts it at the end of this Nodes attributes.

Parameters
NameThe name of the New attribute to be created

This attempts to create an Attribute and stick it at the end of the list of attribute on the current Node. This will fail and return an Empty Attribute if this Node is neither an Element nor a Declaration. This will fail and return an empty attribute if this Node is empty.

Returns
The created Attribute or an empty Attribute on Failure.
Note
Not available in scripting languages in favor of the overload of this function that accepts String as a parameter.
Attribute Mezzanine::XML::Node::AppendAttribute ( const String Name)
inline

Creates an Attribute and puts it at the end of this Nodes attributes.

Parameters
NameThe name of the New attribute to be created
Returns
The created Attribute or an empty Attribute on Failure.

Definition at line 298 of file node.h.

Node Mezzanine::XML::Node::AppendChild ( NodeType  Type = NodeElement)

Creates a Node and makes it a child of this one.

Parameters
TypeThe NodeType of the Node to be added to list of child Nodes.
Returns
A Node representing the freshly added Node, or an empty Node if there was an error.
Node Mezzanine::XML::Node::AppendChild ( const Char8 Name)

Creates an element Node as a child of this Node, with the given name.

Parameters
NameThe name of the Node to be created.

Calls Node::AppendChild(NodeType); using NodeElement as the NodeType.

Returns
The desired Node on success, an empty Node on failure.
Note
Not available in scripting languages in favor of the overload of this function that accepts String as a parameter.
Node Mezzanine::XML::Node::AppendChild ( const String Name)
inline

Creates an element Node as a child of this Node, with the given name.

Parameters
NameThe name of the Node to be created.

Calls Node::AppendChild

Returns
The desired Node on success, an empty Node on failure.

Definition at line 399 of file node.h.

Attribute Mezzanine::XML::Node::AppendCopy ( const Attribute proto)

Copies an Attribute and puts the copy at the end of this Nodes attributes.

Parameters
protoThe attribute to be copied.

This attempts to create a copy of an attribute Attribute and stick it at the end of the list of attribute on the current Node. This will fail and return an Empty Attribute if this Node is neither an Element nor a Declaration. This will fail and return an empty attribute if this Node is empty.

Returns
The created Attribute or an empty Attribute on Failure.
Node Mezzanine::XML::Node::AppendCopy ( const Node proto)

Copies a Node and puts the copy at the end of the list of this Nodes Childrem.

Parameters
protoThe Node to be copied. If this is emptry, no work is performed.
Returns
The copied Node on success, an empty Node on failure.
ObjectRange<AttributeIterator> Mezzanine::XML::Node::attributes ( ) const

A range of iterators for just the attributes of this node.

Returns
A par of iterators suitable for traversing all Attributes directly as children of this noce.
attribute_iterator Mezzanine::XML::Node::attributes_begin ( ) const

Get an Attribute iterator that references the first Attribute on this Node.

Returns
A Node::Iterator that reference the first child node.
attribute_iterator Mezzanine::XML::Node::attributes_end ( ) const

Get an Attribute iterator that references the one past the last Attribute on this Node.

Returns
A Node::Iterator that reference the last Attribute on this Node.
iterator Mezzanine::XML::Node::begin ( ) const

Get a Child node iterator that references the first child Node.

Returns
A Node::Iterator that reference the first child Node.
bool Mezzanine::XML::Node::Empty ( ) const

Is this storing anything at all?

Returns
Returns True if this Node is storing nothing. False if it is storing anything.
iterator Mezzanine::XML::Node::end ( ) const

Get a Child node iterator that references one past the last child Node.

Returns
A Node::Iterator that reference the last child Node.
template<typename Predicate >
Attribute Mezzanine::XML::Node::FindAttribute ( Predicate  pred) const
inline

Search for an Attribute using a function to check each Attribute individually.

Parameters
preda pointer to a function that accepts an Attribute, and returns bool.

This iterates through each Attribute on this node, from begining to end and calls the Predicate function passing an Attribute to it. If the Predicate returns true the Node it was just passed is returned. If Precdicate never returns true, it is called on every Node and a blank Node is returned. The Predicate is never called with a null value.

Returns
This returns the first Attribute that causes Predicate to return true.

Definition at line 480 of file node.h.

template<typename Predicate >
Node Mezzanine::XML::Node::FindChild ( Predicate  pred) const
inline

Search for an child ( only direct children ) Node using a function to check each Node individually.

Parameters
preda pointer to a function that accepts an Node, and returns bool.

This iterates through all immediate children of this Node and calls the Predicate function passing a Node to it. If the Predicate returns true the Node it was just passed is returned. If Predicate never returns true, it is called on every Node and a blank Node is returned. The Predicate is never called with a null value.

Returns
This returns the first Node that causes Predicate to return true.

Definition at line 498 of file node.h.

Node Mezzanine::XML::Node::FindChildbyAttribute ( const Char8 Name,
const Char8 AttrName,
const Char8 AttrValue 
) const

Find a Node by an Attribute it has.

Parameters
NameThe name of the matching Node.
AttrNameThe name of the matching Attribute.
AttrValueThe value of the matching Attribute.

Any Null pointers instead of character arrays passed in will cause undefined behavior. All Matching is Case sensitive.

Returns
The First matching XML::Node
Node Mezzanine::XML::Node::FindChildbyAttribute ( const Char8 AttrName,
const Char8 AttrValue 
) const

Find a Node by an Attribute it has.

Parameters
AttrNameThe name of the matching Attribute.
AttrValueThe value of the matching Attribute.

Any Null pointers instead of character arrays passed in will cause undefined behavior. All Matching is Case sensitive.

Returns
The First matching XML::Node
template<typename Predicate >
Node Mezzanine::XML::Node::FindNode ( Predicate  pred) const
inline

Search for any Node descended from this Node using a function to check each Node individually.

Parameters
preda pointer to a function that accepts an Node, and returns bool.

This iterates through all children of this Node, and their children ( and so on), and calls the Predicate function passing each Node to it. This iterates through all Nodes using a depth first algorithm. If the Predicate returns true the Node it was just passed is returned. If Predicate never returns true, it is called on every Node and a blank Node is returned. The Predicate is never called with a null value.

Returns
This returns the first Node that causes Predicate to return true.

Definition at line 516 of file node.h.

XPathNodeSet Mezzanine::XML::Node::FindNodes ( const Char8 query,
XPathVariableSet variables = 0 
) const

Select a group of nodes by evaluating an XPath query.

Parameters
queryThe XPath query as a c-string to be evaluated.
variablesundocumented.
Returns
An XPathNodeSet with the Matchs of the XPath query.
XPathNodeSet Mezzanine::XML::Node::FindNodes ( const XPathQuery query) const

Select a group of nodes by evaluating an XPath query.

Parameters
queryThe XPath query XPathQuery class instance.
Returns
An XPathNodeSet with the Matchs of the XPath query.
Parameters
queryThe XPath query XPathQuery class instance.
XPathNode Mezzanine::XML::Node::FindSingleNode ( const Char8 query,
XPathVariableSet variables = 0 
) const

Select single node by evaluating an XPath query. Returns first node from the resulting node set.

Parameters
queryThe XPath query as a c-string to be evaluated.
variablesundocumented.
Returns
XPathNode The first matching XPath node.
XPathNode Mezzanine::XML::Node::FindSingleNode ( const XPathQuery query) const

Select single node by evaluating an XPath query. Returns first node from the resulting node set.

Parameters
queryThe XPath query XPathQuery class instance.
Returns
XPathNode The first matching XPath node.
Node Mezzanine::XML::Node::FirstElementByPath ( const Char8 Path,
Char8  delimiter = '/' 
) const

Search for a node by Path consisting of node names and . or .. elements.

Todo:
Investigate this more deeply.
Parameters
PathThe path to search for.
delimiterThe character to use as a pathname separator, this defaults to '/'.
Returns
The matching Node, of an empty Node on failure.
Attribute Mezzanine::XML::Node::GetAttribute ( const Char8 Name) const

Attempt to get an Attribute on this Node with a given name.

Parameters
NameThe name of the desired Attribute.
Returns
An Attribute that represents the first matching Attribute, or an empty Attribute on failure.
Node Mezzanine::XML::Node::GetChild ( const Char8 Name) const

Attempt to get a child Node with a given name.

Parameters
NameThe name of the desired child Node.
Returns
A Node that represents the first desired child, or an empty Node on failure.
Note
Not available in scripting languages in favor of the overload of this function that accepts String as a parameter.
Node Mezzanine::XML::Node::GetChild ( const String Name) const
inline

Attempt to get a child Node with a given name.

Parameters
NameThe name of the desired child Node.
Returns
A Node that represents the first desired child, or an empty Node on failure.

Definition at line 235 of file node.h.

ObjectRange<NodeIterator> Mezzanine::XML::Node::GetChildren ( ) const

Get an iterator range for this node's children nodes.

Returns
The Begin and end iterators for a collection of all child nodes.
ObjectRange<NamedNodeIterator> Mezzanine::XML::Node::GetChildren ( const Char8 Name) const

Get an iterator range for this a subset of this node's children nodes.

Parameters
NameAll members of the returned range with have this for a name.
Returns
A begin and end iterator for a range containing only the child nodes with the given name.
const Char8* Mezzanine::XML::Node::GetChildValue ( ) const

Retrieve the value of this(or a child's) Nodes PCDATA child Node.

If this node represents "<node>Some text in the PCDATA field, that is actually represent by a node</node>", then this would return "Some text in the PCDATA field, that is actually represent by a node". This will iterate through child Nodes from until it finds a PCDATA node or fails

Returns
This will return the Value of the first available PCDATA node.
const Char8* Mezzanine::XML::Node::GetChildValue ( const Char8 Name) const

Get the PCDATA of a given child. The same a calling "GetChild(Name).ChildValue()".

Parameters
NameThe Name of the desired child node.
Returns
This will return the Value of the first available matching PCDATA node.
Attribute Mezzanine::XML::Node::GetFirstAttribute ( ) const

Get the First Attribute in this Node.

Returns
This attempts to return the First Attribute in this node, if it cannot it returns an empty Attribute.
Node Mezzanine::XML::Node::GetFirstChild ( ) const

Get the first child Node of this Node.

Returns
Returns the First child node if it exists, otherwise it return an empty node.
Attribute Mezzanine::XML::Node::GetLastAttribute ( ) const

Get the Last Attribute in this Node.

Returns
This attempts to return the Last Attribute in this node, if it cannot it returns an empty Attribute.
Node Mezzanine::XML::Node::GetLastChild ( ) const

Get the last child Node of this Node.

Returns
Returns the last child node if it exists, otherwise it return an empty node.
Node Mezzanine::XML::Node::GetNextSibling ( ) const

Attempt to retrieve the next sibling of this Node.

A sibling of a Node is another Node that shares the same parent. If this is and the sibling nodes are valid, this retrieves that Node, otherwise this return an empty Node.

Returns
A Node that represents a sibling, or an empty Node on failure.
Node Mezzanine::XML::Node::GetNextSibling ( const Char8 Name) const

Like GetNextSibling except that the return will be a null Node or have a matching name.

Parameters
Nameif possible this will return the next sibling with this name.
Returns
The next sibling with a matching name, or a null/empty node.
Node Mezzanine::XML::Node::GetParent ( ) const

Attempt to retrieve the parent of this Node.

Returns
A Node that represents the parent Node, or an empty Node on failure.
Node Mezzanine::XML::Node::GetPreviousSibling ( ) const

Attempt to retrieve the prvious sibling of this Node.

A sibling of a Node is another Node that shares the same parent. If this is and the sibling nodes are valid, this retrieves that Node, otherwise this return an empty Node.

Returns
A Node that represents a sibling, or an empty Node on failure.
Node Mezzanine::XML::Node::GetPreviousSibling ( const Char8 Name) const

Like GetPreviousSibling except that the return will be a null Node or have a matching name.

Parameters
Nameif possible this will return the previous sibling with this name.
Returns
The previous sibling with a matching name, or a null/empty node.
Node Mezzanine::XML::Node::GetRoot ( ) const

Attempt to retrieve the root Node, or the most base Node containing this Node.

Returns
A Node that represents the root of the XML document, or an empty Node on failure. If there are multiple roots this attempts to retrieve the appropriate one.
NodeText Mezzanine::XML::Node::GetText ( ) const

Get text object for the current node.

Returns
An Mezzanine::XML::NodeText which represents the PCData of this node.
size_t Mezzanine::XML::Node::HashValue ( ) const

Get hash Value (unique for handles to the same object)

Returns
A size_t that uniquely identifies this node.
Attribute Mezzanine::XML::Node::InsertAttributeAfter ( const Char8 Name,
const Attribute attr 
)

Creates an Attribute and puts it into the list of this Nodes attributes.

Parameters
NameThe name of the New attribute to be created
attrAn Attribute that represents an Attribute on this Node, and is just before where you want the new Attribute.

This attempts to create an Attribute and stick it in the list of attributes, Just after another Attribute, on the current Node. This will fail and return an Empty Attribute if this Node is neither an Element nor a Declaration. This will fail and return an empty attribute if this Node is empty.

Returns
The created Attribute or an empty Attribute on Failure.
Attribute Mezzanine::XML::Node::InsertAttributeBefore ( const Char8 Name,
const Attribute attr 
)

Creates an Attribute and puts it into the list of this Nodes attributes.

Parameters
NameThe name of the New attribute to be created
attrAn Attribute that represents an Attribute on this Node, and is just after where you want the new Attribute.

This attempts to create an Attribute and stick it in the list of attributes, Just before another Attribute, on the current Node. This will fail and return an Empty Attribute if this Node is neither an Element nor a Declaration. This will fail and return an empty attribute if this Node is empty.

Returns
The created Attribute or an empty Attribute on Failure.
Node Mezzanine::XML::Node::InsertChildAfter ( NodeType  Type,
const Node node 
)

Creates a Node and makes it a child of this one, and puts at the middle of the Child Nodes.

Parameters
TypeThe NodeType of the Node to be added, just after another specific node.
nodeThe specific node to add the new one after.
Todo:
Not all nodes can be added to other nodes, we need to figure it out and put it here.
Returns
A Node representing the freshly added Node, or an empty Node if there was an error.
Node Mezzanine::XML::Node::InsertChildAfter ( const Char8 Name,
const Node node 
)

Creates an element Node as a child of this Node, with the given name at the middle of the children.

Parameters
NameThe name of the Node to be created.
nodeThe node just before were the Create node is to be placed.

Calls Node::InsertChildAfter(NodeType, Node); using NodeElement as the NodeType.

Returns
The desired Node on success, an empty Node on failure.
Node Mezzanine::XML::Node::InsertChildBefore ( NodeType  Type,
const Node node 
)

Creates a Node and makes it a child of this one, and puts at the middle of the Child Nodes.

Parameters
TypeThe NodeType of the Node to be added, just before another specific node.
nodeThe specific node to add the new one before.
Returns
A Node representing the freshly added Node, or an empty Node if there was an error.
Todo:
Not all nodes can be added to other nodes, we need to figure it out and put it here.
Node Mezzanine::XML::Node::InsertChildBefore ( const Char8 Name,
const Node node 
)

Creates an element Node as a child of this Node, with the given name at the middle of the children.

Parameters
NameThe name of the Node to be created.
nodeThe node just after were the Create node is to be placed.

Calls Node::InsertChildBefore(NodeType, Node); using NodeElement as the NodeType.

Returns
The desired Node on success, an empty Node on failure.
Attribute Mezzanine::XML::Node::InsertCopyAfter ( const Attribute proto,
const Attribute attr 
)

Copies an Attribute and puts the copy into the list of this Nodes attributes.

Parameters
protoThe attribute to be copied.
attrAn Attribute that represents an Attribute on this Node, and is just before where you want the new copy of proto.

This attempts to create a copy of an attribute Attribute and stick it in the middle of the list of attributes, just after a selected attribute, on the current Node. This will fail and return an Empty Attribute if this Node is neither an Element nor a Declaration. This will fail and return an empty attribute if this Node is empty.

Returns
The created Attribute or an empty Attribute on Failure.
Node Mezzanine::XML::Node::InsertCopyAfter ( const Node proto,
const Node node 
)

Copies a Node and puts the copy in the middle the list of this Nodes Childrem.

Parameters
protoThe Node to be copied. If this is emptry, no work is performed.
nodeThe Node just before the desired place in the list of children to insert the copied node.
Returns
The copied Node on success, an empty Node on failure.
Attribute Mezzanine::XML::Node::InsertCopyBefore ( const Attribute proto,
const Attribute attr 
)

Copies an Attribute and puts the copy into the list of this Nodes attributes.

Parameters
protoThe attribute to be copied.
attrAn Attribute that represents an Attribute on this Node, and is just after where you want the new copy of proto.

This attempts to create a copy of an attribute Attribute and stick it in the middle of the list of attributes, just before a selected attribute, on the current Node. This will fail and return an Empty Attribute if this Node is neither an Element nor a Declaration. This will fail and return an empty attribute if this Node is empty.

Returns
The created Attribute or an empty Attribute on Failure.
Node Mezzanine::XML::Node::InsertCopyBefore ( const Node proto,
const Node node 
)

Copies a Node and puts the copy in the middle the list of this Nodes Childrem.

Parameters
protoThe Node to be copied. If this is emptry, no work is performed.
nodeThe Node just after the desired place in the list of children to insert the copied node.
Returns
The copied Node on success, an empty Node on failure.
NodeStruct* Mezzanine::XML::Node::InternalObject ( ) const

Get internal pointer.

Returns
A NodeStruct* that points to the internal data of this Node
const Char8* Mezzanine::XML::Node::Name ( ) const

ptrdiff_tGet the name of this Node.

Returns
Returns A pointer to a const c-style array of the the character type (usually char or wchar_t) containing the name.
Warning
returns "" if Node is empty.
ptrdiff_t Mezzanine::XML::Node::OffSetDebug ( ) const

Get node Offset in parsed file/string (in char_t units) for debugging purposes.

Returns
A ptrdiff_t containing how far into the document this node is.
Mezzanine::XML::Node::operator unspecified_bool_type ( ) const

Used to convert this to a boolean value in a safe way.

Returns
Returns true if the internal data is set and false otherwise.
Note
Not available in scripting languages because conversion is handled on a per langauge basis.
bool Mezzanine::XML::Node::operator! ( ) const

Used to convert this node the opposite of it's normal boolean value.

This is described in the PugiXML source a a workaround for a borland c++ issue.

Returns
Returns false if the internal pointer NodeStruct is set and true otherwise.
bool Mezzanine::XML::Node::operator!= ( const Node r) const

Compares the internal values to check inequality.

Parameters
rThe other Node this is being compared to.

Many of the internal values are pointers, and it is the addresses of these that are being compared.

Returns
Returns true if any of the internal values don't match between this and the other Node.
bool Mezzanine::XML::Node::operator< ( const Node r) const

Compares the internal values to check for lessthanness.

Parameters
rThe other Node this is being compared to.

Many of the internal values are pointers, and it is the addresses of these that are being compared.

Returns
Returns True if the other Node is greater than this one as per sequential comparison of internal pointers.
bool Mezzanine::XML::Node::operator<= ( const Node r) const

Compares the internal values to check for inequality and lessthanness.

Parameters
rThe other Node this is being compared to.

Many of the internal values are pointers, and it is the addresses of these that are being compared.

Returns
Returns True if the other Node is greater than or equal to this one as per sequential comparison of internal pointers.
bool Mezzanine::XML::Node::operator== ( const Node r) const

Compares the internal values to check equality.

Parameters
rThe other Node this is being compared to.

Many of the internal values are pointers, and it is the addresses of these that are being compared.

Returns
Returns true if all the internal values match between this and the other Node.
Note
Not available in scripting languages
bool Mezzanine::XML::Node::operator> ( const Node r) const

Compares the internal values to check for greaterthanness.

Parameters
rThe other Node this is being compared to.

Many of the internal values are pointers, and it is the addresses of these that are being compared.

Returns
Returns True if the other Node is less than this one as per sequential comparison of internal pointers.
bool Mezzanine::XML::Node::operator>= ( const Node r) const

Compares the internal values to check for inequality and greaterthanness.

Parameters
rThe other Node this is being compared to.

Many of the internal values are pointers, and it is the addresses of these that are being compared.

Returns
Returns True if the other Node is less than or equal to this one as per sequential comparison of internal pointers.
String Mezzanine::XML::Node::Path ( Char8  delimiter = '/') const

Get the absolute path to this Node.

Parameters
delimiterThe character to use as a pathname separator, this defaults to '/'.
Returns
A String containing an path
Attribute Mezzanine::XML::Node::PrependAttribute ( const Char8 Name)

Creates an Attribute and puts it at the begining of this Nodes attributes.

Parameters
NameThe name of the New attribute to be created

This attempts to create an Attribute and stick it at the beginning of the list of attributes on the current Node. This will fail and return an Empty Attribute if this Node is neither an Element nor a Declaration. This will fail and return an empty attribute if this Node is empty.

Returns
The created Attribute or an empty Attribute on Failure.
Node Mezzanine::XML::Node::PrependChild ( NodeType  Type = NodeElement)

Creates a Node and makes it a child of this one, and puts at the beginning of the Child Nodes.

Parameters
TypeThe NodeType of the Node to be added to the beginning list of child Nodes.
Returns
A Node representing the freshly added Node, or an empty Node if there was an error.
Todo:
Not all nodes can be added to other nodes, we need to figure it out and put it here.
Node Mezzanine::XML::Node::PrependChild ( const Char8 Name)

Creates an element Node as a child of this Node, with the given name at the beginning of the children.

Parameters
NameThe name of the Node to be created.

Calls Node::PrependChild(NodeType); using NodeElement as the NodeType.

Returns
The desired Node on success, an empty Node on failure.
Note
Not available in scripting languages in favor of the overload of this function that accepts String as a parameter.
Node Mezzanine::XML::Node::PrependChild ( const String Name)
inline

Creates an element Node as a child of this Node, with the given name at the beginning of the children.

Parameters
NameThe name of the Node to be created.

Calls Node::PrependChild

Returns
The desired Node on success, an empty Node on failure.

Definition at line 415 of file node.h.

Attribute Mezzanine::XML::Node::PrependCopy ( const Attribute proto)

Copies an Attribute and puts the copy at the beginning of this Nodes attributes.

Parameters
protoThe attribute to be copied.

This attempts to create a copy of an attribute Attribute and stick it at the beginning of the list of attribute on the current Node. Tptrdiff_this will fail and return an Empty Attribute if this Node is neither an Element nor a Declaration. This will fail and return an empty attribute if this Node is empty.

Returns
The created Attribute or an empty Attribute on Failure.
Node Mezzanine::XML::Node::PrependCopy ( const Node proto)

Copies a Node and puts the copy at the start of the list of this Nodes Childrem.

Parameters
protoThe Node to be copied. If this is emptry, no work is performed.
Returns
The copied Node on success, an empty Node on failure.
void Mezzanine::XML::Node::Print ( Writer WriterInstance,
const Char8 indent = "\t",
unsigned int  flags = FormatDefault,
Encoding  DocumentEncoding = EncodingAuto,
unsigned int  Depth = 0 
) const

Output the XML document using a Writer.

Parameters
WriterInstanceThe Writer that will be used to output the xml text.
indentThe Character(s) used to represent a tab in the output, this defaults to one tab character.
flagsThe output format flags, this is a bitfield that defaults to XML::FormatDefault.
DocumentEncodingThe XML::Encoding of the document, whichs defaults to EncodingAuto
DepthThis defaults to 0. The amount of times to prepend the indentation to the beginning of each output line.

This will never write a Byte Order Mark(BOM), and will default to not outputing a document declaration.

Note
This is not available in the safe libraries in scripting languages
void Mezzanine::XML::Node::Print ( std::basic_ostream< char, std::char_traits< char > > &  os,
const Char8 indent = "\t",
unsigned int  flags = FormatDefault,
Encoding  DocumentEncoding = EncodingAuto,
unsigned int  Depth = 0 
) const

Output the XML document using a Output Stream.

Parameters
osAn output stream to send xml text to.
indentThe Character(s) used to represent a tab in the outpput, this defaults to one tab character.
flagsThe output format flags, this is a bitfield that defaults to XML::FormatDefault
DocumentEncodingThe XML::Encoding of the document, whichs defaults to EncodingAuto
DepthThis defaults to 0. The amount of times to prepend the indentation to the beginning of each output line.

This will never write a Byte Order Mark(BOM), and will default to not outputing a document declaration.

Note
This is not available in the safe libraries in scripting languages
void Mezzanine::XML::Node::Print ( std::basic_ostream< wchar_t, std::char_traits< wchar_t > > &  os,
const Char8 indent = "\t",
unsigned int  flags = FormatDefault,
unsigned int  Depth = 0 
) const

Output the XML document using a Output Stream.

Parameters
osAn output stream to send xml text to.
indentThe Character(s) used to represent a tab in the outpput, this defaults to one tab character.
flagsThe output format flags, this is a bitfield that defaults to XML::FormatDefault
DepthThis defaults to 0. The amount of times to prepend the indentation to the beginning of each output line.

This will never write a Byte Order Mark(BOM), and will default to not outputing a document declaration.

Note
This is not available in the safe libraries in scripting languages
bool Mezzanine::XML::Node::RemoveAttribute ( const Attribute a)

Remove specified Attribute.

Parameters
aThe Attribute to look for. If the given Attribute doesn't belong to this Node then this will fail
Returns
True if the removal was successful, false otherwise.
bool Mezzanine::XML::Node::RemoveAttribute ( const Char8 Name)

Remove Attribute as specified by name.

Parameters
NameThe name of the Attribute to remove.
Returns
True if the removal was successful, false otherwise.
bool Mezzanine::XML::Node::RemoveChild ( const Node n)

Remove specified child element.

Parameters
nThe Node to look for. If the given Attribute doesn't belong to this Node then this will fail
Returns
True if the removal was successful, false otherwise.
bool Mezzanine::XML::Node::RemoveChild ( const Char8 Name)

Remove child element as specified by name.

Parameters
NameThe name of the Node to remove.
Returns
True if the removal was successful, false otherwise
bool Mezzanine::XML::Node::SetName ( const Char8 rhs)

Set the name of .

Parameters
rhsThe desired name.
Returns
True if successful, returns false if the name cannot be stored or there is not enough memory.
Note
Not available in scripting languages in favor of the overload of this function that accepts String as a parameter.
bool Mezzanine::XML::Node::SetName ( const String rhs)
inline

Set the name of this object.

Parameters
rhsThe desired name .
Returns
True if successful, returns false if the name cannot be stored or there is not enough memory.

Definition at line 274 of file node.h.

bool Mezzanine::XML::Node::SetValue ( const Char8 rhs)

Set the value of this.

Parameters
rhsThe new Value.
Returns
True if successful, returns false if this is empty or there is not enough memory.
Todo:

update this to make the error return code redundant and use an exception instead.

Review for possiblity of buffer overflow.

bool Mezzanine::XML::Node::Traverse ( TreeWalker walker)

Perform sophisticated (or whatever) algorithms on this and all descendant Nodes in the XML tree.

Parameters
walkerAny class that fully implement XML::Treewalker. This is where the algorithm to be run is located.
Returns
True if every descendant Node of this Node was iterated through, false if it didn't go through every Node.
See Also
XML::TreeWalker
NodeType Mezzanine::XML::Node::Type ( ) const

Identify what kind of Node this is.

Returns
A NodeType identifying this Node, or o/NULL if this Node is empty.
const Char8* Mezzanine::XML::Node::Value ( ) const

Get the Value of this Node.

Returns
Returns A pointer to a const c-style array of the the character type (usually char or wchar_t) containing the value.
Warning
returns "" if Node is empty.

Member Data Documentation

NodeStruct* Mezzanine::XML::Node::NodeData
protected

Stores pointers to the Node data and some metadata.

Definition at line 98 of file node.h.


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