XML Parser

SAX Parser

template <typename _Handler, typename _Config = sax_parser_default_config>
class

Template-based sax parser that doesn’t use function pointer for callbacks for better performance, especially on large XML streams.

Inherits from orcus::sax::parser_base

Public Types

typedef
typedef

Public Functions

orcus::sax_parser::sax_parser(const char *content, const size_t size, handler_type &handler)
orcus::sax_parser::~sax_parser()
void orcus::sax_parser::parse()
template <typename _Handler>
class

SAX based XML parser with proper namespace handling.

Public Types

typedef

Public Functions

orcus::sax_ns_parser::sax_ns_parser(const char *content, const size_t size, xmlns_context &ns_cxt, handler_type &handler)
orcus::sax_ns_parser::~sax_ns_parser()
void orcus::sax_ns_parser::parse()
template <typename _Handler>
class

XML parser that tokenizes element and attribute names while parsing.

Public Types

typedef

Public Functions

orcus::sax_token_parser::sax_token_parser(const char *content, const size_t size, const tokens &_tokens, xmlns_context &ns_cxt, handler_type &handler)
orcus::sax_token_parser::~sax_token_parser()
void orcus::sax_token_parser::parse()

Namespace

class

Central XML namespace repository that stores all namespaces that are used in the current session.

Public Functions

orcus::xmlns_repository::xmlns_repository()
orcus::xmlns_repository::~xmlns_repository()
void orcus::xmlns_repository::add_predefined_values(const xmlns_id_t *predefined_ns)

Add a set of predefined namespace values to the repository.

Parameters
  • predefined_ns: predefined set of namespace values. This is a null-terminated array of xmlns_id_t. This xmlns_repository instance will assume that the instances of these xmlns_id_t values will be available throughout its life cycle; caller needs to ensure that they won’t get deleted before the corresponding xmlns_repository instance is deleted.

xmlns_context orcus::xmlns_repository::create_context()
xmlns_id_t orcus::xmlns_repository::get_identifier(size_t index) const

Get XML namespace identifier from its numerical index.

Return
valid namespace identifier, or XMLNS_UNKNOWN_ID if not found.
Parameters
  • index: numeric index of namespace.

std::string orcus::xmlns_repository::get_short_name(xmlns_id_t ns_id) const
std::string orcus::xmlns_repository::get_short_name(size_t index) const
class

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.

Public Functions

orcus::xmlns_context::xmlns_context(const xmlns_context &r)
orcus::xmlns_context::~xmlns_context()
xmlns_id_t orcus::xmlns_context::push(const pstring &key, const pstring &uri)
void orcus::xmlns_context::pop(const pstring &key)
xmlns_id_t orcus::xmlns_context::get(const pstring &key) const
size_t orcus::xmlns_context::get_index(xmlns_id_t ns_id) const
std::string orcus::xmlns_context::get_short_name(xmlns_id_t ns_id) const
pstring orcus::xmlns_context::get_alias(xmlns_id_t ns_id) const

Get an alias currently associated with a given namespace identifier.

Return
alias name currently associted with the given namespace identifier, or an empty string if the given namespace is currently not associated with any aliases.
Parameters
  • ns_id: namespace identifier.

void orcus::xmlns_context::get_all_namespaces(std::vector<xmlns_id_t> &nslist) const
void orcus::xmlns_context::dump(std::ostream &os) const