Orcus
sax_token_parser_thread.hpp
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 */
7
8#ifndef INCLUDED_ORCUS_SAX_TOKEN_PARSER_THREAD_HPP
9#define INCLUDED_ORCUS_SAX_TOKEN_PARSER_THREAD_HPP
10
11#include "orcus/env.hpp"
12
13#include <memory>
14#include <vector>
15#include <ostream>
16
17namespace orcus {
18
19class tokens;
20class xmlns_context;
21class pstring;
22class string_pool;
23struct xml_token_element_t;
24
25namespace sax {
26
27enum class parse_token_t
28{
29 unknown,
30 start_element,
31 end_element,
32 characters
33};
34
35struct ORCUS_PSR_DLLPUBLIC parse_token
36{
37 parse_token_t type;
38
39 union
40 {
41 struct
42 {
43 const char* p;
44 size_t n;
45
46 } characters;
47
48 const xml_token_element_t* element;
49 };
50
52 parse_token(const pstring& _characters);
53 parse_token(parse_token_t _type, const xml_token_element_t* _element);
54
55 parse_token(const parse_token& other);
56
57 parse_token& operator= (parse_token) = delete;
58
59 bool operator== (const parse_token& other) const;
60 bool operator!= (const parse_token& other) const;
61};
62
63typedef std::vector<parse_token> parse_tokens_t;
64
65ORCUS_PSR_DLLPUBLIC std::ostream& operator<< (std::ostream& os, const parse_tokens_t& tokens);
66
67class ORCUS_PSR_DLLPUBLIC parser_thread
68{
69 struct impl;
70 std::unique_ptr<impl> mp_impl;
71
72public:
73 parser_thread(const char* p, size_t n, const orcus::tokens& tks, xmlns_context& ns_cxt, size_t min_token_size);
74 parser_thread(const char* p, size_t n, const orcus::tokens& tks, xmlns_context& ns_cxt, size_t min_token_size, size_t max_token_size);
76
77 void start();
78
87 bool next_tokens(parse_tokens_t& tokens);
88
89 void swap_string_pool(string_pool& pool);
90};
91
92}}
93
94#endif
95
96/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Definition: pstring.hpp:28
Definition: sax_token_parser_thread.hpp:68
bool next_tokens(parse_tokens_t &tokens)
Definition: string_pool.hpp:23
Definition: tokens.hpp:22
Definition: xml_namespace.hpp:83
Definition: sax_token_parser_thread.hpp:36
Definition: types.hpp:72