|
|
Donner SVG 0.8.0-pre
SVG editor and embeddable C++20 engine.
|
Cache for parsed SVG sub-documents referenced by <image> or <use> elements. More...
#include "donner/svg/components/resources/SubDocumentCache.h"
Classes | |
| struct | Limits |
| struct | SecurityStats |
Public Types | |
| using | ParseCallback |
| Callback type for parsing SVG content into a document. | |
Public Member Functions | |
| SubDocumentCache ()=default | |
| Constructor. | |
| SubDocumentCache (Limits limits) | |
| ~SubDocumentCache ()=default | |
| Destructor. | |
| SubDocumentCache (const SubDocumentCache &)=delete | |
| SubDocumentCache & | operator= (const SubDocumentCache &)=delete |
| SubDocumentCache (SubDocumentCache &&)=default | |
| Move constructor. | |
| SubDocumentCache & | operator= (SubDocumentCache &&)=default |
| Move assignment operator. | |
| 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. | |
| void | rememberFailure (const RcString &resolvedUrl) |
| Record a failed fetch or parse so the URL is not retried. | |
| bool | isRejected (const RcString &resolvedUrl) const |
| Return true when the URL has a negative cache entry. | |
| void | clearFailures () |
| Clear failed-URL entries when the application replaces its resource loader. | |
| 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. | |
| void | setRootEntityCount (size_t count) |
| Include root-document entities in the aggregate retained-node envelope. | |
| void | setRootPayloadBytes (size_t count) |
| Include root-document parsed payload in the aggregate retained-payload envelope. | |
| const SecurityStats & | securityStats () const |
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.
| struct donner::svg::components::SubDocumentCache::Limits |
| struct donner::svg::components::SubDocumentCache::SecurityStats |
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. |