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
30namespace anch::json {
31
39 enum class EventType {
40
42 VNULL = 0,
43
46
49
52
55
58
61
64
67
70
71 };
72
80 class JSONItem {
81
82 // Attributes +
83 private:
86
88 std::any _value;
89 // Attributes -
90
91 // Constructors +
92 public:
96 JSONItem() = delete;
97
105 // Constructors -
106
107 // Destructor +
108 public:
112 virtual ~JSONItem() noexcept;
113 // Destructor -
114
115 // Accessors +
116 public:
123
129 const std::any& getValue() const;
130 // Accessors -
131
132 };
133
145 class Reader:
147 public anch::events::Observable<std::streamsize>,
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"
Definition reader.hpp:80
virtual ~JSONItem() noexcept
JSONItem(anch::json::EventType type, anch::json::ReaderContext &context)
const std::any & getValue() const
anch::json::EventType getType() const
Mapping error.
Definition mappingError.hpp:62
JSON mapper context.
Definition readerContext.hpp:42
virtual std::streamsize refillBuffer()
Reader(Reader &&reader)=delete
void parse() noexcept
Reader(std::istream &is, const anch::json::MappingOptions &mappingOptions)
Reader(const Reader &reader)=delete
Events management namespace.
Definition event.hpp:25
JSON namespace.
Definition constants.hpp:25
EventType
Definition reader.hpp:39
@ BEGIN_ARRAY
Definition reader.hpp:66
@ END_ARRAY
Definition reader.hpp:69
@ BEGIN_OBJECT
Definition reader.hpp:60
@ NUMBER
Definition reader.hpp:54
@ FIELD
Definition reader.hpp:51
@ STRING
Definition reader.hpp:57
@ VNULL
Definition reader.hpp:42
@ FALSE
Definition reader.hpp:48
@ END_OBJECT
Definition reader.hpp:63
@ TRUE
Definition reader.hpp:45
AnCH framework base namespace.
Definition app.hpp:28
JSON mapping options.
Definition mappingOptions.hpp:35