#include <ticpp.h>
Inheritance diagram for ticpp::Element:
Public Member Functions | |
Element () | |
Default Constructor. | |
Element (const std::string &value) | |
Default Constructor. | |
Element (TiXmlElement *element) | |
Constructor. | |
Attribute * | FirstAttribute (bool throwIfNoAttributes=true) |
Access the first attribute in this element. | |
Attribute * | LastAttribute (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. |
ticpp::Element::Element | ( | const std::string & | value | ) |
Default Constructor.
Initializes all the variables.
Attribute* ticpp::Element::FirstAttribute | ( | bool | throwIfNoAttributes = true |
) |
Access the first attribute in this element.
throwIfNoAttributes | [DEF] If true, throws when there are no attributes |
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.
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 |
Exception | When the attribute doesn't exist and throwIfNotFound is true |
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.
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. |
Exception |
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.
value | [OUT] The container for the returned value | |
throwIfNotFound | [DEF] If true, will throw an exception if there is no text in this element |
This only works if the Text is the FirstChild node
Exception | When there is no text and throwIfNotFound is true |
std::string ticpp::Element::GetText | ( | bool | throwIfNotFound = true |
) | [inline] |
Gets the text of an Element.
throwIfNotFound | [DEF] If true, will throw an exception if there is no text in this element |
Exception | When there is no text and throwIfNotFound is true |
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
value | [OUT] The container for the returned value | |
defaultValue | What to put in 'value' if there is no text in this element |
This only works if the Text is the FirstChild node
GetText( T* value, bool throwIfNotFound = false )
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.
defaultValue | What to put in 'value' if there is no text in this element |
GetText( T* value, bool throwIfNotFound = false )
Attribute* ticpp::Element::LastAttribute | ( | bool | throwIfNoAttributes = true |
) |
Access the last attribute in this element.
throwIfNoAttributes | [DEF] If true, throws when there are no attributes |
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.
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.
value | The text to set. |