AnCH Framework 0.1
Another C++ Hack Framework
Loading...
Searching...
No Matches
readerContext.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 <optional>
25#include <utility>
26#include <functional>
27#include <stdint.h>
28
29#include "json/mappingOptions.hpp"
30
31namespace anch::json {
32
43
44 // Attributes +
45 public:
47 std::istream& input;
48
51
53 std::string pbuf;
54
56 uint32_t offset;
57
59 std::size_t bufferSize;
60
62 char* buffer;
63
65 std::size_t read;
66
67 private:
69 std::function<char()> _discardFunc;
70
72 std::function<void()> _unknownFunc;
73
75 std::function<void(std::streamsize read)> _checkSize;
76 // Attributes -
77
78 // Constructors +
79 public:
83 ReaderContext() = delete;
84
90 ReaderContext(const ReaderContext& context) = delete;
91
97 ReaderContext(ReaderContext&& context) = delete;
98
105 ReaderContext(std::istream& is, const anch::json::MappingOptions& options) noexcept;
106 // Constructors -
107
108 // Destructor +
109 public:
115 virtual ~ReaderContext() noexcept;
116 // Destructor -
117
118 // Methods +
119 public:
127 char discard();
128
135
146 bool next(char& current);
147
151 void back();
152
153 protected:
159 virtual std::streamsize refillBuffer();
160 // Methods -
161
162 };
163
164}
165
166#include "json/impl/readerContext.hpp"
std::size_t read
Definition readerContext.hpp:65
virtual std::streamsize refillBuffer()
anch::json::MappingOptions options
Definition readerContext.hpp:50
ReaderContext(std::istream &is, const anch::json::MappingOptions &options) noexcept
char * buffer
Definition readerContext.hpp:62
ReaderContext(const ReaderContext &context)=delete
std::string pbuf
Definition readerContext.hpp:53
std::size_t bufferSize
Definition readerContext.hpp:59
uint32_t offset
Definition readerContext.hpp:56
ReaderContext(ReaderContext &&context)=delete
bool next(char &current)
std::istream & input
Definition readerContext.hpp:47
virtual ~ReaderContext() noexcept
JSON namespace.
Definition constants.hpp:25
JSON mapping options.
Definition mappingOptions.hpp:35