#include <xmlminus.h>
Public Types | |
| enum | ElementType |
| The type of an XML element, NORMAL, COMMENT, DECLARATION or TERMINATOR. | |
| typedef T | string_type |
| The string type. | |
| typedef string_type::value_type | char_type |
| The character type of the string type. | |
| typedef string_type::traits_type | traits_type |
| The char traits type of the string type. | |
| typedef string_type::allocator_type | allocator_type |
| The allocator type of the string type. | |
|
typedef std::basic_istream< char_type, traits_type > | istream_type |
| An input stream type to use with this type of element. | |
|
typedef std::basic_ostream< char_type, traits_type > | ostream_type |
| An input output type to use with this type of element. | |
|
typedef std::vector< BasicElement< T > > | ChildVector |
| A vector of elements. | |
|
typedef std::map< string_type, string_type > | AttributeMap |
| A map of attributes. | |
Public Member Functions | |
| BasicElement (istream_type &in) | |
| Create and parse a new XML element. | |
| BasicElement (istream_type &in, const std::locale &loc) | |
| Create and parse a new XML element. | |
| BasicElement (const string_type &value="", ElementType type=NORMAL) | |
| Create a new empty element. | |
| BasicElement (const string_type &value, const std::locale &loc, ElementType type=NORMAL) | |
| Create a new empty element. | |
| BasicElement (const std::locale &loc, ElementType type=NORMAL) | |
| Create a new empty element. | |
| std::locale & | getLocale () |
| Get this element's locale. | |
| const std::locale & | getLocale () const |
| Get this element's locale. | |
| void | setLocale (const std::locale &loc) |
| Set this element's locale. | |
| const string_type & | getValue () const |
| Get this element's value. | |
| string_type & | getValue () |
| Get this element's value. | |
| void | setValue (const string_type &val) |
| Set this element's value. | |
| const ChildVector & | getChildren () const |
| Get this element's child elements. | |
| ChildVector & | getChildren () |
| Get this element's child elements. | |
| const AttributeMap & | getAttributes () const |
| Get this element's attributes. | |
| AttributeMap & | getAttributes () |
| Get this element's attributes. | |
| const string_type & | getText () const |
| Get this element's text. | |
| string_type & | getText () |
| Get this element's text. | |
| void | setText (const string_type &str) |
| Set this element's text. | |
| ElementType | getType () const |
| Get this element's type. | |
| void | setType (ElementType t) |
| Set this element's type. | |
| template<typename valueT> | |
| void | setAttribute (const string_type &key, const valueT &val) |
| Set this element's attribute. | |
| template<typename valueT> | |
| valueT | getAttribute (const string_type &key) const |
| Get this element's attribute. | |
| const string_type & | getAttributeRaw (const string_type &key) const |
| Get this element's attribute. | |
| string_type & | getAttributeRaw (const string_type &key) |
| Get this element's attribute. | |
| void | setAttributeRaw (const string_type &key, const string_type &val) |
| Set this element's attribute. | |
| bool | hasAttribute (const string_type &key) const |
| Check if this element has an attribute. | |
| void | print (ostream_type &out, int indent=0) const |
| Write this element to an output stream. | |
| void | parse (istream_type &in) |
| Read and parse this element from a stream. | |
| const BasicElement< T > & | getChild (const string_type &val) const |
| Get a child element of this element. | |
| BasicElement< T > & | getChild (const string_type &val) |
| Get a child element of this element. | |
Static Public Member Functions | |
| static void | entityEncode (string_type &str) |
| Encode all XML entities in a string. | |
| static void | entityDecode (string_type &str) |
| Decode all XML entities in a string. | |
| T | the string type for this element |
| xmlm::BasicElement< T >::BasicElement | ( | istream_type & | in | ) | [inline] |
Create and parse a new XML element.
This element's locale will be queried from the input stream.
| in | the input stream where to read the XML data |
| ParseError | on parsing/syntax errors | |
| std::runtime_error | on I/O errors |
| xmlm::BasicElement< T >::BasicElement | ( | istream_type & | in, | |
| const std::locale & | loc | |||
| ) | [inline] |
Create and parse a new XML element.
The locale will be imbue'd to the input stream and the previous locale will be restored after the parsing.
| in | the input stream where to read the XML | |
| loc | the locale to use |
| ParseError | on parsing/syntax errors | |
| std::runtime_error | on I/O errors |
| xmlm::BasicElement< T >::BasicElement | ( | const string_type & | value = "", |
|
| ElementType | type = NORMAL | |||
| ) | [inline] |
Create a new empty element.
| value | the value of this XML element | |
| type | the Type of this XML element |
| xmlm::BasicElement< T >::BasicElement | ( | const string_type & | value, | |
| const std::locale & | loc, | |||
| ElementType | type = NORMAL | |||
| ) | [inline] |
Create a new empty element.
| value | the value of this XML element | |
| loc | the locale to use with this element8 | |
| type | the Type of this XML element |
| xmlm::BasicElement< T >::BasicElement | ( | const std::locale & | loc, | |
| ElementType | type = NORMAL | |||
| ) | [inline] |
Create a new empty element.
| loc | the locale to use with this element | |
| type | the Type of this XML element |
| std::locale& xmlm::BasicElement< T >::getLocale | ( | ) | [inline] |
Get this element's locale.
| const std::locale& xmlm::BasicElement< T >::getLocale | ( | ) | const [inline] |
Get this element's locale.
| void xmlm::BasicElement< T >::setLocale | ( | const std::locale & | loc | ) | [inline] |
Set this element's locale.
| loc | the new locale of this element |
| const string_type& xmlm::BasicElement< T >::getValue | ( | ) | const [inline] |
Get this element's value.
| string_type& xmlm::BasicElement< T >::getValue | ( | ) | [inline] |
Get this element's value.
| void xmlm::BasicElement< T >::setValue | ( | const string_type & | val | ) | [inline] |
Set this element's value.
| val | this element's new value |
| const ChildVector& xmlm::BasicElement< T >::getChildren | ( | ) | const [inline] |
Get this element's child elements.
| ChildVector& xmlm::BasicElement< T >::getChildren | ( | ) | [inline] |
Get this element's child elements.
| const AttributeMap& xmlm::BasicElement< T >::getAttributes | ( | ) | const [inline] |
Get this element's attributes.
| AttributeMap& xmlm::BasicElement< T >::getAttributes | ( | ) | [inline] |
Get this element's attributes.
| const string_type& xmlm::BasicElement< T >::getText | ( | ) | const [inline] |
Get this element's text.
| string_type& xmlm::BasicElement< T >::getText | ( | ) | [inline] |
Get this element's text.
| void xmlm::BasicElement< T >::setText | ( | const string_type & | str | ) | [inline] |
Set this element's text.
| str | this element's new text |
| ElementType xmlm::BasicElement< T >::getType | ( | ) | const [inline] |
| void xmlm::BasicElement< T >::setType | ( | ElementType | t | ) | [inline] |
| void xmlm::BasicElement< T >::setAttribute | ( | const string_type & | key, | |
| const valueT & | val | |||
| ) |
Set this element's attribute.
Set the value of an attributed named key. If such attribute does not exist, it will be created. The attribute is converted from type valueT to string_type using boost::lexical_cast.
| key | the name of the attribute | |
| val | the value of the attribute |
| valueT xmlm::BasicElement< T >::getAttribute | ( | const string_type & | key | ) | const |
Get this element's attribute.
Get the value of an attribute named key. If such attribute does not exist, an exception will be thrown. The attribute is converted from type string_type to valueT using boost::lexical_cast.
| key | the name of the attribute |
| ParseError | if the attribute is not found |
| const string_type& xmlm::BasicElement< T >::getAttributeRaw | ( | const string_type & | key | ) | const [inline] |
Get this element's attribute.
Get the value of an attribute named key. If such attribute does not exist, an exception will be thrown.
| key | the name of the attribute |
| ParseError | if the attribute is not found |
| string_type& xmlm::BasicElement< T >::getAttributeRaw | ( | const string_type & | key | ) | [inline] |
Get this element's attribute.
Get the value of an attribute named key. If such attribute does not exist, an exception will be thrown.
| key | the name of the attribute |
| ParseError | if the attribute is not found |
| void xmlm::BasicElement< T >::setAttributeRaw | ( | const string_type & | key, | |
| const string_type & | val | |||
| ) | [inline] |
Set this element's attribute.
Set the value of attribute named key to val. If such attribute does not exist, it will be created.
| key | the name of the attribute | |
| val | the value to set to the attribute |
| bool xmlm::BasicElement< T >::hasAttribute | ( | const string_type & | key | ) | const [inline] |
Check if this element has an attribute.
| key | the name of the attribute |
| void xmlm::BasicElement< T >::print | ( | ostream_type & | out, | |
| int | indent = 0 | |||
| ) | const |
Write this element to an output stream.
Writes out this element and all it's subelements recursively.
| out | the output stream where to write this element | |
| indent | the level of indentation (in tab characters) for this element |
| void xmlm::BasicElement< T >::parse | ( | istream_type & | in | ) |
Read and parse this element from a stream.
| in | the input stream where to parse this element from |
| ParseError | on parsing errors | |
| std::runtime_error | on I/O errors |
| const BasicElement<T>& xmlm::BasicElement< T >::getChild | ( | const string_type & | val | ) | const [inline] |
Get a child element of this element.
Returns a child element with value val. If no element is found, an exception is thrown. If there are more than one elements with value val the first one will be returned.
| val | the value of the child element to find |
val | ParseError | if no element will be found |
| BasicElement<T>& xmlm::BasicElement< T >::getChild | ( | const string_type & | val | ) | [inline] |
Get a child element of this element.
Returns a child element with value val. If no element is found, an exception is thrown. If there are more than one elements with value val the first one will be returned.
| val | the value of the child element to find |
val | ParseError | if no element will be found |
| void xmlm::BasicElement< T >::entityEncode | ( | string_type & | str | ) | [static] |
Encode all XML entities in a string.
| str | the string to encode |
| void xmlm::BasicElement< T >::entityDecode | ( | string_type & | str | ) | [static] |
Decode all XML entities in a string.
| str | the string to decode |
1.5.0