Donner 0.8.0-pre
Embeddable browser-grade SVG2 engine
Loading...
Searching...
No Matches
donner::svg::SVGDocumentMutation Class Reference

Typed DOM mutation helper used by SVGDocument::withWriteAccess. More...

#include "donner/svg/SVGDocument.h"

Public Member Functions

 SVGDocumentMutation (SVGDocument document, DocumentWriteAccess &access)
 Create a mutation helper over an active document write access.
 SVGDocumentMutation (const SVGDocumentMutation &other)=delete
 Copying mutation helpers is not allowed.
 SVGDocumentMutation (SVGDocumentMutation &&other) noexcept=delete
 Moving mutation helpers is not allowed.
SVGDocumentMutationoperator= (const SVGDocumentMutation &other)=delete
 Copying mutation helpers is not allowed.
SVGDocumentMutationoperator= (SVGDocumentMutation &&other) noexcept=delete
 Moving mutation helpers is not allowed.
DocumentWriteAccessaccess () const
 Get the raw write access for advanced ECS mutation.
void setCanvasSize (int width, int height)
 Set the canvas size.
void useAutomaticCanvasSize ()
 Automatically determine the canvas size from the root <svg> element.
void setAttribute (SVGElement element, const xml::XMLQualifiedNameRef &name, std::string_view value)
 Set an element attribute.
void removeAttribute (SVGElement element, const xml::XMLQualifiedNameRef &name)
 Remove an element attribute.
void insertBefore (SVGElement parent, const SVGElement &newNode, std::optional< SVGElement > referenceNode)
 Insert newNode into parent before referenceNode.
void appendChild (SVGElement parent, const SVGElement &child)
 Append child to parent.
void replaceChild (SVGElement parent, const SVGElement &newChild, const SVGElement &oldChild)
 Replace oldChild with newChild under parent.
void removeChild (SVGElement parent, const SVGElement &child)
 Remove child from parent.
void remove (SVGElement element)
 Remove element from its parent, if it has one.

Detailed Description

Typed DOM mutation helper used by SVGDocument::withWriteAccess.

Constructor & Destructor Documentation

◆ SVGDocumentMutation()

donner::svg::SVGDocumentMutation::SVGDocumentMutation ( SVGDocument document,
DocumentWriteAccess & access )
explicit

Create a mutation helper over an active document write access.

Parameters
documentDocument facade being mutated.
accessActive write access for the document.

Member Function Documentation

◆ appendChild()

void donner::svg::SVGDocumentMutation::appendChild ( SVGElement parent,
const SVGElement & child )

Append child to parent.

Parameters
parentParent element to mutate.
childChild to append.

◆ insertBefore()

void donner::svg::SVGDocumentMutation::insertBefore ( SVGElement parent,
const SVGElement & newNode,
std::optional< SVGElement > referenceNode )

Insert newNode into parent before referenceNode.

Parameters
parentParent element to mutate.
newNodeNode to insert.
referenceNodeExisting child to insert before, or std::nullopt.

◆ remove()

void donner::svg::SVGDocumentMutation::remove ( SVGElement element)

Remove element from its parent, if it has one.

Parameters
elementElement to remove.

◆ removeAttribute()

void donner::svg::SVGDocumentMutation::removeAttribute ( SVGElement element,
const xml::XMLQualifiedNameRef & name )

Remove an element attribute.

Parameters
elementElement to mutate.
nameAttribute name.

◆ removeChild()

void donner::svg::SVGDocumentMutation::removeChild ( SVGElement parent,
const SVGElement & child )

Remove child from parent.

Parameters
parentParent element to mutate.
childChild to remove.

◆ replaceChild()

void donner::svg::SVGDocumentMutation::replaceChild ( SVGElement parent,
const SVGElement & newChild,
const SVGElement & oldChild )

Replace oldChild with newChild under parent.

Parameters
parentParent element to mutate.
newChildChild to insert.
oldChildExisting child to remove.

◆ setAttribute()

void donner::svg::SVGDocumentMutation::setAttribute ( SVGElement element,
const xml::XMLQualifiedNameRef & name,
std::string_view value )

Set an element attribute.

Parameters
elementElement to mutate.
nameAttribute name.
valueAttribute value.

◆ setCanvasSize()

void donner::svg::SVGDocumentMutation::setCanvasSize ( int width,
int height )

Set the canvas size.

Parameters
widthWidth of the canvas, in pixels.
heightHeight of the canvas, in pixels.

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