AnCH Framework 0.1
Another C++ Hack Framework
Loading...
Searching...
No Matches
writerContext.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 <ostream>
23#include <string>
24#include <functional>
25#include <stdint.h>
26#include <deque>
27
28#include "json/mappingOptions.hpp"
29
30namespace anch::json {
31
42
43 // Attributes +
44 public:
46 std::ostream& output;
47
48 private:
51
53 std::deque<bool> _firsts;
54
56 std::function<void()> _indent;
57 // Attributes -
58
59 // Constructors +
60 public:
64 WriterContext() = delete;
65
71 WriterContext(const WriterContext& context) = delete;
72
78 WriterContext(WriterContext&& context) = delete;
79
86 WriterContext(std::ostream& os, const anch::json::MappingOptions& options) noexcept;
87 // Constructors -
88
89 // Destructor +
90 public:
96 virtual ~WriterContext() noexcept;
97 // Destructor -
98
99 // Methods +
100 public:
108 bool writeNull(const std::string& field);
109
116 bool writeEmptyArray(const std::string& field);
117
124 bool writeEmptyObject(const std::string& field);
125
132 void writeField(const std::string& field);
133
138
142 void endArray();
143
148
152 void endObject();
153
157 void next();
158
159 private:
163 void indent();
164 // Methods -
165
166 };
167
168}
virtual ~WriterContext() noexcept
bool writeEmptyArray(const std::string &field)
bool writeNull(const std::string &field)
void writeField(const std::string &field)
WriterContext(std::ostream &os, const anch::json::MappingOptions &options) noexcept
WriterContext(const WriterContext &context)=delete
WriterContext(WriterContext &&context)=delete
bool writeEmptyObject(const std::string &field)
std::ostream & output
Definition writerContext.hpp:46
JSON namespace.
Definition constants.hpp:25
JSON mapping options.
Definition mappingOptions.hpp:36