Orcus
Public Member Functions | Friends | List of all members
orcus::xmlns_context Class Reference

#include <xml_namespace.hpp>

Public Member Functions

 xmlns_context (xmlns_context &&)
 
 xmlns_context (const xmlns_context &r)
 
xmlns_contextoperator= (const xmlns_context &r)
 
xmlns_contextoperator= (xmlns_context &&r)
 
xmlns_id_t push (std::string_view key, std::string_view uri)
 
void pop (std::string_view key)
 
xmlns_id_t get (std::string_view key) const
 
size_t get_index (xmlns_id_t ns_id) const
 
std::string get_short_name (xmlns_id_t ns_id) const
 
std::string_view get_alias (xmlns_id_t ns_id) const
 
std::vector< xmlns_id_t > get_all_namespaces () const
 
void dump (std::ostream &os) const
 
void dump_state (std::ostream &os) const
 
void swap (xmlns_context &other) noexcept
 

Friends

class xmlns_repository
 

Detailed Description

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 is associated with a default namespace.

Member Function Documentation

◆ dump_state()

void orcus::xmlns_context::dump_state ( std::ostream &  os) const

Dump the internal state for debugging in YAML format.

◆ get()

xmlns_id_t orcus::xmlns_context::get ( std::string_view  key) const

Get the currnet namespace identifier for a specified namespace alias.

Parameters
keynamespace alias to get the current namespace identifier for.
Returns
current namespace identifier associated with the alias.

◆ get_alias()

std::string_view orcus::xmlns_context::get_alias ( xmlns_id_t  ns_id) const

Get an alias currently associated with a given namespace identifier.

Parameters
ns_idnamespace 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.

◆ get_index()

size_t orcus::xmlns_context::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_ida namespace identifier to obtain index for.
Returns
index value associated with the identifier.

◆ get_short_name()

std::string orcus::xmlns_context::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 that the xmlns_repository class has method of the same name, and that method works identically to this method.

Parameters
ns_ida namespace identifier to obtain short name for.
Returns
short name for the specified identifier.