xmlns_context
Defined in header: <orcus/xml_namespace.hpp>
-
class xmlns_context
XML namespace context. A new context should be used for each xml stream since the namespace keys themselves are not interned. Don’t hold an instance of this class any longer than the life cycle of the xml stream it is used in.
An empty key value i.e.
""is associated with a default namespace.Public Functions
-
xmlns_context()
-
xmlns_context(xmlns_context&&)
-
xmlns_context(const xmlns_context &r)
-
~xmlns_context()
-
xmlns_context &operator=(const xmlns_context &r)
-
xmlns_context &operator=(xmlns_context &&r)
-
xmlns_id_t push(std::string_view alias, std::string_view uri)
Push a new namespace alias-value pair to the stack.
- Parameters:
alias – namespace alias to push onto the stack. If the same alias is already present, this overwrites it until it gets popped off the stack.
uri – namespace name to associate with the alias.
- Returns:
normalized namespace identifier for the namespace name.
-
void pop(std::string_view alias)
Pop a namespace alias from the stack.
- Parameters:
alias – namespace alias to pop from the stack.
-
xmlns_id_t get(std::string_view alias) const
Get the current namespace identifier for a specified namespace alias.
- Parameters:
alias – namespace alias to get the current namespace identifier for.
- Returns:
current namespace identifier associated with the alias.
-
size_t get_index(xmlns_id_t ns_id) const
Get a unique index value associated with a specified identifier. An index value is guaranteed to be unique regardless of contexts.
- Parameters:
ns_id – a namespace identifier to obtain index for.
- Returns:
index value associated with the identifier.
-
std::string get_short_name(xmlns_id_t ns_id) const
Get a ‘short’ name associated with a specified identifier. A short name is a string value conveniently short enough for display purposes, but still guaranteed to be unique to the identifier it is associated with.
Note
The xmlns_repository class has method of the same name, and that method works identically to this method.
- Parameters:
ns_id – a namespace identifier to obtain short name for.
- Returns:
short name for the specified identifier.
-
std::string_view get_alias(xmlns_id_t ns_id) const
Get an alias currently associated with a given namespace identifier.
- Parameters:
ns_id – namespace identifier.
- Returns:
alias name currently associted with the given namespace identifier, or an empty string if the given namespace is currently not associated with any aliases.
-
std::vector<xmlns_id_t> get_all_namespaces() const
-
void dump(std::ostream &os) const
-
void dump_state(std::ostream &os) const
Dump the internal state for debugging in YAML format.
-
void swap(xmlns_context &other) noexcept
-
xmlns_context()