| QxOrm 1.4.2 C++ Object Relational Mapping library

- Main Page
- Modules
- Namespaces
- Classes
- Files
- Directories

- File List
- File Members

QxSerializeQJson_std_tuple.h
Go to the documentation of this file.

    00001 /****************************************************************************
    00002 **
    00003 ** http://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 #ifdef _QX_CPP_11_TUPLE
    00034 #ifndef BOOST_NO_CXX11_HDR_TUPLE
    00035 #ifndef _QX_SERIALIZE_QJSON_STD_TUPLE_H_
    00036 #define _QX_SERIALIZE_QJSON_STD_TUPLE_H_
    00037
    00038 #ifdef _MSC_VER
    00039 #pragma once
    00040 #endif
    00041
    00049 #include <QtCore/qjsonvalue.h>
    00050 #include <QtCore/qjsonobject.h>
    00051 #include <QtCore/qjsonarray.h>
    00052
    00053 #include <tuple>
    00054
    00055 #include <QxConvert/QxConvert.h>
    00056 #include <QxConvert/QxConvert_Impl.h>
    00057
    00058 namespace qx {
    00059 namespace cvt {
    00060 namespace detail {
    00061
    00062 template <typename T0, typename T1>
    00063 struct QxConvert_ToJson< std::tuple<T0, T1> >
    00064 {
    00065    static inline QJsonValue toJson(const std::tuple<T0, T1> & t, const QString & format)
    00066    {
    00067       QJsonArray arr; QJsonValue val;
    00068       val = qx::cvt::to_json(std::get<0>(t), format); arr.append(val);
    00069       val = qx::cvt::to_json(std::get<1>(t), format); arr.append(val);
    00070       return QJsonValue(arr);
    00071    }
    00072 };
    00073
    00074 template <typename T0, typename T1, typename T2>
    00075 struct QxConvert_ToJson< std::tuple<T0, T1, T2> >
    00076 {
    00077    static inline QJsonValue toJson(const std::tuple<T0, T1, T2> & t, const QString & format)
    00078    {
    00079       QJsonArray arr; QJsonValue val;
    00080       val = qx::cvt::to_json(std::get<0>(t), format); arr.append(val);
    00081       val = qx::cvt::to_json(std::get<1>(t), format); arr.append(val);
    00082       val = qx::cvt::to_json(std::get<2>(t), format); arr.append(val);
    00083       return QJsonValue(arr);
    00084    }
    00085 };
    00086
    00087 template <typename T0, typename T1, typename T2, typename T3>
    00088 struct QxConvert_ToJson< std::tuple<T0, T1, T2, T3> >
    00089 {
    00090    static inline QJsonValue toJson(const std::tuple<T0, T1, T2, T3> & t, const QString & format)
    00091    {
    00092       QJsonArray arr; QJsonValue val;
    00093       val = qx::cvt::to_json(std::get<0>(t), format); arr.append(val);
    00094       val = qx::cvt::to_json(std::get<1>(t), format); arr.append(val);
    00095       val = qx::cvt::to_json(std::get<2>(t), format); arr.append(val);
    00096       val = qx::cvt::to_json(std::get<3>(t), format); arr.append(val);
    00097       return QJsonValue(arr);
    00098    }
    00099 };
    00100
    00101 template <typename T0, typename T1, typename T2, typename T3, typename T4>
    00102 struct QxConvert_ToJson< std::tuple<T0, T1, T2, T3, T4> >
    00103 {
    00104    static inline QJsonValue toJson(const std::tuple<T0, T1, T2, T3, T4> & t, const QString & format)
    00105    {
    00106       QJsonArray arr; QJsonValue val;
    00107       val = qx::cvt::to_json(std::get<0>(t), format); arr.append(val);
    00108       val = qx::cvt::to_json(std::get<1>(t), format); arr.append(val);
    00109       val = qx::cvt::to_json(std::get<2>(t), format); arr.append(val);
    00110       val = qx::cvt::to_json(std::get<3>(t), format); arr.append(val);
    00111       val = qx::cvt::to_json(std::get<4>(t), format); arr.append(val);
    00112       return QJsonValue(arr);
    00113    }
    00114 };
    00115
    00116 template <typename T0, typename T1, typename T2, typename T3, typename T4, typename T5>
    00117 struct QxConvert_ToJson< std::tuple<T0, T1, T2, T3, T4, T5> >
    00118 {
    00119    static inline QJsonValue toJson(const std::tuple<T0, T1, T2, T3, T4, T5> & t, const QString & format)
    00120    {
    00121       QJsonArray arr; QJsonValue val;
    00122       val = qx::cvt::to_json(std::get<0>(t), format); arr.append(val);
    00123       val = qx::cvt::to_json(std::get<1>(t), format); arr.append(val);
    00124       val = qx::cvt::to_json(std::get<2>(t), format); arr.append(val);
    00125       val = qx::cvt::to_json(std::get<3>(t), format); arr.append(val);
    00126       val = qx::cvt::to_json(std::get<4>(t), format); arr.append(val);
    00127       val = qx::cvt::to_json(std::get<5>(t), format); arr.append(val);
    00128       return QJsonValue(arr);
    00129    }
    00130 };
    00131
    00132 template <typename T0, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
    00133 struct QxConvert_ToJson< std::tuple<T0, T1, T2, T3, T4, T5, T6> >
    00134 {
    00135    static inline QJsonValue toJson(const std::tuple<T0, T1, T2, T3, T4, T5, T6> & t, const QString & format)
    00136    {
    00137       QJsonArray arr; QJsonValue val;
    00138       val = qx::cvt::to_json(std::get<0>(t), format); arr.append(val);
    00139       val = qx::cvt::to_json(std::get<1>(t), format); arr.append(val);
    00140       val = qx::cvt::to_json(std::get<2>(t), format); arr.append(val);
    00141       val = qx::cvt::to_json(std::get<3>(t), format); arr.append(val);
    00142       val = qx::cvt::to_json(std::get<4>(t), format); arr.append(val);
    00143       val = qx::cvt::to_json(std::get<5>(t), format); arr.append(val);
    00144       val = qx::cvt::to_json(std::get<6>(t), format); arr.append(val);
    00145       return QJsonValue(arr);
    00146    }
    00147 };
    00148
    00149 template <typename T0, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7>
    00150 struct QxConvert_ToJson< std::tuple<T0, T1, T2, T3, T4, T5, T6, T7> >
    00151 {
    00152    static inline QJsonValue toJson(const std::tuple<T0, T1, T2, T3, T4, T5, T6, T7> & t, const QString & format)
    00153    {
    00154       QJsonArray arr; QJsonValue val;
    00155       val = qx::cvt::to_json(std::get<0>(t), format); arr.append(val);
    00156       val = qx::cvt::to_json(std::get<1>(t), format); arr.append(val);
    00157       val = qx::cvt::to_json(std::get<2>(t), format); arr.append(val);
    00158       val = qx::cvt::to_json(std::get<3>(t), format); arr.append(val);
    00159       val = qx::cvt::to_json(std::get<4>(t), format); arr.append(val);
    00160       val = qx::cvt::to_json(std::get<5>(t), format); arr.append(val);
    00161       val = qx::cvt::to_json(std::get<6>(t), format); arr.append(val);
    00162       val = qx::cvt::to_json(std::get<7>(t), format); arr.append(val);
    00163       return QJsonValue(arr);
    00164    }
    00165 };
    00166
    00167 template <typename T0, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8>
    00168 struct QxConvert_ToJson< std::tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8> >
    00169 {
    00170    static inline QJsonValue toJson(const std::tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8> & t, const QString & format)
    00171    {
    00172       QJsonArray arr; QJsonValue val;
    00173       val = qx::cvt::to_json(std::get<0>(t), format); arr.append(val);
    00174       val = qx::cvt::to_json(std::get<1>(t), format); arr.append(val);
    00175       val = qx::cvt::to_json(std::get<2>(t), format); arr.append(val);
    00176       val = qx::cvt::to_json(std::get<3>(t), format); arr.append(val);
    00177       val = qx::cvt::to_json(std::get<4>(t), format); arr.append(val);
    00178       val = qx::cvt::to_json(std::get<5>(t), format); arr.append(val);
    00179       val = qx::cvt::to_json(std::get<6>(t), format); arr.append(val);
    00180       val = qx::cvt::to_json(std::get<7>(t), format); arr.append(val);
    00181       val = qx::cvt::to_json(std::get<8>(t), format); arr.append(val);
    00182       return QJsonValue(arr);
    00183    }
    00184 };
    00185
    00186 template <typename T0, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9>
    00187 struct QxConvert_ToJson< std::tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> >
    00188 {
    00189    static inline QJsonValue toJson(const std::tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> & t, const QString & format)
    00190    {
    00191       QJsonArray arr; QJsonValue val;
    00192       val = qx::cvt::to_json(std::get<0>(t), format); arr.append(val);
    00193       val = qx::cvt::to_json(std::get<1>(t), format); arr.append(val);
    00194       val = qx::cvt::to_json(std::get<2>(t), format); arr.append(val);
    00195       val = qx::cvt::to_json(std::get<3>(t), format); arr.append(val);
    00196       val = qx::cvt::to_json(std::get<4>(t), format); arr.append(val);
    00197       val = qx::cvt::to_json(std::get<5>(t), format); arr.append(val);
    00198       val = qx::cvt::to_json(std::get<6>(t), format); arr.append(val);
    00199       val = qx::cvt::to_json(std::get<7>(t), format); arr.append(val);
    00200       val = qx::cvt::to_json(std::get<8>(t), format); arr.append(val);
    00201       val = qx::cvt::to_json(std::get<9>(t), format); arr.append(val);
    00202       return QJsonValue(arr);
    00203    }
    00204 };
    00205
    00206 template <typename T0, typename T1>
    00207 struct QxConvert_FromJson< std::tuple<T0, T1> >
    00208 {
    00209    static inline qx_bool fromJson(const QJsonValue & j, std::tuple<T0, T1> & t, const QString & format)
    00210    {
    00211       if (! j.isArray()) { return qx_bool(true); }
    00212       QJsonArray arr = j.toArray();
    00213       qx::cvt::from_json(arr.at(0), std::get<0>(t), format);
    00214       qx::cvt::from_json(arr.at(1), std::get<1>(t), format);
    00215       return qx_bool(true);
    00216    }
    00217 };
    00218
    00219 template <typename T0, typename T1, typename T2>
    00220 struct QxConvert_FromJson< std::tuple<T0, T1, T2> >
    00221 {
    00222    static inline qx_bool fromJson(const QJsonValue & j, std::tuple<T0, T1, T2> & t, const QString & format)
    00223    {
    00224       if (! j.isArray()) { return qx_bool(true); }
    00225       QJsonArray arr = j.toArray();
    00226       qx::cvt::from_json(arr.at(0), std::get<0>(t), format);
    00227       qx::cvt::from_json(arr.at(1), std::get<1>(t), format);
    00228       qx::cvt::from_json(arr.at(2), std::get<2>(t), format);
    00229       return qx_bool(true);
    00230    }
    00231 };
    00232
    00233 template <typename T0, typename T1, typename T2, typename T3>
    00234 struct QxConvert_FromJson< std::tuple<T0, T1, T2, T3> >
    00235 {
    00236    static inline qx_bool fromJson(const QJsonValue & j, std::tuple<T0, T1, T2, T3> & t, const QString & format)
    00237    {
    00238       if (! j.isArray()) { return qx_bool(true); }
    00239       QJsonArray arr = j.toArray();
    00240       qx::cvt::from_json(arr.at(0), std::get<0>(t), format);
    00241       qx::cvt::from_json(arr.at(1), std::get<1>(t), format);
    00242       qx::cvt::from_json(arr.at(2), std::get<2>(t), format);
    00243       qx::cvt::from_json(arr.at(3), std::get<3>(t), format);
    00244       return qx_bool(true);
    00245    }
    00246 };
    00247
    00248 template <typename T0, typename T1, typename T2, typename T3, typename T4>
    00249 struct QxConvert_FromJson< std::tuple<T0, T1, T2, T3, T4> >
    00250 {
    00251    static inline qx_bool fromJson(const QJsonValue & j, std::tuple<T0, T1, T2, T3, T4> & t, const QString & format)
    00252    {
    00253       if (! j.isArray()) { return qx_bool(true); }
    00254       QJsonArray arr = j.toArray();
    00255       qx::cvt::from_json(arr.at(0), std::get<0>(t), format);
    00256       qx::cvt::from_json(arr.at(1), std::get<1>(t), format);
    00257       qx::cvt::from_json(arr.at(2), std::get<2>(t), format);
    00258       qx::cvt::from_json(arr.at(3), std::get<3>(t), format);
    00259       qx::cvt::from_json(arr.at(4), std::get<4>(t), format);
    00260       return qx_bool(true);
    00261    }
    00262 };
    00263
    00264 template <typename T0, typename T1, typename T2, typename T3, typename T4, typename T5>
    00265 struct QxConvert_FromJson< std::tuple<T0, T1, T2, T3, T4, T5> >
    00266 {
    00267    static inline qx_bool fromJson(const QJsonValue & j, std::tuple<T0, T1, T2, T3, T4, T5> & t, const QString & format)
    00268    {
    00269       if (! j.isArray()) { return qx_bool(true); }
    00270       QJsonArray arr = j.toArray();
    00271       qx::cvt::from_json(arr.at(0), std::get<0>(t), format);
    00272       qx::cvt::from_json(arr.at(1), std::get<1>(t), format);
    00273       qx::cvt::from_json(arr.at(2), std::get<2>(t), format);
    00274       qx::cvt::from_json(arr.at(3), std::get<3>(t), format);
    00275       qx::cvt::from_json(arr.at(4), std::get<4>(t), format);
    00276       qx::cvt::from_json(arr.at(5), std::get<5>(t), format);
    00277       return qx_bool(true);
    00278    }
    00279 };
    00280
    00281 template <typename T0, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
    00282 struct QxConvert_FromJson< std::tuple<T0, T1, T2, T3, T4, T5, T6> >
    00283 {
    00284    static inline qx_bool fromJson(const QJsonValue & j, std::tuple<T0, T1, T2, T3, T4, T5, T6> & t, const QString & format)
    00285    {
    00286       if (! j.isArray()) { return qx_bool(true); }
    00287       QJsonArray arr = j.toArray();
    00288       qx::cvt::from_json(arr.at(0), std::get<0>(t), format);
    00289       qx::cvt::from_json(arr.at(1), std::get<1>(t), format);
    00290       qx::cvt::from_json(arr.at(2), std::get<2>(t), format);
    00291       qx::cvt::from_json(arr.at(3), std::get<3>(t), format);
    00292       qx::cvt::from_json(arr.at(4), std::get<4>(t), format);
    00293       qx::cvt::from_json(arr.at(5), std::get<5>(t), format);
    00294       qx::cvt::from_json(arr.at(6), std::get<6>(t), format);
    00295       return qx_bool(true);
    00296    }
    00297 };
    00298
    00299 template <typename T0, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7>
    00300 struct QxConvert_FromJson< std::tuple<T0, T1, T2, T3, T4, T5, T6, T7> >
    00301 {
    00302    static inline qx_bool fromJson(const QJsonValue & j, std::tuple<T0, T1, T2, T3, T4, T5, T6, T7> & t, const QString & format)
    00303    {
    00304       if (! j.isArray()) { return qx_bool(true); }
    00305       QJsonArray arr = j.toArray();
    00306       qx::cvt::from_json(arr.at(0), std::get<0>(t), format);
    00307       qx::cvt::from_json(arr.at(1), std::get<1>(t), format);
    00308       qx::cvt::from_json(arr.at(2), std::get<2>(t), format);
    00309       qx::cvt::from_json(arr.at(3), std::get<3>(t), format);
    00310       qx::cvt::from_json(arr.at(4), std::get<4>(t), format);
    00311       qx::cvt::from_json(arr.at(5), std::get<5>(t), format);
    00312       qx::cvt::from_json(arr.at(6), std::get<6>(t), format);
    00313       qx::cvt::from_json(arr.at(7), std::get<7>(t), format);
    00314       return qx_bool(true);
    00315    }
    00316 };
    00317
    00318 template <typename T0, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8>
    00319 struct QxConvert_FromJson< std::tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8> >
    00320 {
    00321    static inline qx_bool fromJson(const QJsonValue & j, std::tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8> & t, const QString & format)
    00322    {
    00323       if (! j.isArray()) { return qx_bool(true); }
    00324       QJsonArray arr = j.toArray();
    00325       qx::cvt::from_json(arr.at(0), std::get<0>(t), format);
    00326       qx::cvt::from_json(arr.at(1), std::get<1>(t), format);
    00327       qx::cvt::from_json(arr.at(2), std::get<2>(t), format);
    00328       qx::cvt::from_json(arr.at(3), std::get<3>(t), format);
    00329       qx::cvt::from_json(arr.at(4), std::get<4>(t), format);
    00330       qx::cvt::from_json(arr.at(5), std::get<5>(t), format);
    00331       qx::cvt::from_json(arr.at(6), std::get<6>(t), format);
    00332       qx::cvt::from_json(arr.at(7), std::get<7>(t), format);
    00333       qx::cvt::from_json(arr.at(8), std::get<8>(t), format);
    00334       return qx_bool(true);
    00335    }
    00336 };
    00337
    00338 template <typename T0, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9>
    00339 struct QxConvert_FromJson< std::tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> >
    00340 {
    00341    static inline qx_bool fromJson(const QJsonValue & j, std::tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> & t, const QString & format)
    00342    {
    00343       if (! j.isArray()) { return qx_bool(true); }
    00344       QJsonArray arr = j.toArray();
    00345       qx::cvt::from_json(arr.at(0), std::get<0>(t), format);
    00346       qx::cvt::from_json(arr.at(1), std::get<1>(t), format);
    00347       qx::cvt::from_json(arr.at(2), std::get<2>(t), format);
    00348       qx::cvt::from_json(arr.at(3), std::get<3>(t), format);
    00349       qx::cvt::from_json(arr.at(4), std::get<4>(t), format);
    00350       qx::cvt::from_json(arr.at(5), std::get<5>(t), format);
    00351       qx::cvt::from_json(arr.at(6), std::get<6>(t), format);
    00352       qx::cvt::from_json(arr.at(7), std::get<7>(t), format);
    00353       qx::cvt::from_json(arr.at(8), std::get<8>(t), format);
    00354       qx::cvt::from_json(arr.at(9), std::get<9>(t), format);
    00355       return qx_bool(true);
    00356    }
    00357 };
    00358
    00359 } // namespace detail
    00360 } // namespace cvt
    00361 } // namespace qx
    00362
    00363 #endif // _QX_SERIALIZE_QJSON_STD_TUPLE_H_
    00364 #endif // BOOST_NO_CXX11_HDR_TUPLE
    00365 #endif // _QX_CPP_11_TUPLE
    00366 #endif // _QX_NO_JSON