QxConvert_FromVariant.inl 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363
  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. #ifdef _QX_ENABLE_BOOST_SERIALIZATION
  32. #define QX_CVT_DEFAULT_ARCHIVE_FROM_VARIANT QX_CVT_DEFAULT_ARCHIVE::from_string(t, v.toString())
  33. #else // _QX_ENABLE_BOOST_SERIALIZATION
  34. #define QX_CVT_DEFAULT_ARCHIVE_FROM_VARIANT QX_CVT_DEFAULT_ARCHIVE::from_byte_array(t, v.toByteArray())
  35. #endif // _QX_ENABLE_BOOST_SERIALIZATION
  36. namespace qx {
  37. namespace cvt {
  38. namespace detail {
  39. template <> struct QxConvert_FromVariant< qx::trait::no_type > {
  40. static inline qx_bool fromVariant(const QVariant & v, qx::trait::no_type & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
  41. { Q_UNUSED(v); Q_UNUSED(t); Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); return qx_bool(true); } };
  42. template <> struct QxConvert_FromVariant< bool > {
  43. static inline qx_bool fromVariant(const QVariant & v, bool & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
  44. { Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); t = v.toBool(); return qx_bool(true); } };
  45. template <> struct QxConvert_FromVariant< short > {
  46. static inline qx_bool fromVariant(const QVariant & v, short & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
  47. { Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); bool bOk = false; t = static_cast<short>(v.toInt(& bOk)); return bOk; } };
  48. template <> struct QxConvert_FromVariant< int > {
  49. static inline qx_bool fromVariant(const QVariant & v, int & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
  50. { Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); bool bOk = false; t = v.toInt(& bOk); return bOk; } };
  51. template <> struct QxConvert_FromVariant< long > {
  52. static inline qx_bool fromVariant(const QVariant & v, long & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
  53. { Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); bool bOk = false; t = static_cast<long>(v.toLongLong(& bOk)); return bOk; } };
  54. template <> struct QxConvert_FromVariant< long long > {
  55. static inline qx_bool fromVariant(const QVariant & v, long long & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
  56. { Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); bool bOk = false; t = static_cast<long long>(v.toLongLong(& bOk)); return bOk; } };
  57. template <> struct QxConvert_FromVariant< float > {
  58. static inline qx_bool fromVariant(const QVariant & v, float & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
  59. { Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); bool bOk = false; t = static_cast<float>(v.toDouble(& bOk)); return bOk; } };
  60. template <> struct QxConvert_FromVariant< double > {
  61. static inline qx_bool fromVariant(const QVariant & v, double & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
  62. { Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); bool bOk = false; t = v.toDouble(& bOk); return bOk; } };
  63. template <> struct QxConvert_FromVariant< unsigned short > {
  64. static inline qx_bool fromVariant(const QVariant & v, unsigned short & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
  65. { Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); bool bOk = false; t = static_cast<unsigned short>(v.toUInt(& bOk)); return bOk; } };
  66. template <> struct QxConvert_FromVariant< unsigned int > {
  67. static inline qx_bool fromVariant(const QVariant & v, unsigned int & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
  68. { Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); bool bOk = false; t = static_cast<unsigned int>(v.toUInt(& bOk)); return bOk; } };
  69. template <> struct QxConvert_FromVariant< unsigned long > {
  70. static inline qx_bool fromVariant(const QVariant & v, unsigned long & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
  71. { Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); bool bOk = false; t = static_cast<unsigned long>(v.toULongLong(& bOk)); return bOk; } };
  72. template <> struct QxConvert_FromVariant< unsigned long long > {
  73. static inline qx_bool fromVariant(const QVariant & v, unsigned long long & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
  74. { Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); bool bOk = false; t = static_cast<unsigned long long>(v.toULongLong(& bOk)); return bOk; } };
  75. template <> struct QxConvert_FromVariant< QDate > {
  76. static inline qx_bool fromVariant(const QVariant & v, QDate & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
  77. { Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); t = v.toDate(); return t.isValid(); } };
  78. template <> struct QxConvert_FromVariant< QTime > {
  79. static inline qx_bool fromVariant(const QVariant & v, QTime & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
  80. { Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); t = v.toTime(); return t.isValid(); } };
  81. template <> struct QxConvert_FromVariant< QDateTime > {
  82. static inline qx_bool fromVariant(const QVariant & v, QDateTime & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
  83. { Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); t = v.toDateTime(); return t.isValid(); } };
  84. template <> struct QxConvert_FromVariant< QByteArray > {
  85. static inline qx_bool fromVariant(const QVariant & v, QByteArray & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
  86. { Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); t = v.toByteArray(); return qx_bool(true); } };
  87. template <> struct QxConvert_FromVariant< QString > {
  88. static inline qx_bool fromVariant(const QVariant & v, QString & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
  89. { Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); t = v.toString(); return qx_bool(true); } };
  90. template <>
  91. struct QxConvert_FromVariant< QVariant >
  92. {
  93. static inline qx_bool fromVariant(const QVariant & v, QVariant & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
  94. {
  95. if (ctx != qx::cvt::context::e_database) { t = v; return qx_bool(true); }
  96. QString s = v.toString(); if (! s.startsWith("$$JSON$$")) { t = v; return qx_bool(true); }
  97. return qx::cvt::detail::QxConvert_FromString< QVariant >::fromString(s, t, format, index, ctx);
  98. }
  99. };
  100. template <> struct QxConvert_FromVariant< QUuid > {
  101. static inline qx_bool fromVariant(const QVariant & v, QUuid & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
  102. { Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); t = QUuid(v.toString()); return qx_bool(true); } };
  103. template <> struct QxConvert_FromVariant< qx::QxDateNeutral > {
  104. static inline qx_bool fromVariant(const QVariant & v, qx::QxDateNeutral & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
  105. { Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); t = qx::QxDateNeutral::fromNeutral(v.toString()); return qx_bool(true); } };
  106. template <> struct QxConvert_FromVariant< qx::QxTimeNeutral > {
  107. static inline qx_bool fromVariant(const QVariant & v, qx::QxTimeNeutral & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
  108. { Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); t = qx::QxTimeNeutral::fromNeutral(v.toString()); return qx_bool(true); } };
  109. template <> struct QxConvert_FromVariant< qx::QxDateTimeNeutral > {
  110. static inline qx_bool fromVariant(const QVariant & v, qx::QxDateTimeNeutral & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
  111. { Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); t = qx::QxDateTimeNeutral::fromNeutral(v.toString()); return qx_bool(true); } };
  112. template <> struct QxConvert_FromVariant< std::string > {
  113. static inline qx_bool fromVariant(const QVariant & v, std::string & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
  114. #ifndef QT_NO_STL
  115. { Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); t = v.toString().toStdString(); return qx_bool(true); } };
  116. #else // QT_NO_STL
  117. { Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); t = v.toString().toLatin1().constData(); return qx_bool(true); } };
  118. #endif // QT_NO_STL
  119. template <> struct QxConvert_FromVariant< std::wstring > {
  120. static inline qx_bool fromVariant(const QVariant & v, std::wstring & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
  121. #if ((! defined(QT_NO_STL)) && (! defined(QT_NO_STL_WCHAR)))
  122. { Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); t = v.toString().toStdWString(); return qx_bool(true); } };
  123. #else // ((! defined(QT_NO_STL)) && (! defined(QT_NO_STL_WCHAR)))
  124. { Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); Q_UNUSED(t); Q_UNUSED(v); qAssert(false); /* Need STL compatibility ! */ return qx_bool(true); } };
  125. #endif // ((! defined(QT_NO_STL)) && (! defined(QT_NO_STL_WCHAR)))
  126. template <> struct QxConvert_FromVariant< qx_bool > {
  127. static inline qx_bool fromVariant(const QVariant & v, qx_bool & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
  128. { Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); QString s = v.toString(); t.fromString(s); return qx_bool(true); } };
  129. #ifndef _QX_NO_JSON
  130. template <> struct QxConvert_FromVariant< QJsonValue > {
  131. static inline qx_bool fromVariant(const QVariant & v, QJsonValue & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
  132. { Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); t = QJsonValue::fromVariant(v); return qx_bool(true); } };
  133. template <> struct QxConvert_FromVariant< QJsonArray > {
  134. static inline qx_bool fromVariant(const QVariant & v, QJsonArray & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
  135. { Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); t = v.toJsonArray(); return qx_bool(true); } };
  136. template <> struct QxConvert_FromVariant< QJsonObject > {
  137. static inline qx_bool fromVariant(const QVariant & v, QJsonObject & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
  138. { Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); t = v.toJsonObject(); return qx_bool(true); } };
  139. #endif // _QX_NO_JSON
  140. #ifdef _QX_ENABLE_BOOST
  141. template <typename T> struct QxConvert_FromVariant< boost::optional<T> > {
  142. static inline qx_bool fromVariant(const QVariant & v, boost::optional<T> & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
  143. {
  144. if (v.isNull()) { t = boost::none; return qx_bool(true); }
  145. else if (! t) { t = T(); }
  146. return qx::cvt::from_variant(v, (* t), format, index, ctx);
  147. } };
  148. #endif // _QX_ENABLE_BOOST
  149. template <typename T1, typename T2> struct QxConvert_FromVariant< std::pair<T1, T2> > {
  150. static inline qx_bool fromVariant(const QVariant & v, std::pair<T1, T2> & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
  151. { Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); return QX_CVT_DEFAULT_ARCHIVE_FROM_VARIANT; } };
  152. template <typename T1, typename T2> struct QxConvert_FromVariant< QPair<T1, T2> > {
  153. static inline qx_bool fromVariant(const QVariant & v, QPair<T1, T2> & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
  154. { Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); return QX_CVT_DEFAULT_ARCHIVE_FROM_VARIANT; } };
  155. template <typename T> struct QxConvert_FromVariant< std::vector<T> > {
  156. static inline qx_bool fromVariant(const QVariant & v, std::vector<T> & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
  157. { Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); return QX_CVT_DEFAULT_ARCHIVE_FROM_VARIANT; } };
  158. template <typename T> struct QxConvert_FromVariant< std::list<T> > {
  159. static inline qx_bool fromVariant(const QVariant & v, std::list<T> & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
  160. { Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); return QX_CVT_DEFAULT_ARCHIVE_FROM_VARIANT; } };
  161. template <typename T> struct QxConvert_FromVariant< std::set<T> > {
  162. static inline qx_bool fromVariant(const QVariant & v, std::set<T> & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
  163. { Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); return QX_CVT_DEFAULT_ARCHIVE_FROM_VARIANT; } };
  164. #ifdef _QX_ENABLE_BOOST
  165. template <typename T> struct QxConvert_FromVariant< boost::unordered_set<T> > {
  166. static inline qx_bool fromVariant(const QVariant & v, boost::unordered_set<T> & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
  167. { Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); return QX_CVT_DEFAULT_ARCHIVE_FROM_VARIANT; } };
  168. template <typename T> struct QxConvert_FromVariant< boost::unordered_multiset<T> > {
  169. static inline qx_bool fromVariant(const QVariant & v, boost::unordered_multiset<T> & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
  170. { Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); return QX_CVT_DEFAULT_ARCHIVE_FROM_VARIANT; } };
  171. #endif // _QX_ENABLE_BOOST
  172. template <typename T> struct QxConvert_FromVariant< std::unordered_set<T> > {
  173. static inline qx_bool fromVariant(const QVariant & v, std::unordered_set<T> & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
  174. { Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); return QX_CVT_DEFAULT_ARCHIVE_FROM_VARIANT; } };
  175. template <typename T> struct QxConvert_FromVariant< std::unordered_multiset<T> > {
  176. static inline qx_bool fromVariant(const QVariant & v, std::unordered_multiset<T> & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
  177. { Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); return QX_CVT_DEFAULT_ARCHIVE_FROM_VARIANT; } };
  178. template <typename T> struct QxConvert_FromVariant< QVector<T> > {
  179. static inline qx_bool fromVariant(const QVariant & v, QVector<T> & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
  180. { Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); return QX_CVT_DEFAULT_ARCHIVE_FROM_VARIANT; } };
  181. template <typename T> struct QxConvert_FromVariant< QList<T> > {
  182. static inline qx_bool fromVariant(const QVariant & v, QList<T> & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
  183. { Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); return QX_CVT_DEFAULT_ARCHIVE_FROM_VARIANT; } };
  184. template <typename T> struct QxConvert_FromVariant< QLinkedList<T> > {
  185. static inline qx_bool fromVariant(const QVariant & v, QLinkedList<T> & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
  186. { Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); return QX_CVT_DEFAULT_ARCHIVE_FROM_VARIANT; } };
  187. template <typename T> struct QxConvert_FromVariant< QFlags<T> > {
  188. static inline qx_bool fromVariant(const QVariant & v, QFlags<T> & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
  189. { Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); t = QFlags<T>(QFlag(v.toInt())); return true; } };
  190. template <typename Key, typename Value> struct QxConvert_FromVariant< std::map<Key, Value> > {
  191. static inline qx_bool fromVariant(const QVariant & v, std::map<Key, Value> & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
  192. { Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); return QX_CVT_DEFAULT_ARCHIVE_FROM_VARIANT; } };
  193. #ifdef _QX_ENABLE_BOOST
  194. template <typename Key, typename Value> struct QxConvert_FromVariant< boost::unordered_map<Key, Value> > {
  195. static inline qx_bool fromVariant(const QVariant & v, boost::unordered_map<Key, Value> & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
  196. { Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); return QX_CVT_DEFAULT_ARCHIVE_FROM_VARIANT; } };
  197. template <typename Key, typename Value> struct QxConvert_FromVariant< boost::unordered_multimap<Key, Value> > {
  198. static inline qx_bool fromVariant(const QVariant & v, boost::unordered_multimap<Key, Value> & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
  199. { Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); return QX_CVT_DEFAULT_ARCHIVE_FROM_VARIANT; } };
  200. #endif // _QX_ENABLE_BOOST
  201. template <typename Key, typename Value> struct QxConvert_FromVariant< std::unordered_map<Key, Value> > {
  202. static inline qx_bool fromVariant(const QVariant & v, std::unordered_map<Key, Value> & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
  203. { Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); return QX_CVT_DEFAULT_ARCHIVE_FROM_VARIANT; } };
  204. template <typename Key, typename Value> struct QxConvert_FromVariant< std::unordered_multimap<Key, Value> > {
  205. static inline qx_bool fromVariant(const QVariant & v, std::unordered_multimap<Key, Value> & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
  206. { Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); return QX_CVT_DEFAULT_ARCHIVE_FROM_VARIANT; } };
  207. template <typename Key, typename Value> struct QxConvert_FromVariant< QHash<Key, Value> > {
  208. static inline qx_bool fromVariant(const QVariant & v, QHash<Key, Value> & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
  209. { Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); return QX_CVT_DEFAULT_ARCHIVE_FROM_VARIANT; } };
  210. template <typename Key, typename Value> struct QxConvert_FromVariant< QMultiHash<Key, Value> > {
  211. static inline qx_bool fromVariant(const QVariant & v, QMultiHash<Key, Value> & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
  212. { Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); return QX_CVT_DEFAULT_ARCHIVE_FROM_VARIANT; } };
  213. template <typename Key, typename Value> struct QxConvert_FromVariant< QMap<Key, Value> > {
  214. static inline qx_bool fromVariant(const QVariant & v, QMap<Key, Value> & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
  215. { Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); return QX_CVT_DEFAULT_ARCHIVE_FROM_VARIANT; } };
  216. template <typename Key, typename Value> struct QxConvert_FromVariant< QMultiMap<Key, Value> > {
  217. static inline qx_bool fromVariant(const QVariant & v, QMultiMap<Key, Value> & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
  218. { Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); return QX_CVT_DEFAULT_ARCHIVE_FROM_VARIANT; } };
  219. template <typename Key, typename Value> struct QxConvert_FromVariant< qx::QxCollection<Key, Value> > {
  220. static inline qx_bool fromVariant(const QVariant & v, qx::QxCollection<Key, Value> & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
  221. { Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); return QX_CVT_DEFAULT_ARCHIVE_FROM_VARIANT; } };
  222. #ifdef _QX_ENABLE_BOOST
  223. template <typename T1> struct QxConvert_FromVariant< boost::tuple<T1> > {
  224. static inline qx_bool fromVariant(const QVariant & v, boost::tuple<T1> & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
  225. { Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); return QX_CVT_DEFAULT_ARCHIVE_FROM_VARIANT; } };
  226. template <typename T1, typename T2> struct QxConvert_FromVariant< boost::tuple<T1, T2> > {
  227. static inline qx_bool fromVariant(const QVariant & v, boost::tuple<T1, T2> & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
  228. { Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); return QX_CVT_DEFAULT_ARCHIVE_FROM_VARIANT; } };
  229. template <typename T1, typename T2, typename T3> struct QxConvert_FromVariant< boost::tuple<T1, T2, T3> > {
  230. static inline qx_bool fromVariant(const QVariant & v, boost::tuple<T1, T2, T3> & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
  231. { Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); return QX_CVT_DEFAULT_ARCHIVE_FROM_VARIANT; } };
  232. template <typename T1, typename T2, typename T3, typename T4> struct QxConvert_FromVariant< boost::tuple<T1, T2, T3, T4> > {
  233. static inline qx_bool fromVariant(const QVariant & v, boost::tuple<T1, T2, T3, T4> & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
  234. { Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); return QX_CVT_DEFAULT_ARCHIVE_FROM_VARIANT; } };
  235. template <typename T1, typename T2, typename T3, typename T4, typename T5> struct QxConvert_FromVariant< boost::tuple<T1, T2, T3, T4, T5> > {
  236. static inline qx_bool fromVariant(const QVariant & v, boost::tuple<T1, T2, T3, T4, T5> & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
  237. { Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); return QX_CVT_DEFAULT_ARCHIVE_FROM_VARIANT; } };
  238. template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6> struct QxConvert_FromVariant< boost::tuple<T1, T2, T3, T4, T5, T6> > {
  239. static inline qx_bool fromVariant(const QVariant & v, boost::tuple<T1, T2, T3, T4, T5, T6> & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
  240. { Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); return QX_CVT_DEFAULT_ARCHIVE_FROM_VARIANT; } };
  241. template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7> struct QxConvert_FromVariant< boost::tuple<T1, T2, T3, T4, T5, T6, T7> > {
  242. static inline qx_bool fromVariant(const QVariant & v, boost::tuple<T1, T2, T3, T4, T5, T6, T7> & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
  243. { Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); return QX_CVT_DEFAULT_ARCHIVE_FROM_VARIANT; } };
  244. template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8> struct QxConvert_FromVariant< boost::tuple<T1, T2, T3, T4, T5, T6, T7, T8> > {
  245. static inline qx_bool fromVariant(const QVariant & v, boost::tuple<T1, T2, T3, T4, T5, T6, T7, T8> & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
  246. { Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); return QX_CVT_DEFAULT_ARCHIVE_FROM_VARIANT; } };
  247. template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9> struct QxConvert_FromVariant< boost::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9> > {
  248. static inline qx_bool fromVariant(const QVariant & v, boost::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9> & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
  249. { Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); return QX_CVT_DEFAULT_ARCHIVE_FROM_VARIANT; } };
  250. #endif // _QX_ENABLE_BOOST
  251. template <typename T1> struct QxConvert_FromVariant< std::tuple<T1> > {
  252. static inline qx_bool fromVariant(const QVariant & v, std::tuple<T1> & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
  253. { Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); return QX_CVT_DEFAULT_ARCHIVE_FROM_VARIANT; } };
  254. template <typename T1, typename T2> struct QxConvert_FromVariant< std::tuple<T1, T2> > {
  255. static inline qx_bool fromVariant(const QVariant & v, std::tuple<T1, T2> & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
  256. { Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); return QX_CVT_DEFAULT_ARCHIVE_FROM_VARIANT; } };
  257. template <typename T1, typename T2, typename T3> struct QxConvert_FromVariant< std::tuple<T1, T2, T3> > {
  258. static inline qx_bool fromVariant(const QVariant & v, std::tuple<T1, T2, T3> & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
  259. { Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); return QX_CVT_DEFAULT_ARCHIVE_FROM_VARIANT; } };
  260. template <typename T1, typename T2, typename T3, typename T4> struct QxConvert_FromVariant< std::tuple<T1, T2, T3, T4> > {
  261. static inline qx_bool fromVariant(const QVariant & v, std::tuple<T1, T2, T3, T4> & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
  262. { Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); return QX_CVT_DEFAULT_ARCHIVE_FROM_VARIANT; } };
  263. template <typename T1, typename T2, typename T3, typename T4, typename T5> struct QxConvert_FromVariant< std::tuple<T1, T2, T3, T4, T5> > {
  264. static inline qx_bool fromVariant(const QVariant & v, std::tuple<T1, T2, T3, T4, T5> & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
  265. { Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); return QX_CVT_DEFAULT_ARCHIVE_FROM_VARIANT; } };
  266. template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6> struct QxConvert_FromVariant< std::tuple<T1, T2, T3, T4, T5, T6> > {
  267. static inline qx_bool fromVariant(const QVariant & v, std::tuple<T1, T2, T3, T4, T5, T6> & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
  268. { Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); return QX_CVT_DEFAULT_ARCHIVE_FROM_VARIANT; } };
  269. template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7> struct QxConvert_FromVariant< std::tuple<T1, T2, T3, T4, T5, T6, T7> > {
  270. static inline qx_bool fromVariant(const QVariant & v, std::tuple<T1, T2, T3, T4, T5, T6, T7> & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
  271. { Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); return QX_CVT_DEFAULT_ARCHIVE_FROM_VARIANT; } };
  272. template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8> struct QxConvert_FromVariant< std::tuple<T1, T2, T3, T4, T5, T6, T7, T8> > {
  273. static inline qx_bool fromVariant(const QVariant & v, std::tuple<T1, T2, T3, T4, T5, T6, T7, T8> & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
  274. { Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); return QX_CVT_DEFAULT_ARCHIVE_FROM_VARIANT; } };
  275. template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9> struct QxConvert_FromVariant< std::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9> > {
  276. static inline qx_bool fromVariant(const QVariant & v, std::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9> & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
  277. { Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); return QX_CVT_DEFAULT_ARCHIVE_FROM_VARIANT; } };
  278. } // namespace detail
  279. } // namespace cvt
  280. } // namespace qx