Cache for parsed SVG sub-documents referenced by <image> or <use> elements.
More...
#include "donner/svg/components/resources/SubDocumentCache.h"
|
| 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...
|
|
| using | ParseCallback |
| | Callback type for parsing SVG content into a document.
|
|
|
| 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.
|
|
|
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.
◆ donner::svg::components::SubDocumentCache::Limits
| 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.
| Class Members |
|
size_t |
maximumAggregateEntities = 32 * 1024 |
Root plus cached sub-document entities. |
|
size_t |
maximumAggregatePayloadBytes |
Root plus cached parsed-payload bytes. |
|
size_t |
maximumDocuments = 64 |
Distinct cached documents. |
|
size_t |
maximumParseAttempts = 128 |
Parse attempts, including failures. |
◆ donner::svg::components::SubDocumentCache::SecurityStats
| struct donner::svg::components::SubDocumentCache::SecurityStats |
Observed cache size, parse work, and admission failures.
| Class Members |
|
size_t |
documents = 0 |
Successfully cached sub-documents. |
|
size_t |
entities = 0 |
Aggregate entities in cached sub-documents. |
|
size_t |
negativeCacheHits = 0 |
Negative-cache or reject-all short-circuits. |
|
size_t |
parseAttempts = 0 |
Parse attempts charged to this cache. |
|
size_t |
payloadBytes = 0 |
Aggregate retained parsed-payload bytes. |
|
bool |
rejected = false |
Whether an admission limit rejected a request. |
◆ ParseCallback
Initial value: std::function<std::optional<SVGDocumentHandle>(
Collects parse warnings during parsing.
Definition ParseWarningSink.h:29
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.
◆ SubDocumentCache()
| donner::svg::components::SubDocumentCache::SubDocumentCache |
( |
Limits | limits | ) |
|
|
inlineexplicit |
Create a cache with caller-selected document and parse limits.
- Parameters
-
| limits | Admission limits for referenced sub-documents. |
◆ bindFamily()
| bool donner::svg::components::SubDocumentCache::bindFamily |
( |
Registry & | registry | ) |
|
Bind production resource admission to this registry and its requesting families.
- Parameters
-
◆ get()
Get a previously cached sub-document by URL.
- Parameters
-
| resolvedUrl | The resolved URL to look up. |
- Returns
- Cached document-state handle, or std::nullopt if not found.
◆ getOrParse()
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.
- Parameters
-
| 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. |
- Returns
- Cached document-state handle, or std::nullopt on failure.
The documentation for this class was generated from the following file: