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

Represents a reference to an SVG entity by its href, typically created from a url(#id) string. More...

#include "donner/svg/graph/Reference.h"

Collaboration diagram for donner::svg::Reference:
[legend]

Public Member Functions

 Reference (const RcString &href)
 Constructs a Reference from an RcString.
 
 Reference (const char *href)
 Constructs a Reference from a C-style string.
 
std::optional< ResolvedReferenceresolve (Registry &registry) const
 Attempts to resolve the reference using the provided registry.
 
bool operator== (const Reference &other) const =default
 Equality operator.
 

Public Attributes

RcString href
 The href string identifying the referenced entity, e.g. #id
 

Friends

std::ostream & operator<< (std::ostream &os, const Reference &ref)
 Outputs the href string to a stream.
 

Detailed Description

Represents a reference to an SVG entity by its href, typically created from a url(#id) string.

The reference can be resolved to an entity using resolve.

Source **href value**
url(#id) #id
href="#id #id
xlink:href="#id" #id
xlink:href="url(#id)" url(#id) (invalid syntax)

Note that absolute references, such as path/to/other-file.svg#elementId, are not supported.

Constructor & Destructor Documentation

◆ Reference() [1/2]

donner::svg::Reference::Reference ( const RcString & href)
inline

Constructs a Reference from an RcString.

Parameters
hrefThe href string

◆ Reference() [2/2]

donner::svg::Reference::Reference ( const char * href)
inline

Constructs a Reference from a C-style string.

Parameters
hrefThe href string

Member Function Documentation

◆ resolve()

std::optional< ResolvedReference > donner::svg::Reference::resolve ( Registry & registry) const

Attempts to resolve the reference using the provided registry.

Parameters
registryThe Registry to use for resolution
Returns
An optional ResolvedReference, which is empty if resolution fails

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