Orcus
Toggle main menu visibility
Loading...
Searching...
No Matches
include
orcus
json_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_JSON_PARSER_THREAD_HPP
9
#define INCLUDED_ORCUS_JSON_PARSER_THREAD_HPP
10
11
#include "env.hpp"
12
#include "types.hpp"
13
14
#include <memory>
15
#include <vector>
16
#include <ostream>
17
#include <variant>
18
19
namespace
orcus {
20
21
class
string_pool
;
22
23
namespace
json {
24
25
struct
ORCUS_PSR_DLLPUBLIC
parser_stats
26
{
27
size_t
token_buffer_size_threshold;
28
};
29
30
enum class
parse_token_t
31
{
32
unknown,
33
begin_parse,
34
end_parse,
35
begin_array,
36
end_array,
37
begin_object,
38
object_key,
39
end_object,
40
boolean_true,
41
boolean_false,
42
null,
43
string,
44
number,
45
parse_error
,
46
};
47
48
struct
ORCUS_PSR_DLLPUBLIC parse_token
49
{
50
using
value_type = std::variant<std::string_view, parse_error_value_t, double>;
51
52
parse_token_t type;
53
value_type value;
54
55
parse_token();
56
parse_token(parse_token_t _type);
57
parse_token(parse_token_t _type, std::string_view s);
58
parse_token(std::string_view s, std::ptrdiff_t offset);
59
parse_token(
double
value);
60
61
parse_token(
const
parse_token& other);
62
63
parse_token& operator= (parse_token) =
delete
;
64
65
bool
operator== (
const
parse_token& other)
const
;
66
bool
operator!= (
const
parse_token& other)
const
;
67
};
68
69
typedef
std::vector<parse_token> parse_tokens_t;
70
71
ORCUS_PSR_DLLPUBLIC std::ostream& operator<< (std::ostream& os,
const
parse_tokens_t&
tokens
);
72
73
class
ORCUS_PSR_DLLPUBLIC parser_thread
74
{
75
struct
impl;
76
std::unique_ptr<impl> mp_impl;
77
78
public
:
79
parser_thread(
const
char
* p,
size_t
n,
size_t
min_token_size);
80
parser_thread(
const
char
* p,
size_t
n,
size_t
min_token_size,
size_t
max_token_size);
81
~parser_thread();
82
83
void
start();
84
93
bool
next_tokens
(parse_tokens_t&
tokens
);
94
95
parser_stats
get_stats()
const
;
96
97
void
swap_string_pool(
string_pool
& pool);
98
};
99
100
}}
101
102
#endif
103
104
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
orcus::json::parser_thread::next_tokens
bool next_tokens(parse_tokens_t &tokens)
orcus::parse_error
Definition
exception.hpp:94
orcus::string_pool
Definition
string_pool.hpp:26
orcus::tokens
Definition
tokens.hpp:30
orcus::json::parser_stats
Definition
json_parser_thread.hpp:26
Generated on
for Orcus by
1.17.0