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

Stores XML attribute values. More...

#include "donner/svg/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 XMLQualifiedNameRef &name) const
 Returns true if the element has an attribute with the given name.
 
std::optional< RcStringgetAttribute (const XMLQualifiedNameRef &name) const
 Get the value of an attribute, if it exists.
 
SmallVector< XMLQualifiedNameRef, 1 > findMatchingAttributes (const XMLQualifiedNameRef &matcher) const
 Find attributes matching the given name matcher.
 
void setAttribute (const 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 (const XMLQualifiedNameRef &name)
 Remove an attribute from the element.
 

Detailed Description

Stores XML attribute values.

Member Function Documentation

◆ findMatchingAttributes()

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

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::svg::components::AttributesComponent::getAttribute ( const 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::svg::components::AttributesComponent::hasAttribute ( const 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::svg::components::AttributesComponent::removeAttribute ( const XMLQualifiedNameRef & name)
inline

Remove an attribute from the element.

Parameters
nameName of the attribute to remove.

◆ setAttribute()

void donner::svg::components::AttributesComponent::setAttribute ( const XMLQualifiedNameRef & name,
const RcString & value )
inline

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
nameName of the attribute to set.
valueNew value to set.

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