ticpp::Element Class Reference

Wrapper around TiXmlElement. More...

#include <ticpp.h>

Inheritance diagram for ticpp::Element:

ticpp::NodeImp< TiXmlElement > ticpp::Node ticpp::Base List of all members.

Public Member Functions

 Element ()
 Default Constructor.
 Element (const std::string &value)
 Default Constructor.
 Element (TiXmlElement *element)
 Constructor.
AttributeFirstAttribute (bool throwIfNoAttributes=true)
 Access the first attribute in this element.
AttributeLastAttribute (bool throwIfNoAttributes=true)
 Access the last attribute in this element.
template<class T>
void SetAttribute (const std::string &name, const T &value)
 Sets an attribute of name to a given value.
std::string GetText (bool throwIfNotFound=true)
 Gets the text of an Element.
std::string GetTextOrDefault (const std::string &defaultValue)
 Gets the text of an Element, if it doesn't exist it will return the defaultValue.
template<class T, class DefaultT>
void GetTextOrDefault (T *value, const DefaultT &defaultValue)
 Gets the text value of an Element, if it doesn't exist it will return the defaultValue.
template<class T>
void GetText (T *value, bool throwIfNotFound=true)
 Gets the text of an Element.
template<class T>
void SetText (const T &value)
 Convenience function to set the text of an element.
template<class T, class DefaulT>
void GetAttributeOrDefault (const std::string &name, T *value, const DefaulT &defaultValue)
 Gets an attribute of name from an element, if it doesn't exist it will return the defaultValue.
template<class T>
void GetAttribute (const std::string &name, T *value, bool throwIfNotFound=true)
 Gets an attribute of name from an element.

Detailed Description

Wrapper around TiXmlElement.


Constructor & Destructor Documentation

ticpp::Element::Element ( const std::string &  value  ) 

Default Constructor.

Initializes all the variables.


Member Function Documentation

Attribute* ticpp::Element::FirstAttribute ( bool  throwIfNoAttributes = true  ) 

Access the first attribute in this element.

Parameters:
throwIfNoAttributes [DEF] If true, throws when there are no attributes
Returns:
The first attribute, NULL if there are none and throwIfNoAttributes is true

template<class T>
void ticpp::Element::GetAttribute ( const std::string &  name,
T *  value,
bool  throwIfNotFound = true 
) [inline]

Gets an attribute of name from an element.

Uses FromString to convert the string to the type of choice.

Parameters:
name The name of the attribute you are querying.
value [OUT] The container for the returned value
throwIfNotFound [DEF] If true, will throw an exception if the attribute doesn't exist
Exceptions:
Exception When the attribute doesn't exist and throwIfNotFound is true
See also:
GetAttributeOrDefault

template<class T, class DefaulT>
void ticpp::Element::GetAttributeOrDefault ( const std::string &  name,
T *  value,
const DefaulT &  defaultValue 
) [inline]

Gets an attribute of name from an element, if it doesn't exist it will return the defaultValue.

Uses FromString to convert the string to the type of choice.

Parameters:
name The name of the attribute you are querying.
value [OUT] The container for the returned value.
defaultValue What to put in value if there is no attribute in this element.
Exceptions:
Exception 
See also:
GetAttribute

template<class T>
void ticpp::Element::GetText ( T *  value,
bool  throwIfNotFound = true 
) [inline]

Gets the text of an Element.

Uses FromString to convert the string to the type of choice.

Parameters:
value [OUT] The container for the returned value
throwIfNotFound [DEF] If true, will throw an exception if there is no text in this element
Note:
This is different than GetText() in that it will covert the text to what ever type you want

This only works if the Text is the FirstChild node

Exceptions:
Exception When there is no text and throwIfNotFound is true
See also:
GetText

GetTextOrDefault

GetTextOrDefault( T* value, const DefaultT& defaultValue )

TiXmlElement::GetText

std::string ticpp::Element::GetText ( bool  throwIfNotFound = true  )  [inline]

Gets the text of an Element.

Parameters:
throwIfNotFound [DEF] If true, will throw an exception if there is no text in this element
Note:
This only works if the Text is the FirstChild node
Exceptions:
Exception When there is no text and throwIfNotFound is true
See also:
GetText( T* value, bool throwIfNotFound = false )

GetTextOrDefault

GetTextOrDefault( T* value, const DefaultT& defaultValue )

TiXmlElement::GetText

template<class T, class DefaultT>
void ticpp::Element::GetTextOrDefault ( T *  value,
const DefaultT &  defaultValue 
) [inline]

Gets the text value of an Element, if it doesn't exist it will return the defaultValue.

Uses FromString to convert the string to the type of choice

Parameters:
value [OUT] The container for the returned value
defaultValue What to put in 'value' if there is no text in this element
Note:
This is different than GetText() in that it will covert the text to what ever type you want.

This only works if the Text is the FirstChild node

See also:
GetText

GetText( T* value, bool throwIfNotFound = false )

GetTextOrDefault( const std::string& defaultValue )

TiXmlElement::GetText

std::string ticpp::Element::GetTextOrDefault ( const std::string &  defaultValue  )  [inline]

Gets the text of an Element, if it doesn't exist it will return the defaultValue.

Parameters:
defaultValue What to put in 'value' if there is no text in this element
Note:
This only works if the Text is the FirstChild node
See also:
GetText

GetText( T* value, bool throwIfNotFound = false )

GetTextOrDefault( T* value, const DefaultT& defaultValue )

TiXmlElement::GetText

Attribute* ticpp::Element::LastAttribute ( bool  throwIfNoAttributes = true  ) 

Access the last attribute in this element.

Parameters:
throwIfNoAttributes [DEF] If true, throws when there are no attributes
Returns:
The last attribute, NULL if there are none and throwIfNoAttributes is true

template<class T>
void ticpp::Element::SetAttribute ( const std::string &  name,
const T &  value 
) [inline]

Sets an attribute of name to a given value.

The attribute will be created if it does not exist, or changed if it does. Uses ToString to convert the value to a string, so there is no need to use any other SetAttribute methods.

See also:
GetAttribute

template<class T>
void ticpp::Element::SetText ( const T &  value  )  [inline]

Convenience function to set the text of an element.

Creates a Text node and inserts it as the first child. Uses ToString to convert the parameter to a string.

Parameters:
value The text to set.


The documentation for this class was generated from the following file:
Generated on Thu Sep 7 14:23:33 2006 for TinyXml by  doxygen 1.4.7