QxOrm 1.4.9
C++ Object Relational Mapping library
Loading...
Searching...
No Matches
QxConvert_Impl.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_CONVERT_IMPL_H_
33#define _QX_CONVERT_IMPL_H_
34
35#ifdef _MSC_VER
36#pragma once
37#endif
38
39#include <QxConvert/QxConvert.h>
40#include <QxCommon/QxBool.h>
41
42#include <QxDao/QxDateNeutral.h>
43#include <QxDao/QxTimeNeutral.h>
45#include <QxDao/QxSqlQuery.h>
46#include <QxDao/IxPersistable.h>
47
49
50#include <QxRegister/QxClass.h>
51
56
59
67
68#define QX_STR_CVT_QDATE_FORMAT "yyyyMMdd"
69#define QX_STR_CVT_QTIME_FORMAT "hhmmsszzz"
70#define QX_STR_CVT_QDATETIME_FORMAT "yyyyMMddhhmmsszzz"
71
72#ifdef _QX_ENABLE_BOOST_SERIALIZATION
73#if _QX_SERIALIZE_POLYMORPHIC
74#define QX_CVT_DEFAULT_ARCHIVE qx::serialization::polymorphic_xml
75#elif _QX_SERIALIZE_XML
76#define QX_CVT_DEFAULT_ARCHIVE qx::serialization::xml
77#elif _QX_SERIALIZE_TEXT
78#define QX_CVT_DEFAULT_ARCHIVE qx::serialization::text
79#elif _QX_SERIALIZE_BINARY
80#define QX_CVT_DEFAULT_ARCHIVE qx::serialization::binary
81#endif // _QX_SERIALIZE_XML
82#else // _QX_ENABLE_BOOST_SERIALIZATION
83#define QX_CVT_DEFAULT_ARCHIVE qx::serialization::qt
84#endif // _QX_ENABLE_BOOST_SERIALIZATION
85
86#define QX_CVT_USING_ARCHIVE_IMPL(className) \
87namespace qx { namespace cvt { namespace detail { \
88template <> struct QxConvert_ToString< className > { \
89static inline QString toString(const className & t, const QString & format, int index, qx::cvt::context::ctx_type ctx) \
90{ Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); return QX_CVT_DEFAULT_ARCHIVE::to_string(t); } }; \
91template <> struct QxConvert_FromString< className > { \
92static inline qx_bool fromString(const QString & s, className & t, const QString & format, int index, qx::cvt::context::ctx_type ctx) \
93{ Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); return QX_CVT_DEFAULT_ARCHIVE::from_string(t, s); } }; \
94template <> struct QxConvert_ToVariant< className > { \
95static inline QVariant toVariant(const className & t, const QString & format, int index, qx::cvt::context::ctx_type ctx) \
96{ Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); return QX_CVT_DEFAULT_ARCHIVE::to_string(t); } }; \
97template <> struct QxConvert_FromVariant< className > { \
98static inline qx_bool fromVariant(const QVariant & v, className & t, const QString & format, int index, qx::cvt::context::ctx_type ctx) \
99{ Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); QString s = v.toString(); return QX_CVT_DEFAULT_ARCHIVE::from_string(t, s); } }; \
100} } } // namespace qx::cvt::detail
101
102#if (QT_VERSION >= QT_VERSION_CHECK(5, 8, 0))
103#define QX_JSON_DATE_TIME_FORMAT Qt::ISODateWithMs
104#define QX_JSON_DATE_TIME_FORMAT_SIZE 23 // yyyy-MM-ddTHH:mm:ss.zzz
105#else // (QT_VERSION >= QT_VERSION_CHECK(5, 8, 0))
106#define QX_JSON_DATE_TIME_FORMAT Qt::ISODate
107#define QX_JSON_DATE_TIME_FORMAT_SIZE 19 // yyyy-MM-ddTHH:mm:ss
108#endif // (QT_VERSION >= QT_VERSION_CHECK(5, 8, 0))
109
110namespace qx {
111namespace cvt {
112namespace detail {
113namespace helper {
114
121
122inline bool checkConvertQVariantToString(const QVariant & v) { return ((v.type() == QVariant::List) || (v.type() == QVariant::Map) || (v.type() == QVariant::Hash) || (v.type() == QVariant::StringList)); }
123
124} // namespace helper
125
126template <typename T, typename H>
128{
129 static inline QString toString(const T & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
130 { qAssertMsg(false, "qx::cvt::detail::QxConvertHelper_ToString", "template must be specialized"); Q_UNUSED(t); Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); return QString(); }
131};
132
133template <typename T, typename H>
135{
136 static inline qx_bool fromString(const QString & s, T & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
137 { qAssertMsg(false, "qx::cvt::detail::QxConvertHelper_FromString", "template must be specialized"); Q_UNUSED(s); Q_UNUSED(t); Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); return qx_bool(); }
138};
139
140template <typename T, typename H>
142{
143 static inline QVariant toVariant(const T & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
144 { qAssertMsg(false, "qx::cvt::detail::QxConvertHelper_ToVariant", "template must be specialized"); Q_UNUSED(t); Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); return QVariant(); }
145};
146
147template <typename T, typename H>
149{
150 static inline qx_bool fromVariant(const QVariant & v, T & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
151 { qAssertMsg(false, "qx::cvt::detail::QxConvertHelper_FromVariant", "template must be specialized"); Q_UNUSED(v); Q_UNUSED(t); Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); return qx_bool(); }
152};
153
154#ifndef _QX_NO_JSON
155
156template <typename T, typename H>
158{
159 static inline QJsonValue toJson(const T & t, const QString & format)
160 { qAssertMsg(false, "qx::cvt::detail::QxConvertHelper_ToJson", "template must be specialized"); Q_UNUSED(t); Q_UNUSED(format); return QJsonValue(); }
161};
162
163template <typename T, typename H>
165{
166 static inline qx_bool fromJson(const QJsonValue & j, T & t, const QString & format)
167 { qAssertMsg(false, "qx::cvt::detail::QxConvertHelper_FromJson", "template must be specialized"); Q_UNUSED(j); Q_UNUSED(t); Q_UNUSED(format); return qx_bool(); }
168};
169
170#endif // _QX_NO_JSON
171
172template <typename T>
174{
175
176 enum { qx_need_to_specialize_template_convert_to_string_from_string = 0 };
177
178 static inline QString toString(const T & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
179 {
180 Q_UNUSED(t); Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx);
181 static_assert(qx_need_to_specialize_template_convert_to_string_from_string, "qx_need_to_specialize_template_convert_to_string_from_string"); // If a compilation error occurred here : you have to specialize template 'qx::cvt::detail::QxConvert_ToString< MyType >'
182 return QString();
183 }
184
185};
186
187template <typename T>
189{
190
191 enum { qx_need_to_specialize_template_convert_to_string_from_string = 0 };
192
193 static inline qx_bool fromString(const QString & s, T & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
194 {
195 Q_UNUSED(s); Q_UNUSED(t); Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx);
196 static_assert(qx_need_to_specialize_template_convert_to_string_from_string, "qx_need_to_specialize_template_convert_to_string_from_string"); // If a compilation error occurred here : you have to specialize template 'qx::cvt::detail::QxConvert_FromString< MyType >'
197 return qx_bool(true);
198 }
199
200};
201
202template <typename T>
204{
205
206 static inline QVariant toVariant(const T & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
208
209private:
210
211 template <bool isQVariantCompatible /* = false */, int dummy>
213 { static inline QVariant toVariant(const T & t, const QString & format, int index, qx::cvt::context::ctx_type ctx) { return qx::cvt::to_string(t, format, index, ctx); }; };
214
215 template <int dummy>
216 struct cvtQVariant<true, dummy>
217 { static inline QVariant toVariant(const T & t, const QString & format, int index, qx::cvt::context::ctx_type ctx) { Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); return QVariant(t); }; };
218
219};
220
221template <typename T>
223{
224
225 static inline qx_bool fromVariant(const QVariant & v, T & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
226 { return cvtQVariant<qx::trait::is_qt_variant_compatible<T>::value, 0>::fromVariant(v, t, format, index, ctx); }
227
228private:
229
230 template <bool isQVariantCompatible /* = false */, int dummy>
232 { static inline qx_bool fromVariant(const QVariant & v, T & t, const QString & format, int index, qx::cvt::context::ctx_type ctx) { return qx::cvt::from_string(v.toString(), t, format, index, ctx); }; };
233
234 template <int dummy>
235 struct cvtQVariant<true, dummy>
236 { static inline qx_bool fromVariant(const QVariant & v, T & t, const QString & format, int index, qx::cvt::context::ctx_type ctx) { Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); t = v.value<T>(); return qx_bool(true); }; };
237
238};
239
240#ifndef _QX_NO_JSON
241
242template <typename T>
244{
245 static inline QJsonValue toJson(const T & t, const QString & format)
247};
248
249template <typename T>
251{
252 static inline qx_bool fromJson(const QJsonValue & j, T & t, const QString & format)
254};
255
256#endif // _QX_NO_JSON
257
258template <typename T>
260{
261
262 enum { qx_need_to_specialize_template_convert_to_string_from_string = 0 };
263
264 static inline QString toString(const T & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
265 {
266 Q_UNUSED(t); Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx);
267#ifndef _QX_NO_JSON
268 return t.toJson(format);
269#else // _QX_NO_JSON
270 static_assert(qx_need_to_specialize_template_convert_to_string_from_string, "qx_need_to_specialize_template_convert_to_string_from_string"); // If a compilation error occurred here : you have to specialize template 'qx::cvt::detail::QxConvert_ToString< MyType >'
271 return QString();
272#endif // _QX_NO_JSON
273 }
274
275};
276
277template <typename T>
279{
280
281 enum { qx_need_to_specialize_template_convert_to_string_from_string = 0 };
282
283 static inline qx_bool fromString(const QString & s, T & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
284 {
285 Q_UNUSED(s); Q_UNUSED(t); Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx);
286#ifndef _QX_NO_JSON
287 return t.fromJson(s, format);
288#else // _QX_NO_JSON
289 static_assert(qx_need_to_specialize_template_convert_to_string_from_string, "qx_need_to_specialize_template_convert_to_string_from_string"); // If a compilation error occurred here : you have to specialize template 'qx::cvt::detail::QxConvert_FromString< MyType >'
290 return qx_bool(true);
291#endif // _QX_NO_JSON
292 }
293
294};
295
296template <typename T>
298{
299
300 enum { qx_need_to_specialize_template_convert_to_variant_from_variant = 0 };
301
302 static inline QVariant toVariant(const T & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
303 {
304 Q_UNUSED(t); Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx);
305#ifndef _QX_NO_JSON
306 return QVariant(t.toJson(format));
307#else // _QX_NO_JSON
308 static_assert(qx_need_to_specialize_template_convert_to_variant_from_variant, "qx_need_to_specialize_template_convert_to_variant_from_variant"); // If a compilation error occurred here : you have to specialize template 'qx::cvt::detail::QxConvert_ToVariant< MyType >'
309 return QVariant();
310#endif // _QX_NO_JSON
311 }
312
313};
314
315template <typename T>
317{
318
319 enum { qx_need_to_specialize_template_convert_to_variant_from_variant = 0 };
320
321 static inline qx_bool fromVariant(const QVariant & v, T & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
322 {
323 Q_UNUSED(v); Q_UNUSED(t); Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx);
324#ifndef _QX_NO_JSON
325 return t.fromJson(v.toString(), format);
326#else // _QX_NO_JSON
327 static_assert(qx_need_to_specialize_template_convert_to_variant_from_variant, "qx_need_to_specialize_template_convert_to_variant_from_variant"); // If a compilation error occurred here : you have to specialize template 'qx::cvt::detail::QxConvert_FromVariant< MyType >'
328 return qx_bool(true);
329#endif // _QX_NO_JSON
330 }
331
332};
333
334#ifndef _QX_NO_JSON
335
336template <typename T>
338{
339 static inline QJsonValue toJson(const T & t, const QString & format)
340 { const qx::IxPersistable * p = static_cast<const qx::IxPersistable *>(& t); return qx::cvt::to_json((* p), format); }
341};
342
343template <typename T>
345{
346 static inline qx_bool fromJson(const QJsonValue & j, T & t, const QString & format)
347 { qx::IxPersistable * p = static_cast<qx::IxPersistable *>(& t); return qx::cvt::from_json(j, (* p), format); }
348};
349
350#endif // _QX_NO_JSON
351
352template <typename T>
354{
355 static inline QString toString(const T & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
356 { return (t ? qx::cvt::to_string((* t), format, index, ctx) : ""); }
357};
358
359template <typename T>
361{
362 static inline qx_bool fromString(const QString & s, T & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
363 { if (! t) { qx::trait::construct_ptr<T>::get(t); }; return (t ? qx::cvt::from_string(s, (* t), format, index, ctx) : qx_bool(false)); }
364};
365
366template <typename T>
368{
369 static inline QVariant toVariant(const T & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
370 { return (t ? qx::cvt::to_variant((* t), format, index, ctx) : QVariant()); }
371};
372
373template <typename T>
375{
376 static inline qx_bool fromVariant(const QVariant & v, T & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
377 { if (! t && ! v.isNull()) { qx::trait::construct_ptr<T>::get(t); } else if (v.isNull()) { qx::trait::construct_ptr<T>::get(t, true); }; return (t ? qx::cvt::from_variant(v, (* t), format, index, ctx) : qx_bool(false)); }
378};
379
380#ifndef _QX_NO_JSON
381
382template <typename T>
384{
385 static inline QJsonValue toJson(const T & t, const QString & format)
386 { return (t ? qx::cvt::to_json((* t), format) : QJsonValue()); }
387};
388
389template <typename T>
391{
392 static inline qx_bool fromJson(const QJsonValue & j, T & t, const QString & format)
393 { if (! t && ! j.isNull()) { qx::trait::construct_ptr<T>::get(t); } else if (j.isNull()) { qx::trait::construct_ptr<T>::get(t, true); }; return (t ? qx::cvt::from_json(j, (* t), format) : qx_bool(false)); }
394};
395
396#endif // _QX_NO_JSON
397
398template <typename T>
400{
401 static inline QString toString(const T & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
402 {
404 { qx::IxDataMember * pId = qx::QxClass<T>::getSingleton()->getDataMemberX()->getId_WithDaoStrategy(); return (pId ? pId->toVariant((& t), format, index, ctx).toString() : QString()); }
406 }
407};
408
409template <typename T>
411{
412 static inline qx_bool fromString(const QString & s, T & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
413 {
415 { qx::IxDataMember * pId = qx::QxClass<T>::getSingleton()->getDataMemberX()->getId_WithDaoStrategy(); QVariant tmp(s); return (pId ? pId->fromVariant((& t), tmp, format, index, ctx) : qx_bool(false)); }
417 }
418};
419
420template <typename T>
422{
423 static inline QVariant toVariant(const T & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
424 {
426 { qx::IxDataMember * pId = qx::QxClass<T>::getSingleton()->getDataMemberX()->getId_WithDaoStrategy(); return (pId ? pId->toVariant((& t), format, index, ctx) : QVariant()); }
428 }
429};
430
431template <typename T>
433{
434 static inline qx_bool fromVariant(const QVariant & v, T & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
435 {
437 { qx::IxDataMember * pId = qx::QxClass<T>::getSingleton()->getDataMemberX()->getId_WithDaoStrategy(); return (pId ? pId->fromVariant((& t), v, format, index, ctx) : qx_bool(false)); }
438 return qx::serialization::qt::from_byte_array<T>(t, v.toByteArray());
439 }
440};
441
442#ifndef _QX_NO_JSON
443
444template <typename T>
446{
447 static inline QJsonValue toJson(const T & t, const QString & format)
449};
450
451template <typename T>
453{
454 static inline qx_bool fromJson(const QJsonValue & j, T & t, const QString & format)
456};
457
458#endif // _QX_NO_JSON
459
460template <typename T>
462{
463 static inline QString toString(const T & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
464 { Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); return QX_CVT_DEFAULT_ARCHIVE::to_string(t); }
465};
466
467template <typename T>
469{
470 static inline qx_bool fromString(const QString & s, T & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
471 { Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); return QX_CVT_DEFAULT_ARCHIVE::from_string(t, s); }
472};
473
474template <typename T>
476{
477 static inline QVariant toVariant(const T & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
478 { Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); return QX_CVT_DEFAULT_ARCHIVE::to_string(t); }
479};
480
481template <typename T>
483{
484 static inline qx_bool fromVariant(const QVariant & v, T & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
485 { Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); return QX_CVT_DEFAULT_ARCHIVE::from_string(t, v.toString()); }
486};
487
488#ifndef _QX_NO_JSON
489
490template <typename T>
492{
493 static inline QJsonValue toJson(const T & t, const QString & format)
495};
496
497template <typename T>
499{
500 static inline qx_bool fromJson(const QJsonValue & j, T & t, const QString & format)
502};
503
504#endif // _QX_NO_JSON
505
506template <typename T>
508{
509 static inline QString toString(const T & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
510 { Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); return QString::number(static_cast<long>(t)); }
511};
512
513template <typename T>
515{
516 static inline qx_bool fromString(const QString & s, T & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
517 { Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); bool bOk = false; t = static_cast<T>(static_cast<long>(s.toLongLong(& bOk))); return bOk; }
518};
519
520template <typename T>
522{
523 static inline QVariant toVariant(const T & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
524 { Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); return QVariant(static_cast<qlonglong>(t)); }
525};
526
527template <typename T>
529{
530 static inline qx_bool fromVariant(const QVariant & v, T & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
531 { Q_UNUSED(format); Q_UNUSED(index); Q_UNUSED(ctx); bool bOk = false; t = static_cast<T>(static_cast<long>(v.toLongLong(& bOk))); return bOk; }
532};
533
534#ifndef _QX_NO_JSON
535
536template <typename T>
538{
539 static inline QJsonValue toJson(const T & t, const QString & format)
540 { Q_UNUSED(format); return QJsonValue(static_cast<int>(t)); }
541};
542
543template <typename T>
545{
546 static inline qx_bool fromJson(const QJsonValue & j, T & t, const QString & format)
547 { Q_UNUSED(format); t = static_cast<T>(static_cast<long>(qRound(j.toDouble()))); return qx_bool(true); }
548};
549
550#endif // _QX_NO_JSON
551
552template <typename T>
554{
555
556private:
557
559 typedef typename std::conditional< std::is_pointer<T>::value, qx::cvt::detail::helper::QxConvertHelper_Ptr, type_str_cvt_helper_0 >::type type_str_cvt_helper_1;
560 typedef typename std::conditional< qx::trait::is_smart_ptr<T>::value, qx::cvt::detail::helper::QxConvertHelper_Ptr, type_str_cvt_helper_1 >::type type_str_cvt_helper_2;
561 typedef typename std::conditional< qx::trait::is_container<T>::value, qx::cvt::detail::helper::QxConvertHelper_Container, type_str_cvt_helper_2 >::type type_str_cvt_helper_3;
562 typedef typename std::conditional< qx::trait::is_qx_registered<T>::value, qx::cvt::detail::helper::QxConvertHelper_Registered, type_str_cvt_helper_3 >::type type_str_cvt_helper_4;
563 typedef typename std::conditional< std::is_enum<T>::value, qx::cvt::detail::helper::QxConvertHelper_Enum, type_str_cvt_helper_4 >::type type_str_cvt_helper_5;
564
565public:
566
568
569};
570
571template <typename T>
573{
574 static inline QString toString(const T & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
576};
577
578template <typename T>
580{
581 static inline qx_bool fromString(const QString & s, T & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
583};
584
585template <typename T>
587{
588 static inline QVariant toVariant(const T & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
590};
591
592template <typename T>
594{
595 static inline qx_bool fromVariant(const QVariant & v, T & t, const QString & format, int index, qx::cvt::context::ctx_type ctx)
597};
598
599#ifndef _QX_NO_JSON
600
601template <typename T>
603{
604 static inline QJsonValue toJson(const T & t, const QString & format)
606};
607
608template <typename T>
610{
611 static inline qx_bool fromJson(const QJsonValue & j, T & t, const QString & format)
613};
614
615#endif // _QX_NO_JSON
616
617} // namespace detail
618} // namespace cvt
619} // namespace qx
620
621#include "../../inl/QxConvert/QxConvert_WithIndex.inl"
622#include "../../inl/QxConvert/QxConvert_ToString.inl"
623#include "../../inl/QxConvert/QxConvert_FromString.inl"
624#include "../../inl/QxConvert/QxConvert_ToVariant.inl"
625#include "../../inl/QxConvert/QxConvert_FromVariant.inl"
626#include "../../inl/QxConvert/QxConvert_ToJson.inl"
627#include "../../inl/QxConvert/QxConvert_FromJson.inl"
628#include "../../inl/QxConvert/QxConvert_Qt.inl"
629
630#endif // _QX_CONVERT_IMPL_H_
Common interface (abstract class) for persistents classes using QX_PERSISTABLE_HPP() and QX_PERSISTAB...
Provide some tools to serialize a class registered into QxOrm context into/from binary/XML archive (f...
qx_bool : QxOrm library boolean type with code and description message when an error occured
qx::QxBool qx_bool
Definition QxBool.h:150
Concrete class registered into QxOrm context.
QxOrm thread-safe container (keep insertion order + quick access by index + quick access by key)
qx::cvt : namespace to provide global functions to convert any kind of objects to/from QString and QV...
Helper class to store a date value into database under neutral format (YYYYMMDD) => cross database co...
Helper class to store a date-time value into database under neutral format (YYYYMMDDHHMMSS) => cross ...
Invalid value when a property fails to pass a constraint.
List of invalid values.
#define qAssertMsg(test, where, what)
Definition QxMacro.h:60
Used when _QX_ENABLE_BOOST_SERIALIZATION compilation option is not defined to provide serialization e...
Include all Qt QDataStream serialization method (save/load) provided by QxOrm library.
Provide a generic Qt QJson serialization method (save/load) for classes registered into QxOrm context...
Define a user SQL query added to default SQL query builded by QxOrm library, and used by qx::dao::xxx...
Helper class to store a time value into database under neutral format (HHMMSS) => cross database comp...
qx::IxDataMember : common interface for all class properties registered into QxOrm context
virtual qx_bool fromVariant(void *pOwner, const QVariant &v, const QString &sFormat, int iIndexName=-1, qx::cvt::context::ctx_type ctx=qx::cvt::context::e_no_context)=0
virtual QVariant toVariant(const void *pOwner, const QString &sFormat, int iIndexName=-1, qx::cvt::context::ctx_type ctx=qx::cvt::context::e_no_context) const =0
qx::IxPersistable : common interface (abstract class) for persistents classes using QX_PERSISTABLE_HP...
qx_bool : boolean type with code and description message when an error occured
Definition QxBool.h:71
qx::trait::construct_ptr<T>::get(T & t, bool bReset = false) : instantiate (or reset) a new pointer,...
qx::trait::generic_container<T> : provide some tools to manage all containers without knowing its typ...
Register all primitive and useful types of stl, boost and Qt libraries using QX_REGISTER_CLASS_NAME(T...
qx::trait::is_container<T>::value : return true if T is a container from stl, boost,...
qx::trait::is_qt_variant_compatible<T>::value : return true if T can be host into a QVariant object o...
qx::trait::is_qx_registered<T>::value : return true if T is registered into QxOrm context to provide ...
qx::trait::is_smart_ptr<T>::value : return true if T is a smart-pointer of boost, Qt or QxOrm librari...
bool checkConvertQVariantToString(const QVariant &v)
qx_bool from_variant(const QVariant &v, T &t, const QString &format=QString(), int index=-1, qx::cvt::context::ctx_type ctx=qx::cvt::context::e_no_context)
Definition QxConvert.h:80
QVariant to_variant(const T &t, const QString &format=QString(), int index=-1, qx::cvt::context::ctx_type ctx=qx::cvt::context::e_no_context)
Definition QxConvert.h:79
QString to_string(const T &t, const QString &format=QString(), int index=-1, qx::cvt::context::ctx_type ctx=qx::cvt::context::e_no_context)
Definition QxConvert.h:77
qx_bool from_json(const QJsonValue &j, T &t, const QString &format=QString())
Definition QxConvert.h:84
qx_bool from_string(const QString &s, T &t, const QString &format=QString(), int index=-1, qx::cvt::context::ctx_type ctx=qx::cvt::context::e_no_context)
Definition QxConvert.h:78
QJsonValue to_json(const T &t, const QString &format=QString())
Definition QxConvert.h:83
QString to_string(const T &obj, unsigned int flags=1)
qx_bool from_string(T &obj, const QString &sString, unsigned int flags=1)
qx_bool from_byte_array(T &obj, const QByteArray &data, unsigned int flags=1)
QByteArray to_byte_array(const T &obj, void *owner=NULL, unsigned int flags=1)
Root namespace for all QxOrm library features.
static qx_bool fromJson(const QJsonValue &j, T &t, const QString &format)
static qx_bool fromString(const QString &s, T &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
static qx_bool fromVariant(const QVariant &v, T &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
static QJsonValue toJson(const T &t, const QString &format)
static QString toString(const T &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
static QVariant toVariant(const T &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
static qx_bool fromJson(const QJsonValue &j, T &t, const QString &format)
static qx_bool fromJson(const QJsonValue &j, T &t, const QString &format)
static qx_bool fromJson(const QJsonValue &j, T &t, const QString &format)
static qx_bool fromJson(const QJsonValue &j, T &t, const QString &format)
static qx_bool fromString(const QString &s, T &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
static qx_bool fromString(const QString &s, T &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
static qx_bool fromString(const QString &s, T &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
static qx_bool fromString(const QString &s, T &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
static qx_bool fromString(const QString &s, T &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
static qx_bool fromString(const QString &s, T &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
static qx_bool fromString(const QString &s, T &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
static qx_bool fromVariant(const QVariant &v, T &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
static qx_bool fromVariant(const QVariant &v, T &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
static qx_bool fromVariant(const QVariant &v, T &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
static qx_bool fromVariant(const QVariant &v, T &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
static qx_bool fromVariant(const QVariant &v, T &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
static qx_bool fromVariant(const QVariant &v, T &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
static qx_bool fromVariant(const QVariant &v, T &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
static qx_bool fromVariant(const QVariant &v, T &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
static qx_bool fromVariant(const QVariant &v, T &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
static QJsonValue toJson(const T &t, const QString &format)
static QString toString(const T &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
static QString toString(const T &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
static QString toString(const T &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
static QString toString(const T &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
static QString toString(const T &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
static QString toString(const T &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
static QString toString(const T &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
static QVariant toVariant(const T &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
static QVariant toVariant(const T &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
static QVariant toVariant(const T &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
static QVariant toVariant(const T &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
static QVariant toVariant(const T &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
static QVariant toVariant(const T &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
static QVariant toVariant(const T &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
static QVariant toVariant(const T &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
static QVariant toVariant(const T &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
std::conditional< qx::trait::is_ix_persistable< T >::value, qx::cvt::detail::helper::QxConvertHelper_Persistable, qx::cvt::detail::helper::QxConvertHelper_Generic >::type type_str_cvt_helper_0
std::conditional< std::is_enum< T >::value, qx::cvt::detail::helper::QxConvertHelper_Enum, type_str_cvt_helper_4 >::type type_str_cvt_helper_5
std::conditional< qx::trait::is_qx_registered< T >::value, qx::cvt::detail::helper::QxConvertHelper_Registered, type_str_cvt_helper_3 >::type type_str_cvt_helper_4
std::conditional< qx::trait::is_smart_ptr< T >::value, qx::cvt::detail::helper::QxConvertHelper_Ptr, type_str_cvt_helper_1 >::type type_str_cvt_helper_2
std::conditional< std::is_pointer< T >::value, qx::cvt::detail::helper::QxConvertHelper_Ptr, type_str_cvt_helper_0 >::type type_str_cvt_helper_1
QxConvertHelper< T >::type_str_cvt_helper_5 type
std::conditional< qx::trait::is_container< T >::value, qx::cvt::detail::helper::QxConvertHelper_Container, type_str_cvt_helper_2 >::type type_str_cvt_helper_3
static QJsonValue save(const T &t, const QString &format)
static qx_bool load(const QJsonValue &j, T &t, const QString &format)
static void get(T &t, bool bReset=false)