AnCH Framework
0.2
Another C++ Hack: C++23 utility libraries
Loading...
Searching...
No Matches
reader.hpp
1
/*
2
ANCH Framework: ANother C++ Hack is a C++ framework based on C++23 standard
3
Copyright (C) 2020 Vincent Lachenal
4
5
This file is part of ANCH Framework.
6
7
ANCH Framework is free software: you can redistribute it and/or modify
8
it under the terms of the GNU Lesser General Public License as published by
9
the Free Software Foundation, either version 3 of the License, or
10
(at your option) any later version.
11
12
ANCH Framework is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
GNU Lesser General Public License for more details.
16
17
You should have received a copy of the GNU Lesser General Public License
18
along with ANCH Framework. If not, see <https://www.gnu.org/licenses/>.
19
*/
20
#pragma once
21
22
#include "anch-json-export.hpp"
23
24
#include <istream>
25
#include <string>
26
#include <any>
27
28
#include "json/readerContext.hpp"
29
#include "json/mappingError.hpp"
30
#include "events/observable.hpp"
31
32
namespace
anch::json
{
33
41
enum class
EventType
{
42
44
VNULL
= 0,
45
47
TRUE
,
48
50
FALSE
,
51
53
FIELD
,
54
56
NUMBER
,
57
59
STRING
,
60
62
BEGIN_OBJECT
,
63
65
END_OBJECT
,
66
68
BEGIN_ARRAY
,
69
71
END_ARRAY
72
73
};
74
82
class
ANCH_JSON_EXPORT
JSONItem
{
83
84
// Attributes +
85
private
:
87
anch::json::EventType
_type;
88
90
std::any _value;
91
// Attributes -
92
93
// Constructors +
94
public
:
98
JSONItem
() =
delete
;
99
106
JSONItem
(
anch::json::EventType
type,
anch::json::ReaderContext
& context);
107
// Constructors -
108
109
// Destructor +
110
public
:
114
virtual
~JSONItem
() noexcept;
115
// Destructor -
116
117
// Accessors +
118
public:
124
anch
::
json
::
EventType
getType
() const;
125
131
const std::any&
getValue
() const;
132
// Accessors -
133
134
};
135
147
class ANCH_JSON_EXPORT
Reader
:
148
public
anch
::
events
::
Observable
<
anch
::
json
::
JSONItem
>,
149
public
anch
::
events
::
Observable
<std::streamsize>,
150
public
anch
::
events
::
Observable
<
anch
::
json
::
MappingError
>,
151
private
anch
::
json
::
ReaderContext
{
152
153
// Constructors +
154
public
:
158
Reader
() =
delete
;
159
165
Reader
(
const
Reader
& reader) =
delete
;
166
172
Reader
(
Reader
&& reader) =
delete
;
173
182
Reader
(std::istream& is,
const
anch::json::MappingOptions
&
options
);
183
// Constructors -
184
185
// Destructor +
186
public
:
192
virtual
~Reader
();
193
// Destructor -
194
195
// Methods +
196
public
:
201
void
parse
() noexcept;
202
208
anch
::
events
::
Observable
<
JSONItem
>&
itemObs
();
209
215
anch
::
events
::
Observable
<std::streamsize>&
sizeObs
();
216
222
anch
::
events
::
Observable
<
anch
::
json
::
MappingError
>&
errorObs
();
223
224
protected:
231
virtual std::streamsize
refillBuffer
();
232
233
private:
237
void
parseField();
238
242
void
parseObject();
243
247
void
parseValue();
248
252
void
parseArray();
253
// Methods -
254
255
};
256
257
}
258
259
#include "json/impl/reader.hpp"
anch::events::Observable< anch::json::JSONItem >::Observable
Observable()
anch::json::JSONItem
Definition
reader.hpp:82
anch::json::JSONItem::~JSONItem
virtual ~JSONItem() noexcept
anch::json::JSONItem::JSONItem
JSONItem(anch::json::EventType type, anch::json::ReaderContext &context)
anch::json::JSONItem::getValue
const std::any & getValue() const
anch::json::JSONItem::JSONItem
JSONItem()=delete
anch::json::JSONItem::getType
anch::json::EventType getType() const
anch::json::MappingError
Mapping error.
Definition
mappingError.hpp:84
anch::json::ReaderContext
JSON reader context.
Definition
readerContext.hpp:44
anch::json::ReaderContext::options
anch::json::MappingOptions options
Definition
readerContext.hpp:52
anch::json::ReaderContext::ReaderContext
ReaderContext()=delete
anch::json::Reader::Reader
Reader(std::istream &is, const anch::json::MappingOptions &options)
anch::json::Reader::refillBuffer
virtual std::streamsize refillBuffer()
anch::json::Reader::errorObs
anch::events::Observable< anch::json::MappingError > & errorObs()
anch::json::Reader::itemObs
anch::events::Observable< JSONItem > & itemObs()
anch::json::Reader::sizeObs
anch::events::Observable< std::streamsize > & sizeObs()
anch::json::Reader::Reader
Reader(Reader &&reader)=delete
anch::json::Reader::parse
void parse() noexcept
anch::json::Reader::~Reader
virtual ~Reader()
anch::json::Reader::Reader
Reader()=delete
anch::json::Reader::Reader
Reader(const Reader &reader)=delete
anch::events
Events management namespace.
Definition
event.hpp:25
anch::json
JSON namespace.
Definition
constants.hpp:27
anch::json::EventType
EventType
Definition
reader.hpp:41
anch::json::EventType::BEGIN_ARRAY
@ BEGIN_ARRAY
Definition
reader.hpp:68
anch::json::EventType::END_ARRAY
@ END_ARRAY
Definition
reader.hpp:71
anch::json::EventType::BEGIN_OBJECT
@ BEGIN_OBJECT
Definition
reader.hpp:62
anch::json::EventType::NUMBER
@ NUMBER
Definition
reader.hpp:56
anch::json::EventType::FIELD
@ FIELD
Definition
reader.hpp:53
anch::json::EventType::STRING
@ STRING
Definition
reader.hpp:59
anch::json::EventType::VNULL
@ VNULL
Definition
reader.hpp:44
anch::json::EventType::FALSE
@ FALSE
Definition
reader.hpp:50
anch::json::EventType::END_OBJECT
@ END_OBJECT
Definition
reader.hpp:65
anch::json::EventType::TRUE
@ TRUE
Definition
reader.hpp:47
anch
AnCH framework base namespace.
Definition
app.hpp:30
anch::json::MappingOptions
JSON mapping options.
Definition
mappingOptions.hpp:38
anch-json
inc
json
reader.hpp
Generated by
1.18.0