QxOrm 1.4.9
C++ Object Relational Mapping library
Loading...
Searching...
No Matches
QxSerializeQJson_boost_tuple.h
Go to the documentation of this file.
1/****************************************************************************
2**
3** https://www.qxorm.com/
4** Copyright (C) 2013 Lionel Marty (contact@qxorm.com)
5**
6** This file is part of the QxOrm library
7**
8** This software is provided 'as-is', without any express or implied
9** warranty. In no event will the authors be held liable for any
10** damages arising from the use of this software
11**
12** Commercial Usage
13** Licensees holding valid commercial QxOrm licenses may use this file in
14** accordance with the commercial license agreement provided with the
15** Software or, alternatively, in accordance with the terms contained in
16** a written agreement between you and Lionel Marty
17**
18** GNU General Public License Usage
19** Alternatively, this file may be used under the terms of the GNU
20** General Public License version 3.0 as published by the Free Software
21** Foundation and appearing in the file 'license.gpl3.txt' included in the
22** packaging of this file. Please review the following information to
23** ensure the GNU General Public License version 3.0 requirements will be
24** met : http://www.gnu.org/copyleft/gpl.html
25**
26** If you are unsure which license is appropriate for your use, or
27** if you have questions regarding the use of this file, please contact :
28** contact@qxorm.com
29**
30****************************************************************************/
31
32#ifndef _QX_NO_JSON
33#ifdef _QX_ENABLE_BOOST
34#ifndef _QX_SERIALIZE_QJSON_BOOST_TUPLE_H_
35#define _QX_SERIALIZE_QJSON_BOOST_TUPLE_H_
36
37#ifdef _MSC_VER
38#pragma once
39#endif
40
48#include <QtCore/qjsonvalue.h>
49#include <QtCore/qjsonobject.h>
50#include <QtCore/qjsonarray.h>
51
52#include <QxConvert/QxConvert.h>
54
55namespace qx {
56namespace cvt {
57namespace detail {
58
59template <typename T0, typename T1>
60struct QxConvert_ToJson< boost::tuple<T0, T1> >
61{
62 static inline QJsonValue toJson(const boost::tuple<T0, T1> & t, const QString & format)
63 {
64 QJsonArray arr; QJsonValue val;
65 val = qx::cvt::to_json(boost::get<0>(t), format); arr.append(val);
66 val = qx::cvt::to_json(boost::get<1>(t), format); arr.append(val);
67 return QJsonValue(arr);
68 }
69};
70
71template <typename T0, typename T1, typename T2>
72struct QxConvert_ToJson< boost::tuple<T0, T1, T2> >
73{
74 static inline QJsonValue toJson(const boost::tuple<T0, T1, T2> & t, const QString & format)
75 {
76 QJsonArray arr; QJsonValue val;
77 val = qx::cvt::to_json(boost::get<0>(t), format); arr.append(val);
78 val = qx::cvt::to_json(boost::get<1>(t), format); arr.append(val);
79 val = qx::cvt::to_json(boost::get<2>(t), format); arr.append(val);
80 return QJsonValue(arr);
81 }
82};
83
84template <typename T0, typename T1, typename T2, typename T3>
85struct QxConvert_ToJson< boost::tuple<T0, T1, T2, T3> >
86{
87 static inline QJsonValue toJson(const boost::tuple<T0, T1, T2, T3> & t, const QString & format)
88 {
89 QJsonArray arr; QJsonValue val;
90 val = qx::cvt::to_json(boost::get<0>(t), format); arr.append(val);
91 val = qx::cvt::to_json(boost::get<1>(t), format); arr.append(val);
92 val = qx::cvt::to_json(boost::get<2>(t), format); arr.append(val);
93 val = qx::cvt::to_json(boost::get<3>(t), format); arr.append(val);
94 return QJsonValue(arr);
95 }
96};
97
98template <typename T0, typename T1, typename T2, typename T3, typename T4>
99struct QxConvert_ToJson< boost::tuple<T0, T1, T2, T3, T4> >
100{
101 static inline QJsonValue toJson(const boost::tuple<T0, T1, T2, T3, T4> & t, const QString & format)
102 {
103 QJsonArray arr; QJsonValue val;
104 val = qx::cvt::to_json(boost::get<0>(t), format); arr.append(val);
105 val = qx::cvt::to_json(boost::get<1>(t), format); arr.append(val);
106 val = qx::cvt::to_json(boost::get<2>(t), format); arr.append(val);
107 val = qx::cvt::to_json(boost::get<3>(t), format); arr.append(val);
108 val = qx::cvt::to_json(boost::get<4>(t), format); arr.append(val);
109 return QJsonValue(arr);
110 }
111};
112
113template <typename T0, typename T1, typename T2, typename T3, typename T4, typename T5>
114struct QxConvert_ToJson< boost::tuple<T0, T1, T2, T3, T4, T5> >
115{
116 static inline QJsonValue toJson(const boost::tuple<T0, T1, T2, T3, T4, T5> & t, const QString & format)
117 {
118 QJsonArray arr; QJsonValue val;
119 val = qx::cvt::to_json(boost::get<0>(t), format); arr.append(val);
120 val = qx::cvt::to_json(boost::get<1>(t), format); arr.append(val);
121 val = qx::cvt::to_json(boost::get<2>(t), format); arr.append(val);
122 val = qx::cvt::to_json(boost::get<3>(t), format); arr.append(val);
123 val = qx::cvt::to_json(boost::get<4>(t), format); arr.append(val);
124 val = qx::cvt::to_json(boost::get<5>(t), format); arr.append(val);
125 return QJsonValue(arr);
126 }
127};
128
129template <typename T0, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
130struct QxConvert_ToJson< boost::tuple<T0, T1, T2, T3, T4, T5, T6> >
131{
132 static inline QJsonValue toJson(const boost::tuple<T0, T1, T2, T3, T4, T5, T6> & t, const QString & format)
133 {
134 QJsonArray arr; QJsonValue val;
135 val = qx::cvt::to_json(boost::get<0>(t), format); arr.append(val);
136 val = qx::cvt::to_json(boost::get<1>(t), format); arr.append(val);
137 val = qx::cvt::to_json(boost::get<2>(t), format); arr.append(val);
138 val = qx::cvt::to_json(boost::get<3>(t), format); arr.append(val);
139 val = qx::cvt::to_json(boost::get<4>(t), format); arr.append(val);
140 val = qx::cvt::to_json(boost::get<5>(t), format); arr.append(val);
141 val = qx::cvt::to_json(boost::get<6>(t), format); arr.append(val);
142 return QJsonValue(arr);
143 }
144};
145
146template <typename T0, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7>
147struct QxConvert_ToJson< boost::tuple<T0, T1, T2, T3, T4, T5, T6, T7> >
148{
149 static inline QJsonValue toJson(const boost::tuple<T0, T1, T2, T3, T4, T5, T6, T7> & t, const QString & format)
150 {
151 QJsonArray arr; QJsonValue val;
152 val = qx::cvt::to_json(boost::get<0>(t), format); arr.append(val);
153 val = qx::cvt::to_json(boost::get<1>(t), format); arr.append(val);
154 val = qx::cvt::to_json(boost::get<2>(t), format); arr.append(val);
155 val = qx::cvt::to_json(boost::get<3>(t), format); arr.append(val);
156 val = qx::cvt::to_json(boost::get<4>(t), format); arr.append(val);
157 val = qx::cvt::to_json(boost::get<5>(t), format); arr.append(val);
158 val = qx::cvt::to_json(boost::get<6>(t), format); arr.append(val);
159 val = qx::cvt::to_json(boost::get<7>(t), format); arr.append(val);
160 return QJsonValue(arr);
161 }
162};
163
164template <typename T0, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8>
165struct QxConvert_ToJson< boost::tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8> >
166{
167 static inline QJsonValue toJson(const boost::tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8> & t, const QString & format)
168 {
169 QJsonArray arr; QJsonValue val;
170 val = qx::cvt::to_json(boost::get<0>(t), format); arr.append(val);
171 val = qx::cvt::to_json(boost::get<1>(t), format); arr.append(val);
172 val = qx::cvt::to_json(boost::get<2>(t), format); arr.append(val);
173 val = qx::cvt::to_json(boost::get<3>(t), format); arr.append(val);
174 val = qx::cvt::to_json(boost::get<4>(t), format); arr.append(val);
175 val = qx::cvt::to_json(boost::get<5>(t), format); arr.append(val);
176 val = qx::cvt::to_json(boost::get<6>(t), format); arr.append(val);
177 val = qx::cvt::to_json(boost::get<7>(t), format); arr.append(val);
178 val = qx::cvt::to_json(boost::get<8>(t), format); arr.append(val);
179 return QJsonValue(arr);
180 }
181};
182
183template <typename T0, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9>
184struct QxConvert_ToJson< boost::tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> >
185{
186 static inline QJsonValue toJson(const boost::tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> & t, const QString & format)
187 {
188 QJsonArray arr; QJsonValue val;
189 val = qx::cvt::to_json(boost::get<0>(t), format); arr.append(val);
190 val = qx::cvt::to_json(boost::get<1>(t), format); arr.append(val);
191 val = qx::cvt::to_json(boost::get<2>(t), format); arr.append(val);
192 val = qx::cvt::to_json(boost::get<3>(t), format); arr.append(val);
193 val = qx::cvt::to_json(boost::get<4>(t), format); arr.append(val);
194 val = qx::cvt::to_json(boost::get<5>(t), format); arr.append(val);
195 val = qx::cvt::to_json(boost::get<6>(t), format); arr.append(val);
196 val = qx::cvt::to_json(boost::get<7>(t), format); arr.append(val);
197 val = qx::cvt::to_json(boost::get<8>(t), format); arr.append(val);
198 val = qx::cvt::to_json(boost::get<9>(t), format); arr.append(val);
199 return QJsonValue(arr);
200 }
201};
202
203template <typename T0, typename T1>
204struct QxConvert_FromJson< boost::tuple<T0, T1> >
205{
206 static inline qx_bool fromJson(const QJsonValue & j, boost::tuple<T0, T1> & t, const QString & format)
207 {
208 if (! j.isArray()) { return qx_bool(true); }
209 QJsonArray arr = j.toArray();
210 qx::cvt::from_json(arr.at(0), boost::get<0>(t), format);
211 qx::cvt::from_json(arr.at(1), boost::get<1>(t), format);
212 return qx_bool(true);
213 }
214};
215
216template <typename T0, typename T1, typename T2>
217struct QxConvert_FromJson< boost::tuple<T0, T1, T2> >
218{
219 static inline qx_bool fromJson(const QJsonValue & j, boost::tuple<T0, T1, T2> & t, const QString & format)
220 {
221 if (! j.isArray()) { return qx_bool(true); }
222 QJsonArray arr = j.toArray();
223 qx::cvt::from_json(arr.at(0), boost::get<0>(t), format);
224 qx::cvt::from_json(arr.at(1), boost::get<1>(t), format);
225 qx::cvt::from_json(arr.at(2), boost::get<2>(t), format);
226 return qx_bool(true);
227 }
228};
229
230template <typename T0, typename T1, typename T2, typename T3>
231struct QxConvert_FromJson< boost::tuple<T0, T1, T2, T3> >
232{
233 static inline qx_bool fromJson(const QJsonValue & j, boost::tuple<T0, T1, T2, T3> & t, const QString & format)
234 {
235 if (! j.isArray()) { return qx_bool(true); }
236 QJsonArray arr = j.toArray();
237 qx::cvt::from_json(arr.at(0), boost::get<0>(t), format);
238 qx::cvt::from_json(arr.at(1), boost::get<1>(t), format);
239 qx::cvt::from_json(arr.at(2), boost::get<2>(t), format);
240 qx::cvt::from_json(arr.at(3), boost::get<3>(t), format);
241 return qx_bool(true);
242 }
243};
244
245template <typename T0, typename T1, typename T2, typename T3, typename T4>
246struct QxConvert_FromJson< boost::tuple<T0, T1, T2, T3, T4> >
247{
248 static inline qx_bool fromJson(const QJsonValue & j, boost::tuple<T0, T1, T2, T3, T4> & t, const QString & format)
249 {
250 if (! j.isArray()) { return qx_bool(true); }
251 QJsonArray arr = j.toArray();
252 qx::cvt::from_json(arr.at(0), boost::get<0>(t), format);
253 qx::cvt::from_json(arr.at(1), boost::get<1>(t), format);
254 qx::cvt::from_json(arr.at(2), boost::get<2>(t), format);
255 qx::cvt::from_json(arr.at(3), boost::get<3>(t), format);
256 qx::cvt::from_json(arr.at(4), boost::get<4>(t), format);
257 return qx_bool(true);
258 }
259};
260
261template <typename T0, typename T1, typename T2, typename T3, typename T4, typename T5>
262struct QxConvert_FromJson< boost::tuple<T0, T1, T2, T3, T4, T5> >
263{
264 static inline qx_bool fromJson(const QJsonValue & j, boost::tuple<T0, T1, T2, T3, T4, T5> & t, const QString & format)
265 {
266 if (! j.isArray()) { return qx_bool(true); }
267 QJsonArray arr = j.toArray();
268 qx::cvt::from_json(arr.at(0), boost::get<0>(t), format);
269 qx::cvt::from_json(arr.at(1), boost::get<1>(t), format);
270 qx::cvt::from_json(arr.at(2), boost::get<2>(t), format);
271 qx::cvt::from_json(arr.at(3), boost::get<3>(t), format);
272 qx::cvt::from_json(arr.at(4), boost::get<4>(t), format);
273 qx::cvt::from_json(arr.at(5), boost::get<5>(t), format);
274 return qx_bool(true);
275 }
276};
277
278template <typename T0, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
279struct QxConvert_FromJson< boost::tuple<T0, T1, T2, T3, T4, T5, T6> >
280{
281 static inline qx_bool fromJson(const QJsonValue & j, boost::tuple<T0, T1, T2, T3, T4, T5, T6> & t, const QString & format)
282 {
283 if (! j.isArray()) { return qx_bool(true); }
284 QJsonArray arr = j.toArray();
285 qx::cvt::from_json(arr.at(0), boost::get<0>(t), format);
286 qx::cvt::from_json(arr.at(1), boost::get<1>(t), format);
287 qx::cvt::from_json(arr.at(2), boost::get<2>(t), format);
288 qx::cvt::from_json(arr.at(3), boost::get<3>(t), format);
289 qx::cvt::from_json(arr.at(4), boost::get<4>(t), format);
290 qx::cvt::from_json(arr.at(5), boost::get<5>(t), format);
291 qx::cvt::from_json(arr.at(6), boost::get<6>(t), format);
292 return qx_bool(true);
293 }
294};
295
296template <typename T0, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7>
297struct QxConvert_FromJson< boost::tuple<T0, T1, T2, T3, T4, T5, T6, T7> >
298{
299 static inline qx_bool fromJson(const QJsonValue & j, boost::tuple<T0, T1, T2, T3, T4, T5, T6, T7> & t, const QString & format)
300 {
301 if (! j.isArray()) { return qx_bool(true); }
302 QJsonArray arr = j.toArray();
303 qx::cvt::from_json(arr.at(0), boost::get<0>(t), format);
304 qx::cvt::from_json(arr.at(1), boost::get<1>(t), format);
305 qx::cvt::from_json(arr.at(2), boost::get<2>(t), format);
306 qx::cvt::from_json(arr.at(3), boost::get<3>(t), format);
307 qx::cvt::from_json(arr.at(4), boost::get<4>(t), format);
308 qx::cvt::from_json(arr.at(5), boost::get<5>(t), format);
309 qx::cvt::from_json(arr.at(6), boost::get<6>(t), format);
310 qx::cvt::from_json(arr.at(7), boost::get<7>(t), format);
311 return qx_bool(true);
312 }
313};
314
315template <typename T0, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8>
316struct QxConvert_FromJson< boost::tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8> >
317{
318 static inline qx_bool fromJson(const QJsonValue & j, boost::tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8> & t, const QString & format)
319 {
320 if (! j.isArray()) { return qx_bool(true); }
321 QJsonArray arr = j.toArray();
322 qx::cvt::from_json(arr.at(0), boost::get<0>(t), format);
323 qx::cvt::from_json(arr.at(1), boost::get<1>(t), format);
324 qx::cvt::from_json(arr.at(2), boost::get<2>(t), format);
325 qx::cvt::from_json(arr.at(3), boost::get<3>(t), format);
326 qx::cvt::from_json(arr.at(4), boost::get<4>(t), format);
327 qx::cvt::from_json(arr.at(5), boost::get<5>(t), format);
328 qx::cvt::from_json(arr.at(6), boost::get<6>(t), format);
329 qx::cvt::from_json(arr.at(7), boost::get<7>(t), format);
330 qx::cvt::from_json(arr.at(8), boost::get<8>(t), format);
331 return qx_bool(true);
332 }
333};
334
335template <typename T0, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9>
336struct QxConvert_FromJson< boost::tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> >
337{
338 static inline qx_bool fromJson(const QJsonValue & j, boost::tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> & t, const QString & format)
339 {
340 if (! j.isArray()) { return qx_bool(true); }
341 QJsonArray arr = j.toArray();
342 qx::cvt::from_json(arr.at(0), boost::get<0>(t), format);
343 qx::cvt::from_json(arr.at(1), boost::get<1>(t), format);
344 qx::cvt::from_json(arr.at(2), boost::get<2>(t), format);
345 qx::cvt::from_json(arr.at(3), boost::get<3>(t), format);
346 qx::cvt::from_json(arr.at(4), boost::get<4>(t), format);
347 qx::cvt::from_json(arr.at(5), boost::get<5>(t), format);
348 qx::cvt::from_json(arr.at(6), boost::get<6>(t), format);
349 qx::cvt::from_json(arr.at(7), boost::get<7>(t), format);
350 qx::cvt::from_json(arr.at(8), boost::get<8>(t), format);
351 qx::cvt::from_json(arr.at(9), boost::get<9>(t), format);
352 return qx_bool(true);
353 }
354};
355
356} // namespace detail
357} // namespace cvt
358} // namespace qx
359
360#endif // _QX_SERIALIZE_QJSON_BOOST_TUPLE_H_
361#endif // _QX_ENABLE_BOOST
362#endif // _QX_NO_JSON
qx::QxBool qx_bool
Definition QxBool.h:150
qx::cvt : namespace to provide global functions to convert any kind of objects to/from QString and QV...
qx_bool : boolean type with code and description message when an error occured
Definition QxBool.h:71
qx_bool from_json(const QJsonValue &j, T &t, const QString &format=QString())
Definition QxConvert.h:84
QJsonValue to_json(const T &t, const QString &format=QString())
Definition QxConvert.h:83
Root namespace for all QxOrm library features.
static qx_bool fromJson(const QJsonValue &j, boost::tuple< T0, T1, T2, T3, T4 > &t, const QString &format)
static qx_bool fromJson(const QJsonValue &j, boost::tuple< T0, T1, T2, T3 > &t, const QString &format)
static qx_bool fromJson(const QJsonValue &j, boost::tuple< T0, T1, T2 > &t, const QString &format)
static qx_bool fromJson(const QJsonValue &j, boost::tuple< T0, T1, T2, T3, T4, T5, T6, T7, T8 > &t, const QString &format)
static qx_bool fromJson(const QJsonValue &j, boost::tuple< T0, T1, T2, T3, T4, T5, T6 > &t, const QString &format)
static qx_bool fromJson(const QJsonValue &j, boost::tuple< T0, T1, T2, T3, T4, T5, T6, T7, T8, T9 > &t, const QString &format)
static qx_bool fromJson(const QJsonValue &j, boost::tuple< T0, T1, T2, T3, T4, T5, T6, T7 > &t, const QString &format)
static qx_bool fromJson(const QJsonValue &j, boost::tuple< T0, T1, T2, T3, T4, T5 > &t, const QString &format)
static qx_bool fromJson(const QJsonValue &j, boost::tuple< T0, T1 > &t, const QString &format)
static QJsonValue toJson(const boost::tuple< T0, T1, T2, T3, T4 > &t, const QString &format)
static QJsonValue toJson(const boost::tuple< T0, T1, T2, T3 > &t, const QString &format)
static QJsonValue toJson(const boost::tuple< T0, T1, T2 > &t, const QString &format)
static QJsonValue toJson(const boost::tuple< T0, T1, T2, T3, T4, T5 > &t, const QString &format)
static QJsonValue toJson(const boost::tuple< T0, T1, T2, T3, T4, T5, T6, T7, T8, T9 > &t, const QString &format)
static QJsonValue toJson(const boost::tuple< T0, T1, T2, T3, T4, T5, T6, T7 > &t, const QString &format)
static QJsonValue toJson(const boost::tuple< T0, T1, T2, T3, T4, T5, T6, T7, T8 > &t, const QString &format)
static QJsonValue toJson(const boost::tuple< T0, T1, T2, T3, T4, T5, T6 > &t, const QString &format)
static QJsonValue toJson(const boost::tuple< T0, T1 > &t, const QString &format)