QxOrm
1.5.0
C++ Object Relational Mapping library
|
00001 /**************************************************************************** 00002 ** 00003 ** https://www.qxorm.com/ 00004 ** Copyright (C) 2013 Lionel Marty (contact@qxorm.com) 00005 ** 00006 ** This file is part of the QxOrm library 00007 ** 00008 ** This software is provided 'as-is', without any express or implied 00009 ** warranty. In no event will the authors be held liable for any 00010 ** damages arising from the use of this software 00011 ** 00012 ** Commercial Usage 00013 ** Licensees holding valid commercial QxOrm licenses may use this file in 00014 ** accordance with the commercial license agreement provided with the 00015 ** Software or, alternatively, in accordance with the terms contained in 00016 ** a written agreement between you and Lionel Marty 00017 ** 00018 ** GNU General Public License Usage 00019 ** Alternatively, this file may be used under the terms of the GNU 00020 ** General Public License version 3.0 as published by the Free Software 00021 ** Foundation and appearing in the file 'license.gpl3.txt' included in the 00022 ** packaging of this file. Please review the following information to 00023 ** ensure the GNU General Public License version 3.0 requirements will be 00024 ** met : http://www.gnu.org/copyleft/gpl.html 00025 ** 00026 ** If you are unsure which license is appropriate for your use, or 00027 ** if you have questions regarding the use of this file, please contact : 00028 ** contact@qxorm.com 00029 ** 00030 ****************************************************************************/ 00031 00032 #ifndef _QX_NO_JSON 00033 #ifndef _QX_SERIALIZE_QJSON_STD_TUPLE_H_ 00034 #define _QX_SERIALIZE_QJSON_STD_TUPLE_H_ 00035 00036 #ifdef _MSC_VER 00037 #pragma once 00038 #endif 00039 00047 #include <QtCore/qjsonvalue.h> 00048 #include <QtCore/qjsonobject.h> 00049 #include <QtCore/qjsonarray.h> 00050 00051 #include <QxConvert/QxConvert.h> 00052 #include <QxConvert/QxConvert_Impl.h> 00053 00054 namespace qx { 00055 namespace cvt { 00056 namespace detail { 00057 00058 template <typename T0, typename T1> 00059 struct QxConvert_ToJson< std::tuple<T0, T1> > 00060 { 00061 static inline QJsonValue toJson(const std::tuple<T0, T1> & t, const QString & format) 00062 { 00063 QJsonArray arr; QJsonValue val; 00064 val = qx::cvt::to_json(std::get<0>(t), format); arr.append(val); 00065 val = qx::cvt::to_json(std::get<1>(t), format); arr.append(val); 00066 return QJsonValue(arr); 00067 } 00068 }; 00069 00070 template <typename T0, typename T1, typename T2> 00071 struct QxConvert_ToJson< std::tuple<T0, T1, T2> > 00072 { 00073 static inline QJsonValue toJson(const std::tuple<T0, T1, T2> & t, const QString & format) 00074 { 00075 QJsonArray arr; QJsonValue val; 00076 val = qx::cvt::to_json(std::get<0>(t), format); arr.append(val); 00077 val = qx::cvt::to_json(std::get<1>(t), format); arr.append(val); 00078 val = qx::cvt::to_json(std::get<2>(t), format); arr.append(val); 00079 return QJsonValue(arr); 00080 } 00081 }; 00082 00083 template <typename T0, typename T1, typename T2, typename T3> 00084 struct QxConvert_ToJson< std::tuple<T0, T1, T2, T3> > 00085 { 00086 static inline QJsonValue toJson(const std::tuple<T0, T1, T2, T3> & t, const QString & format) 00087 { 00088 QJsonArray arr; QJsonValue val; 00089 val = qx::cvt::to_json(std::get<0>(t), format); arr.append(val); 00090 val = qx::cvt::to_json(std::get<1>(t), format); arr.append(val); 00091 val = qx::cvt::to_json(std::get<2>(t), format); arr.append(val); 00092 val = qx::cvt::to_json(std::get<3>(t), format); arr.append(val); 00093 return QJsonValue(arr); 00094 } 00095 }; 00096 00097 template <typename T0, typename T1, typename T2, typename T3, typename T4> 00098 struct QxConvert_ToJson< std::tuple<T0, T1, T2, T3, T4> > 00099 { 00100 static inline QJsonValue toJson(const std::tuple<T0, T1, T2, T3, T4> & t, const QString & format) 00101 { 00102 QJsonArray arr; QJsonValue val; 00103 val = qx::cvt::to_json(std::get<0>(t), format); arr.append(val); 00104 val = qx::cvt::to_json(std::get<1>(t), format); arr.append(val); 00105 val = qx::cvt::to_json(std::get<2>(t), format); arr.append(val); 00106 val = qx::cvt::to_json(std::get<3>(t), format); arr.append(val); 00107 val = qx::cvt::to_json(std::get<4>(t), format); arr.append(val); 00108 return QJsonValue(arr); 00109 } 00110 }; 00111 00112 template <typename T0, typename T1, typename T2, typename T3, typename T4, typename T5> 00113 struct QxConvert_ToJson< std::tuple<T0, T1, T2, T3, T4, T5> > 00114 { 00115 static inline QJsonValue toJson(const std::tuple<T0, T1, T2, T3, T4, T5> & t, const QString & format) 00116 { 00117 QJsonArray arr; QJsonValue val; 00118 val = qx::cvt::to_json(std::get<0>(t), format); arr.append(val); 00119 val = qx::cvt::to_json(std::get<1>(t), format); arr.append(val); 00120 val = qx::cvt::to_json(std::get<2>(t), format); arr.append(val); 00121 val = qx::cvt::to_json(std::get<3>(t), format); arr.append(val); 00122 val = qx::cvt::to_json(std::get<4>(t), format); arr.append(val); 00123 val = qx::cvt::to_json(std::get<5>(t), format); arr.append(val); 00124 return QJsonValue(arr); 00125 } 00126 }; 00127 00128 template <typename T0, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6> 00129 struct QxConvert_ToJson< std::tuple<T0, T1, T2, T3, T4, T5, T6> > 00130 { 00131 static inline QJsonValue toJson(const std::tuple<T0, T1, T2, T3, T4, T5, T6> & t, const QString & format) 00132 { 00133 QJsonArray arr; QJsonValue val; 00134 val = qx::cvt::to_json(std::get<0>(t), format); arr.append(val); 00135 val = qx::cvt::to_json(std::get<1>(t), format); arr.append(val); 00136 val = qx::cvt::to_json(std::get<2>(t), format); arr.append(val); 00137 val = qx::cvt::to_json(std::get<3>(t), format); arr.append(val); 00138 val = qx::cvt::to_json(std::get<4>(t), format); arr.append(val); 00139 val = qx::cvt::to_json(std::get<5>(t), format); arr.append(val); 00140 val = qx::cvt::to_json(std::get<6>(t), format); arr.append(val); 00141 return QJsonValue(arr); 00142 } 00143 }; 00144 00145 template <typename T0, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7> 00146 struct QxConvert_ToJson< std::tuple<T0, T1, T2, T3, T4, T5, T6, T7> > 00147 { 00148 static inline QJsonValue toJson(const std::tuple<T0, T1, T2, T3, T4, T5, T6, T7> & t, const QString & format) 00149 { 00150 QJsonArray arr; QJsonValue val; 00151 val = qx::cvt::to_json(std::get<0>(t), format); arr.append(val); 00152 val = qx::cvt::to_json(std::get<1>(t), format); arr.append(val); 00153 val = qx::cvt::to_json(std::get<2>(t), format); arr.append(val); 00154 val = qx::cvt::to_json(std::get<3>(t), format); arr.append(val); 00155 val = qx::cvt::to_json(std::get<4>(t), format); arr.append(val); 00156 val = qx::cvt::to_json(std::get<5>(t), format); arr.append(val); 00157 val = qx::cvt::to_json(std::get<6>(t), format); arr.append(val); 00158 val = qx::cvt::to_json(std::get<7>(t), format); arr.append(val); 00159 return QJsonValue(arr); 00160 } 00161 }; 00162 00163 template <typename T0, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8> 00164 struct QxConvert_ToJson< std::tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8> > 00165 { 00166 static inline QJsonValue toJson(const std::tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8> & t, const QString & format) 00167 { 00168 QJsonArray arr; QJsonValue val; 00169 val = qx::cvt::to_json(std::get<0>(t), format); arr.append(val); 00170 val = qx::cvt::to_json(std::get<1>(t), format); arr.append(val); 00171 val = qx::cvt::to_json(std::get<2>(t), format); arr.append(val); 00172 val = qx::cvt::to_json(std::get<3>(t), format); arr.append(val); 00173 val = qx::cvt::to_json(std::get<4>(t), format); arr.append(val); 00174 val = qx::cvt::to_json(std::get<5>(t), format); arr.append(val); 00175 val = qx::cvt::to_json(std::get<6>(t), format); arr.append(val); 00176 val = qx::cvt::to_json(std::get<7>(t), format); arr.append(val); 00177 val = qx::cvt::to_json(std::get<8>(t), format); arr.append(val); 00178 return QJsonValue(arr); 00179 } 00180 }; 00181 00182 template <typename T0, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9> 00183 struct QxConvert_ToJson< std::tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> > 00184 { 00185 static inline QJsonValue toJson(const std::tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> & t, const QString & format) 00186 { 00187 QJsonArray arr; QJsonValue val; 00188 val = qx::cvt::to_json(std::get<0>(t), format); arr.append(val); 00189 val = qx::cvt::to_json(std::get<1>(t), format); arr.append(val); 00190 val = qx::cvt::to_json(std::get<2>(t), format); arr.append(val); 00191 val = qx::cvt::to_json(std::get<3>(t), format); arr.append(val); 00192 val = qx::cvt::to_json(std::get<4>(t), format); arr.append(val); 00193 val = qx::cvt::to_json(std::get<5>(t), format); arr.append(val); 00194 val = qx::cvt::to_json(std::get<6>(t), format); arr.append(val); 00195 val = qx::cvt::to_json(std::get<7>(t), format); arr.append(val); 00196 val = qx::cvt::to_json(std::get<8>(t), format); arr.append(val); 00197 val = qx::cvt::to_json(std::get<9>(t), format); arr.append(val); 00198 return QJsonValue(arr); 00199 } 00200 }; 00201 00202 template <typename T0, typename T1> 00203 struct QxConvert_FromJson< std::tuple<T0, T1> > 00204 { 00205 static inline qx_bool fromJson(const QJsonValue & j, std::tuple<T0, T1> & t, const QString & format) 00206 { 00207 if (! j.isArray()) { return qx_bool(true); } 00208 QJsonArray arr = j.toArray(); 00209 qx::cvt::from_json(arr.at(0), std::get<0>(t), format); 00210 qx::cvt::from_json(arr.at(1), std::get<1>(t), format); 00211 return qx_bool(true); 00212 } 00213 }; 00214 00215 template <typename T0, typename T1, typename T2> 00216 struct QxConvert_FromJson< std::tuple<T0, T1, T2> > 00217 { 00218 static inline qx_bool fromJson(const QJsonValue & j, std::tuple<T0, T1, T2> & t, const QString & format) 00219 { 00220 if (! j.isArray()) { return qx_bool(true); } 00221 QJsonArray arr = j.toArray(); 00222 qx::cvt::from_json(arr.at(0), std::get<0>(t), format); 00223 qx::cvt::from_json(arr.at(1), std::get<1>(t), format); 00224 qx::cvt::from_json(arr.at(2), std::get<2>(t), format); 00225 return qx_bool(true); 00226 } 00227 }; 00228 00229 template <typename T0, typename T1, typename T2, typename T3> 00230 struct QxConvert_FromJson< std::tuple<T0, T1, T2, T3> > 00231 { 00232 static inline qx_bool fromJson(const QJsonValue & j, std::tuple<T0, T1, T2, T3> & t, const QString & format) 00233 { 00234 if (! j.isArray()) { return qx_bool(true); } 00235 QJsonArray arr = j.toArray(); 00236 qx::cvt::from_json(arr.at(0), std::get<0>(t), format); 00237 qx::cvt::from_json(arr.at(1), std::get<1>(t), format); 00238 qx::cvt::from_json(arr.at(2), std::get<2>(t), format); 00239 qx::cvt::from_json(arr.at(3), std::get<3>(t), format); 00240 return qx_bool(true); 00241 } 00242 }; 00243 00244 template <typename T0, typename T1, typename T2, typename T3, typename T4> 00245 struct QxConvert_FromJson< std::tuple<T0, T1, T2, T3, T4> > 00246 { 00247 static inline qx_bool fromJson(const QJsonValue & j, std::tuple<T0, T1, T2, T3, T4> & t, const QString & format) 00248 { 00249 if (! j.isArray()) { return qx_bool(true); } 00250 QJsonArray arr = j.toArray(); 00251 qx::cvt::from_json(arr.at(0), std::get<0>(t), format); 00252 qx::cvt::from_json(arr.at(1), std::get<1>(t), format); 00253 qx::cvt::from_json(arr.at(2), std::get<2>(t), format); 00254 qx::cvt::from_json(arr.at(3), std::get<3>(t), format); 00255 qx::cvt::from_json(arr.at(4), std::get<4>(t), format); 00256 return qx_bool(true); 00257 } 00258 }; 00259 00260 template <typename T0, typename T1, typename T2, typename T3, typename T4, typename T5> 00261 struct QxConvert_FromJson< std::tuple<T0, T1, T2, T3, T4, T5> > 00262 { 00263 static inline qx_bool fromJson(const QJsonValue & j, std::tuple<T0, T1, T2, T3, T4, T5> & t, const QString & format) 00264 { 00265 if (! j.isArray()) { return qx_bool(true); } 00266 QJsonArray arr = j.toArray(); 00267 qx::cvt::from_json(arr.at(0), std::get<0>(t), format); 00268 qx::cvt::from_json(arr.at(1), std::get<1>(t), format); 00269 qx::cvt::from_json(arr.at(2), std::get<2>(t), format); 00270 qx::cvt::from_json(arr.at(3), std::get<3>(t), format); 00271 qx::cvt::from_json(arr.at(4), std::get<4>(t), format); 00272 qx::cvt::from_json(arr.at(5), std::get<5>(t), format); 00273 return qx_bool(true); 00274 } 00275 }; 00276 00277 template <typename T0, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6> 00278 struct QxConvert_FromJson< std::tuple<T0, T1, T2, T3, T4, T5, T6> > 00279 { 00280 static inline qx_bool fromJson(const QJsonValue & j, std::tuple<T0, T1, T2, T3, T4, T5, T6> & t, const QString & format) 00281 { 00282 if (! j.isArray()) { return qx_bool(true); } 00283 QJsonArray arr = j.toArray(); 00284 qx::cvt::from_json(arr.at(0), std::get<0>(t), format); 00285 qx::cvt::from_json(arr.at(1), std::get<1>(t), format); 00286 qx::cvt::from_json(arr.at(2), std::get<2>(t), format); 00287 qx::cvt::from_json(arr.at(3), std::get<3>(t), format); 00288 qx::cvt::from_json(arr.at(4), std::get<4>(t), format); 00289 qx::cvt::from_json(arr.at(5), std::get<5>(t), format); 00290 qx::cvt::from_json(arr.at(6), std::get<6>(t), format); 00291 return qx_bool(true); 00292 } 00293 }; 00294 00295 template <typename T0, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7> 00296 struct QxConvert_FromJson< std::tuple<T0, T1, T2, T3, T4, T5, T6, T7> > 00297 { 00298 static inline qx_bool fromJson(const QJsonValue & j, std::tuple<T0, T1, T2, T3, T4, T5, T6, T7> & t, const QString & format) 00299 { 00300 if (! j.isArray()) { return qx_bool(true); } 00301 QJsonArray arr = j.toArray(); 00302 qx::cvt::from_json(arr.at(0), std::get<0>(t), format); 00303 qx::cvt::from_json(arr.at(1), std::get<1>(t), format); 00304 qx::cvt::from_json(arr.at(2), std::get<2>(t), format); 00305 qx::cvt::from_json(arr.at(3), std::get<3>(t), format); 00306 qx::cvt::from_json(arr.at(4), std::get<4>(t), format); 00307 qx::cvt::from_json(arr.at(5), std::get<5>(t), format); 00308 qx::cvt::from_json(arr.at(6), std::get<6>(t), format); 00309 qx::cvt::from_json(arr.at(7), std::get<7>(t), format); 00310 return qx_bool(true); 00311 } 00312 }; 00313 00314 template <typename T0, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8> 00315 struct QxConvert_FromJson< std::tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8> > 00316 { 00317 static inline qx_bool fromJson(const QJsonValue & j, std::tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8> & t, const QString & format) 00318 { 00319 if (! j.isArray()) { return qx_bool(true); } 00320 QJsonArray arr = j.toArray(); 00321 qx::cvt::from_json(arr.at(0), std::get<0>(t), format); 00322 qx::cvt::from_json(arr.at(1), std::get<1>(t), format); 00323 qx::cvt::from_json(arr.at(2), std::get<2>(t), format); 00324 qx::cvt::from_json(arr.at(3), std::get<3>(t), format); 00325 qx::cvt::from_json(arr.at(4), std::get<4>(t), format); 00326 qx::cvt::from_json(arr.at(5), std::get<5>(t), format); 00327 qx::cvt::from_json(arr.at(6), std::get<6>(t), format); 00328 qx::cvt::from_json(arr.at(7), std::get<7>(t), format); 00329 qx::cvt::from_json(arr.at(8), std::get<8>(t), format); 00330 return qx_bool(true); 00331 } 00332 }; 00333 00334 template <typename T0, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9> 00335 struct QxConvert_FromJson< std::tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> > 00336 { 00337 static inline qx_bool fromJson(const QJsonValue & j, std::tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> & t, const QString & format) 00338 { 00339 if (! j.isArray()) { return qx_bool(true); } 00340 QJsonArray arr = j.toArray(); 00341 qx::cvt::from_json(arr.at(0), std::get<0>(t), format); 00342 qx::cvt::from_json(arr.at(1), std::get<1>(t), format); 00343 qx::cvt::from_json(arr.at(2), std::get<2>(t), format); 00344 qx::cvt::from_json(arr.at(3), std::get<3>(t), format); 00345 qx::cvt::from_json(arr.at(4), std::get<4>(t), format); 00346 qx::cvt::from_json(arr.at(5), std::get<5>(t), format); 00347 qx::cvt::from_json(arr.at(6), std::get<6>(t), format); 00348 qx::cvt::from_json(arr.at(7), std::get<7>(t), format); 00349 qx::cvt::from_json(arr.at(8), std::get<8>(t), format); 00350 qx::cvt::from_json(arr.at(9), std::get<9>(t), format); 00351 return qx_bool(true); 00352 } 00353 }; 00354 00355 } // namespace detail 00356 } // namespace cvt 00357 } // namespace qx 00358 00359 #endif // _QX_SERIALIZE_QJSON_STD_TUPLE_H_ 00360 #endif // _QX_NO_JSON