Manages XML namespace state for a document.
More...
#include "donner/base/xml/components/XMLNamespaceContext.h"
|
| | XMLNamespaceContext (Registry ®istry, std::size_t maximumCachedScopeBindings=kMaximumCachedScopeBindings) |
| | Constructor, this should only be called once to construct on the given Registry, with registry.ctx().emplace<XMLNamespaceContext>(registry).
|
| void | addNamespaceOverride (Entity entity, const XMLQualifiedName &name, const RcString &uri) |
| | Add a namespace override for the given entity.
|
| void | removeNamespaceOverride (Entity entity, const XMLQualifiedName &name) |
| | Removes a namespace override for the given entity.
|
| std::optional< RcString > | getNamespaceUri (Registry ®istry, Entity entity, const RcString &prefix) const |
| | Get the URI for the given namespace prefix.
|
|
std::uint64_t | scopeResolutionCountForTesting () const |
| | Number of entities whose scope has been computed from their ancestors, which only happens when the entity has no cached scope. Lets a test tell a cache hit from a recomputation.
|
|
std::size_t | cachedScopeBindingsForTesting () const |
| | Number of unique prefix bindings retained by cached scope maps.
|
|
bool | scopeCacheRejectedForTesting () const |
| | True after namespace-scope cache admission exceeded its aggregate bound.
|
|
|
static constexpr std::size_t | kMaximumCachedScopeBindings = 64 * 1024 |
| | Maximum aggregate prefix bindings retained across cached namespace-scope maps.
|
Manages XML namespace state for a document.
Access via the Registry::ctx API:
XMLNamespaceContext(Registry ®istry, std::size_t maximumCachedScopeBindings=kMaximumCachedScopeBindings)
Constructor, this should only be called once to construct on the given Registry, with registry....
Definition XMLNamespaceContext.h:50
◆ XMLNamespaceContext()
Constructor, this should only be called once to construct on the given Registry, with registry.ctx().emplace<XMLNamespaceContext>(registry).
To use this class, access it via the Registry::ctx API.
- Parameters
-
| registry | Underlying registry for the document. |
◆ addNamespaceOverride()
Add a namespace override for the given entity.
If the attribute has changed this may be called again with the same name but different URI.
- Parameters
-
| entity | Entity to add the namespace override for. |
| name | Namespace attribute to override. |
| uri | Namespace URI to use for the prefix. |
◆ getNamespaceUri()
| std::optional< RcString > donner::xml::components::XMLNamespaceContext::getNamespaceUri |
( |
Registry & | registry, |
|
|
Entity | entity, |
|
|
const RcString & | prefix ) const |
|
inline |
Get the URI for the given namespace prefix.
Resolved scopes are cached, so the first lookup below an element pays for the ancestor walk and later ones are a map lookup. Like the rest of the document's read paths that populate state on demand, this must not run concurrently with another access to the same document.
- Parameters
-
| registry | Registry to use for the lookup. |
| entity | Entity to get the namespace URI for. |
| prefix | Namespace prefix to get the URI for. |
- Returns
- The URI for the given namespace prefix, or an empty string if the prefix is not found.
◆ InvalidateScopesForTreeChange()
| void donner::xml::components::XMLNamespaceContext::InvalidateScopesForTreeChange |
( |
Registry & | registry, |
|
|
Entity | entity ) |
|
inlinestatic |
Drop cached namespace scopes for a subtree that was just attached or detached.
An element's in-scope namespaces come from its ancestors, so re-parenting a node can change which declarations apply to it and to everything below it, and nothing else. Registries without an XMLNamespaceContext are ignored.
- Parameters
-
| registry | Registry whose tree changed. |
| entity | Root of the subtree that moved. |
◆ removeNamespaceOverride()
| void donner::xml::components::XMLNamespaceContext::removeNamespaceOverride |
( |
Entity | entity, |
|
|
const XMLQualifiedName & | name ) |
|
inline |
Removes a namespace override for the given entity.
- Parameters
-
| entity | Entity to remove the namespace override for. |
| name | Namespace attribute to remove. |
The documentation for this class was generated from the following file: