AnCH Framework 0.1
Another C++ Hack Framework
Loading...
Searching...
No Matches
genericMapper.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 <string>
23#include <vector>
24#include <map>
25#include <optional>
26#include <list>
27#include <set>
28#include <map>
29#include <memory>
30
31#include "json/readerContext.hpp"
32#include "json/writerContext.hpp"
33
34#include "flux.hpp"
35
36namespace anch::json {
37
48 template<typename M, typename T>
50
51 // Constructors +
52 protected:
57
58 public:
64 GenericMapper(const GenericMapper<M,T>& other) = delete;
65
72 // Constructors -
73
74 // Destructor +
75 protected:
79 virtual ~GenericMapper();
80 // Destructor -
81
82 // Methods +
83 public:
84 // Serialization +
85 // Raw value +
92 void serialize(const T& value, anch::json::WriterContext& context) const;
93
100 void serialize(const std::optional<T>& value, anch::json::WriterContext& context) const;
101
108 void serialize(const T* const value, anch::json::WriterContext& context) const;
109
116 void serialize(const std::shared_ptr<T>& value, anch::json::WriterContext& context) const;
117
124 void serialize(const std::vector<T>& value, anch::json::WriterContext& context) const;
125
132 void serialize(const std::list<T>& value, anch::json::WriterContext& context) const;
133
140 void serialize(const std::set<T>& value, anch::json::WriterContext& context) const;
141
148 void serialize(const std::map<std::string,T>& value, anch::json::WriterContext& context) const;
149 // Raw value -
150
151 // With field +
161 bool serialize(const std::string& field,
162 const T& value,
163 anch::json::WriterContext& context) const;
164
174 bool serialize(const std::string& field,
175 const std::optional<T>& value,
176 anch::json::WriterContext& context) const;
177
187 bool serialize(const std::string& field,
188 const T* const value,
189 anch::json::WriterContext& context) const;
190
200 bool serialize(const std::string& field,
201 const std::shared_ptr<T>& value,
202 anch::json::WriterContext& context) const;
203
213 bool serialize(const std::string& field,
214 const std::vector<T>& value,
215 anch::json::WriterContext& context) const;
216
226 bool serialize(const std::string& field,
227 const std::list<T>& value,
228 anch::json::WriterContext& context) const;
229
239 bool serialize(const std::string& field,
240 const std::set<T>& value,
241 anch::json::WriterContext& context) const;
242
252 bool serialize(const std::string& field,
253 const std::map<std::string,T>& value,
254 anch::json::WriterContext& context) const;
255 // With field -
256 // Serialization -
257
258 // Deserialization +
267 bool deserialize(T& value, anch::json::ReaderContext& context) const;
268
277 bool deserialize(std::optional<T>& value, anch::json::ReaderContext& context) const;
278
287 bool deserialize(T* value, anch::json::ReaderContext& context) const;
288
297 bool deserialize(std::shared_ptr<T>& value, anch::json::ReaderContext& context) const;
298
305 bool deserialize(std::vector<T>& value, anch::json::ReaderContext& context) const;
306
313 bool deserialize(std::list<T>& value, anch::json::ReaderContext& context) const;
314
321 bool deserialize(std::set<T>& value, anch::json::ReaderContext& context) const;
322
330
337 bool deserialize(std::map<std::string,T>& value, anch::json::ReaderContext& context) const;
338 // Deserialization -
339 // Methods -
340
341 };
342
343}
344
345#include "json/impl/genericMapper.hpp"
Manage collection as stream.
Definition flux.hpp:50
GenericMapper(GenericMapper< M, T > &&other)=delete
void serialize(const std::list< T > &value, anch::json::WriterContext &context) const
GenericMapper(const GenericMapper< M, T > &other)=delete
bool deserialize(std::list< T > &value, anch::json::ReaderContext &context) const
bool deserialize(std::vector< T > &value, anch::json::ReaderContext &context) const
bool serialize(const std::string &field, const std::shared_ptr< T > &value, anch::json::WriterContext &context) const
bool deserialize(std::map< std::string, T > &value, anch::json::ReaderContext &context) const
void serialize(const T *const value, anch::json::WriterContext &context) const
bool deserialize(T &value, anch::json::ReaderContext &context) const
bool deserialize(T *value, anch::json::ReaderContext &context) const
void serialize(const std::shared_ptr< T > &value, anch::json::WriterContext &context) const
bool deserialize(std::shared_ptr< T > &value, anch::json::ReaderContext &context) const
bool serialize(const std::string &field, const std::vector< T > &value, anch::json::WriterContext &context) const
void serialize(const std::optional< T > &value, anch::json::WriterContext &context) const
bool serialize(const std::string &field, const std::set< T > &value, anch::json::WriterContext &context) const
void serialize(const std::vector< T > &value, anch::json::WriterContext &context) const
bool serialize(const std::string &field, const std::map< std::string, T > &value, anch::json::WriterContext &context) const
bool deserialize(std::optional< T > &value, anch::json::ReaderContext &context) const
bool deserialize(anch::Flux< T > &value, anch::json::ReaderContext &context) const
bool deserialize(std::set< T > &value, anch::json::ReaderContext &context) const
void serialize(const std::map< std::string, T > &value, anch::json::WriterContext &context) const
void serialize(const T &value, anch::json::WriterContext &context) const
bool serialize(const std::string &field, const T *const value, anch::json::WriterContext &context) const
bool serialize(const std::string &field, const std::list< T > &value, anch::json::WriterContext &context) const
bool serialize(const std::string &field, const std::optional< T > &value, anch::json::WriterContext &context) const
bool serialize(const std::string &field, const T &value, anch::json::WriterContext &context) const
void serialize(const std::set< T > &value, anch::json::WriterContext &context) const
JSON reader context.
Definition readerContext.hpp:42
JSON writer context.
Definition writerContext.hpp:41
JSON namespace.
Definition constants.hpp:25