Donner
C++20 SVG rendering library
Loading...
Searching...
No Matches
donner::components::AttributesComponent Struct Reference

Stores XML attribute values. More...

#include "donner/base/xml/components/AttributesComponent.h"

Public Member Functions

 AttributesComponent ()=default
 Constructor.
 
 AttributesComponent (const AttributesComponent &)=delete
 
AttributesComponentoperator= (const AttributesComponent &)=delete
 
 AttributesComponent (AttributesComponent &&)=default
 Move constructor.
 
AttributesComponentoperator= (AttributesComponent &&)=default
 Move assignment operator.
 
 ~AttributesComponent ()=default
 Destructor.
 
bool hasAttribute (const xml::XMLQualifiedNameRef &name) const
 Returns true if the element has an attribute with the given name.
 
std::optional< RcStringgetAttribute (const xml::XMLQualifiedNameRef &name) const
 Get the value of an attribute, if it exists.
 
SmallVector< xml::XMLQualifiedNameRef, 10 > attributes () const
 Get a list of all attributes.
 
SmallVector< xml::XMLQualifiedNameRef, 1 > findMatchingAttributes (const xml::XMLQualifiedNameRef &matcher) const
 Find attributes matching the given name matcher.
 
void setAttribute (Registry &registry, const xml::XMLQualifiedNameRef &name, const RcString &value)
 Set the value of a generic XML attribute, which may be either a presentation attribute or custom user-provided attribute.
 
void removeAttribute (Registry &registry, const xml::XMLQualifiedNameRef &name)
 Remove an attribute from the element.
 
bool hasNamespaceOverrides () const
 Returns true if the element has any namespace overrides.
 

Detailed Description

Stores XML attribute values.

Member Function Documentation

◆ attributes()

SmallVector< xml::XMLQualifiedNameRef, 10 > donner::components::AttributesComponent::attributes ( ) const
inline

Get a list of all attributes.

Parameters
nameName of the attribute to get.
Returns
The value of the attribute, or std::nullopt if the attribute does not exist.

◆ findMatchingAttributes()

SmallVector< xml::XMLQualifiedNameRef, 1 > donner::components::AttributesComponent::findMatchingAttributes ( const xml::XMLQualifiedNameRef & matcher) const

Find attributes matching the given name matcher.

Parameters
matcherMatcher to use to find attributes. If XMLQualifiedNameRef::namespacePrefix is "*", the matcher will match any namespace with the given attribute name.
Returns
A vector of attributes matching the given name matcher.

◆ getAttribute()

std::optional< RcString > donner::components::AttributesComponent::getAttribute ( const xml::XMLQualifiedNameRef & name) const
inline

Get the value of an attribute, if it exists.

Parameters
nameName of the attribute to get.
Returns
The value of the attribute, or std::nullopt if the attribute does not exist.

◆ hasAttribute()

bool donner::components::AttributesComponent::hasAttribute ( const xml::XMLQualifiedNameRef & name) const
inline

Returns true if the element has an attribute with the given name.

Parameters
nameName of the attribute to check.
Returns
true if the attribute exists, false otherwise.

◆ removeAttribute()

void donner::components::AttributesComponent::removeAttribute ( Registry & registry,
const xml::XMLQualifiedNameRef & name )

Remove an attribute from the element.

Parameters
registryRegistry to use for the operation.
nameName of the attribute to remove.

◆ setAttribute()

void donner::components::AttributesComponent::setAttribute ( Registry & registry,
const xml::XMLQualifiedNameRef & name,
const RcString & value )

Set the value of a generic XML attribute, which may be either a presentation attribute or custom user-provided attribute.

This API only stores the underlying strings for the attribute name and value, and does not parse them. To parse, use the upper-layer API: SVGElement::setAttribute.

Parameters
registryRegistry to use for the operation.
nameName of the attribute to set.
valueNew value to set.

The documentation for this struct was generated from the following files: