|
|
Donner
C++20 SVG rendering library
|
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 | Box |
| 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 | ElementTraversalGenerator |
| Selectors may need to traverse the tree in different ways to match, and this is abstracted away using C++20 coroutines. More... | |
| class | FakeElement |
| A test fake for a type that satisfies the ElementLike concept. 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 | FileOffsetRange |
| Holds a selection range for a region in the source text. 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 | ParseError |
| Error context for a failed parse, such as the error reason, line, and character offset. More... | |
| class | ParseResult |
| A parser result, which may contain a result of type T, or an error, or both. 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... | |
| class | Runfiles |
| Helper class to access bazel runfiles in a test environment. More... | |
| struct | Transform |
| 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 | Boxd = Box<double> |
| Shorthand for Box<double>. | |
| 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 | Transformf = Transform<float> |
Shorthand for Transform<float>. | |
| using | Transformd = Transform<double> |
Shorthand for Transform<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 | 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 | StringComparison : uint8_t { Default , IgnoreCase } |
| String comparison options, e.g. case sensitivity. More... | |
Functions | |
| constexpr std::size_t | mixHash (std::size_t baseHash, std::uint32_t seed) |
| template<typename Key> | |
| constexpr bool | supportsConstexprHash () |
| template<typename Key> | |
| constexpr std::size_t | constexprHashValue (const Key &key) |
| 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. | |
| int | LLVMFuzzerTestOneInput (const uint8_t *data, size_t size) |
| Fuzzer entry point, see https://llvm.org/docs/LibFuzzer.html. | |
| 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. | |
| 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, const ParseError &error) |
| Ostream output operator for ParseError, outputs the error message. | |
| MATCHER_P (ToStringIs, expected, "") | |
| Matches the string representation of an object, by calling testing::PrintToString and comparing the results with the expected value. | |
| MATCHER_P2 (Vector2Eq, xMatcher, yMatcher, "") | |
| Matches a Vector. | |
| MATCHER_P2 (Vector2Near, xValue, yValue, "") | |
| Matches a Vector2 with DoubleNear(0.01). | |
| MATCHER_P (NormalizedEq, expectedVector, "") | |
| Matches if two vectors are equal when both are normalized, within an error of 0.01. | |
| MATCHER_P (TransformEq, other, "transform eq "+testing::PrintToString(other)) | |
| Matches a transform with near-equals comparison. | |
| MATCHER_P6 (TransformIs, d0, d1, d2, d3, d4, d5, "") | |
| Matches a transform per-element, with a near-equals comparison using a threshold of 0.0001. | |
| MATCHER (TransformIsIdentity, "") | |
| Matches if a transform is identity. | |
| MATCHER_P2 (BoxEq, topLeftMatcher, bottomRightMatcher, "") | |
| Matches a Box. | |
| MATCHER_P2 (LengthIs, valueMatcher, unitMatcher, "") | |
| Matches a Length. | |
| template<typename T> | |
| void | PrintTo (const ParseResult< T > &result, std::ostream *os) |
| Outputs a ParseResult to a stream for debugging purposes. | |
| MATCHER (NoParseError, "") | |
| Matches if the result does not contain a ParseError. | |
| MATCHER_P (ParseErrorIs, errorMessageMatcher, std::string("parse error is (")+testing::PrintToString(errorMessageMatcher)+")") | |
| Given a ParseResult, matches if it contains an error whose reason matches the given errorMessageMatcher (string or matcher). | |
| MATCHER_P2 (ParseErrorPos, lineMatcher, offsetMatcher, "") | |
| Given a ParseResult, matches if it contains an error at the given offset. | |
| MATCHER (ParseErrorEndOfString, "") | |
| Matches if a ParseResult contains an error at the end of the string. | |
| MATCHER_P (ParseResultIs, resultMatcher, "") | |
| Matches if a ParseResult contains a result that matches the given value, and that it does not contain an error. | |
| MATCHER_P2 (ParseResultAndError, resultMatcher, errorMessageMatcher, "") | |
| Matches if a ParseResult contains a result that matches the given value, and that it does not contain an error. | |
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::FileOffsetRange |
Holds a selection range for a region in the source text.
| Class Members | ||
|---|---|---|
| FileOffset | end | End offset. |
| FileOffset | start | Start offset. |
| 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 |
| using donner::EntityHandle = entt::basic_handle<Registry> |
| 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.
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 |
The unit identifier for a length, corresponding to CSS unit identifiers.
See https://www.w3.org/TR/css-values-3/#lengths for definitions.
|
strong |
| 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:
|
inline |
Returns linear interpolation of a and b with ratio t.
| donner::MATCHER_P | ( | NormalizedEq | , |
| expectedVector | , | ||
| "" | ) |
Matches if two vectors are equal when both are normalized, within an error of 0.01.
Example:
| expectedVector | Expected value vector, which will be normalized. |
| donner::MATCHER_P | ( | ParseErrorIs | , |
| errorMessageMatcher | , | ||
| std::string("parse error is (")+testing::PrintToString(errorMessageMatcher)+")" | ) |
Given a ParseResult, matches if it contains an error whose reason matches the given errorMessageMatcher (string or matcher).
Outputs a readable message on mismatch, e.g.: Expected: parse error is (starts with "Unexpected") Actual: parse error reason is "Failed to parse number: not finite"
Usage:
| errorMessageMatcher | Matcher to match the error message against, either a string or gmock matcher. |
| donner::MATCHER_P | ( | ParseResultIs | , |
| resultMatcher | , | ||
| "" | ) |
Matches if a ParseResult contains a result that matches the given value, and that it does not contain an error.
| resultMatcher | Value to match with. |
| donner::MATCHER_P | ( | ToStringIs | , |
| expected | , | ||
| "" | ) |
Matches the string representation of an object, by calling testing::PrintToString and comparing the results with the expected value.
Example:
| expected | Expected string representation. |
| donner::MATCHER_P | ( | TransformEq | , |
| other | , | ||
| "transform eq "+ | testing::PrintToStringother ) |
Matches a transform with near-equals comparison.
Example:
| other | Transform object to compare. |
| donner::MATCHER_P2 | ( | BoxEq | , |
| topLeftMatcher | , | ||
| bottomRightMatcher | , | ||
| "" | ) |
Matches a Box.
| topLeftMatcher | Matcher for topLeft field. |
| bottomRightMatcher | Matcher for bottomRight field. |
| donner::MATCHER_P2 | ( | LengthIs | , |
| valueMatcher | , | ||
| unitMatcher | , | ||
| "" | ) |
Matches a Length.
Example:
| valueMatcher | Matcher for value field. |
| unitMatcher | Matcher for unit field. |
| donner::MATCHER_P2 | ( | ParseErrorPos | , |
| lineMatcher | , | ||
| offsetMatcher | , | ||
| "" | ) |
Given a ParseResult, matches if it contains an error at the given offset.
| lineMatcher | Line number of the error. |
| offsetMatcher | Column offset of the error. |
| donner::MATCHER_P2 | ( | ParseResultAndError | , |
| resultMatcher | , | ||
| errorMessageMatcher | , | ||
| "" | ) |
Matches if a ParseResult contains a result that matches the given value, and that it does not contain an error.
| resultMatcher | Result to match with. |
| errorMessageMatcher | Parse error message to match with, either a string or a gmock matcher. |
| donner::MATCHER_P2 | ( | Vector2Eq | , |
| xMatcher | , | ||
| yMatcher | , | ||
| "" | ) |
Matches a Vector.
Example:
| xMatcher | X coordinate matcher. |
| yMatcher | Y coordinate matcher. |
| donner::MATCHER_P2 | ( | Vector2Near | , |
| xValue | , | ||
| yValue | , | ||
| "" | ) |
Matches a Vector2 with DoubleNear(0.01).
| xValue | X coordinate, note that this is not a matcher. |
| yValue | Y coordinate, note that this is not a matcher. |
| donner::MATCHER_P6 | ( | TransformIs | , |
| d0 | , | ||
| d1 | , | ||
| d2 | , | ||
| d3 | , | ||
| d4 | , | ||
| d5 | , | ||
| "" | ) |
Matches a transform per-element, with a near-equals comparison using a threshold of 0.0001.
Example:
| d0 | Corresponds to Transform::data[0] |
| d1 | Corresponds to Transform::data[1] |
| d2 | Corresponds to Transform::data[2] |
| d3 | Corresponds to Transform::data[3] |
| d4 | Corresponds to Transform::data[4] |
| d5 | Corresponds to Transform::data[5] |
|
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. |
| 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. |