32#ifndef _QX_STD_OPTIONAL_H_
33#define _QX_STD_OPTIONAL_H_
48#include <QtCore/qdatastream.h>
55QDataStream &
operator<< (QDataStream & stream,
const std::optional<T> & t)
57 qint8 iHasData = (t ? 1 : 0);
59 if (t) { stream << (* t); }
64QDataStream &
operator>> (QDataStream & stream, std::optional<T> & t)
68 if (iHasData) { t = T(); stream >> (* t); }
69 else { t = std::optional<T>(); }
92static inline QJsonValue
toJson(
const std::optional<T> & t,
const QString & format)
93{
if (t) {
return qx::cvt::to_json((* t), format); };
return QJsonValue(); } };
96static inline qx_bool fromJson(
const QJsonValue & j, std::optional<T> & t,
const QString & format)
98 if (j.isNull()) { t = std::optional<T>();
return qx_bool(
true); }
99 else if (! t) { t = T(); }
107{
if (t) {
return qx::cvt::to_string((* t), format, index, ctx); };
return QString(); } };
120 if (v.isNull()) { t = std::optional<T>();
return qx_bool(
true); }
121 else if (! t) { t = T(); }
QDataStream & operator>>(QDataStream &stream, std::optional< T > &t)
QDataStream & operator<<(QDataStream &stream, const std::optional< T > &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, std::optional< T > &t, const QString &format)
static qx_bool fromString(const QString &s, std::optional< T > &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
static qx_bool fromVariant(const QVariant &v, std::optional< T > &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
static QJsonValue toJson(const std::optional< T > &t, const QString &format)
static QString toString(const std::optional< T > &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
static QVariant toVariant(const std::optional< T > &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
static const char * get()
qx::trait::get_sql_type<T>::get() : return type name under const char * format used by database engin...
static const char * get()