Orcus
Toggle main menu visibility
Loading...
Searching...
No Matches
include
orcus
yaml_parser_base.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_YAML_PARSER_BASE_HPP
9
#define INCLUDED_ORCUS_YAML_PARSER_BASE_HPP
10
11
#include "orcus/parser_base.hpp"
12
13
#include <memory>
14
#include <cassert>
15
16
namespace
orcus {
namespace
yaml {
17
18
namespace
detail {
19
20
enum class
scope_t
21
{
22
unset,
23
sequence,
24
map,
25
multi_line_string
26
};
27
28
enum class
keyword_t
29
{
30
unknown,
31
boolean_true,
32
boolean_false,
33
null
34
};
35
36
enum class
parse_token_t
37
{
38
unknown,
39
40
// handler tokens (tokens associated with handler events)
41
42
begin_parse,
43
end_parse,
44
begin_document,
45
end_document,
46
begin_sequence,
47
end_sequence,
48
begin_map,
49
end_map,
50
begin_map_key,
51
end_map_key,
52
string,
53
number,
54
boolean_true,
55
boolean_false,
56
null,
57
58
// non-handler tokens
59
60
begin_sequence_element
61
};
62
63
}
64
65
class
ORCUS_PSR_DLLPUBLIC parser_base :
public
::orcus::parser_base
66
{
67
struct
impl;
68
std::unique_ptr<impl> mp_impl;
69
70
protected
:
71
72
// The entire line is empty.
73
static
const
size_t
parse_indent_blank_line;
74
75
// End of stream has reached while parsing in the indent part of a line.
76
static
const
size_t
parse_indent_end_of_stream;
77
78
static
const
size_t
scope_empty;
79
80
struct
key_value
81
{
82
std::string_view key;
83
std::string_view value;
84
};
85
86
parser_base() =
delete
;
87
parser_base(
const
parser_base&) =
delete
;
88
parser_base& operator=(
const
parser_base&) =
delete
;
89
90
parser_base(std::string_view content);
91
~parser_base();
92
93
void
push_parse_token(detail::parse_token_t t);
94
95
detail::parse_token_t get_last_parse_token()
const
;
96
105
size_t
offset_last_char_of_line
()
const
;
106
112
size_t
parse_indent
();
113
118
std::string_view
parse_to_end_of_line
();
119
124
void
skip_comment
();
125
126
void
reset_on_new_line();
127
128
size_t
get_scope()
const
;
129
130
void
push_scope(
size_t
scope_width);
131
132
void
clear_scopes();
133
134
detail::scope_t get_scope_type()
const
;
135
136
void
set_scope_type(detail::scope_t type);
137
143
size_t
pop_scope
();
144
145
void
push_line_back(
const
char
* p,
size_t
n);
146
147
std::string_view pop_line_front();
148
149
bool
has_line_buffer()
const
;
150
151
size_t
get_line_buffer_count()
const
;
152
153
std::string_view merge_line_buffer();
154
161
const
char
*
get_doc_hash
()
const
;
162
170
void
set_doc_hash
(
const
char
* hash);
171
172
detail::keyword_t parse_keyword(
const
char
* p,
size_t
len);
173
174
key_value
parse_key_value(
const
char
* p,
size_t
len);
175
176
std::string_view parse_single_quoted_string_value(
const
char
*& p,
size_t
max_length);
177
178
std::string_view parse_double_quoted_string_value(
const
char
*& p,
size_t
max_length);
179
180
void
skip_blanks(
const
char
*& p,
size_t
len);
181
182
void
start_literal_block();
183
184
bool
in_literal_block()
const
;
185
186
void
handle_line_in_literal(
size_t
indent);
187
188
void
handle_line_in_multi_line_string();
189
};
190
191
}}
192
193
#endif
194
195
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
orcus::parser_base
Definition
parser_base.hpp:23
orcus::yaml::parser_base::pop_scope
size_t pop_scope()
orcus::yaml::parser_base::parse_indent
size_t parse_indent()
orcus::yaml::parser_base::parse_to_end_of_line
std::string_view parse_to_end_of_line()
orcus::yaml::parser_base::get_doc_hash
const char * get_doc_hash() const
orcus::yaml::parser_base::set_doc_hash
void set_doc_hash(const char *hash)
orcus::yaml::parser_base::skip_comment
void skip_comment()
orcus::yaml::parser_base::offset_last_char_of_line
size_t offset_last_char_of_line() const
orcus::yaml::parser_base::key_value
Definition
yaml_parser_base.hpp:81
Generated on
for Orcus by
1.17.0