AnCH Framework
0.1
Another C++ Hack Framework
Loading...
Searching...
No Matches
reader.hpp
1
/*
2
ANCH Framework: ANother C++ Hack is a C++ framework based on C++11 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 <http://www.gnu.org/licenses/>.
19
*/
20
#pragma once
21
22
#include <istream>
23
#include <string>
24
#include <any>
25
26
#include "json/readerContext.hpp"
27
#include "json/mappingError.hpp"
28
#include "events/observable.hpp"
29
30
namespace
anch::json
{
31
39
enum class
EventType
{
40
42
VNULL
= 0,
43
45
TRUE
,
46
48
FALSE
,
49
51
FIELD
,
52
54
NUMBER
,
55
57
STRING
,
58
60
BEGIN_OBJECT
,
61
63
END_OBJECT
,
64
66
BEGIN_ARRAY
,
67
69
END_ARRAY
70
71
};
72
80
class
JSONItem
{
81
82
// Attributes +
83
private
:
85
anch::json::EventType
_type;
86
88
std::any _value;
89
// Attributes -
90
91
// Constructors +
92
public
:
96
JSONItem
() =
delete
;
97
104
JSONItem
(
anch::json::EventType
type,
anch::json::ReaderContext
& context);
105
// Constructors -
106
107
// Destructor +
108
public
:
112
virtual
~JSONItem
() noexcept;
113
// Destructor -
114
115
// Accessors +
116
public:
122
anch
::
json
::
EventType
getType
() const;
123
129
const std::any&
getValue
() const;
130
// Accessors -
131
132
};
133
145
class
Reader
:
146
public
anch
::
events
::
Observable
<
anch
::
json
::
JSONItem
>,
147
public
anch
::
events
::
Observable
<std::streamsize>,
148
public
anch
::
events
::
Observable
<
anch
::
json
::
MappingError
>,
149
private
anch
::
json
::
ReaderContext
{
150
151
// Constructors +
152
public
:
156
Reader
() =
delete
;
157
163
Reader
(
const
Reader
& reader) =
delete
;
164
170
Reader
(
Reader
&& reader) =
delete
;
171
180
Reader
(std::istream& is,
const
anch::json::MappingOptions
& mappingOptions);
181
// Constructors -
182
183
// Destructor +
184
public
:
190
virtual
~Reader
();
191
// Destructor -
192
193
// Methods +
194
public
:
199
void
parse
() noexcept;
200
201
protected:
208
virtual std::streamsize
refillBuffer
();
209
210
private:
214
void
parseField();
215
219
void
parseObject();
220
224
void
parseValue();
225
229
void
parseArray();
230
// Methods -
231
232
};
233
234
}
235
236
#include "json/impl/reader.hpp"
anch::events::Observable< anch::json::JSONItem >::Observable
Observable()
anch::json::JSONItem
Definition
reader.hpp:80
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:62
anch::json::ReaderContext
JSON mapper context.
Definition
readerContext.hpp:42
anch::json::ReaderContext::ReaderContext
ReaderContext()=delete
anch::json::Reader::refillBuffer
virtual std::streamsize refillBuffer()
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(std::istream &is, const anch::json::MappingOptions &mappingOptions)
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:25
anch::json::EventType
EventType
Definition
reader.hpp:39
anch::json::EventType::BEGIN_ARRAY
@ BEGIN_ARRAY
Definition
reader.hpp:66
anch::json::EventType::END_ARRAY
@ END_ARRAY
Definition
reader.hpp:69
anch::json::EventType::BEGIN_OBJECT
@ BEGIN_OBJECT
Definition
reader.hpp:60
anch::json::EventType::NUMBER
@ NUMBER
Definition
reader.hpp:54
anch::json::EventType::FIELD
@ FIELD
Definition
reader.hpp:51
anch::json::EventType::STRING
@ STRING
Definition
reader.hpp:57
anch::json::EventType::VNULL
@ VNULL
Definition
reader.hpp:42
anch::json::EventType::FALSE
@ FALSE
Definition
reader.hpp:48
anch::json::EventType::END_OBJECT
@ END_OBJECT
Definition
reader.hpp:63
anch::json::EventType::TRUE
@ TRUE
Definition
reader.hpp:45
anch
AnCH framework base namespace.
Definition
app.hpp:28
anch::json::MappingOptions
JSON mapping options.
Definition
mappingOptions.hpp:35
anch-json
inc
json
reader.hpp
Generated by
1.13.2