Donner SVG 0.8.0-pre
SVG editor and embeddable C⁠+⁠+⁠20 engine.
Loading...
Searching...
No Matches
donner::svg::parser::SVGParser::Options Struct Reference

Options to modify the parsing behavior. More...

#include "donner/svg/parser/SVGParser.h"

Public Member Functions

constexpr Options ()
 Default options.

Public Attributes

bool disableUserAttributes = true
 By default, the parser will ignore user-defined attributes (only presentation attributes will be parsed), to optimize for performance.
bool enableExperimental = false
 Enable experimental or incomplete features.
bool parseAsInlineSVG = false
 Parse as inlined SVG content.
size_t maximumInputSize = kDefaultMaximumInputSize
 Maximum source size accepted by ParseSVG.
size_t maximumParsedPayloadSize = kDefaultMaximumParsedPayloadSize
 Maximum estimated bytes retained by parsed lists, stylesheets, and deferred geometry.
size_t maximumContentProjectionChunks = kDefaultMaximumContentProjectionChunks
 Maximum direct text/CDATA chunks joined into one text, style, or descriptive element.
size_t maximumTreeNodes = kDefaultMaximumTreeNodes
 Maximum XML tree nodes visited while converting either parser entry point.
size_t maximumTreeDepth = kDefaultMaximumTreeDepth
 Maximum nested SVG element depth converted from an XML document.

Detailed Description

Options to modify the parsing behavior.

Examples
svg_to_png.cc.

Member Data Documentation

◆ disableUserAttributes

bool donner::svg::parser::SVGParser::Options::disableUserAttributes = true

By default, the parser will ignore user-defined attributes (only presentation attributes will be parsed), to optimize for performance.

This behavior breaks some CSS matchers, which may use user-defined attributes to control styling.

For example:

<svg>
<style>
rect[fill="red"] { fill: green; }
rect[my-custom-attribute="value"] { stroke: green; }
</style>
<rect x="10" y="20" width="30" height="40"
my-custom-attribute="value"
fill="red" stroke="red" />
</svg>

If user attributes are disabled (disableUserAttributes is true), the above example will only match the first rule, because my-custom-attribute will be ignored during parsing.

To support rendering documents that use user-defined attributes, set this to false.

Examples
svg_to_png.cc.

◆ enableExperimental

bool donner::svg::parser::SVGParser::Options::enableExperimental = false

Enable experimental or incomplete features.

When true, element types that declare static constexpr bool IsExperimental = true are parsed as their concrete type; when false, they are treated as unknown elements.

The SVG animation elements (animate, animateTransform, and set) are currently experimental and require this option. Text and filters are enabled independently.

◆ maximumInputSize

size_t donner::svg::parser::SVGParser::Options::maximumInputSize = kDefaultMaximumInputSize

Maximum source size accepted by ParseSVG.

For SVGZ input the same limit applies to both the compressed and expanded forms, preventing decompression bombs.

◆ maximumParsedPayloadSize

size_t donner::svg::parser::SVGParser::Options::maximumParsedPayloadSize = kDefaultMaximumParsedPayloadSize

Maximum estimated bytes retained by parsed lists, stylesheets, and deferred geometry.

This is aggregate across the document, rather than a per-attribute limit.

◆ parseAsInlineSVG

bool donner::svg::parser::SVGParser::Options::parseAsInlineSVG = false

Parse as inlined SVG content.

This will treat the input as a fragment of SVG content, rather than a full SVG document. This is useful for parsing SVG content embedded in HTML or other XML documents.

This enables the following shorthand without the xmlns attribute:

<svg><rect /></svg>

Instead of the full document:

<svg xmlns="http://www.w3.org/2000/svg"><rect /></svg>

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