MUSX Document Model
Loading...
Searching...
No Matches
musx::xml::IXmlAttribute Class Referenceabstract

Interface for an XML attribute. More...

#include <XmlInterface.h>

+ Inheritance diagram for musx::xml::IXmlAttribute:

Public Member Functions

virtual std::string getName () const =0
 Gets the name of the attribute.
 
virtual std::string getValue () const =0
 Gets the value of the attribute.
 
std::string getValueTrimmed () const
 Gets the text content of the attribute with whitespace trimmed.
 
template<typename T >
getValueAs () const
 Gets the value of the attribute, converted to the specified type.
 
virtual std::shared_ptr< IXmlAttributenextAttribute () const =0
 Advances to the next attribute.
 

Detailed Description

Interface for an XML attribute.

Member Function Documentation

◆ getName()

virtual std::string musx::xml::IXmlAttribute::getName ( ) const
pure virtual

Gets the name of the attribute.

Returns
The name of the attribute.

Implemented in musx::xml::pugi::Attribute, musx::xml::rapidxml::Attribute, and musx::xml::tinyxml2::Attribute.

◆ getValue()

virtual std::string musx::xml::IXmlAttribute::getValue ( ) const
pure virtual

Gets the value of the attribute.

Returns
The value of the attribute.

Implemented in musx::xml::pugi::Attribute, musx::xml::rapidxml::Attribute, and musx::xml::tinyxml2::Attribute.

◆ getValueAs()

template<typename T >
T musx::xml::IXmlAttribute::getValueAs ( ) const
inline

Gets the value of the attribute, converted to the specified type.

Template Parameters
TThe type to which the value should be converted.
Returns
The value converted to the specified type.
Exceptions
std::invalid_argumentif the conversion fails.

◆ nextAttribute()

virtual std::shared_ptr< IXmlAttribute > musx::xml::IXmlAttribute::nextAttribute ( ) const
pure virtual

Advances to the next attribute.

Returns
A shared pointer to the next attribute, or nullptr if there are no more attributes.

Implemented in musx::xml::pugi::Attribute, musx::xml::rapidxml::Attribute, and musx::xml::tinyxml2::Attribute.