MUSX Document Model
Loading...
Searching...
No Matches
musx::xml::tinyxml2::Element Class Reference

Implementation of IXmlElement using tinyxml2. More...

#include <TinyXmlImpl.h>

+ Inheritance diagram for musx::xml::tinyxml2::Element:

Public Member Functions

 Element (const ::tinyxml2::XMLElement *elem)
 Constructor.
 
std::string getTagName () const override
 Gets the tag name of the element.
 
std::string getText () const override
 Gets the text content of the element.
 
std::shared_ptr< IXmlAttributegetFirstAttribute () const override
 Gets the first attribute.
 
std::shared_ptr< IXmlAttributefindAttribute (const std::string &tagName) const override
 Finds the first attribute.
 
std::shared_ptr< IXmlElementgetFirstChildElement (const std::string &tagName={}) const override
 Finds the first child element.
 
std::shared_ptr< IXmlElementgetNextSibling (const std::string &tagName={}) const override
 Gets the next sibling element.
 
std::shared_ptr< IXmlElementgetPreviousSibling (const std::string &tagName={}) const override
 Gets the previous sibling element.
 
std::shared_ptr< IXmlElementgetParent () const override
 Gets the parent element.
 
- Public Member Functions inherited from musx::xml::IXmlElement
std::string getTextTrimmed () const
 Gets the text content of the element with whitespace trimmed.
 
template<typename T >
getTextAs (T defaultValue={}) const
 Gets the text content of the element, converted to the specified type.
 

Detailed Description

Implementation of IXmlElement using tinyxml2.

Member Function Documentation

◆ findAttribute()

std::shared_ptr< IXmlAttribute > musx::xml::tinyxml2::Element::findAttribute ( const std::string &  name) const
inlineoverridevirtual

Finds the first attribute.

Parameters
nameThe name of the attribute to find.
Returns
A shared pointer to the attribute, or nullptr if not found.

Implements musx::xml::IXmlElement.

◆ getFirstAttribute()

std::shared_ptr< IXmlAttribute > musx::xml::tinyxml2::Element::getFirstAttribute ( ) const
inlineoverridevirtual

Gets the first attribute.

Returns
A shared pointer to the attribute, or nullptr if not found.

Implements musx::xml::IXmlElement.

◆ getFirstChildElement()

std::shared_ptr< IXmlElement > musx::xml::tinyxml2::Element::getFirstChildElement ( const std::string &  tagName = {}) const
inlineoverridevirtual

Finds the first child element.

Parameters
tagName[optional] The tag name of the child elements to find. If omitted or empty, finds the first child with any name.
Returns
A shared pointer to the child element, or nullptr if not found.

Implements musx::xml::IXmlElement.

◆ getNextSibling()

std::shared_ptr< IXmlElement > musx::xml::tinyxml2::Element::getNextSibling ( const std::string &  tagName = {}) const
inlineoverridevirtual

Gets the next sibling element.

Parameters
tagName[optional] The tag name of the sibling elements to find. If omitted or empty, finds the next sibling with any name.
Returns
A shared pointer to the next sibling element, or nullptr if not found.

Implements musx::xml::IXmlElement.

◆ getParent()

std::shared_ptr< IXmlElement > musx::xml::tinyxml2::Element::getParent ( ) const
inlineoverridevirtual

Gets the parent element.

Returns
A shared pointer to the parent element, or nullptr if not applicable.

Implements musx::xml::IXmlElement.

◆ getPreviousSibling()

std::shared_ptr< IXmlElement > musx::xml::tinyxml2::Element::getPreviousSibling ( const std::string &  tagName = {}) const
inlineoverridevirtual

Gets the previous sibling element.

Parameters
tagName[optional] The tag name of the sibling elements to find. If omitted or empty, finds the previous sibling with any name.
Returns
A shared pointer to the previous sibling element, or nullptr if not found.

Implements musx::xml::IXmlElement.

◆ getTagName()

std::string musx::xml::tinyxml2::Element::getTagName ( ) const
inlineoverridevirtual

Gets the tag name of the element.

Returns
The tag name of the element.

Implements musx::xml::IXmlElement.

◆ getText()

std::string musx::xml::tinyxml2::Element::getText ( ) const
inlineoverridevirtual

Gets the text content of the element.

Returns
The text content of the element.

Implements musx::xml::IXmlElement.