sptk2 logo
SPTK Home Page

sptk::CXmlElement Class Reference
[XML]

XML Element is a named item that may optionally have sub-nodes and attributes. More...

#include <CXmlElement.h>

Inheritance diagram for sptk::CXmlElement:

sptk::CXmlNamedItem sptk::CXmlNode sptk::CXmlDoc sptk::CRegistry

List of all members.

Public Member Functions

 CXmlElement (CXmlNode &parent, const char *tagname)
 Constructor.
 CXmlElement (CXmlNode *parent, const char *tagname)
 Constructor.
 CXmlElement (CXmlNode &parent, const std::string &tagname)
 Constructor.
virtual CXmlNodeType type () const
 Returns node type.
virtual iterator begin ()
 Returns the first subnode iterator.
virtual const_iterator begin () const
 Returns the first subnode const iterator.
virtual iterator end ()
 Returns the end subnode iterator.
virtual const_iterator end () const
 Returns the end subnode const iterator.
virtual uint32_t size () const
 Returns a number of subnodes.
virtual bool empty () const
 Returns true if node has no subnodes of subnodes.
virtual void push_back (CXmlNode *node)
 Appends a subnode.
virtual void insert (iterator pos, CXmlNode *node)
 Inserts a subnode.
virtual void remove (CXmlNode *node)
 Removes a subnode.
virtual void unlink (CXmlNode *node)
 Removes a subnode.
virtual void clearChildren ()
 Deletes all child nodes.
virtual void clear ()
 Deletes all children and clears all the attributes.
virtual CXmlAttributesattributes ()
 Returns referrence to node attributes.
virtual const CXmlAttributesattributes () const
 Returns referrence to node attributes (const version).
virtual bool hasAttributes () const
 Returns true, if node has any attributes.
virtual bool hasAttribute (const char *attr) const
virtual CXmlValue getAttribute (std::string attr, const char *defaultValue="") const
virtual void setAttribute (const char *attr, CXmlValue value, const char *defaultValue="")
virtual void setAttribute (const std::string &attr, CXmlValue value, const char *defaultValue="")

Protected Member Functions

 CXmlElement (CXmlDoc &doc)
 Protected constructor for creating CXmlDoc only.

Protected Attributes

CXmlAttributes m_attributes
 Node attributes.

Friends

class CXmlDoc


Detailed Description

XML Element is a named item that may optionally have sub-nodes and attributes.

Constructor & Destructor Documentation

sptk::CXmlElement::CXmlElement ( CXmlDoc doc  )  [inline, protected]

Protected constructor for creating CXmlDoc only.

Parameters:
doc CXmlDoc&, a document.

sptk::CXmlElement::CXmlElement ( CXmlNode parent,
const char *  tagname 
) [inline]

Constructor.

Parameters:
parent CXmlNode*, a parent node.
tagname const char*, a name of XML tag

sptk::CXmlElement::CXmlElement ( CXmlNode parent,
const char *  tagname 
) [inline]

Constructor.

Parameters:
parent CXmlNode*, a parent node.
tagname const char*, a name of XML tag

sptk::CXmlElement::CXmlElement ( CXmlNode parent,
const std::string &  tagname 
) [inline]

Constructor.

Parameters:
parent CXmlNode &, a parent node.
tagname const string&, a name of XML tag


Member Function Documentation

virtual void sptk::CXmlElement::clear (  )  [virtual]

Deletes all children and clears all the attributes.

Any memory, associated with children or attributes, is released.

Reimplemented from sptk::CXmlNode.

Reimplemented in sptk::CXmlDoc.

virtual void sptk::CXmlElement::clearChildren (  )  [virtual]

Deletes all child nodes.

Any memory, associated with child nodes, is released.

Reimplemented from sptk::CXmlNode.

virtual CXmlValue sptk::CXmlElement::getAttribute ( std::string  attr,
const char *  defaultValue = "" 
) const [inline, virtual]

Returns attribute value for given attribute. HTML tags can have empty attributes, for those you should use has_attribute() method.

Parameters:
attr std::string, name of attribute
defaultValue const char *, a default value. If attribute doesn't exist then default value is returned.
Returns:
attribute value

Reimplemented from sptk::CXmlNode.

References sptk::CXmlAttributes::getAttribute(), and m_attributes.

virtual bool sptk::CXmlElement::hasAttribute ( const char *  attr  )  const [inline, virtual]

Returns true, if given attribute is found

Parameters:
attr const char *, attribute to search

Reimplemented from sptk::CXmlNode.

References sptk::CXmlAttributes::hasAttribute(), and m_attributes.

virtual void sptk::CXmlElement::insert ( iterator  pos,
CXmlNode node 
) [virtual]

Inserts a subnode.

Parameters:
pos iterator, insert position with the list of subnodes
node CXmlNode*, node to insert

Reimplemented from sptk::CXmlNode.

virtual void sptk::CXmlElement::push_back ( CXmlNode node  )  [virtual]

Appends a subnode.

Parameters:
node CXmlNode*, node to append

Reimplemented from sptk::CXmlNode.

virtual void sptk::CXmlElement::remove ( CXmlNode node  )  [virtual]

Removes a subnode.

Any memory allocated for subnode is released and subnode is removed from its parent

Parameters:
node CXmlNode*, node to remove

Reimplemented from sptk::CXmlNode.

virtual void sptk::CXmlElement::setAttribute ( const std::string &  attr,
CXmlValue  value,
const char *  defaultValue = "" 
) [inline, virtual]

Sets new value to attribute 'attr'. If attribute is not found, it's added to map.

Parameters:
attr const string&, an attribute name
value CXmlValue, attribute value
defaultValue const char *, a default value. If attribute value is matching default value than attribute isn't stored (or removed if it existed).

Reimplemented from sptk::CXmlNode.

References m_attributes, and sptk::CXmlAttributes::setAttribute().

virtual void sptk::CXmlElement::setAttribute ( const char *  attr,
CXmlValue  value,
const char *  defaultValue = "" 
) [inline, virtual]

Sets new value to attribute 'attr'. If attribute is not found, it's added to map.

Parameters:
attr const char*, attribute name
value CXmlValue, attribute value
defaultValue const char *, a default value. If attribute value is matching default value than attribute isn't stored (or removed if it existed).

Reimplemented from sptk::CXmlNode.

References m_attributes, and sptk::CXmlAttributes::setAttribute().

virtual void sptk::CXmlElement::unlink ( CXmlNode node  )  [virtual]

Removes a subnode.

Disconnects subnode from parent (this node)

Reimplemented from sptk::CXmlNode.


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

Mon Mar 5 11:56:22 2012: SPTK 3.5.7