Donner SVG 0.8.0-pre
SVG editor and embeddable C⁠+⁠+⁠20 engine.
Loading...
Searching...
No Matches
donner::components::AttributesComponent Struct Reference

Stores XML attribute values. More...

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

Classes

struct  AttributeSourceAnchors
 Source anchors for one serialized attribute. More...

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.
std::optional< AttributeSourceAnchorsgetAttributeSourceAnchors (const xml::XMLQualifiedNameRef &name) const
 Get source-anchor metadata for an attribute, if it exists.
std::optional< AttributeSourceAnchors > * attributeSourceAnchorsSlot (const xml::XMLQualifiedNameRef &name)
 Return a pointer to an attribute's source-anchor slot.
void clearAttributeSourceAnchors (const xml::XMLQualifiedNameRef &name)
 Remove source-anchor metadata for an attribute.
SmallVector< xml::XMLQualifiedNameRef, 10 > attributes () const
 Get a list of all attributes.
std::size_t attributeCount () const
 Number of attributes retained by this component, without allocating a name list.
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.

Returns
The list of all attribute names currently set on this component.

◆ attributeSourceAnchorsSlot()

std::optional< AttributeSourceAnchors > * donner::components::AttributesComponent::attributeSourceAnchorsSlot ( const xml::XMLQualifiedNameRef & name)
inline

Return a pointer to an attribute's source-anchor slot.

For callers that check, read, and then write the anchors of one attribute, which would otherwise look the same attribute up once per step. The returned pointer is invalidated by anything that adds or removes an attribute on this component.

Parameters
nameName of the attribute to query.
Returns
Pointer to the attribute's anchor slot, or nullptr when the attribute is not set.

◆ clearAttributeSourceAnchors()

void donner::components::AttributesComponent::clearAttributeSourceAnchors ( const xml::XMLQualifiedNameRef & name)
inline

Remove source-anchor metadata for an attribute.

Parameters
nameName of the attribute to clear.

◆ 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 donner::xml::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.

◆ getAttributeSourceAnchors()

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

Get source-anchor metadata for an attribute, if it exists.

Parameters
nameName of the attribute to query.
Returns
Anchor ids for the serialized attribute, or std::nullopt if unavailable.

◆ 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: donner::svg::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 file: