Donner SVG 0.8.0
0.8.0 ยท ebf353960.8.0 main
SVG editor and embeddable C⁠+⁠+⁠20 engine.
Loading...
Searching...
No Matches
donner::svg::parser::PathParser Class Reference

Parse an SVG path "d"-string, see Path Data Syntax. More...

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

Classes

struct  Command
 One authored command, before coordinate or curve normalization. More...
struct  CommandList
 Owning command syntax; implicit repetitions are expanded, including moveto's later lineto. More...

Static Public Member Functions

static ParseResult< Path > Parse (std::string_view d)
 Parse an SVG path "d"-string, see Path Data Syntax.
static ParseResult< CommandList > ParseCommands (std::string_view d)
 Parse authored command parameters with the same grammar as Parse, without expanding geometry.

Static Public Attributes

static constexpr std::size_t kMaximumCommands = 128 * 1024
 Maximum number of path commands accepted from one untrusted d attribute.
static constexpr std::size_t kMaximumPoints = 256 * 1024
 Maximum number of points retained while parsing one untrusted d attribute.
static constexpr std::size_t kMaximumParameters = kMaximumPoints * 2
 Maximum scalar parameters retained by ParseCommands.

Detailed Description

Parse an SVG path "d"-string, see Path Data Syntax.


Class Documentation

◆ donner::svg::parser::PathParser::Command

struct donner::svg::parser::PathParser::Command

One authored command, before coordinate or curve normalization.

Class Members
char letter = 0 SVG command letter; closepath is always uppercase Z.
uint8_t parameterCount = 0 Number of parameters, at most seven.
uint32_t parameterOffset = 0 First entry in CommandList::parameters.

◆ donner::svg::parser::PathParser::CommandList

struct donner::svg::parser::PathParser::CommandList

Owning command syntax; implicit repetitions are expanded, including moveto's later lineto.

Class Members
vector< Command > commands Authored command kinds and parameter ranges.
vector< double > parameters Parameters before relative-coordinate conversion.

Member Function Documentation

◆ Parse()

ParseResult< Path > donner::svg::parser::PathParser::Parse ( std::string_view d)
static

Parse an SVG path "d"-string, see Path Data Syntax.

Note that this parser may return both an error and a partial path, since path parsing will return anything that it has parsed before it encountered the error. The caller should use both ParseResult::hasResult() and ParseResult::hasError() to determine what has been returned.

Parameters
dString corresponding to the SVG <path d="..."> parameter.
Returns
Parsed Path and/or an error.

◆ ParseCommands()

ParseResult< CommandList > donner::svg::parser::PathParser::ParseCommands ( std::string_view d)
static

Parse authored command parameters with the same grammar as Parse, without expanding geometry.

The result retains relative commands, shorthand curves and arc parameters. Like Parse, it may contain a completed prefix and an error; incomplete commands are omitted.

Parameters
dSVG path data.
Returns
Owned commands and/or an error, bounded by kMaximumCommands and kMaximumParameters.

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