32#ifndef _QX_ENABLE_BOOST
33#ifndef _QX_BOOST_OPTIONAL_ONLY_H_
34#define _QX_BOOST_OPTIONAL_ONLY_H_
47#include <boost/optional.hpp>
48#include <boost/none.hpp>
52#define _QX_ENABLE_BOOST
54#undef _QX_ENABLE_BOOST
64struct get_sql_type<
boost::optional<T> >
76template <
typename T>
struct QxConvert_ToJson<
boost::optional<T> > {
77static inline QJsonValue
toJson(
const boost::optional<T> & t,
const QString & format)
78{
if (t) {
return qx::cvt::to_json((* t), format); };
return QJsonValue(); } };
80template <
typename T>
struct QxConvert_FromJson<
boost::optional<T> > {
81static inline qx_bool fromJson(
const QJsonValue & j, boost::optional<T> & t,
const QString & format)
83 if (j.isNull()) { t = boost::none;
return qx_bool(
true); }
84 else if (! t) { t = T(); }
90template <
typename T>
struct QxConvert_ToString<
boost::optional<T> > {
92{
if (t) {
return qx::cvt::to_string((* t), format, index, ctx); };
return QString(); } };
94template <
typename T>
struct QxConvert_FromString<
boost::optional<T> > {
98template <
typename T>
struct QxConvert_ToVariant<
boost::optional<T> > {
102template <
typename T>
struct QxConvert_FromVariant<
boost::optional<T> > {
105 if (v.isNull()) { t = boost::none;
return qx_bool(
true); }
106 else if (! t) { t = T(); }
Provide a Qt QDataStream serialization method (save/load) for type boost::optional<T>
qx_bool : boolean type with code and description message when an error occured
qx::trait::construct_null_qvariant<T>::get() : create a NULL QVariant which matches QVariant::Type wi...
#define QX_REGISTER_CLASS_NAME_TEMPLATE_1(className)
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)
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)
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)
qx_bool from_json(const QJsonValue &j, T &t, const QString &format=QString())
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)
QJsonValue to_json(const T &t, const QString &format=QString())
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 const char * get()