# Class parser

- Defined in File parser.hpp

## Nested Relationships

### Nested Types

- Struct parser::attr

## Class Documentation

class parser

  A SAX parser.

  zeem::parser is a SAX parser. After construction, you should assign call back handlers for the SAX events and then call parse().

  Public Types

  using attr_list_type = std::vector<attr>

  Public Functions

  explicit parser(std::istream &is)

    constructor taking a std::istream in is

  virtual ~parser()

    destructor

  void parse(bool validate, bool validate_ns)

    Start the actual parsing, optionally validating content and namespaces.

  Public Members

  std::function<void(encoding_type encoding, bool standalone, version_type version)> xml_decl_handler

    The callbacks can be set by assinging a callback to each of the following callback function variables.

  std::function<void(std::string name, std::string uri, const attr_list_type &atts)> start_element_handler
  std::function<void(std::string name, std::string uri)> end_element_handler
  std::function<void(std::string data)> character_data_handler
  std::function<void(std::string target, std::string data)> processing_instruction_handler
  std::function<void(std::string data)> comment_handler
  std::function<void()> start_cdata_section_handler
  std::function<void()> end_cdata_section_handler
  std::function<void(std::string prefix, std::string uri)> start_namespace_decl_handler
  std::function<void(std::string prefix)> end_namespace_decl_handler
  std::function<void(std::string root, std::string publicId, std::string uri)> doctype_decl_handler
  std::function<void(std::string name, std::string systemId, std::string publicId)> notation_decl_handler
  std::function<std::unique_ptr<std::istream>(std::string_view base, std::string_view pubid, std::string_view uri)> external_entity_ref_handler
  std::function<void(std::string msg)> report_invalidation_handler
  struct attr

    Struct containing information about a parsed attribute.

    Public Members

    std::string m_ns

      The namespace for this attribute.

    std::string m_name

      The name of the attribute.

    std::string m_value

      The value of the attribute.

    bool m_id = {}

      Flag indicating the attribute is defined as type ID in its ATTLIST decl.