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