Cache for parsed SVG sub-documents referenced by <image> or <use> elements. More...
#include "donner/svg/components/resources/SubDocumentCache.h"
Classes | |
| struct | Limits |
| Local admission ceilings, also tightening the family when bound to a resource registry. Entity and parsed-payload admission snapshots include the original root. More... | |
| struct | SecurityStats |
| Observed cache size, parse work, and admission failures. More... | |
Public Types | |
| using | ParseCallback |
| Callback type for parsing SVG content into a document. | |
Public Member Functions | |
| SubDocumentCache ()=default | |
| Constructor. | |
| SubDocumentCache (Limits limits) | |
| Create a cache with caller-selected document and parse 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. | |
| bool | bindFamily (Registry ®istry) |
| Bind production resource admission to this registry and its requesting families. | |
| const SecurityStats & | securityStats () const |
| Current parse, cache, and rejection counters. | |
| std::vector< uint64_t > | admissionFingerprint (const SVGDocumentHandle &document) const |
SubDocumentAdmission::fingerprint of document, or empty when unbound. | |
| size_t | cachedDocumentAdmissions () const |
| Number of times an already cached document was re-admitted to the resource family, which walks its whole retained resource graph. | |
Friends | |
| class | SubDocumentAdmission |
Cache for parsed SVG sub-documents referenced by <image> or <use> elements.
Default sub-document parsing uses ProcessingMode::SecureStatic, which blocks external fetching. Nested data resources also pass shared family admission and bounded cycle checks.
This stores SVGDocumentHandle values, which are the same shared internal state used by SVGDocument's by-value facade.
| struct donner::svg::components::SubDocumentCache::Limits |
Local admission ceilings, also tightening the family when bound to a resource registry. Entity and parsed-payload admission snapshots include the original root.
| struct donner::svg::components::SubDocumentCache::SecurityStats |
Observed cache size, parse work, and admission failures.
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.
|
inlineexplicit |
Create a cache with caller-selected document and parse limits.
| limits | Admission limits for referenced sub-documents. |
| std::vector< uint64_t > donner::svg::components::SubDocumentCache::admissionFingerprint | ( | const SVGDocumentHandle & | document | ) | const |
SubDocumentAdmission::fingerprint of document, or empty when unbound.
| document | A document this cache admitted. |
| bool donner::svg::components::SubDocumentCache::bindFamily | ( | Registry & | registry | ) |
Bind production resource admission to this registry and its requesting families.
| registry | Registry owning this cache. |
| 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. |