AnCH Framework 0.2
Another C++ Hack: C++23 utility libraries
Loading...
Searching...
No Matches
lexer.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 <string>
25#include <optional>
26#include <map>
27#include <set>
28#include <functional>
29
30#include "json/readerContext.hpp"
31#include "json/mappingError.hpp"
32
33namespace anch::json {
34
35 // Types' definitions +
37 using AddItem = std::function<bool(anch::json::ReaderContext&)>;
38
40 using PushItem = std::function<void(const std::string&, anch::json::ReaderContext&)>;
41
43 using jint = int64_t;
44
46 using juint = uint64_t;
47
49 using jfloat = long double;
50 // Types' definitions -
51
52 // Boolean lexer functions +
60 ANCH_JSON_EXPORT void lexTrue(anch::json::ReaderContext& context);
61
69 ANCH_JSON_EXPORT void lexFalse(anch::json::ReaderContext& context);
70
82 ANCH_JSON_EXPORT bool lexBoolean(bool& value, anch::json::ReaderContext& context);
83 // Boolean lexer functions -
84
85 // Integer lexer functions +
91 ANCH_JSON_EXPORT void parseDecimal(anch::json::ReaderContext& context);
92
104 ANCH_JSON_EXPORT bool lexInteger(anch::json::jint& value, anch::json::ReaderContext& context);
105
117 ANCH_JSON_EXPORT bool lexUInteger(anch::json::juint& value, anch::json::ReaderContext& context);
118 // Integer lexer functions -
119
120 // Number lexer functions +
127 ANCH_JSON_EXPORT void parseNumber(anch::json::ReaderContext& context);
128
140 ANCH_JSON_EXPORT bool lexNumber(double& value, anch::json::ReaderContext& context);
141 // Number lexer functions -
142
143 // String lexer functions +
154 ANCH_JSON_EXPORT void lexStringContent(std::string& value, anch::json::ReaderContext& context);
155
164 ANCH_JSON_EXPORT void lexStringContent(anch::json::ReaderContext& context);
165
179 ANCH_JSON_EXPORT bool lexString(std::string& value, anch::json::ReaderContext& context);
180
194 ANCH_JSON_EXPORT bool lexField(std::string& field, anch::json::ReaderContext& context);
195 // String lexer functions -
196
197 // Generic lexer functions +
207 ANCH_JSON_EXPORT char discardFail(anch::json::ReaderContext& context);
208
219 ANCH_JSON_EXPORT void lexEnd(anch::json::ReaderContext& context);
220
230 ANCH_JSON_EXPORT char lexDiscard(anch::json::ReaderContext& context);
231
239 ANCH_JSON_EXPORT void lexNull(anch::json::ReaderContext& context);
240
250 ANCH_JSON_EXPORT bool objectHasValueLex(anch::json::ReaderContext& context);
251
265 template<typename F>
266 void lexObject(F&& onField, anch::json::ReaderContext& context);
267 // Generic lexer functions -
268
269 // Container lexer functions +
282 template<typename F>
283 bool lexArray(F&& addFunc, anch::json::ReaderContext& context);
284
297 template<typename F>
298 bool lexMap(F&& pushFunc, anch::json::ReaderContext& context);
299 // Container lexer functions -
300
301 // Unknown lexer functions +
309 ANCH_JSON_EXPORT void lexUnknown(anch::json::ReaderContext& context);
310
318 ANCH_JSON_EXPORT void lexUnknownFail(anch::json::ReaderContext& context);
319 // Unknown lexer functions +
320
321}
322
323#include "json/impl/lexer.hpp"
JSON reader context.
Definition readerContext.hpp:44
JSON namespace.
Definition constants.hpp:27
bool objectHasValueLex(anch::json::ReaderContext &context)
bool lexNumber(double &value, anch::json::ReaderContext &context)
void lexFalse(anch::json::ReaderContext &context)
bool lexInteger(anch::json::jint &value, anch::json::ReaderContext &context)
void lexTrue(anch::json::ReaderContext &context)
void lexEnd(anch::json::ReaderContext &context)
char lexDiscard(anch::json::ReaderContext &context)
void lexStringContent(std::string &value, anch::json::ReaderContext &context)
std::function< void(const std::string &, anch::json::ReaderContext &)> PushItem
Definition lexer.hpp:40
long double jfloat
Definition lexer.hpp:49
void lexUnknownFail(anch::json::ReaderContext &context)
void lexUnknown(anch::json::ReaderContext &context)
std::function< bool(anch::json::ReaderContext &)> AddItem
Definition lexer.hpp:37
void lexObject(F &&onField, anch::json::ReaderContext &context)
void lexNull(anch::json::ReaderContext &context)
bool lexUInteger(anch::json::juint &value, anch::json::ReaderContext &context)
bool lexMap(F &&pushFunc, anch::json::ReaderContext &context)
int64_t jint
Definition lexer.hpp:43
char discardFail(anch::json::ReaderContext &context)
bool lexField(std::string &field, anch::json::ReaderContext &context)
void parseDecimal(anch::json::ReaderContext &context)
bool lexArray(F &&addFunc, anch::json::ReaderContext &context)
bool lexString(std::string &value, anch::json::ReaderContext &context)
void parseNumber(anch::json::ReaderContext &context)
bool lexBoolean(bool &value, anch::json::ReaderContext &context)
uint64_t juint
Definition lexer.hpp:46