AnCH Framework 0.1
Another C++ Hack Framework
 
Loading...
Searching...
No Matches
json.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 <iomanip>
25
26#include "json/mapper.hpp"
27
28
29namespace anch::json {
30
39 template<typename T>
41
51 template<typename T>
52 void serialize(const T& value, std::ostream& out, const anch::json::MappingOptions& options = anch::json::DEFAULT_MAPPING_OPTIONS);
53
63 template<typename T>
64 void serialize(const std::vector<T>& value, std::ostream& out, const anch::json::MappingOptions& options = anch::json::DEFAULT_MAPPING_OPTIONS);
65
75 template<typename T>
76 void serialize(const std::list<T>& value, std::ostream& out, const anch::json::MappingOptions& options = anch::json::DEFAULT_MAPPING_OPTIONS);
77
87 template<typename T>
88 void serialize(const std::set<T>& value, std::ostream& out, const anch::json::MappingOptions& options = anch::json::DEFAULT_MAPPING_OPTIONS);
89
100 template<typename T>
101 std::string serialize(const T& value, const anch::json::MappingOptions& options = anch::json::DEFAULT_MAPPING_OPTIONS);
102
113 template<typename T>
114 std::string serialize(const std::vector<T>& value, const anch::json::MappingOptions& options = anch::json::DEFAULT_MAPPING_OPTIONS);
115
126 template<typename T>
127 std::string serialize(const std::list<T>& value, const anch::json::MappingOptions& options = anch::json::DEFAULT_MAPPING_OPTIONS);
128
139 template<typename T>
140 std::string serialize(const std::set<T>& value, const anch::json::MappingOptions& options = anch::json::DEFAULT_MAPPING_OPTIONS);
141
151 template<typename T>
152 void deserialize(T& value, std::istream& input, const anch::json::MappingOptions& options = anch::json::DEFAULT_MAPPING_OPTIONS);
153
164 template<typename T>
166
176 template<typename T>
177 void deserialize(std::vector<T>& values, std::istream& input, const anch::json::MappingOptions& options = anch::json::DEFAULT_MAPPING_OPTIONS);
178
188 template<typename T>
189 void deserialize(std::list<T>& values, std::istream& input, const anch::json::MappingOptions& options = anch::json::DEFAULT_MAPPING_OPTIONS);
190
200 template<typename T>
201 void deserialize(std::set<T>& values, std::istream& input, const anch::json::MappingOptions& options = anch::json::DEFAULT_MAPPING_OPTIONS);
202
213
214 // Attributes +
215 private:
218 // Attributes -
219
220 // Constructors +
221 public:
225 JSONMapper() = delete;
226
233 // Constructors -
234
235 // Destructor +
236 public:
240 virtual ~JSONMapper();
241 // Destructor +
242
243 // Methods +
244 public:
253 template<typename T>
254 void serialize(const T& value, std::ostream& out);
255
264 template<typename T>
265 void serialize(const std::vector<T>& value, std::ostream& out);
266
275 template<typename T>
276 void serialize(const std::list<T>& value, std::ostream& out);
277
286 template<typename T>
287 void serialize(const std::set<T>& value, std::ostream& out);
288
297 template<typename T>
298 void serialize(const std::map<std::string,T>& value, std::ostream& out);
299
309 template<typename T>
310 std::string serialize(const T& value);
311
321 template<typename T>
322 std::string serialize(const std::vector<T>& value);
323
333 template<typename T>
334 std::string serialize(const std::list<T>& value);
335
345 template<typename T>
346 std::string serialize(const std::set<T>& value);
347
357 template<typename T>
358 std::string serialize(const std::map<std::string,T>& value);
359
370 template<typename T>
371 void deserialize(T& value, std::istream& input);
372
382 template<typename T>
383 T deserialize(std::istream& input);
384
395 template<typename T>
396 void deserialize(std::vector<T>& values, std::istream& input);
397
408 template<typename T>
409 void deserialize(std::list<T>& values, std::istream& input);
410
421 template<typename T>
422 void deserialize(std::set<T>& values, std::istream& input);
423
432 template<typename T>
433 void deserialize(std::map<std::string,T>& values, std::istream& input);
434 // Methods -
435
436 };
437
438} // anch::json
439
440#include "json/impl/json.hpp"
void serialize(const T &value, std::ostream &out)
std::string serialize(const std::set< T > &value)
void deserialize(T &value, std::istream &input)
std::string serialize(const std::map< std::string, T > &value)
JSONMapper(const anch::json::MappingOptions &options)
void serialize(const std::vector< T > &value, std::ostream &out)
void deserialize(std::list< T > &values, std::istream &input)
void serialize(const std::map< std::string, T > &value, std::ostream &out)
std::string serialize(const T &value)
T deserialize(std::istream &input)
void deserialize(std::vector< T > &values, std::istream &input)
std::string serialize(const std::vector< T > &value)
void deserialize(std::map< std::string, T > &values, std::istream &input)
void serialize(const std::list< T > &value, std::ostream &out)
void serialize(const std::set< T > &value, std::ostream &out)
std::string serialize(const std::list< T > &value)
void deserialize(std::set< T > &values, std::istream &input)
JSON complex object mapper.
Definition mapper.hpp:72
JSON namespace.
Definition constants.hpp:25
void deserialize(T &value, std::istream &input, const anch::json::MappingOptions &options=anch::json::DEFAULT_MAPPING_OPTIONS)
void serialize(const T &value, std::ostream &out, const anch::json::MappingOptions &options=anch::json::DEFAULT_MAPPING_OPTIONS)
MappingOptions DEFAULT_MAPPING_OPTIONS
void registerObject(anch::json::ObjectMapper< T > &mapper)
JSON mapping options.
Definition mappingOptions.hpp:35