|
|
Donner 0.5.1
Embeddable browser-grade SVG2 engine
|
Top-level Donner namespace, which is split into different sub-namespaces such as donner::svg and donner::css. More...
Namespaces | |
| namespace | parser |
| Parsers for shared data types such as NumberParser and LengthParser. | |
| namespace | css |
| Donner CSS library, a standalone composable CSS parser. | |
| namespace | svg |
| Donner SVG library, which can load, manipulate and render SVG files. | |
| namespace | xml |
| XML parsing and document model support, top-level objects are donner::xml::XMLParser and donner::xml::XMLDocument. | |
Classes | |
| struct | Box2 |
| A 2D axis-aligned bounding box. More... | |
| class | ChunkedString |
| ChunkedString is a small helper to accumulate multiple RcStringOrRef pieces, either as small appended fragments or single codepoints. More... | |
| struct | CompileTimeMapTables |
| Perfect-hash metadata used to resolve keys into storage slots. More... | |
| struct | CompileTimeMapDiagnostics |
| Diagnostics describing how a CompileTimeMap was constructed. More... | |
| class | CompileTimeMap |
| Compile-time associative container backed by a perfect hash layout. More... | |
| class | DiagnosticRenderer |
| Renders diagnostic messages with source context and caret/tilde indicators, similar to clang/rustc output. More... | |
| class | ElementTraversalGenerator |
| Selectors may need to traverse the tree in different ways to match, and this is abstracted away using C++20 coroutines. More... | |
| class | Decompress |
| A utility class for decompressing data. More... | |
| struct | FileOffset |
| Error context for a failed parse, such as the error reason, line, and character offset. More... | |
| struct | SourceRange |
| Holds a selection range for a region in the source text, as a half-open interval [start, end). More... | |
| struct | Length |
| Parses a CSS <length-percentage> type as defined by https://www.w3.org/TR/css-values-3/#typedef-length-percentage. More... | |
| struct | MathConstants |
| Contains a set of math constants for the specified type (float or double). More... | |
| struct | MathConstants< float > |
| Math constants for float. More... | |
| struct | MathConstants< double > |
| Math constants for double. More... | |
| struct | QuadraticSolution |
| Holds the solution of a quadratic equation, as returned by SolveQuadratic. More... | |
| class | OptionalRef |
| A class that simulates an optional reference to a constant object of type T. More... | |
| struct | ParseDiagnostic |
| A diagnostic message from a parser, with severity, source range, and human-readable reason. More... | |
| class | ParseResult |
| A parser result, which may contain a result of type T, or an error, or both. More... | |
| class | ParseWarningSink |
| Collects parse warnings during parsing. More... | |
| struct | StrokeStyle |
| Parameters for converting a stroked path to a filled outline. More... | |
| class | Path |
| Immutable 2D vector path. More... | |
| class | PathBuilder |
| Mutable builder for constructing immutable Path objects. More... | |
| class | RcString |
| A reference counted string, that is copy-on-write and implements the small-string optimization. More... | |
| class | RcStringOrRef |
| An in-transit type that can hold either an RcString or std::string_view, to enable transferring the RcString reference or also accepting a non-owning std::string_view from API surfaces. More... | |
| struct | FontMetrics |
| A container for font information relevant for computing font-relative lengths, per https://www.w3.org/TR/css-values/#font-relative-lengths. More... | |
| struct | AbsoluteLengthMetrics |
| A container with ratios for converting absolute lengths, such as "cm" or "in", see https://www.w3.org/TR/css-values/#absolute-lengths. More... | |
| class | SmallVector |
| A vector with small-size optimization. More... | |
| struct | CaseInsensitiveCharTraits |
| Type traits for case-insensitive string comparison, usable with algorithms that accept an STL std::char_traits. More... | |
| class | StringUtils |
| A collection of string utils, such as case-insensitive comparison and StartsWith/EndsWith. More... | |
| struct | Transform2 |
| A 2D matrix representing an affine transformation. More... | |
| class | Utf8 |
| Utility class for working with UTF-8 encoded strings. More... | |
| struct | Vector2 |
| A 2D vector, (x, y). More... | |
Concepts | |
| concept | ElementLike |
| Concept for types that can be matched against a selector, such as a donner::svg::SVGElement. | |
| concept | StringLike |
| A concept for types that are string-like, i.e. | |
Typedefs | |
| using | Entity = entt::entity |
Entity type for the Registry, a std::uint32_t alias. | |
| using | Registry = entt::basic_registry<Entity, std::allocator<Entity>> |
| Registry type for the SVG ECS, which is the entry point for storing all data. | |
| using | EntityHandle = entt::basic_handle<Registry> |
| Convenience handle for a Entity with an attached Registry. | |
| using | Lengthd = Length<double> |
| Shorthand for Length<double>. | |
Typedefs | |
| using | Box2d = Box2<double> |
| Shorthand for Box2<double>. | |
| using | Transform2f = Transform2<float> |
Shorthand for Transform2<float>. | |
| using | Transform2d = Transform2<double> |
Shorthand for Transform2<double>. | |
| using | Vector2f = Vector2<float> |
Shorthand for Vector2<float>. | |
| using | Vector2d = Vector2<double> |
Shorthand for Vector2<double>. | |
| using | Vector2i = Vector2<int> |
Shorthand for Vector2<int>. | |
Enumerations | |
| enum class | CompileTimeMapStatus { kOk , kUsingFallbackHash , kDuplicateKey , kSeedSearchFailed , kConstexprHashUnsupported } |
| Indicates the result of building a CompileTimeMap. More... | |
| enum class | FillRule : uint8_t { NonZero , EvenOdd } |
| The parsed result of the 'fill-rule' property, see: https://www.w3.org/TR/SVG2/painting.html#FillRuleProperty. More... | |
| enum class | LengthUnit : uint8_t { None , Percent , Cm , Mm , Q , In , Pc , Pt , Px , Em , Ex , Ch , Rem , Vw , Vh , Vmin , Vmax } |
| The unit identifier for a length, corresponding to CSS unit identifiers. More... | |
| enum class | DiagnosticSeverity : uint8_t { Warning , Error } |
| Severity level for a parser diagnostic. More... | |
| enum class | LineCap : uint8_t { Butt , Round , Square } |
| Line cap style for stroke endpoints. More... | |
| enum class | LineJoin : uint8_t { Miter , Round , Bevel } |
| Line join style for stroke corners. More... | |
| enum class | StringComparison : uint8_t { Default , IgnoreCase } |
| String comparison options, e.g. case sensitivity. More... | |
Functions | |
| Vector2d | EvalQuadratic (const Vector2d &p0, const Vector2d &p1, const Vector2d &p2, double t) |
Evaluate a quadratic Bezier curve at parameter t using the standard basis expansion. | |
| Vector2d | EvalCubic (const Vector2d &p0, const Vector2d &p1, const Vector2d &p2, const Vector2d &p3, double t) |
Evaluate a cubic Bezier curve at parameter t using the standard basis expansion. | |
| std::pair< std::array< Vector2d, 3 >, std::array< Vector2d, 3 > > | SplitQuadratic (const Vector2d &p0, const Vector2d &p1, const Vector2d &p2, double t) |
Split a quadratic Bezier curve at parameter t using De Casteljau subdivision. | |
| std::pair< std::array< Vector2d, 4 >, std::array< Vector2d, 4 > > | SplitCubic (const Vector2d &p0, const Vector2d &p1, const Vector2d &p2, const Vector2d &p3, double t) |
Split a cubic Bezier curve at parameter t using De Casteljau subdivision. | |
| void | ApproximateCubicWithQuadratics (const Vector2d &p0, const Vector2d &p1, const Vector2d &p2, const Vector2d &p3, double tolerance, std::vector< Vector2d > &out) |
| Approximate a cubic Bezier curve as a sequence of quadratic Bezier curves within a given tolerance. | |
| SmallVector< double, 1 > | QuadraticYExtrema (const Vector2d &p0, const Vector2d &p1, const Vector2d &p2) |
| Find parameter values where the Y-derivative is zero for a quadratic Bezier curve. | |
| SmallVector< double, 2 > | CubicYExtrema (const Vector2d &p0, const Vector2d &p1, const Vector2d &p2, const Vector2d &p3) |
| Find parameter values where the Y-derivative is zero for a cubic Bezier curve. | |
| Box2d | QuadraticBounds (const Vector2d &p0, const Vector2d &p1, const Vector2d &p2) |
| Compute the tight axis-aligned bounding box of a quadratic Bezier curve. | |
| Box2d | CubicBounds (const Vector2d &p0, const Vector2d &p1, const Vector2d &p2, const Vector2d &p3) |
| Compute the tight axis-aligned bounding box of a cubic Bezier curve. | |
| constexpr uint64_t | mixHash (uint64_t baseHash, std::uint32_t seed) |
| Mix a base hash value with a seed to produce a new hash. Used to construct perfect-hash bucket seeds during CompileTimeMap construction. | |
| template<typename Key> | |
| constexpr bool | supportsConstexprHash () |
| Returns true when the provided key type can be hashed in a constexpr context by constexprHashValue. | |
| template<typename Key> | |
| constexpr uint64_t | constexprHashValue (const Key &key) |
Compute a constexpr-friendly hash of key for supported key types. | |
| template<typename Key, std::size_t N, typename KeyEqual> | |
| constexpr bool | hasDuplicateKeys (const std::array< Key, N > &keys, KeyEqual keyEqual) |
| Returns true when the provided keys contain duplicates. | |
| auto | operator<=> (Entity lhs, Entity rhs) |
| Compare two Entity values. | |
| template<ElementLike T> | |
| ElementTraversalGenerator< T > | singleElementGenerator (T element) |
| A generator that yields a single element, if it exists. | |
| template<ElementLike T> | |
| ElementTraversalGenerator< T > | parentsGenerator (T element) |
| A generator that yields all parents of an element, repeatedly following parentElement() until reaching the root. | |
| template<ElementLike T> | |
| ElementTraversalGenerator< T > | previousSiblingsGenerator (T element) |
| A generator that yields all siblings of an element, in reverse order. | |
| template<ElementLike T> | |
| ElementTraversalGenerator< T > | allChildrenRecursiveGenerator (T element) |
| A generator that yields all children of an element recursively with pre-order traversal. | |
| ParseResult< std::vector< uint8_t > > | DecodeBase64Data (std::string_view base64String) |
| Decode a base64-encoded string into a byte array. | |
| std::string | EncodeBase64Data (std::span< const uint8_t > data) |
| Encode a byte array into a base64-encoded string. | |
| std::vector< uint8_t > | UrlDecode (std::string_view urlEncodedString) |
| Decode a URL-encoded string into a byte array, translating XX sequences into the corresponding byte value. | |
| void | InstallFailureSignalHandler () |
| Install signal handlers for crash signals (SIGSEGV, SIGABRT, SIGFPE, SIGILL, SIGBUS, SIGTRAP). | |
| std::ostream & | operator<< (std::ostream &os, FillRule value) |
| Ostream output operator for FillRule enum, outputs the CSS value. | |
| std::ostream & | operator<< (std::ostream &os, LengthUnit unit) |
| OStream output operator, writes the CSS unit identifier to the stream, e.g. % or px. | |
| float | NarrowToFloat (double from) |
| Semantically represent a narrowing conversion, such as converting a double to a float, to make the conversion more visible. | |
| template<typename T> | |
| const T & | Min (const T &a, const T &b) |
| Returns minimum of the provided values. | |
| template<typename T, typename... Args> | |
| const T & | Min (const T &a, const T &b, Args &&... args) |
| Returns minimum of the provided values. | |
| template<typename T> | |
| const T & | Max (const T &a, const T &b) |
| Returns maximum of the provided values. | |
| template<typename T, typename... Args> | |
| const T & | Max (const T &a, const T &b, Args &&... args) |
| Returns maximum of the provided values. | |
| float | Abs (float a) |
| Returns the absolute value of the number. | |
| double | Abs (double a) |
| Returns the absolute value of the number. | |
| template<typename T, typename = std::enable_if<std::is_integral<T>::value && std::is_signed<T>::value>> | |
| T | Abs (T a) |
| Returns the absolute value of the number. | |
| template<typename T, typename = std::enable_if<std::is_floating_point<T>::value>> | |
| T | Round (T orig) |
| Round a floating point value to an integer. | |
| template<typename T> | |
| T | Lerp (T a, T b, const float t) |
| Returns linear interpolation of a and b with ratio t. | |
| template<typename T> | |
| const T | Clamp (T value, T low, T high) |
| Clamps a value between low and high. | |
| template<typename T> | |
| bool | NearEquals (T a, T b, T tolerance=std::numeric_limits< T >::epsilon()) |
| Returns if a equals b, taking possible rounding errors into account. | |
| template<typename T> | |
| bool | NearZero (T a, T tolerance=std::numeric_limits< T >::epsilon()) |
| Returns if a equals zero, taking rounding errors into account. | |
| template<typename T, typename = std::enable_if<std::is_integral<T>::value>> | |
| bool | InRange (T var, T start, T end) |
| Test if a variable is in a specific range, using an optimized technique that requires only one branch. | |
| template<typename T> | |
| QuadraticSolution< T > | SolveQuadratic (T a, T b, T c) |
| Solve a quadratic equation. | |
| std::ostream & | operator<< (std::ostream &os, DiagnosticSeverity severity) |
| Ostream output operator for DiagnosticSeverity. | |
| std::ostream & | operator<< (std::ostream &os, LineCap cap) |
| Ostream output operator for LineCap. | |
| std::ostream & | operator<< (std::ostream &os, LineJoin join) |
| Ostream output operator for LineJoin. | |
| RcString | toSVGTransformString (const Transform2d &transform) |
| Serialize a Transform2d to its canonical SVG transform attribute text, decomposing to the simplest form when possible: | |
Top-level Donner namespace, which is split into different sub-namespaces such as donner::svg and donner::css.
| struct donner::CompileTimeMapTables |
Perfect-hash metadata used to resolve keys into storage slots.
| struct donner::CompileTimeMapDiagnostics |
Diagnostics describing how a CompileTimeMap was constructed.
| struct donner::MathConstants |
Contains a set of math constants for the specified type (float or double).
| T |
| struct donner::QuadraticSolution |
Holds the solution of a quadratic equation, as returned by SolveQuadratic.
| T |
| Class Members | ||
|---|---|---|
| bool | hasSolution = false | True if the equation has solutions. |
| array< T, 2 > | solution | Solutions to the equation, valid if hasSolution is true. |
| using donner::Entity = entt::entity |
| typedef entt::basic_handle< Registry > donner::EntityHandle = entt::basic_handle<Registry> |
Convenience handle for a Entity with an attached Registry.
Forward declaration of EntityHandle.
Allows calling functions typically on Registry without having to pass around two values.
| using donner::Registry = entt::basic_registry<Entity, std::allocator<Entity>> |
Registry type for the SVG ECS, which is the entry point for storing all data.
Forward declaration of Registry.
It is used to create new entities:
Attach or remove data classes to entities:
Store global objects (singleton-like):
|
strong |
Indicates the result of building a CompileTimeMap.
|
strong |
|
strong |
The parsed result of the 'fill-rule' property, see: https://www.w3.org/TR/SVG2/painting.html#FillRuleProperty.
|
strong |
The unit identifier for a length, corresponding to CSS unit identifiers.
See https://www.w3.org/TR/css-values-3/#lengths for definitions.
|
strong |
|
strong |
|
strong |
|
constexpr |
Compute a constexpr-friendly hash of key for supported key types.
Returns uint64_t to ensure consistent hashing on both 32-bit and 64-bit platforms.
| ParseResult< std::vector< uint8_t > > donner::DecodeBase64Data | ( | std::string_view | base64String | ) |
Decode a base64-encoded string into a byte array.
If the string is not valid base64, an error is returned.
| base64String | The base64-encoded string to decode. |
| std::string donner::EncodeBase64Data | ( | std::span< const uint8_t > | data | ) |
Encode a byte array into a base64-encoded string.
| data | The byte array to encode. |
|
inline |
Test if a variable is in a specific range, using an optimized technique that requires only one branch.
Some compilers do this automatically.
Example:
| void donner::InstallFailureSignalHandler | ( | ) |
Install signal handlers for crash signals (SIGSEGV, SIGABRT, SIGFPE, SIGILL, SIGBUS, SIGTRAP).
When a crash signal is received, the handler prints a stack trace to stderr and then re-raises the signal so the default handler can produce a core dump.
|
inline |
Returns linear interpolation of a and b with ratio t.
|
constexpr |
Mix a base hash value with a seed to produce a new hash. Used to construct perfect-hash bucket seeds during CompileTimeMap construction.
Uses uint64_t explicitly to ensure correct behavior on 32-bit platforms (e.g., WASM) where std::size_t is 32 bits and the >> 33 shift would be undefined behavior.
|
inline |
Semantically represent a narrowing conversion, such as converting a double to a float, to make the conversion more visible.
For example: const float f = NarrowToFloat(1.0);
| ElementTraversalGenerator< T > donner::parentsGenerator | ( | T | element | ) |
A generator that yields all parents of an element, repeatedly following parentElement() until reaching the root.
| element | The element to start from, which is not yielded. |
| ElementTraversalGenerator< T > donner::previousSiblingsGenerator | ( | T | element | ) |
A generator that yields all siblings of an element, in reverse order.
This repeatedly follows previousSibling().
| element | The element to start from, which is not yielded. |
| ElementTraversalGenerator< T > donner::singleElementGenerator | ( | T | element | ) |
A generator that yields a single element, if it exists.
| element | The element to yield. If this is std::nullopt, the generator will yield nothing. |
| QuadraticSolution< T > donner::SolveQuadratic | ( | T | a, |
| T | b, | ||
| T | c ) |
Solve a quadratic equation.
\( a x^2 + b x + c = 0 \)
| a | First coefficient. |
| b | Second coefficient. |
| c | Third coefficient. |
|
inline |
Serialize a Transform2d to its canonical SVG transform attribute text, decomposing to the simplest form when possible:
Numbers are emitted via {} (integer-valued doubles) or {:g} (fractional) so the output is the shortest form that round-trips. Arguments are comma-separated with a space after the comma, matching the canonical CSS transform syntax.
Round-trips with donner::svg::parser::TransformParser::Parse for every shape above.
| transform | Transform to serialize. |
| std::vector< uint8_t > donner::UrlDecode | ( | std::string_view | urlEncodedString | ) |
Decode a URL-encoded string into a byte array, translating XX sequences into the corresponding byte value.
| urlEncodedString | The URL-encoded string to decode. |