|
|
Donner 0.5.0
Embeddable browser-grade SVG2 engine
|
Cache for parsed SVG sub-documents referenced by <image> or <use> elements. More...
#include "donner/svg/components/resources/SubDocumentCache.h"
Public Types | |
| using | ParseCallback |
| Callback type for parsing SVG content into a document. | |
Public Member Functions | |
| SubDocumentCache ()=default | |
| Constructor. | |
| ~SubDocumentCache ()=default | |
| Destructor. | |
| SubDocumentCache (const SubDocumentCache &)=delete | |
| SubDocumentCache & | operator= (const SubDocumentCache &)=delete |
| SubDocumentCache (SubDocumentCache &&)=default | |
| SubDocumentCache & | operator= (SubDocumentCache &&)=default |
| std::optional< SVGDocumentHandle > | getOrParse (const RcString &resolvedUrl, const std::vector< uint8_t > &svgContent, const ParseCallback &parseCallback, ParseWarningSink &warningSink) |
| Get a previously cached sub-document, or parse and cache a new one from raw SVG bytes. | |
| std::optional< SVGDocumentHandle > | get (const RcString &resolvedUrl) const |
| Get a previously cached sub-document by URL. | |
| bool | isLoading (const RcString &resolvedUrl) const |
| Returns true if the given URL is currently being loaded (for recursion detection). | |
| size_t | size () const |
| Returns the number of cached sub-documents. | |
Cache for parsed SVG sub-documents referenced by <image> or <use> elements.
Sub-documents are parsed in ProcessingMode::SecureStatic mode, which prevents them from loading their own external resources (per SVG2 ยง2.7.1). This prevents infinite recursion when document A references document B which references document A.
This stores SVGDocumentHandle values, which are the same shared internal state used by SVGDocument's by-value facade.
Callback type for parsing SVG content into a document.
Called by getOrParse when the URL is not cached. Should return an SVGDocumentHandle on success, or std::nullopt on failure.
| std::optional< SVGDocumentHandle > donner::svg::components::SubDocumentCache::get | ( | const RcString & | resolvedUrl | ) | const |
Get a previously cached sub-document by URL.
| resolvedUrl | The resolved URL to look up. |
| std::optional< SVGDocumentHandle > donner::svg::components::SubDocumentCache::getOrParse | ( | const RcString & | resolvedUrl, |
| const std::vector< uint8_t > & | svgContent, | ||
| const ParseCallback & | parseCallback, | ||
| ParseWarningSink & | warningSink ) |
Get a previously cached sub-document, or parse and cache a new one from raw SVG bytes.
If the URL is already being loaded (circular reference), returns std::nullopt.
| resolvedUrl | The resolved URL used as the cache key. |
| svgContent | Raw SVG document bytes to parse if not already cached. |
| parseCallback | Callback to parse SVG content into a document. |
| warningSink | Sink to collect parse warnings. |