sptk2 logo
SPTK Home Page

sptk::CXmlAttributes Class Reference
[XML]

XML node attributes. More...

#include <CXmlAttributes.h>

Inheritance diagram for sptk::CXmlAttributes:

sptk::CXmlNodeList

List of all members.

Public Member Functions

 CXmlAttributes (CXmlElement *parent)
 Constructor.
CXmlAttributesoperator= (const CXmlAttributes &src)
 Assign operator.
bool hasAttribute (std::string attr) const
 Searches for named attribute.
CXmlValue getAttribute (std::string attr, const char *defaultValue="") const
 Returns an attribute value.
void setAttribute (std::string attr, CXmlValue value, const char *defaultValue="")
 Sets attribute value for given attribute.

Protected Member Functions

CXmlAttributegetAttributeNode (std::string attr)
 Returns an attribute node.
const CXmlAttributegetAttributeNode (std::string attr) const
 Returns an attribute node (const version).

Protected Attributes

CXmlElementm_parent
 The parent XML element.

Friends

class CXmlNode
class CXmlElement


Detailed Description

XML node attributes.

The CXmlAttributes class is map for node attributes.


Constructor & Destructor Documentation

sptk::CXmlAttributes::CXmlAttributes ( CXmlElement parent  )  [inline]

Constructor.

The XML attributes object uses the shared strings table (SST) for attribute names

Parameters:
parent CXmlElement*, the parent XML element


Member Function Documentation

CXmlValue sptk::CXmlAttributes::getAttribute ( std::string  attr,
const char *  defaultValue = "" 
) const

Returns an attribute value.

If the attribute is not found, empty string is returned. 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

Referenced by sptk::CXmlElement::getAttribute().

const CXmlAttribute* sptk::CXmlAttributes::getAttributeNode ( std::string  attr  )  const [protected]

Returns an attribute node (const version).

If the attribute is not found, empty string is returned. HTML tags can have empty attributes, for those you should use has_attribute() method.

Parameters:
attr std::string, name of attribute
Returns:
attribute node or NULL

CXmlAttribute* sptk::CXmlAttributes::getAttributeNode ( std::string  attr  )  [protected]

Returns an attribute node.

If the attribute is not found, empty string is returned. HTML tags can have empty attributes, for those you should use has_attribute() method.

Parameters:
attr std::string, name of attribute
Returns:
attribute node or NULL

bool sptk::CXmlAttributes::hasAttribute ( std::string  attr  )  const

Searches for named attribute.

Returns true, if given attribute is found.

Parameters:
attr std::string, name of attribute to search

Referenced by sptk::CXmlElement::hasAttribute().

CXmlAttributes& sptk::CXmlAttributes::operator= ( const CXmlAttributes src  ) 

Assign operator.

Makes copy of an attribute set to another.

Parameters:
src as copy source

void sptk::CXmlAttributes::setAttribute ( std::string  attr,
CXmlValue  value,
const char *  defaultValue = "" 
)

Sets attribute value for given attribute.

Parameters:
attr std::string, name of attribute
value CXmlValue, an attribute value. See CXmlValue class description for data convertions.
defaultValue const char *, a default value. If attribute value is matching default value than attribute isn't stored (or removed if it existed).

Referenced by sptk::CXmlElement::setAttribute().


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

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