first commit
This commit is contained in:
413
inl/QxConvert/QxConvert_FromJson.inl
Normal file
413
inl/QxConvert/QxConvert_FromJson.inl
Normal file
@@ -0,0 +1,413 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** https://www.qxorm.com/
|
||||
** Copyright (C) 2013 XDL Team (ic-east.com)
|
||||
**
|
||||
** This file is part of the QxOrm library
|
||||
**
|
||||
** This software is provided 'as-is', without any express or implied
|
||||
** warranty. In no event will the authors be held liable for any
|
||||
** damages arising from the use of this software
|
||||
**
|
||||
** Commercial Usage
|
||||
** Licensees holding valid commercial QxOrm licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and XDL Team
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3.0 as published by the Free Software
|
||||
** Foundation and appearing in the file 'license.gpl3.txt' included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU General Public License version 3.0 requirements will be
|
||||
** met : http://www.gnu.org/copyleft/gpl.html
|
||||
**
|
||||
** If you are unsure which license is appropriate for your use, or
|
||||
** if you have questions regarding the use of this file, please contact :
|
||||
** ic-east.com
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef _QX_NO_JSON
|
||||
|
||||
namespace qx
|
||||
{
|
||||
namespace cvt
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template <>
|
||||
struct QxConvert_FromJson<qx::trait::no_type>
|
||||
{
|
||||
static inline qx_bool fromJson(const QJsonValue &j, qx::trait::no_type &t, const QString &format)
|
||||
{
|
||||
Q_UNUSED(j);
|
||||
Q_UNUSED(t);
|
||||
Q_UNUSED(format);
|
||||
return qx_bool(true);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_FromJson<bool>
|
||||
{
|
||||
static inline qx_bool fromJson(const QJsonValue &j, bool &t, const QString &format)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
t = j.toBool();
|
||||
return qx_bool(true);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_FromJson<short>
|
||||
{
|
||||
static inline qx_bool fromJson(const QJsonValue &j, short &t, const QString &format)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
t = static_cast<short>(qRound(j.toDouble()));
|
||||
return qx_bool(true);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_FromJson<int>
|
||||
{
|
||||
static inline qx_bool fromJson(const QJsonValue &j, int &t, const QString &format)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
t = qRound(j.toDouble());
|
||||
return qx_bool(true);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_FromJson<long>
|
||||
{
|
||||
static inline qx_bool fromJson(const QJsonValue &j, long &t, const QString &format)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
t = static_cast<long>(qRound64(j.toDouble()));
|
||||
return qx_bool(true);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_FromJson<long long>
|
||||
{
|
||||
static inline qx_bool fromJson(const QJsonValue &j, long long &t, const QString &format)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
t = static_cast<long long>(qRound64(j.toDouble()));
|
||||
return qx_bool(true);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_FromJson<float>
|
||||
{
|
||||
static inline qx_bool fromJson(const QJsonValue &j, float &t, const QString &format)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
t = static_cast<float>(j.toDouble());
|
||||
return qx_bool(true);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_FromJson<double>
|
||||
{
|
||||
static inline qx_bool fromJson(const QJsonValue &j, double &t, const QString &format)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
t = j.toDouble();
|
||||
return qx_bool(true);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_FromJson<unsigned short>
|
||||
{
|
||||
static inline qx_bool fromJson(const QJsonValue &j, unsigned short &t, const QString &format)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
t = static_cast<unsigned short>(qRound(j.toDouble()));
|
||||
return qx_bool(true);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_FromJson<unsigned int>
|
||||
{
|
||||
static inline qx_bool fromJson(const QJsonValue &j, unsigned int &t, const QString &format)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
t = static_cast<unsigned int>(qRound(j.toDouble()));
|
||||
return qx_bool(true);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_FromJson<unsigned long>
|
||||
{
|
||||
static inline qx_bool fromJson(const QJsonValue &j, unsigned long &t, const QString &format)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
t = static_cast<unsigned long>(qRound64(j.toDouble()));
|
||||
return qx_bool(true);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_FromJson<unsigned long long>
|
||||
{
|
||||
static inline qx_bool fromJson(const QJsonValue &j, unsigned long long &t, const QString &format)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
t = static_cast<unsigned long long>(qRound64(j.toDouble()));
|
||||
return qx_bool(true);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_FromJson<QDateTime>
|
||||
{
|
||||
static inline qx_bool fromJson(const QJsonValue &j, QDateTime &t, const QString &format)
|
||||
{
|
||||
#ifdef _QX_ENABLE_MONGODB
|
||||
if (j.isObject() && format.startsWith("mongodb"))
|
||||
{
|
||||
QJsonObject obj = j.toObject();
|
||||
QString dt;
|
||||
if (obj.contains("$date"))
|
||||
{
|
||||
dt = obj.value("$date").toString();
|
||||
}
|
||||
if (!dt.isEmpty())
|
||||
{
|
||||
t = QDateTime::fromString(dt, QX_JSON_DATE_TIME_FORMAT);
|
||||
return qx_bool(true);
|
||||
}
|
||||
}
|
||||
#endif // _QX_ENABLE_MONGODB
|
||||
|
||||
Q_UNUSED(format);
|
||||
t = (j.isNull() ? QDateTime() : QDateTime::fromString(j.toString(), QX_JSON_DATE_TIME_FORMAT));
|
||||
return qx_bool(true);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_FromJson<QDate>
|
||||
{
|
||||
static inline qx_bool fromJson(const QJsonValue &j, QDate &t, const QString &format)
|
||||
{
|
||||
#ifdef _QX_ENABLE_MONGODB
|
||||
if (j.isObject() && format.startsWith("mongodb"))
|
||||
{
|
||||
QDateTime dt;
|
||||
QxConvert_FromJson<QDateTime>::fromJson(j, dt, format);
|
||||
t = dt.date();
|
||||
return qx_bool(true);
|
||||
}
|
||||
#endif // _QX_ENABLE_MONGODB
|
||||
|
||||
Q_UNUSED(format);
|
||||
t = (j.isNull() ? QDate() : QDate::fromString(j.toString(), Qt::ISODate));
|
||||
return qx_bool(true);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_FromJson<QTime>
|
||||
{
|
||||
static inline qx_bool fromJson(const QJsonValue &j, QTime &t, const QString &format)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
t = (j.isNull() ? QTime() : QTime::fromString(j.toString(), QX_JSON_DATE_TIME_FORMAT));
|
||||
return qx_bool(true);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_FromJson<QByteArray>
|
||||
{
|
||||
static inline qx_bool fromJson(const QJsonValue &j, QByteArray &t, const QString &format)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
t = QByteArray::fromBase64(j.toString().toLatin1());
|
||||
return qx_bool(true);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_FromJson<QString>
|
||||
{
|
||||
static inline qx_bool fromJson(const QJsonValue &j, QString &t, const QString &format)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
t = j.toString();
|
||||
|
||||
#ifdef _QX_ENABLE_MONGODB
|
||||
if (t.isEmpty() && j.isObject() && format.startsWith("mongodb"))
|
||||
{
|
||||
QJsonObject obj = j.toObject();
|
||||
if (obj.contains("$oid"))
|
||||
{
|
||||
t = obj.value("$oid").toString();
|
||||
}
|
||||
if (!t.isEmpty())
|
||||
{
|
||||
t = "qx_oid:" + t;
|
||||
}
|
||||
}
|
||||
#endif // _QX_ENABLE_MONGODB
|
||||
|
||||
return qx_bool(true);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_FromJson<QVariant>
|
||||
{
|
||||
static inline qx_bool fromJson(const QJsonValue &j, QVariant &t, const QString &format)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
t = j.toVariant();
|
||||
return qx_bool(true);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_FromJson<QUuid>
|
||||
{
|
||||
static inline qx_bool fromJson(const QJsonValue &j, QUuid &t, const QString &format)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
t = QUuid(j.toString());
|
||||
return qx_bool(true);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_FromJson<qx::QxDateNeutral>
|
||||
{
|
||||
static inline qx_bool fromJson(const QJsonValue &j, qx::QxDateNeutral &t, const QString &format)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
t = qx::QxDateNeutral::fromNeutral(j.toString());
|
||||
return qx_bool(true);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_FromJson<qx::QxTimeNeutral>
|
||||
{
|
||||
static inline qx_bool fromJson(const QJsonValue &j, qx::QxTimeNeutral &t, const QString &format)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
t = qx::QxTimeNeutral::fromNeutral(j.toString());
|
||||
return qx_bool(true);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_FromJson<qx::QxDateTimeNeutral>
|
||||
{
|
||||
static inline qx_bool fromJson(const QJsonValue &j, qx::QxDateTimeNeutral &t, const QString &format)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
t = qx::QxDateTimeNeutral::fromNeutral(j.toString());
|
||||
return qx_bool(true);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_FromJson<std::string>
|
||||
{
|
||||
static inline qx_bool fromJson(const QJsonValue &j, std::string &t, const QString &format)
|
||||
#ifndef QT_NO_STL
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
t = j.toString().toStdString();
|
||||
return qx_bool(true);
|
||||
}
|
||||
};
|
||||
#else // QT_NO_STL
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
t = j.toString().toLatin1().constData();
|
||||
return qx_bool(true);
|
||||
}
|
||||
};
|
||||
#endif // QT_NO_STL
|
||||
|
||||
template <>
|
||||
struct QxConvert_FromJson<std::wstring>
|
||||
{
|
||||
static inline qx_bool fromJson(const QJsonValue &j, std::wstring &t, const QString &format)
|
||||
#if ((!defined(QT_NO_STL)) && (!defined(QT_NO_STL_WCHAR)))
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
t = j.toString().toStdWString();
|
||||
return qx_bool(true);
|
||||
}
|
||||
};
|
||||
#else // ((! defined(QT_NO_STL)) && (! defined(QT_NO_STL_WCHAR)))
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(t);
|
||||
Q_UNUSED(j);
|
||||
qAssert(false); /* Need STL compatibility ! */
|
||||
return qx_bool(true);
|
||||
}
|
||||
};
|
||||
#endif // ((! defined(QT_NO_STL)) && (! defined(QT_NO_STL_WCHAR)))
|
||||
|
||||
template <>
|
||||
struct QxConvert_FromJson<qx_bool>
|
||||
{
|
||||
static inline qx_bool fromJson(const QJsonValue &j, qx_bool &t, const QString &format)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
t = qx_bool();
|
||||
if (j.isObject())
|
||||
{
|
||||
QJsonObject obj = j.toObject();
|
||||
t.setValue(obj["value"].toBool());
|
||||
t.setCode(static_cast<long>(qRound64(obj["code"].toDouble())));
|
||||
t.setDesc(obj["desc"].toString());
|
||||
}
|
||||
return qx_bool(true);
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef _QX_ENABLE_BOOST
|
||||
|
||||
template <typename T>
|
||||
struct QxConvert_FromJson<boost::optional<T>>
|
||||
{
|
||||
static inline qx_bool fromJson(const QJsonValue &j, boost::optional<T> &t, const QString &format)
|
||||
{
|
||||
if (j.isNull())
|
||||
{
|
||||
t = boost::none;
|
||||
return qx_bool(true);
|
||||
}
|
||||
else if (!t)
|
||||
{
|
||||
t = T();
|
||||
}
|
||||
return qx::cvt::from_json(j, (*t), format);
|
||||
}
|
||||
};
|
||||
|
||||
#endif // _QX_ENABLE_BOOST
|
||||
|
||||
} // namespace detail
|
||||
} // namespace cvt
|
||||
} // namespace qx
|
||||
|
||||
#endif // _QX_NO_JSON
|
||||
979
inl/QxConvert/QxConvert_FromString.inl
Normal file
979
inl/QxConvert/QxConvert_FromString.inl
Normal file
@@ -0,0 +1,979 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** https://www.qxorm.com/
|
||||
** Copyright (C) 2013 XDL Team (ic-east.com)
|
||||
**
|
||||
** This file is part of the QxOrm library
|
||||
**
|
||||
** This software is provided 'as-is', without any express or implied
|
||||
** warranty. In no event will the authors be held liable for any
|
||||
** damages arising from the use of this software
|
||||
**
|
||||
** Commercial Usage
|
||||
** Licensees holding valid commercial QxOrm licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and XDL Team
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3.0 as published by the Free Software
|
||||
** Foundation and appearing in the file 'license.gpl3.txt' included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU General Public License version 3.0 requirements will be
|
||||
** met : http://www.gnu.org/copyleft/gpl.html
|
||||
**
|
||||
** If you are unsure which license is appropriate for your use, or
|
||||
** if you have questions regarding the use of this file, please contact :
|
||||
** ic-east.com
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
namespace qx
|
||||
{
|
||||
namespace cvt
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template <>
|
||||
struct QxConvert_FromString<qx::trait::no_type>
|
||||
{
|
||||
static inline qx_bool fromString(const QString &s, qx::trait::no_type &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(s);
|
||||
Q_UNUSED(t);
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return qx_bool(true);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_FromString<QString>
|
||||
{
|
||||
static inline qx_bool fromString(const QString &s, QString &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
t = s;
|
||||
return qx_bool(true);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_FromString<QUuid>
|
||||
{
|
||||
static inline qx_bool fromString(const QString &s, QUuid &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
t = QUuid(s);
|
||||
return qx_bool(true);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_FromString<QDate>
|
||||
{
|
||||
static inline qx_bool fromString(const QString &s, QDate &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
t = QDate::fromString(s, (format.isEmpty() ? QString(QX_STR_CVT_QDATE_FORMAT) : format));
|
||||
return t.isValid();
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_FromString<QTime>
|
||||
{
|
||||
static inline qx_bool fromString(const QString &s, QTime &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
t = QTime::fromString(s, (format.isEmpty() ? QString(QX_STR_CVT_QTIME_FORMAT) : format));
|
||||
return t.isValid();
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_FromString<QDateTime>
|
||||
{
|
||||
static inline qx_bool fromString(const QString &s, QDateTime &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
t = QDateTime::fromString(s, (format.isEmpty() ? QString(QX_STR_CVT_QDATETIME_FORMAT) : format));
|
||||
return t.isValid();
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_FromString<QByteArray>
|
||||
{
|
||||
static inline qx_bool fromString(const QString &s, QByteArray &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
t = s.toLatin1();
|
||||
return qx_bool(true);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_FromString<QVariant>
|
||||
{
|
||||
static inline qx_bool fromString(const QString &s, QVariant &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
|
||||
#ifndef _QX_NO_JSON
|
||||
if (s.startsWith("$$JSON$$"))
|
||||
{
|
||||
QJsonParseError err;
|
||||
QString stream = s.right(s.size() - 16); // $$JSON$$0000XX$$
|
||||
QJsonDocument doc = QJsonDocument::fromJson(stream.toUtf8(), (&err));
|
||||
if (err.error == QJsonParseError::NoError)
|
||||
{
|
||||
QJsonValue json = (doc.isArray() ? QJsonValue(doc.array()) : QJsonValue(doc.object()));
|
||||
t = json.toVariant();
|
||||
return qx_bool(true);
|
||||
}
|
||||
}
|
||||
#endif // _QX_NO_JSON
|
||||
|
||||
t = QVariant(s);
|
||||
return qx_bool(true);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_FromString<qx_bool>
|
||||
{
|
||||
static inline qx_bool fromString(const QString &s, qx_bool &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
t.fromString(s);
|
||||
return qx_bool(true);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_FromString<bool>
|
||||
{
|
||||
static inline qx_bool fromString(const QString &s, bool &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
t = (((s == "0") || s.trimmed().isEmpty()) ? false : true);
|
||||
return qx_bool(true);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_FromString<char>
|
||||
{
|
||||
static inline qx_bool fromString(const QString &s, char &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
t = (s.isEmpty() ? ' ' : s.toLatin1().at(0));
|
||||
return (!s.isEmpty());
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_FromString<short>
|
||||
{
|
||||
static inline qx_bool fromString(const QString &s, short &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
bool bOk = false;
|
||||
t = s.toShort(&bOk);
|
||||
return bOk;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_FromString<int>
|
||||
{
|
||||
static inline qx_bool fromString(const QString &s, int &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
bool bOk = false;
|
||||
t = s.toInt(&bOk);
|
||||
return bOk;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_FromString<long>
|
||||
{
|
||||
static inline qx_bool fromString(const QString &s, long &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
bool bOk = false;
|
||||
t = static_cast<long>(s.toLongLong(&bOk));
|
||||
return bOk;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_FromString<long long>
|
||||
{
|
||||
static inline qx_bool fromString(const QString &s, long long &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
bool bOk = false;
|
||||
t = static_cast<long long>(s.toLongLong(&bOk));
|
||||
return bOk;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_FromString<float>
|
||||
{
|
||||
static inline qx_bool fromString(const QString &s, float &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
bool bOk = false;
|
||||
t = static_cast<float>(s.toDouble(&bOk));
|
||||
return bOk;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_FromString<double>
|
||||
{
|
||||
static inline qx_bool fromString(const QString &s, double &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
bool bOk = false;
|
||||
t = s.toDouble(&bOk);
|
||||
return bOk;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_FromString<unsigned short>
|
||||
{
|
||||
static inline qx_bool fromString(const QString &s, unsigned short &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
bool bOk = false;
|
||||
t = static_cast<unsigned short>(s.toUShort(&bOk));
|
||||
return bOk;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_FromString<unsigned int>
|
||||
{
|
||||
static inline qx_bool fromString(const QString &s, unsigned int &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
bool bOk = false;
|
||||
t = static_cast<unsigned int>(s.toUInt(&bOk));
|
||||
return bOk;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_FromString<unsigned long>
|
||||
{
|
||||
static inline qx_bool fromString(const QString &s, unsigned long &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
bool bOk = false;
|
||||
t = static_cast<unsigned long>(s.toULongLong(&bOk));
|
||||
return bOk;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_FromString<unsigned long long>
|
||||
{
|
||||
static inline qx_bool fromString(const QString &s, unsigned long long &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
bool bOk = false;
|
||||
t = static_cast<unsigned long long>(s.toULongLong(&bOk));
|
||||
return bOk;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_FromString<qx::QxDateNeutral>
|
||||
{
|
||||
static inline qx_bool fromString(const QString &s, qx::QxDateNeutral &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
t = qx::QxDateNeutral::fromNeutral(s);
|
||||
return qx_bool(true);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_FromString<qx::QxTimeNeutral>
|
||||
{
|
||||
static inline qx_bool fromString(const QString &s, qx::QxTimeNeutral &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
t = qx::QxTimeNeutral::fromNeutral(s);
|
||||
return qx_bool(true);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_FromString<qx::QxDateTimeNeutral>
|
||||
{
|
||||
static inline qx_bool fromString(const QString &s, qx::QxDateTimeNeutral &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
t = qx::QxDateTimeNeutral::fromNeutral(s);
|
||||
return qx_bool(true);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_FromString<std::string>
|
||||
{
|
||||
static inline qx_bool fromString(const QString &s, std::string &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
#ifndef QT_NO_STL
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
t = s.toStdString();
|
||||
return qx_bool(true);
|
||||
}
|
||||
};
|
||||
#else // QT_NO_STL
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
t = s.toLatin1().constData();
|
||||
return qx_bool(true);
|
||||
}
|
||||
};
|
||||
#endif // QT_NO_STL
|
||||
|
||||
template <>
|
||||
struct QxConvert_FromString<std::wstring>
|
||||
{
|
||||
static inline qx_bool fromString(const QString &s, std::wstring &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
#if ((!defined(QT_NO_STL)) && (!defined(QT_NO_STL_WCHAR)))
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
t = s.toStdWString();
|
||||
return qx_bool(true);
|
||||
}
|
||||
};
|
||||
#else // ((! defined(QT_NO_STL)) && (! defined(QT_NO_STL_WCHAR)))
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
Q_UNUSED(t);
|
||||
Q_UNUSED(s);
|
||||
qAssert(false); /* Need STL compatibility ! */
|
||||
return qx_bool(true);
|
||||
}
|
||||
};
|
||||
#endif // ((! defined(QT_NO_STL)) && (! defined(QT_NO_STL_WCHAR)))
|
||||
|
||||
#ifndef _QX_NO_JSON
|
||||
|
||||
template <>
|
||||
struct QxConvert_FromString<QJsonValue>
|
||||
{
|
||||
static inline qx_bool fromString(const QString &s, QJsonValue &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
QJsonParseError jsonError;
|
||||
QByteArray dataAsByteArray = s.toUtf8();
|
||||
QJsonDocument doc = QJsonDocument::fromJson(dataAsByteArray, (&jsonError));
|
||||
if (jsonError.error != QJsonParseError::NoError)
|
||||
{
|
||||
return qx_bool(static_cast<long>(jsonError.error), jsonError.errorString());
|
||||
}
|
||||
t = (doc.isArray() ? QJsonValue(doc.array()) : QJsonValue(doc.object()));
|
||||
return qx_bool(true);
|
||||
}
|
||||
};
|
||||
|
||||
#endif // _QX_NO_JSON
|
||||
|
||||
#ifdef _QX_ENABLE_BOOST
|
||||
|
||||
template <typename T>
|
||||
struct QxConvert_FromString<boost::optional<T>>
|
||||
{
|
||||
static inline qx_bool fromString(const QString &s, boost::optional<T> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
if (!t)
|
||||
{
|
||||
t = T();
|
||||
};
|
||||
return qx::cvt::from_string(s, (*t), format, index, ctx);
|
||||
}
|
||||
};
|
||||
|
||||
#endif // _QX_ENABLE_BOOST
|
||||
|
||||
template <typename T1, typename T2>
|
||||
struct QxConvert_FromString<std::pair<T1, T2>>
|
||||
{
|
||||
static inline qx_bool fromString(const QString &s, std::pair<T1, T2> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE::from_string(t, s);
|
||||
}
|
||||
};
|
||||
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
|
||||
template <typename T1, typename T2>
|
||||
struct QxConvert_FromString<QPair<T1, T2>>
|
||||
{
|
||||
static inline qx_bool fromString(const QString &s, QPair<T1, T2> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE::from_string(t, s);
|
||||
}
|
||||
};
|
||||
#endif // (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
|
||||
|
||||
template <typename T>
|
||||
struct QxConvert_FromString<std::vector<T>>
|
||||
{
|
||||
static inline qx_bool fromString(const QString &s, std::vector<T> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE::from_string(t, s);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct QxConvert_FromString<std::list<T>>
|
||||
{
|
||||
static inline qx_bool fromString(const QString &s, std::list<T> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE::from_string(t, s);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct QxConvert_FromString<std::set<T>>
|
||||
{
|
||||
static inline qx_bool fromString(const QString &s, std::set<T> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE::from_string(t, s);
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef _QX_ENABLE_BOOST
|
||||
|
||||
template <typename T>
|
||||
struct QxConvert_FromString<boost::unordered_set<T>>
|
||||
{
|
||||
static inline qx_bool fromString(const QString &s, boost::unordered_set<T> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE::from_string(t, s);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct QxConvert_FromString<boost::unordered_multiset<T>>
|
||||
{
|
||||
static inline qx_bool fromString(const QString &s, boost::unordered_multiset<T> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE::from_string(t, s);
|
||||
}
|
||||
};
|
||||
|
||||
#endif // _QX_ENABLE_BOOST
|
||||
|
||||
template <typename T>
|
||||
struct QxConvert_FromString<std::unordered_set<T>>
|
||||
{
|
||||
static inline qx_bool fromString(const QString &s, std::unordered_set<T> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE::from_string(t, s);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct QxConvert_FromString<std::unordered_multiset<T>>
|
||||
{
|
||||
static inline qx_bool fromString(const QString &s, std::unordered_multiset<T> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE::from_string(t, s);
|
||||
}
|
||||
};
|
||||
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
|
||||
template <typename T>
|
||||
struct QxConvert_FromString<QVector<T>>
|
||||
{
|
||||
static inline qx_bool fromString(const QString &s, QVector<T> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE::from_string(t, s);
|
||||
}
|
||||
};
|
||||
#endif // (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
|
||||
|
||||
template <typename T>
|
||||
struct QxConvert_FromString<QList<T>>
|
||||
{
|
||||
static inline qx_bool fromString(const QString &s, QList<T> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE::from_string(t, s);
|
||||
}
|
||||
};
|
||||
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 0))
|
||||
template <typename T>
|
||||
struct QxConvert_FromString<QLinkedList<T>>
|
||||
{
|
||||
static inline qx_bool fromString(const QString &s, QLinkedList<T> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE::from_string(t, s);
|
||||
}
|
||||
};
|
||||
#endif // (QT_VERSION < QT_VERSION_CHECK(5, 15, 0))
|
||||
|
||||
template <typename T>
|
||||
struct QxConvert_FromString<QFlags<T>>
|
||||
{
|
||||
static inline qx_bool fromString(const QString &s, QFlags<T> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
t = QFlags<T>(QFlag(s.toInt()));
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Key, typename Value>
|
||||
struct QxConvert_FromString<std::map<Key, Value>>
|
||||
{
|
||||
static inline qx_bool fromString(const QString &s, std::map<Key, Value> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE::from_string(t, s);
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef _QX_ENABLE_BOOST
|
||||
|
||||
template <typename Key, typename Value>
|
||||
struct QxConvert_FromString<boost::unordered_map<Key, Value>>
|
||||
{
|
||||
static inline qx_bool fromString(const QString &s, boost::unordered_map<Key, Value> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE::from_string(t, s);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Key, typename Value>
|
||||
struct QxConvert_FromString<boost::unordered_multimap<Key, Value>>
|
||||
{
|
||||
static inline qx_bool fromString(const QString &s, boost::unordered_multimap<Key, Value> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE::from_string(t, s);
|
||||
}
|
||||
};
|
||||
|
||||
#endif // _QX_ENABLE_BOOST
|
||||
|
||||
template <typename Key, typename Value>
|
||||
struct QxConvert_FromString<std::unordered_map<Key, Value>>
|
||||
{
|
||||
static inline qx_bool fromString(const QString &s, std::unordered_map<Key, Value> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE::from_string(t, s);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Key, typename Value>
|
||||
struct QxConvert_FromString<std::unordered_multimap<Key, Value>>
|
||||
{
|
||||
static inline qx_bool fromString(const QString &s, std::unordered_multimap<Key, Value> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE::from_string(t, s);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Key, typename Value>
|
||||
struct QxConvert_FromString<QHash<Key, Value>>
|
||||
{
|
||||
static inline qx_bool fromString(const QString &s, QHash<Key, Value> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE::from_string(t, s);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Key, typename Value>
|
||||
struct QxConvert_FromString<QMultiHash<Key, Value>>
|
||||
{
|
||||
static inline qx_bool fromString(const QString &s, QMultiHash<Key, Value> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE::from_string(t, s);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Key, typename Value>
|
||||
struct QxConvert_FromString<QMap<Key, Value>>
|
||||
{
|
||||
static inline qx_bool fromString(const QString &s, QMap<Key, Value> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE::from_string(t, s);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Key, typename Value>
|
||||
struct QxConvert_FromString<QMultiMap<Key, Value>>
|
||||
{
|
||||
static inline qx_bool fromString(const QString &s, QMultiMap<Key, Value> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE::from_string(t, s);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Key, typename Value>
|
||||
struct QxConvert_FromString<qx::QxCollection<Key, Value>>
|
||||
{
|
||||
static inline qx_bool fromString(const QString &s, qx::QxCollection<Key, Value> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE::from_string(t, s);
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef _QX_ENABLE_BOOST
|
||||
|
||||
template <typename T1>
|
||||
struct QxConvert_FromString<boost::tuple<T1>>
|
||||
{
|
||||
static inline qx_bool fromString(const QString &s, boost::tuple<T1> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE::from_string(t, s);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T1, typename T2>
|
||||
struct QxConvert_FromString<boost::tuple<T1, T2>>
|
||||
{
|
||||
static inline qx_bool fromString(const QString &s, boost::tuple<T1, T2> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE::from_string(t, s);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T1, typename T2, typename T3>
|
||||
struct QxConvert_FromString<boost::tuple<T1, T2, T3>>
|
||||
{
|
||||
static inline qx_bool fromString(const QString &s, boost::tuple<T1, T2, T3> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE::from_string(t, s);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T1, typename T2, typename T3, typename T4>
|
||||
struct QxConvert_FromString<boost::tuple<T1, T2, T3, T4>>
|
||||
{
|
||||
static inline qx_bool fromString(const QString &s, boost::tuple<T1, T2, T3, T4> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE::from_string(t, s);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T1, typename T2, typename T3, typename T4, typename T5>
|
||||
struct QxConvert_FromString<boost::tuple<T1, T2, T3, T4, T5>>
|
||||
{
|
||||
static inline qx_bool fromString(const QString &s, boost::tuple<T1, T2, T3, T4, T5> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE::from_string(t, s);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
|
||||
struct QxConvert_FromString<boost::tuple<T1, T2, T3, T4, T5, T6>>
|
||||
{
|
||||
static inline qx_bool fromString(const QString &s, boost::tuple<T1, T2, T3, T4, T5, T6> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE::from_string(t, s);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7>
|
||||
struct QxConvert_FromString<boost::tuple<T1, T2, T3, T4, T5, T6, T7>>
|
||||
{
|
||||
static inline qx_bool fromString(const QString &s, boost::tuple<T1, T2, T3, T4, T5, T6, T7> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE::from_string(t, s);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8>
|
||||
struct QxConvert_FromString<boost::tuple<T1, T2, T3, T4, T5, T6, T7, T8>>
|
||||
{
|
||||
static inline qx_bool fromString(const QString &s, boost::tuple<T1, T2, T3, T4, T5, T6, T7, T8> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE::from_string(t, s);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9>
|
||||
struct QxConvert_FromString<boost::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9>>
|
||||
{
|
||||
static inline qx_bool fromString(const QString &s, boost::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE::from_string(t, s);
|
||||
}
|
||||
};
|
||||
|
||||
#endif // _QX_ENABLE_BOOST
|
||||
|
||||
template <typename T1>
|
||||
struct QxConvert_FromString<std::tuple<T1>>
|
||||
{
|
||||
static inline qx_bool fromString(const QString &s, std::tuple<T1> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE::from_string(t, s);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T1, typename T2>
|
||||
struct QxConvert_FromString<std::tuple<T1, T2>>
|
||||
{
|
||||
static inline qx_bool fromString(const QString &s, std::tuple<T1, T2> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE::from_string(t, s);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T1, typename T2, typename T3>
|
||||
struct QxConvert_FromString<std::tuple<T1, T2, T3>>
|
||||
{
|
||||
static inline qx_bool fromString(const QString &s, std::tuple<T1, T2, T3> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE::from_string(t, s);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T1, typename T2, typename T3, typename T4>
|
||||
struct QxConvert_FromString<std::tuple<T1, T2, T3, T4>>
|
||||
{
|
||||
static inline qx_bool fromString(const QString &s, std::tuple<T1, T2, T3, T4> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE::from_string(t, s);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T1, typename T2, typename T3, typename T4, typename T5>
|
||||
struct QxConvert_FromString<std::tuple<T1, T2, T3, T4, T5>>
|
||||
{
|
||||
static inline qx_bool fromString(const QString &s, std::tuple<T1, T2, T3, T4, T5> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE::from_string(t, s);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
|
||||
struct QxConvert_FromString<std::tuple<T1, T2, T3, T4, T5, T6>>
|
||||
{
|
||||
static inline qx_bool fromString(const QString &s, std::tuple<T1, T2, T3, T4, T5, T6> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE::from_string(t, s);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7>
|
||||
struct QxConvert_FromString<std::tuple<T1, T2, T3, T4, T5, T6, T7>>
|
||||
{
|
||||
static inline qx_bool fromString(const QString &s, std::tuple<T1, T2, T3, T4, T5, T6, T7> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE::from_string(t, s);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8>
|
||||
struct QxConvert_FromString<std::tuple<T1, T2, T3, T4, T5, T6, T7, T8>>
|
||||
{
|
||||
static inline qx_bool fromString(const QString &s, std::tuple<T1, T2, T3, T4, T5, T6, T7, T8> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE::from_string(t, s);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9>
|
||||
struct QxConvert_FromString<std::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9>>
|
||||
{
|
||||
static inline qx_bool fromString(const QString &s, std::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE::from_string(t, s);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
} // namespace cvt
|
||||
} // namespace qx
|
||||
991
inl/QxConvert/QxConvert_FromVariant.inl
Normal file
991
inl/QxConvert/QxConvert_FromVariant.inl
Normal file
@@ -0,0 +1,991 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** https://www.qxorm.com/
|
||||
** Copyright (C) 2013 XDL Team (ic-east.com)
|
||||
**
|
||||
** This file is part of the QxOrm library
|
||||
**
|
||||
** This software is provided 'as-is', without any express or implied
|
||||
** warranty. In no event will the authors be held liable for any
|
||||
** damages arising from the use of this software
|
||||
**
|
||||
** Commercial Usage
|
||||
** Licensees holding valid commercial QxOrm licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and XDL Team
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3.0 as published by the Free Software
|
||||
** Foundation and appearing in the file 'license.gpl3.txt' included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU General Public License version 3.0 requirements will be
|
||||
** met : http://www.gnu.org/copyleft/gpl.html
|
||||
**
|
||||
** If you are unsure which license is appropriate for your use, or
|
||||
** if you have questions regarding the use of this file, please contact :
|
||||
** ic-east.com
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef _QX_ENABLE_BOOST_SERIALIZATION
|
||||
#define QX_CVT_DEFAULT_ARCHIVE_FROM_VARIANT QX_CVT_DEFAULT_ARCHIVE::from_string(t, v.toString())
|
||||
#else // _QX_ENABLE_BOOST_SERIALIZATION
|
||||
#define QX_CVT_DEFAULT_ARCHIVE_FROM_VARIANT QX_CVT_DEFAULT_ARCHIVE::from_byte_array(t, v.toByteArray())
|
||||
#endif // _QX_ENABLE_BOOST_SERIALIZATION
|
||||
|
||||
namespace qx
|
||||
{
|
||||
namespace cvt
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template <>
|
||||
struct QxConvert_FromVariant<qx::trait::no_type>
|
||||
{
|
||||
static inline qx_bool fromVariant(const QVariant &v, qx::trait::no_type &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(v);
|
||||
Q_UNUSED(t);
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return qx_bool(true);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_FromVariant<bool>
|
||||
{
|
||||
static inline qx_bool fromVariant(const QVariant &v, bool &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
t = v.toBool();
|
||||
return qx_bool(true);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_FromVariant<short>
|
||||
{
|
||||
static inline qx_bool fromVariant(const QVariant &v, short &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
bool bOk = false;
|
||||
t = static_cast<short>(v.toInt(&bOk));
|
||||
return bOk;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_FromVariant<int>
|
||||
{
|
||||
static inline qx_bool fromVariant(const QVariant &v, int &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
bool bOk = false;
|
||||
t = v.toInt(&bOk);
|
||||
return bOk;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_FromVariant<long>
|
||||
{
|
||||
static inline qx_bool fromVariant(const QVariant &v, long &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
bool bOk = false;
|
||||
t = static_cast<long>(v.toLongLong(&bOk));
|
||||
return bOk;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_FromVariant<long long>
|
||||
{
|
||||
static inline qx_bool fromVariant(const QVariant &v, long long &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
bool bOk = false;
|
||||
t = static_cast<long long>(v.toLongLong(&bOk));
|
||||
return bOk;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_FromVariant<float>
|
||||
{
|
||||
static inline qx_bool fromVariant(const QVariant &v, float &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
bool bOk = false;
|
||||
t = static_cast<float>(v.toDouble(&bOk));
|
||||
return bOk;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_FromVariant<double>
|
||||
{
|
||||
static inline qx_bool fromVariant(const QVariant &v, double &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
bool bOk = false;
|
||||
t = v.toDouble(&bOk);
|
||||
return bOk;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_FromVariant<unsigned short>
|
||||
{
|
||||
static inline qx_bool fromVariant(const QVariant &v, unsigned short &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
bool bOk = false;
|
||||
t = static_cast<unsigned short>(v.toUInt(&bOk));
|
||||
return bOk;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_FromVariant<unsigned int>
|
||||
{
|
||||
static inline qx_bool fromVariant(const QVariant &v, unsigned int &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
bool bOk = false;
|
||||
t = static_cast<unsigned int>(v.toUInt(&bOk));
|
||||
return bOk;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_FromVariant<unsigned long>
|
||||
{
|
||||
static inline qx_bool fromVariant(const QVariant &v, unsigned long &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
bool bOk = false;
|
||||
t = static_cast<unsigned long>(v.toULongLong(&bOk));
|
||||
return bOk;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_FromVariant<unsigned long long>
|
||||
{
|
||||
static inline qx_bool fromVariant(const QVariant &v, unsigned long long &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
bool bOk = false;
|
||||
t = static_cast<unsigned long long>(v.toULongLong(&bOk));
|
||||
return bOk;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_FromVariant<QDate>
|
||||
{
|
||||
static inline qx_bool fromVariant(const QVariant &v, QDate &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
t = v.toDate();
|
||||
return t.isValid();
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_FromVariant<QTime>
|
||||
{
|
||||
static inline qx_bool fromVariant(const QVariant &v, QTime &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
t = v.toTime();
|
||||
return t.isValid();
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_FromVariant<QDateTime>
|
||||
{
|
||||
static inline qx_bool fromVariant(const QVariant &v, QDateTime &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
t = v.toDateTime();
|
||||
return t.isValid();
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_FromVariant<QByteArray>
|
||||
{
|
||||
static inline qx_bool fromVariant(const QVariant &v, QByteArray &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
t = v.toByteArray();
|
||||
return qx_bool(true);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_FromVariant<QString>
|
||||
{
|
||||
static inline qx_bool fromVariant(const QVariant &v, QString &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
t = v.toString();
|
||||
return qx_bool(true);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_FromVariant<QVariant>
|
||||
{
|
||||
static inline qx_bool fromVariant(const QVariant &v, QVariant &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
if (ctx != qx::cvt::context::e_database)
|
||||
{
|
||||
t = v;
|
||||
return qx_bool(true);
|
||||
}
|
||||
QString s = v.toString();
|
||||
if (!s.startsWith("$$JSON$$"))
|
||||
{
|
||||
t = v;
|
||||
return qx_bool(true);
|
||||
}
|
||||
return qx::cvt::detail::QxConvert_FromString<QVariant>::fromString(s, t, format, index, ctx);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_FromVariant<QUuid>
|
||||
{
|
||||
static inline qx_bool fromVariant(const QVariant &v, QUuid &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
t = QUuid(v.toString());
|
||||
return qx_bool(true);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_FromVariant<qx::QxDateNeutral>
|
||||
{
|
||||
static inline qx_bool fromVariant(const QVariant &v, qx::QxDateNeutral &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
t = qx::QxDateNeutral::fromNeutral(v.toString());
|
||||
return qx_bool(true);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_FromVariant<qx::QxTimeNeutral>
|
||||
{
|
||||
static inline qx_bool fromVariant(const QVariant &v, qx::QxTimeNeutral &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
t = qx::QxTimeNeutral::fromNeutral(v.toString());
|
||||
return qx_bool(true);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_FromVariant<qx::QxDateTimeNeutral>
|
||||
{
|
||||
static inline qx_bool fromVariant(const QVariant &v, qx::QxDateTimeNeutral &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
t = qx::QxDateTimeNeutral::fromNeutral(v.toString());
|
||||
return qx_bool(true);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_FromVariant<std::string>
|
||||
{
|
||||
static inline qx_bool fromVariant(const QVariant &v, std::string &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
#ifndef QT_NO_STL
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
t = v.toString().toStdString();
|
||||
return qx_bool(true);
|
||||
}
|
||||
};
|
||||
#else // QT_NO_STL
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
t = v.toString().toLatin1().constData();
|
||||
return qx_bool(true);
|
||||
}
|
||||
};
|
||||
#endif // QT_NO_STL
|
||||
|
||||
template <>
|
||||
struct QxConvert_FromVariant<std::wstring>
|
||||
{
|
||||
static inline qx_bool fromVariant(const QVariant &v, std::wstring &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
#if ((!defined(QT_NO_STL)) && (!defined(QT_NO_STL_WCHAR)))
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
t = v.toString().toStdWString();
|
||||
return qx_bool(true);
|
||||
}
|
||||
};
|
||||
#else // ((! defined(QT_NO_STL)) && (! defined(QT_NO_STL_WCHAR)))
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
Q_UNUSED(t);
|
||||
Q_UNUSED(v);
|
||||
qAssert(false); /* Need STL compatibility ! */
|
||||
return qx_bool(true);
|
||||
}
|
||||
};
|
||||
#endif // ((! defined(QT_NO_STL)) && (! defined(QT_NO_STL_WCHAR)))
|
||||
|
||||
template <>
|
||||
struct QxConvert_FromVariant<qx_bool>
|
||||
{
|
||||
static inline qx_bool fromVariant(const QVariant &v, qx_bool &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
QString s = v.toString();
|
||||
t.fromString(s);
|
||||
return qx_bool(true);
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef _QX_NO_JSON
|
||||
|
||||
template <>
|
||||
struct QxConvert_FromVariant<QJsonValue>
|
||||
{
|
||||
static inline qx_bool fromVariant(const QVariant &v, QJsonValue &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
t = QJsonValue::fromVariant(v);
|
||||
return qx_bool(true);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_FromVariant<QJsonArray>
|
||||
{
|
||||
static inline qx_bool fromVariant(const QVariant &v, QJsonArray &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
t = v.toJsonArray();
|
||||
return qx_bool(true);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_FromVariant<QJsonObject>
|
||||
{
|
||||
static inline qx_bool fromVariant(const QVariant &v, QJsonObject &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
t = v.toJsonObject();
|
||||
return qx_bool(true);
|
||||
}
|
||||
};
|
||||
|
||||
#endif // _QX_NO_JSON
|
||||
|
||||
#ifdef _QX_ENABLE_BOOST
|
||||
|
||||
template <typename T>
|
||||
struct QxConvert_FromVariant<boost::optional<T>>
|
||||
{
|
||||
static inline qx_bool fromVariant(const QVariant &v, boost::optional<T> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
if (v.isNull())
|
||||
{
|
||||
t = boost::none;
|
||||
return qx_bool(true);
|
||||
}
|
||||
else if (!t)
|
||||
{
|
||||
t = T();
|
||||
}
|
||||
return qx::cvt::from_variant(v, (*t), format, index, ctx);
|
||||
}
|
||||
};
|
||||
|
||||
#endif // _QX_ENABLE_BOOST
|
||||
|
||||
template <typename T1, typename T2>
|
||||
struct QxConvert_FromVariant<std::pair<T1, T2>>
|
||||
{
|
||||
static inline qx_bool fromVariant(const QVariant &v, std::pair<T1, T2> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE_FROM_VARIANT;
|
||||
}
|
||||
};
|
||||
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
|
||||
template <typename T1, typename T2>
|
||||
struct QxConvert_FromVariant<QPair<T1, T2>>
|
||||
{
|
||||
static inline qx_bool fromVariant(const QVariant &v, QPair<T1, T2> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE_FROM_VARIANT;
|
||||
}
|
||||
};
|
||||
#endif // (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
|
||||
|
||||
template <typename T>
|
||||
struct QxConvert_FromVariant<std::vector<T>>
|
||||
{
|
||||
static inline qx_bool fromVariant(const QVariant &v, std::vector<T> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE_FROM_VARIANT;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct QxConvert_FromVariant<std::list<T>>
|
||||
{
|
||||
static inline qx_bool fromVariant(const QVariant &v, std::list<T> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE_FROM_VARIANT;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct QxConvert_FromVariant<std::set<T>>
|
||||
{
|
||||
static inline qx_bool fromVariant(const QVariant &v, std::set<T> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE_FROM_VARIANT;
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef _QX_ENABLE_BOOST
|
||||
|
||||
template <typename T>
|
||||
struct QxConvert_FromVariant<boost::unordered_set<T>>
|
||||
{
|
||||
static inline qx_bool fromVariant(const QVariant &v, boost::unordered_set<T> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE_FROM_VARIANT;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct QxConvert_FromVariant<boost::unordered_multiset<T>>
|
||||
{
|
||||
static inline qx_bool fromVariant(const QVariant &v, boost::unordered_multiset<T> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE_FROM_VARIANT;
|
||||
}
|
||||
};
|
||||
|
||||
#endif // _QX_ENABLE_BOOST
|
||||
|
||||
template <typename T>
|
||||
struct QxConvert_FromVariant<std::unordered_set<T>>
|
||||
{
|
||||
static inline qx_bool fromVariant(const QVariant &v, std::unordered_set<T> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE_FROM_VARIANT;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct QxConvert_FromVariant<std::unordered_multiset<T>>
|
||||
{
|
||||
static inline qx_bool fromVariant(const QVariant &v, std::unordered_multiset<T> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE_FROM_VARIANT;
|
||||
}
|
||||
};
|
||||
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
|
||||
template <typename T>
|
||||
struct QxConvert_FromVariant<QVector<T>>
|
||||
{
|
||||
static inline qx_bool fromVariant(const QVariant &v, QVector<T> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE_FROM_VARIANT;
|
||||
}
|
||||
};
|
||||
#endif // (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
|
||||
|
||||
template <typename T>
|
||||
struct QxConvert_FromVariant<QList<T>>
|
||||
{
|
||||
static inline qx_bool fromVariant(const QVariant &v, QList<T> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE_FROM_VARIANT;
|
||||
}
|
||||
};
|
||||
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 0))
|
||||
template <typename T>
|
||||
struct QxConvert_FromVariant<QLinkedList<T>>
|
||||
{
|
||||
static inline qx_bool fromVariant(const QVariant &v, QLinkedList<T> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE_FROM_VARIANT;
|
||||
}
|
||||
};
|
||||
#endif // (QT_VERSION < QT_VERSION_CHECK(5, 15, 0))
|
||||
|
||||
template <typename T>
|
||||
struct QxConvert_FromVariant<QFlags<T>>
|
||||
{
|
||||
static inline qx_bool fromVariant(const QVariant &v, QFlags<T> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
t = QFlags<T>(QFlag(v.toInt()));
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Key, typename Value>
|
||||
struct QxConvert_FromVariant<std::map<Key, Value>>
|
||||
{
|
||||
static inline qx_bool fromVariant(const QVariant &v, std::map<Key, Value> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE_FROM_VARIANT;
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef _QX_ENABLE_BOOST
|
||||
|
||||
template <typename Key, typename Value>
|
||||
struct QxConvert_FromVariant<boost::unordered_map<Key, Value>>
|
||||
{
|
||||
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)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE_FROM_VARIANT;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Key, typename Value>
|
||||
struct QxConvert_FromVariant<boost::unordered_multimap<Key, Value>>
|
||||
{
|
||||
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)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE_FROM_VARIANT;
|
||||
}
|
||||
};
|
||||
|
||||
#endif // _QX_ENABLE_BOOST
|
||||
|
||||
template <typename Key, typename Value>
|
||||
struct QxConvert_FromVariant<std::unordered_map<Key, Value>>
|
||||
{
|
||||
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)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE_FROM_VARIANT;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Key, typename Value>
|
||||
struct QxConvert_FromVariant<std::unordered_multimap<Key, Value>>
|
||||
{
|
||||
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)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE_FROM_VARIANT;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Key, typename Value>
|
||||
struct QxConvert_FromVariant<QHash<Key, Value>>
|
||||
{
|
||||
static inline qx_bool fromVariant(const QVariant &v, QHash<Key, Value> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE_FROM_VARIANT;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Key, typename Value>
|
||||
struct QxConvert_FromVariant<QMultiHash<Key, Value>>
|
||||
{
|
||||
static inline qx_bool fromVariant(const QVariant &v, QMultiHash<Key, Value> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE_FROM_VARIANT;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Key, typename Value>
|
||||
struct QxConvert_FromVariant<QMap<Key, Value>>
|
||||
{
|
||||
static inline qx_bool fromVariant(const QVariant &v, QMap<Key, Value> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE_FROM_VARIANT;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Key, typename Value>
|
||||
struct QxConvert_FromVariant<QMultiMap<Key, Value>>
|
||||
{
|
||||
static inline qx_bool fromVariant(const QVariant &v, QMultiMap<Key, Value> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE_FROM_VARIANT;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Key, typename Value>
|
||||
struct QxConvert_FromVariant<qx::QxCollection<Key, Value>>
|
||||
{
|
||||
static inline qx_bool fromVariant(const QVariant &v, qx::QxCollection<Key, Value> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE_FROM_VARIANT;
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef _QX_ENABLE_BOOST
|
||||
|
||||
template <typename T1>
|
||||
struct QxConvert_FromVariant<boost::tuple<T1>>
|
||||
{
|
||||
static inline qx_bool fromVariant(const QVariant &v, boost::tuple<T1> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE_FROM_VARIANT;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T1, typename T2>
|
||||
struct QxConvert_FromVariant<boost::tuple<T1, T2>>
|
||||
{
|
||||
static inline qx_bool fromVariant(const QVariant &v, boost::tuple<T1, T2> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE_FROM_VARIANT;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T1, typename T2, typename T3>
|
||||
struct QxConvert_FromVariant<boost::tuple<T1, T2, T3>>
|
||||
{
|
||||
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)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE_FROM_VARIANT;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T1, typename T2, typename T3, typename T4>
|
||||
struct QxConvert_FromVariant<boost::tuple<T1, T2, T3, T4>>
|
||||
{
|
||||
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)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE_FROM_VARIANT;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T1, typename T2, typename T3, typename T4, typename T5>
|
||||
struct QxConvert_FromVariant<boost::tuple<T1, T2, T3, T4, T5>>
|
||||
{
|
||||
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)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE_FROM_VARIANT;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
|
||||
struct QxConvert_FromVariant<boost::tuple<T1, T2, T3, T4, T5, T6>>
|
||||
{
|
||||
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)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE_FROM_VARIANT;
|
||||
}
|
||||
};
|
||||
|
||||
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>>
|
||||
{
|
||||
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)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE_FROM_VARIANT;
|
||||
}
|
||||
};
|
||||
|
||||
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>>
|
||||
{
|
||||
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)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE_FROM_VARIANT;
|
||||
}
|
||||
};
|
||||
|
||||
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>>
|
||||
{
|
||||
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)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE_FROM_VARIANT;
|
||||
}
|
||||
};
|
||||
|
||||
#endif // _QX_ENABLE_BOOST
|
||||
|
||||
template <typename T1>
|
||||
struct QxConvert_FromVariant<std::tuple<T1>>
|
||||
{
|
||||
static inline qx_bool fromVariant(const QVariant &v, std::tuple<T1> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE_FROM_VARIANT;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T1, typename T2>
|
||||
struct QxConvert_FromVariant<std::tuple<T1, T2>>
|
||||
{
|
||||
static inline qx_bool fromVariant(const QVariant &v, std::tuple<T1, T2> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE_FROM_VARIANT;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T1, typename T2, typename T3>
|
||||
struct QxConvert_FromVariant<std::tuple<T1, T2, T3>>
|
||||
{
|
||||
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)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE_FROM_VARIANT;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T1, typename T2, typename T3, typename T4>
|
||||
struct QxConvert_FromVariant<std::tuple<T1, T2, T3, T4>>
|
||||
{
|
||||
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)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE_FROM_VARIANT;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T1, typename T2, typename T3, typename T4, typename T5>
|
||||
struct QxConvert_FromVariant<std::tuple<T1, T2, T3, T4, T5>>
|
||||
{
|
||||
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)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE_FROM_VARIANT;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
|
||||
struct QxConvert_FromVariant<std::tuple<T1, T2, T3, T4, T5, T6>>
|
||||
{
|
||||
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)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE_FROM_VARIANT;
|
||||
}
|
||||
};
|
||||
|
||||
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>>
|
||||
{
|
||||
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)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE_FROM_VARIANT;
|
||||
}
|
||||
};
|
||||
|
||||
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>>
|
||||
{
|
||||
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)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE_FROM_VARIANT;
|
||||
}
|
||||
};
|
||||
|
||||
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>>
|
||||
{
|
||||
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)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE_FROM_VARIANT;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
} // namespace cvt
|
||||
} // namespace qx
|
||||
71
inl/QxConvert/QxConvert_Qt.inl
Normal file
71
inl/QxConvert/QxConvert_Qt.inl
Normal file
@@ -0,0 +1,71 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** https://www.qxorm.com/
|
||||
** Copyright (C) 2013 XDL Team (ic-east.com)
|
||||
**
|
||||
** This file is part of the QxOrm library
|
||||
**
|
||||
** This software is provided 'as-is', without any express or implied
|
||||
** warranty. In no event will the authors be held liable for any
|
||||
** damages arising from the use of this software
|
||||
**
|
||||
** Commercial Usage
|
||||
** Licensees holding valid commercial QxOrm licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and XDL Team
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3.0 as published by the Free Software
|
||||
** Foundation and appearing in the file 'license.gpl3.txt' included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU General Public License version 3.0 requirements will be
|
||||
** met : http://www.gnu.org/copyleft/gpl.html
|
||||
**
|
||||
** If you are unsure which license is appropriate for your use, or
|
||||
** if you have questions regarding the use of this file, please contact :
|
||||
** ic-east.com
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef _QX_STRING_CVT_QT_H_
|
||||
#define _QX_STRING_CVT_QT_H_
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <QxConvert/QxConvert.h>
|
||||
#include <QxConvert/QxConvert_Impl.h>
|
||||
|
||||
QX_CVT_USING_ARCHIVE_IMPL(QObject)
|
||||
QX_CVT_USING_ARCHIVE_IMPL(QPoint)
|
||||
QX_CVT_USING_ARCHIVE_IMPL(QRect)
|
||||
QX_CVT_USING_ARCHIVE_IMPL(QSize)
|
||||
QX_CVT_USING_ARCHIVE_IMPL(QStringList)
|
||||
QX_CVT_USING_ARCHIVE_IMPL(QUrl)
|
||||
QX_CVT_USING_ARCHIVE_IMPL(QSqlError)
|
||||
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
|
||||
QX_CVT_USING_ARCHIVE_IMPL(QRegExp)
|
||||
#endif // (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
|
||||
|
||||
#ifdef _QX_ENABLE_QT_GUI
|
||||
QX_CVT_USING_ARCHIVE_IMPL(QBrush)
|
||||
QX_CVT_USING_ARCHIVE_IMPL(QColor)
|
||||
QX_CVT_USING_ARCHIVE_IMPL(QFont)
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
|
||||
QX_CVT_USING_ARCHIVE_IMPL(QMatrix)
|
||||
#endif // (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
|
||||
QX_CVT_USING_ARCHIVE_IMPL(QRegion)
|
||||
QX_CVT_USING_ARCHIVE_IMPL(QImage)
|
||||
QX_CVT_USING_ARCHIVE_IMPL(QPicture)
|
||||
QX_CVT_USING_ARCHIVE_IMPL(QPixmap)
|
||||
#endif // _QX_ENABLE_QT_GUI
|
||||
|
||||
QX_CVT_USING_ARCHIVE_IMPL(qx::QxSqlQuery)
|
||||
QX_CVT_USING_ARCHIVE_IMPL(qx::QxInvalidValue)
|
||||
QX_CVT_USING_ARCHIVE_IMPL(qx::QxInvalidValueX)
|
||||
|
||||
#endif // _QX_STRING_CVT_QT_H_
|
||||
387
inl/QxConvert/QxConvert_ToJson.inl
Normal file
387
inl/QxConvert/QxConvert_ToJson.inl
Normal file
@@ -0,0 +1,387 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** https://www.qxorm.com/
|
||||
** Copyright (C) 2013 XDL Team (ic-east.com)
|
||||
**
|
||||
** This file is part of the QxOrm library
|
||||
**
|
||||
** This software is provided 'as-is', without any express or implied
|
||||
** warranty. In no event will the authors be held liable for any
|
||||
** damages arising from the use of this software
|
||||
**
|
||||
** Commercial Usage
|
||||
** Licensees holding valid commercial QxOrm licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and XDL Team
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3.0 as published by the Free Software
|
||||
** Foundation and appearing in the file 'license.gpl3.txt' included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU General Public License version 3.0 requirements will be
|
||||
** met : http://www.gnu.org/copyleft/gpl.html
|
||||
**
|
||||
** If you are unsure which license is appropriate for your use, or
|
||||
** if you have questions regarding the use of this file, please contact :
|
||||
** ic-east.com
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef _QX_NO_JSON
|
||||
|
||||
namespace qx
|
||||
{
|
||||
namespace cvt
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template <>
|
||||
struct QxConvert_ToJson<qx::trait::no_type>
|
||||
{
|
||||
static inline QJsonValue toJson(const qx::trait::no_type &t, const QString &format)
|
||||
{
|
||||
Q_UNUSED(t);
|
||||
Q_UNUSED(format);
|
||||
return QJsonValue();
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_ToJson<bool>
|
||||
{
|
||||
static inline QJsonValue toJson(const bool &t, const QString &format)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
return QJsonValue(t);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_ToJson<short>
|
||||
{
|
||||
static inline QJsonValue toJson(const short &t, const QString &format)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
return QJsonValue(static_cast<int>(t));
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_ToJson<int>
|
||||
{
|
||||
static inline QJsonValue toJson(const int &t, const QString &format)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
return QJsonValue(t);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_ToJson<long>
|
||||
{
|
||||
static inline QJsonValue toJson(const long &t, const QString &format)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
return QJsonValue(static_cast<double>(t));
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_ToJson<long long>
|
||||
{
|
||||
static inline QJsonValue toJson(const long long &t, const QString &format)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
return QJsonValue(static_cast<double>(t));
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_ToJson<float>
|
||||
{
|
||||
static inline QJsonValue toJson(const float &t, const QString &format)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
return QJsonValue(static_cast<double>(t));
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_ToJson<double>
|
||||
{
|
||||
static inline QJsonValue toJson(const double &t, const QString &format)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
return QJsonValue(t);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_ToJson<unsigned short>
|
||||
{
|
||||
static inline QJsonValue toJson(const unsigned short &t, const QString &format)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
return QJsonValue(static_cast<int>(t));
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_ToJson<unsigned int>
|
||||
{
|
||||
static inline QJsonValue toJson(const unsigned int &t, const QString &format)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
return QJsonValue(static_cast<int>(t));
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_ToJson<unsigned long>
|
||||
{
|
||||
static inline QJsonValue toJson(const unsigned long &t, const QString &format)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
return QJsonValue(static_cast<double>(t));
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_ToJson<unsigned long long>
|
||||
{
|
||||
static inline QJsonValue toJson(const unsigned long long &t, const QString &format)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
return QJsonValue(static_cast<double>(t));
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_ToJson<QDateTime>
|
||||
{
|
||||
static inline QJsonValue toJson(const QDateTime &t, const QString &format)
|
||||
{
|
||||
#ifdef _QX_ENABLE_MONGODB
|
||||
if (t.isValid() && format.startsWith("mongodb"))
|
||||
{
|
||||
QString dt = t.toString(QX_JSON_DATE_TIME_FORMAT);
|
||||
if (dt.count() <= QX_JSON_DATE_TIME_FORMAT_SIZE)
|
||||
{
|
||||
dt += "Z";
|
||||
}
|
||||
QJsonObject obj;
|
||||
obj.insert("$date", QJsonValue(dt));
|
||||
return QJsonValue(obj);
|
||||
}
|
||||
#endif // _QX_ENABLE_MONGODB
|
||||
|
||||
Q_UNUSED(format);
|
||||
if (t.isValid())
|
||||
{
|
||||
return QJsonValue(t.toString(QX_JSON_DATE_TIME_FORMAT));
|
||||
};
|
||||
return QJsonValue();
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_ToJson<QDate>
|
||||
{
|
||||
static inline QJsonValue toJson(const QDate &t, const QString &format)
|
||||
{
|
||||
#ifdef _QX_ENABLE_MONGODB
|
||||
if (t.isValid() && format.startsWith("mongodb"))
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
||||
{
|
||||
QTime time = ((t.isValid()) ? QTime(0, 0) : QTime());
|
||||
QDateTime dt(t, time);
|
||||
return QxConvert_ToJson<QDateTime>::toJson(dt, format);
|
||||
}
|
||||
#else // (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
||||
{
|
||||
QDateTime dt(t);
|
||||
return QxConvert_ToJson<QDateTime>::toJson(dt, format);
|
||||
}
|
||||
#endif // (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
||||
#endif // _QX_ENABLE_MONGODB
|
||||
|
||||
Q_UNUSED(format);
|
||||
if (t.isValid())
|
||||
{
|
||||
return QJsonValue(t.toString(Qt::ISODate));
|
||||
};
|
||||
return QJsonValue();
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_ToJson<QTime>
|
||||
{
|
||||
static inline QJsonValue toJson(const QTime &t, const QString &format)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
if (t.isValid())
|
||||
{
|
||||
return QJsonValue(t.toString(QX_JSON_DATE_TIME_FORMAT));
|
||||
};
|
||||
return QJsonValue();
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_ToJson<QByteArray>
|
||||
{
|
||||
static inline QJsonValue toJson(const QByteArray &t, const QString &format)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
QString s = t.toBase64();
|
||||
return QJsonValue(s);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_ToJson<QString>
|
||||
{
|
||||
static inline QJsonValue toJson(const QString &t, const QString &format)
|
||||
{
|
||||
#ifdef _QX_ENABLE_MONGODB
|
||||
if (t.startsWith("qx_oid:") && format.startsWith("mongodb"))
|
||||
{
|
||||
QJsonObject obj;
|
||||
obj.insert("$oid", QJsonValue(t.right(t.size() - 7)));
|
||||
return QJsonValue(obj);
|
||||
}
|
||||
#endif // _QX_ENABLE_MONGODB
|
||||
|
||||
Q_UNUSED(format);
|
||||
return QJsonValue(t);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_ToJson<QVariant>
|
||||
{
|
||||
static inline QJsonValue toJson(const QVariant &t, const QString &format)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
return QJsonValue::fromVariant(t);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_ToJson<QUuid>
|
||||
{
|
||||
static inline QJsonValue toJson(const QUuid &t, const QString &format)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
return QJsonValue(t.toString());
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_ToJson<qx::QxDateNeutral>
|
||||
{
|
||||
static inline QJsonValue toJson(const qx::QxDateNeutral &t, const QString &format)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
return QJsonValue(t.toNeutral());
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_ToJson<qx::QxTimeNeutral>
|
||||
{
|
||||
static inline QJsonValue toJson(const qx::QxTimeNeutral &t, const QString &format)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
return QJsonValue(t.toNeutral());
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_ToJson<qx::QxDateTimeNeutral>
|
||||
{
|
||||
static inline QJsonValue toJson(const qx::QxDateTimeNeutral &t, const QString &format)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
return QJsonValue(t.toNeutral());
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_ToJson<std::string>
|
||||
{
|
||||
static inline QJsonValue toJson(const std::string &t, const QString &format)
|
||||
#ifndef QT_NO_STL
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
return QJsonValue(QString::fromStdString(t));
|
||||
}
|
||||
};
|
||||
#else // QT_NO_STL
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
return QJsonValue(QString::fromLatin1(t.data(), int(t.size())));
|
||||
}
|
||||
};
|
||||
#endif // QT_NO_STL
|
||||
|
||||
template <>
|
||||
struct QxConvert_ToJson<std::wstring>
|
||||
{
|
||||
static inline QJsonValue toJson(const std::wstring &t, const QString &format)
|
||||
#if ((!defined(QT_NO_STL)) && (!defined(QT_NO_STL_WCHAR)))
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
return QJsonValue(QString::fromStdWString(t));
|
||||
}
|
||||
};
|
||||
#else // ((! defined(QT_NO_STL)) && (! defined(QT_NO_STL_WCHAR)))
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(t);
|
||||
qAssert(false); /* Need STL compatibility ! */
|
||||
return QJsonValue();
|
||||
}
|
||||
};
|
||||
#endif // ((! defined(QT_NO_STL)) && (! defined(QT_NO_STL_WCHAR)))
|
||||
|
||||
template <>
|
||||
struct QxConvert_ToJson<qx_bool>
|
||||
{
|
||||
static inline QJsonValue toJson(const qx_bool &t, const QString &format)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
QJsonObject obj;
|
||||
obj["value"] = t.getValue();
|
||||
obj["code"] = static_cast<double>(t.getCode());
|
||||
obj["desc"] = t.getDesc();
|
||||
return QJsonValue(obj);
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef _QX_ENABLE_BOOST
|
||||
|
||||
template <typename T>
|
||||
struct QxConvert_ToJson<boost::optional<T>>
|
||||
{
|
||||
static inline QJsonValue toJson(const boost::optional<T> &t, const QString &format)
|
||||
{
|
||||
if (t)
|
||||
{
|
||||
return qx::cvt::to_json((*t), format);
|
||||
};
|
||||
return QJsonValue();
|
||||
}
|
||||
};
|
||||
|
||||
#endif // _QX_ENABLE_BOOST
|
||||
|
||||
} // namespace detail
|
||||
} // namespace cvt
|
||||
} // namespace qx
|
||||
|
||||
#endif // _QX_NO_JSON
|
||||
923
inl/QxConvert/QxConvert_ToString.inl
Normal file
923
inl/QxConvert/QxConvert_ToString.inl
Normal file
@@ -0,0 +1,923 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** https://www.qxorm.com/
|
||||
** Copyright (C) 2013 XDL Team (ic-east.com)
|
||||
**
|
||||
** This file is part of the QxOrm library
|
||||
**
|
||||
** This software is provided 'as-is', without any express or implied
|
||||
** warranty. In no event will the authors be held liable for any
|
||||
** damages arising from the use of this software
|
||||
**
|
||||
** Commercial Usage
|
||||
** Licensees holding valid commercial QxOrm licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and XDL Team
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3.0 as published by the Free Software
|
||||
** Foundation and appearing in the file 'license.gpl3.txt' included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU General Public License version 3.0 requirements will be
|
||||
** met : http://www.gnu.org/copyleft/gpl.html
|
||||
**
|
||||
** If you are unsure which license is appropriate for your use, or
|
||||
** if you have questions regarding the use of this file, please contact :
|
||||
** ic-east.com
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
namespace qx
|
||||
{
|
||||
namespace cvt
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template <>
|
||||
struct QxConvert_ToString<qx::trait::no_type>
|
||||
{
|
||||
static inline QString toString(const qx::trait::no_type &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(t);
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return "";
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_ToString<QString>
|
||||
{
|
||||
static inline QString toString(const QString &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return t;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_ToString<QUuid>
|
||||
{
|
||||
static inline QString toString(const QUuid &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return t.toString();
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_ToString<QDate>
|
||||
{
|
||||
static inline QString toString(const QDate &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return t.toString(format.isEmpty() ? QString(QX_STR_CVT_QDATE_FORMAT) : format);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_ToString<QTime>
|
||||
{
|
||||
static inline QString toString(const QTime &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return t.toString(format.isEmpty() ? QString(QX_STR_CVT_QTIME_FORMAT) : format);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_ToString<QDateTime>
|
||||
{
|
||||
static inline QString toString(const QDateTime &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return t.toString(format.isEmpty() ? QString(QX_STR_CVT_QDATETIME_FORMAT) : format);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_ToString<QByteArray>
|
||||
{
|
||||
static inline QString toString(const QByteArray &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QString(t);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_ToString<QVariant>
|
||||
{
|
||||
static inline QString toString(const QVariant &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
|
||||
#ifndef _QX_NO_JSON
|
||||
if (qx::cvt::detail::helper::checkConvertQVariantToString(t))
|
||||
{
|
||||
QString type = QString("%1").arg(static_cast<int>(t.type()), 6, 10, QChar('0'));
|
||||
QString val = "$$JSON$$" + type + "$$";
|
||||
QJsonValue json = QJsonValue::fromVariant(t);
|
||||
QJsonDocument doc = (json.isArray() ? QJsonDocument(json.toArray()) : QJsonDocument(json.toObject()));
|
||||
return (val + QString::fromUtf8(doc.toJson()));
|
||||
}
|
||||
#endif // _QX_NO_JSON
|
||||
|
||||
return t.toString();
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_ToString<qx_bool>
|
||||
{
|
||||
static inline QString toString(const qx_bool &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return t.toString();
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_ToString<bool>
|
||||
{
|
||||
static inline QString toString(const bool &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return (t ? "1" : "0");
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_ToString<char>
|
||||
{
|
||||
static inline QString toString(const char &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QString(t);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_ToString<short>
|
||||
{
|
||||
static inline QString toString(const short &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return (format.isEmpty() ? QString::number(t) : QString(format).arg(t));
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_ToString<int>
|
||||
{
|
||||
static inline QString toString(const int &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return (format.isEmpty() ? QString::number(t) : QString(format).arg(t));
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_ToString<long>
|
||||
{
|
||||
static inline QString toString(const long &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return (format.isEmpty() ? QString::number(t) : QString(format).arg(t));
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_ToString<long long>
|
||||
{
|
||||
static inline QString toString(const long long &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return (format.isEmpty() ? QString::number(t) : QString(format).arg(t));
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_ToString<float>
|
||||
{
|
||||
static inline QString toString(const float &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return (format.isEmpty() ? QString::number(t) : QString(format).arg(t));
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_ToString<double>
|
||||
{
|
||||
static inline QString toString(const double &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return (format.isEmpty() ? QString::number(t) : QString(format).arg(t));
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_ToString<unsigned short>
|
||||
{
|
||||
static inline QString toString(const unsigned short &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return (format.isEmpty() ? QString::number(t) : QString(format).arg(t));
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_ToString<unsigned int>
|
||||
{
|
||||
static inline QString toString(const unsigned int &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return (format.isEmpty() ? QString::number(t) : QString(format).arg(t));
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_ToString<unsigned long>
|
||||
{
|
||||
static inline QString toString(const unsigned long &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return (format.isEmpty() ? QString::number(t) : QString(format).arg(t));
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_ToString<unsigned long long>
|
||||
{
|
||||
static inline QString toString(const unsigned long long &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return (format.isEmpty() ? QString::number(t) : QString(format).arg(t));
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_ToString<qx::QxDateNeutral>
|
||||
{
|
||||
static inline QString toString(const qx::QxDateNeutral &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return t.toNeutral();
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_ToString<qx::QxTimeNeutral>
|
||||
{
|
||||
static inline QString toString(const qx::QxTimeNeutral &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return t.toNeutral();
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_ToString<qx::QxDateTimeNeutral>
|
||||
{
|
||||
static inline QString toString(const qx::QxDateTimeNeutral &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return t.toNeutral();
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_ToString<std::string>
|
||||
{
|
||||
static inline QString toString(const std::string &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
#ifndef QT_NO_STL
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QString::fromStdString(t);
|
||||
}
|
||||
};
|
||||
#else // QT_NO_STL
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QString::fromLatin1(t.data(), int(t.size()));
|
||||
}
|
||||
};
|
||||
#endif // QT_NO_STL
|
||||
|
||||
template <>
|
||||
struct QxConvert_ToString<std::wstring>
|
||||
{
|
||||
static inline QString toString(const std::wstring &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
#if ((!defined(QT_NO_STL)) && (!defined(QT_NO_STL_WCHAR)))
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QString::fromStdWString(t);
|
||||
}
|
||||
};
|
||||
#else // ((! defined(QT_NO_STL)) && (! defined(QT_NO_STL_WCHAR)))
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
Q_UNUSED(t);
|
||||
qAssert(false); /* Need STL compatibility ! */
|
||||
return QString();
|
||||
}
|
||||
};
|
||||
#endif // ((! defined(QT_NO_STL)) && (! defined(QT_NO_STL_WCHAR)))
|
||||
|
||||
#ifndef _QX_NO_JSON
|
||||
|
||||
template <>
|
||||
struct QxConvert_ToString<QJsonValue>
|
||||
{
|
||||
static inline QString toString(const QJsonValue &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
QJsonDocument::JsonFormat jsonFormat = QJsonDocument::Compact;
|
||||
if (!format.isEmpty())
|
||||
{
|
||||
jsonFormat = ((format == "indented") ? QJsonDocument::Indented : jsonFormat);
|
||||
}
|
||||
QJsonDocument doc = (t.isArray() ? QJsonDocument(t.toArray()) : QJsonDocument(t.toObject()));
|
||||
return QString::fromUtf8(doc.toJson(jsonFormat));
|
||||
}
|
||||
};
|
||||
|
||||
#endif // _QX_NO_JSON
|
||||
|
||||
#ifdef _QX_ENABLE_BOOST
|
||||
|
||||
template <typename T>
|
||||
struct QxConvert_ToString<boost::optional<T>>
|
||||
{
|
||||
static inline QString toString(const boost::optional<T> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
if (t)
|
||||
{
|
||||
return qx::cvt::to_string((*t), format, index, ctx);
|
||||
};
|
||||
return QString();
|
||||
}
|
||||
};
|
||||
|
||||
#endif // _QX_ENABLE_BOOST
|
||||
|
||||
template <typename T1, typename T2>
|
||||
struct QxConvert_ToString<std::pair<T1, T2>>
|
||||
{
|
||||
static inline QString toString(const std::pair<T1, T2> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE::to_string(t);
|
||||
}
|
||||
};
|
||||
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
|
||||
template <typename T1, typename T2>
|
||||
struct QxConvert_ToString<QPair<T1, T2>>
|
||||
{
|
||||
static inline QString toString(const QPair<T1, T2> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE::to_string(t);
|
||||
}
|
||||
};
|
||||
#endif // (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
|
||||
|
||||
template <typename T>
|
||||
struct QxConvert_ToString<std::vector<T>>
|
||||
{
|
||||
static inline QString toString(const std::vector<T> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE::to_string(t);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct QxConvert_ToString<std::list<T>>
|
||||
{
|
||||
static inline QString toString(const std::list<T> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE::to_string(t);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct QxConvert_ToString<std::set<T>>
|
||||
{
|
||||
static inline QString toString(const std::set<T> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE::to_string(t);
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef _QX_ENABLE_BOOST
|
||||
|
||||
template <typename T>
|
||||
struct QxConvert_ToString<boost::unordered_set<T>>
|
||||
{
|
||||
static inline QString toString(const boost::unordered_set<T> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE::to_string(t);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct QxConvert_ToString<boost::unordered_multiset<T>>
|
||||
{
|
||||
static inline QString toString(const boost::unordered_multiset<T> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE::to_string(t);
|
||||
}
|
||||
};
|
||||
|
||||
#endif // _QX_ENABLE_BOOST
|
||||
|
||||
template <typename T>
|
||||
struct QxConvert_ToString<std::unordered_set<T>>
|
||||
{
|
||||
static inline QString toString(const std::unordered_set<T> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE::to_string(t);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct QxConvert_ToString<std::unordered_multiset<T>>
|
||||
{
|
||||
static inline QString toString(const std::unordered_multiset<T> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE::to_string(t);
|
||||
}
|
||||
};
|
||||
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
|
||||
template <typename T>
|
||||
struct QxConvert_ToString<QVector<T>>
|
||||
{
|
||||
static inline QString toString(const QVector<T> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE::to_string(t);
|
||||
}
|
||||
};
|
||||
#endif // (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
|
||||
|
||||
template <typename T>
|
||||
struct QxConvert_ToString<QList<T>>
|
||||
{
|
||||
static inline QString toString(const QList<T> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE::to_string(t);
|
||||
}
|
||||
};
|
||||
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 0))
|
||||
template <typename T>
|
||||
struct QxConvert_ToString<QLinkedList<T>>
|
||||
{
|
||||
static inline QString toString(const QLinkedList<T> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE::to_string(t);
|
||||
}
|
||||
};
|
||||
#endif // (QT_VERSION < QT_VERSION_CHECK(5, 15, 0))
|
||||
|
||||
template <typename T>
|
||||
struct QxConvert_ToString<QFlags<T>>
|
||||
{
|
||||
static inline QString toString(const QFlags<T> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QString::number(static_cast<int>(t));
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Key, typename Value>
|
||||
struct QxConvert_ToString<std::map<Key, Value>>
|
||||
{
|
||||
static inline QString toString(const std::map<Key, Value> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE::to_string(t);
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef _QX_ENABLE_BOOST
|
||||
|
||||
template <typename Key, typename Value>
|
||||
struct QxConvert_ToString<boost::unordered_map<Key, Value>>
|
||||
{
|
||||
static inline QString toString(const boost::unordered_map<Key, Value> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE::to_string(t);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Key, typename Value>
|
||||
struct QxConvert_ToString<boost::unordered_multimap<Key, Value>>
|
||||
{
|
||||
static inline QString toString(const boost::unordered_multimap<Key, Value> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE::to_string(t);
|
||||
}
|
||||
};
|
||||
|
||||
#endif // _QX_ENABLE_BOOST
|
||||
|
||||
template <typename Key, typename Value>
|
||||
struct QxConvert_ToString<std::unordered_map<Key, Value>>
|
||||
{
|
||||
static inline QString toString(const std::unordered_map<Key, Value> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE::to_string(t);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Key, typename Value>
|
||||
struct QxConvert_ToString<std::unordered_multimap<Key, Value>>
|
||||
{
|
||||
static inline QString toString(const std::unordered_multimap<Key, Value> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE::to_string(t);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Key, typename Value>
|
||||
struct QxConvert_ToString<QHash<Key, Value>>
|
||||
{
|
||||
static inline QString toString(const QHash<Key, Value> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE::to_string(t);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Key, typename Value>
|
||||
struct QxConvert_ToString<QMultiHash<Key, Value>>
|
||||
{
|
||||
static inline QString toString(const QMultiHash<Key, Value> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE::to_string(t);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Key, typename Value>
|
||||
struct QxConvert_ToString<QMap<Key, Value>>
|
||||
{
|
||||
static inline QString toString(const QMap<Key, Value> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE::to_string(t);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Key, typename Value>
|
||||
struct QxConvert_ToString<QMultiMap<Key, Value>>
|
||||
{
|
||||
static inline QString toString(const QMultiMap<Key, Value> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE::to_string(t);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Key, typename Value>
|
||||
struct QxConvert_ToString<qx::QxCollection<Key, Value>>
|
||||
{
|
||||
static inline QString toString(const qx::QxCollection<Key, Value> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE::to_string(t);
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef _QX_ENABLE_BOOST
|
||||
|
||||
template <typename T1>
|
||||
struct QxConvert_ToString<boost::tuple<T1>>
|
||||
{
|
||||
static inline QString toString(const boost::tuple<T1> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE::to_string(t);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T1, typename T2>
|
||||
struct QxConvert_ToString<boost::tuple<T1, T2>>
|
||||
{
|
||||
static inline QString toString(const boost::tuple<T1, T2> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE::to_string(t);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T1, typename T2, typename T3>
|
||||
struct QxConvert_ToString<boost::tuple<T1, T2, T3>>
|
||||
{
|
||||
static inline QString toString(const boost::tuple<T1, T2, T3> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE::to_string(t);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T1, typename T2, typename T3, typename T4>
|
||||
struct QxConvert_ToString<boost::tuple<T1, T2, T3, T4>>
|
||||
{
|
||||
static inline QString toString(const boost::tuple<T1, T2, T3, T4> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE::to_string(t);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T1, typename T2, typename T3, typename T4, typename T5>
|
||||
struct QxConvert_ToString<boost::tuple<T1, T2, T3, T4, T5>>
|
||||
{
|
||||
static inline QString toString(const boost::tuple<T1, T2, T3, T4, T5> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE::to_string(t);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
|
||||
struct QxConvert_ToString<boost::tuple<T1, T2, T3, T4, T5, T6>>
|
||||
{
|
||||
static inline QString toString(const boost::tuple<T1, T2, T3, T4, T5, T6> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE::to_string(t);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7>
|
||||
struct QxConvert_ToString<boost::tuple<T1, T2, T3, T4, T5, T6, T7>>
|
||||
{
|
||||
static inline QString toString(const boost::tuple<T1, T2, T3, T4, T5, T6, T7> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE::to_string(t);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8>
|
||||
struct QxConvert_ToString<boost::tuple<T1, T2, T3, T4, T5, T6, T7, T8>>
|
||||
{
|
||||
static inline QString toString(const boost::tuple<T1, T2, T3, T4, T5, T6, T7, T8> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE::to_string(t);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9>
|
||||
struct QxConvert_ToString<boost::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9>>
|
||||
{
|
||||
static inline QString toString(const boost::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE::to_string(t);
|
||||
}
|
||||
};
|
||||
|
||||
#endif // _QX_ENABLE_BOOST
|
||||
|
||||
template <typename T1>
|
||||
struct QxConvert_ToString<std::tuple<T1>>
|
||||
{
|
||||
static inline QString toString(const std::tuple<T1> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE::to_string(t);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T1, typename T2>
|
||||
struct QxConvert_ToString<std::tuple<T1, T2>>
|
||||
{
|
||||
static inline QString toString(const std::tuple<T1, T2> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE::to_string(t);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T1, typename T2, typename T3>
|
||||
struct QxConvert_ToString<std::tuple<T1, T2, T3>>
|
||||
{
|
||||
static inline QString toString(const std::tuple<T1, T2, T3> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE::to_string(t);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T1, typename T2, typename T3, typename T4>
|
||||
struct QxConvert_ToString<std::tuple<T1, T2, T3, T4>>
|
||||
{
|
||||
static inline QString toString(const std::tuple<T1, T2, T3, T4> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE::to_string(t);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T1, typename T2, typename T3, typename T4, typename T5>
|
||||
struct QxConvert_ToString<std::tuple<T1, T2, T3, T4, T5>>
|
||||
{
|
||||
static inline QString toString(const std::tuple<T1, T2, T3, T4, T5> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE::to_string(t);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
|
||||
struct QxConvert_ToString<std::tuple<T1, T2, T3, T4, T5, T6>>
|
||||
{
|
||||
static inline QString toString(const std::tuple<T1, T2, T3, T4, T5, T6> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE::to_string(t);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7>
|
||||
struct QxConvert_ToString<std::tuple<T1, T2, T3, T4, T5, T6, T7>>
|
||||
{
|
||||
static inline QString toString(const std::tuple<T1, T2, T3, T4, T5, T6, T7> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE::to_string(t);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8>
|
||||
struct QxConvert_ToString<std::tuple<T1, T2, T3, T4, T5, T6, T7, T8>>
|
||||
{
|
||||
static inline QString toString(const std::tuple<T1, T2, T3, T4, T5, T6, T7, T8> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE::to_string(t);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9>
|
||||
struct QxConvert_ToString<std::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9>>
|
||||
{
|
||||
static inline QString toString(const std::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE::to_string(t);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
} // namespace cvt
|
||||
} // namespace qx
|
||||
946
inl/QxConvert/QxConvert_ToVariant.inl
Normal file
946
inl/QxConvert/QxConvert_ToVariant.inl
Normal file
@@ -0,0 +1,946 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** https://www.qxorm.com/
|
||||
** Copyright (C) 2013 XDL Team (ic-east.com)
|
||||
**
|
||||
** This file is part of the QxOrm library
|
||||
**
|
||||
** This software is provided 'as-is', without any express or implied
|
||||
** warranty. In no event will the authors be held liable for any
|
||||
** damages arising from the use of this software
|
||||
**
|
||||
** Commercial Usage
|
||||
** Licensees holding valid commercial QxOrm licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and XDL Team
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3.0 as published by the Free Software
|
||||
** Foundation and appearing in the file 'license.gpl3.txt' included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU General Public License version 3.0 requirements will be
|
||||
** met : http://www.gnu.org/copyleft/gpl.html
|
||||
**
|
||||
** If you are unsure which license is appropriate for your use, or
|
||||
** if you have questions regarding the use of this file, please contact :
|
||||
** ic-east.com
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef _QX_ENABLE_BOOST_SERIALIZATION
|
||||
#define QX_CVT_DEFAULT_ARCHIVE_TO_VARIANT QX_CVT_DEFAULT_ARCHIVE::to_string(t)
|
||||
#else // _QX_ENABLE_BOOST_SERIALIZATION
|
||||
#define QX_CVT_DEFAULT_ARCHIVE_TO_VARIANT QX_CVT_DEFAULT_ARCHIVE::to_byte_array(t)
|
||||
#endif // _QX_ENABLE_BOOST_SERIALIZATION
|
||||
|
||||
#include <QxTraits/construct_null_qvariant.h>
|
||||
|
||||
namespace qx
|
||||
{
|
||||
namespace cvt
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template <>
|
||||
struct QxConvert_ToVariant<qx::trait::no_type>
|
||||
{
|
||||
static inline QVariant toVariant(const qx::trait::no_type &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(t);
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QVariant();
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_ToVariant<bool>
|
||||
{
|
||||
static inline QVariant toVariant(const bool &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QVariant(t);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_ToVariant<short>
|
||||
{
|
||||
static inline QVariant toVariant(const short &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QVariant(static_cast<int>(t));
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_ToVariant<int>
|
||||
{
|
||||
static inline QVariant toVariant(const int &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QVariant(t);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_ToVariant<long>
|
||||
{
|
||||
static inline QVariant toVariant(const long &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QVariant(static_cast<qlonglong>(t));
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_ToVariant<long long>
|
||||
{
|
||||
static inline QVariant toVariant(const long long &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QVariant(static_cast<qlonglong>(t));
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_ToVariant<float>
|
||||
{
|
||||
static inline QVariant toVariant(const float &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QVariant(static_cast<double>(t));
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_ToVariant<double>
|
||||
{
|
||||
static inline QVariant toVariant(const double &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QVariant(t);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_ToVariant<unsigned short>
|
||||
{
|
||||
static inline QVariant toVariant(const unsigned short &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QVariant(static_cast<unsigned int>(t));
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_ToVariant<unsigned int>
|
||||
{
|
||||
static inline QVariant toVariant(const unsigned int &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QVariant(t);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_ToVariant<unsigned long>
|
||||
{
|
||||
static inline QVariant toVariant(const unsigned long &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QVariant(static_cast<qulonglong>(t));
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_ToVariant<unsigned long long>
|
||||
{
|
||||
static inline QVariant toVariant(const unsigned long long &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QVariant(static_cast<qulonglong>(t));
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_ToVariant<QDate>
|
||||
{
|
||||
static inline QVariant toVariant(const QDate &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QVariant(t);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_ToVariant<QTime>
|
||||
{
|
||||
static inline QVariant toVariant(const QTime &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QVariant(t);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_ToVariant<QDateTime>
|
||||
{
|
||||
static inline QVariant toVariant(const QDateTime &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QVariant(t);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_ToVariant<QByteArray>
|
||||
{
|
||||
static inline QVariant toVariant(const QByteArray &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QVariant(t);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_ToVariant<QString>
|
||||
{
|
||||
static inline QVariant toVariant(const QString &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QVariant(t);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_ToVariant<QVariant>
|
||||
{
|
||||
static inline QVariant toVariant(const QVariant &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
if (ctx != qx::cvt::context::e_database)
|
||||
{
|
||||
return t;
|
||||
}
|
||||
if (!qx::cvt::detail::helper::checkConvertQVariantToString(t))
|
||||
{
|
||||
return t;
|
||||
}
|
||||
return QVariant(qx::cvt::detail::QxConvert_ToString<QVariant>::toString(t, format, index, ctx));
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_ToVariant<QUuid>
|
||||
{
|
||||
static inline QVariant toVariant(const QUuid &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QVariant(t.toString());
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_ToVariant<qx::QxDateNeutral>
|
||||
{
|
||||
static inline QVariant toVariant(const qx::QxDateNeutral &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QVariant(t.toNeutral());
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_ToVariant<qx::QxTimeNeutral>
|
||||
{
|
||||
static inline QVariant toVariant(const qx::QxTimeNeutral &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QVariant(t.toNeutral());
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_ToVariant<qx::QxDateTimeNeutral>
|
||||
{
|
||||
static inline QVariant toVariant(const qx::QxDateTimeNeutral &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QVariant(t.toNeutral());
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_ToVariant<std::string>
|
||||
{
|
||||
static inline QVariant toVariant(const std::string &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
#ifndef QT_NO_STL
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QString::fromStdString(t);
|
||||
}
|
||||
};
|
||||
#else // QT_NO_STL
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QString::fromLatin1(t.data(), int(t.size()));
|
||||
}
|
||||
};
|
||||
#endif // QT_NO_STL
|
||||
|
||||
template <>
|
||||
struct QxConvert_ToVariant<std::wstring>
|
||||
{
|
||||
static inline QVariant toVariant(const std::wstring &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
#if ((!defined(QT_NO_STL)) && (!defined(QT_NO_STL_WCHAR)))
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QString::fromStdWString(t);
|
||||
}
|
||||
};
|
||||
#else // ((! defined(QT_NO_STL)) && (! defined(QT_NO_STL_WCHAR)))
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
Q_UNUSED(t);
|
||||
qAssert(false); /* Need STL compatibility ! */
|
||||
return QVariant();
|
||||
}
|
||||
};
|
||||
#endif // ((! defined(QT_NO_STL)) && (! defined(QT_NO_STL_WCHAR)))
|
||||
|
||||
template <>
|
||||
struct QxConvert_ToVariant<qx_bool>
|
||||
{
|
||||
static inline QVariant toVariant(const qx_bool &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return t.toString();
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef _QX_NO_JSON
|
||||
|
||||
template <>
|
||||
struct QxConvert_ToVariant<QJsonValue>
|
||||
{
|
||||
static inline QVariant toVariant(const QJsonValue &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return t.toVariant();
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_ToVariant<QJsonArray>
|
||||
{
|
||||
static inline QVariant toVariant(const QJsonArray &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
QVariant var(t);
|
||||
return var;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct QxConvert_ToVariant<QJsonObject>
|
||||
{
|
||||
static inline QVariant toVariant(const QJsonObject &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
QVariant var(t);
|
||||
return var;
|
||||
}
|
||||
};
|
||||
|
||||
#endif // _QX_NO_JSON
|
||||
|
||||
#ifdef _QX_ENABLE_BOOST
|
||||
|
||||
template <typename T>
|
||||
struct QxConvert_ToVariant<boost::optional<T>>
|
||||
{
|
||||
static inline QVariant toVariant(const boost::optional<T> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
if (t)
|
||||
{
|
||||
return qx::cvt::to_variant((*t), format, index, ctx);
|
||||
};
|
||||
return qx::trait::construct_null_qvariant<T>::get();
|
||||
}
|
||||
};
|
||||
|
||||
#endif // _QX_ENABLE_BOOST
|
||||
|
||||
template <typename T1, typename T2>
|
||||
struct QxConvert_ToVariant<std::pair<T1, T2>>
|
||||
{
|
||||
static inline QVariant toVariant(const std::pair<T1, T2> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE_TO_VARIANT;
|
||||
}
|
||||
};
|
||||
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
|
||||
template <typename T1, typename T2>
|
||||
struct QxConvert_ToVariant<QPair<T1, T2>>
|
||||
{
|
||||
static inline QVariant toVariant(const QPair<T1, T2> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE_TO_VARIANT;
|
||||
}
|
||||
};
|
||||
#endif // (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
|
||||
|
||||
template <typename T>
|
||||
struct QxConvert_ToVariant<std::vector<T>>
|
||||
{
|
||||
static inline QVariant toVariant(const std::vector<T> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE_TO_VARIANT;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct QxConvert_ToVariant<std::list<T>>
|
||||
{
|
||||
static inline QVariant toVariant(const std::list<T> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE_TO_VARIANT;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct QxConvert_ToVariant<std::set<T>>
|
||||
{
|
||||
static inline QVariant toVariant(const std::set<T> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE_TO_VARIANT;
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef _QX_ENABLE_BOOST
|
||||
|
||||
template <typename T>
|
||||
struct QxConvert_ToVariant<boost::unordered_set<T>>
|
||||
{
|
||||
static inline QVariant toVariant(const boost::unordered_set<T> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE_TO_VARIANT;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct QxConvert_ToVariant<boost::unordered_multiset<T>>
|
||||
{
|
||||
static inline QVariant toVariant(const boost::unordered_multiset<T> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE_TO_VARIANT;
|
||||
}
|
||||
};
|
||||
|
||||
#endif // _QX_ENABLE_BOOST
|
||||
|
||||
template <typename T>
|
||||
struct QxConvert_ToVariant<std::unordered_set<T>>
|
||||
{
|
||||
static inline QVariant toVariant(const std::unordered_set<T> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE_TO_VARIANT;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct QxConvert_ToVariant<std::unordered_multiset<T>>
|
||||
{
|
||||
static inline QVariant toVariant(const std::unordered_multiset<T> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE_TO_VARIANT;
|
||||
}
|
||||
};
|
||||
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
|
||||
template <typename T>
|
||||
struct QxConvert_ToVariant<QVector<T>>
|
||||
{
|
||||
static inline QVariant toVariant(const QVector<T> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE_TO_VARIANT;
|
||||
}
|
||||
};
|
||||
#endif // (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
|
||||
|
||||
template <typename T>
|
||||
struct QxConvert_ToVariant<QList<T>>
|
||||
{
|
||||
static inline QVariant toVariant(const QList<T> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE_TO_VARIANT;
|
||||
}
|
||||
};
|
||||
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 0))
|
||||
template <typename T>
|
||||
struct QxConvert_ToVariant<QLinkedList<T>>
|
||||
{
|
||||
static inline QVariant toVariant(const QLinkedList<T> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE_TO_VARIANT;
|
||||
}
|
||||
};
|
||||
#endif // (QT_VERSION < QT_VERSION_CHECK(5, 15, 0))
|
||||
|
||||
template <typename T>
|
||||
struct QxConvert_ToVariant<QFlags<T>>
|
||||
{
|
||||
static inline QVariant toVariant(const QFlags<T> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QString::number(static_cast<int>(t));
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Key, typename Value>
|
||||
struct QxConvert_ToVariant<std::map<Key, Value>>
|
||||
{
|
||||
static inline QVariant toVariant(const std::map<Key, Value> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE_TO_VARIANT;
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef _QX_ENABLE_BOOST
|
||||
|
||||
template <typename Key, typename Value>
|
||||
struct QxConvert_ToVariant<boost::unordered_map<Key, Value>>
|
||||
{
|
||||
static inline QVariant toVariant(const boost::unordered_map<Key, Value> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE_TO_VARIANT;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Key, typename Value>
|
||||
struct QxConvert_ToVariant<boost::unordered_multimap<Key, Value>>
|
||||
{
|
||||
static inline QVariant toVariant(const boost::unordered_multimap<Key, Value> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE_TO_VARIANT;
|
||||
}
|
||||
};
|
||||
|
||||
#endif // _QX_ENABLE_BOOST
|
||||
|
||||
template <typename Key, typename Value>
|
||||
struct QxConvert_ToVariant<std::unordered_map<Key, Value>>
|
||||
{
|
||||
static inline QVariant toVariant(const std::unordered_map<Key, Value> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE_TO_VARIANT;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Key, typename Value>
|
||||
struct QxConvert_ToVariant<std::unordered_multimap<Key, Value>>
|
||||
{
|
||||
static inline QVariant toVariant(const std::unordered_multimap<Key, Value> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE_TO_VARIANT;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Key, typename Value>
|
||||
struct QxConvert_ToVariant<QHash<Key, Value>>
|
||||
{
|
||||
static inline QVariant toVariant(const QHash<Key, Value> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE_TO_VARIANT;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Key, typename Value>
|
||||
struct QxConvert_ToVariant<QMultiHash<Key, Value>>
|
||||
{
|
||||
static inline QVariant toVariant(const QMultiHash<Key, Value> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE_TO_VARIANT;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Key, typename Value>
|
||||
struct QxConvert_ToVariant<QMap<Key, Value>>
|
||||
{
|
||||
static inline QVariant toVariant(const QMap<Key, Value> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE_TO_VARIANT;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Key, typename Value>
|
||||
struct QxConvert_ToVariant<QMultiMap<Key, Value>>
|
||||
{
|
||||
static inline QVariant toVariant(const QMultiMap<Key, Value> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE_TO_VARIANT;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Key, typename Value>
|
||||
struct QxConvert_ToVariant<qx::QxCollection<Key, Value>>
|
||||
{
|
||||
static inline QVariant toVariant(const qx::QxCollection<Key, Value> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE_TO_VARIANT;
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef _QX_ENABLE_BOOST
|
||||
|
||||
template <typename T1>
|
||||
struct QxConvert_ToVariant<boost::tuple<T1>>
|
||||
{
|
||||
static inline QVariant toVariant(const boost::tuple<T1> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE_TO_VARIANT;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T1, typename T2>
|
||||
struct QxConvert_ToVariant<boost::tuple<T1, T2>>
|
||||
{
|
||||
static inline QVariant toVariant(const boost::tuple<T1, T2> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE_TO_VARIANT;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T1, typename T2, typename T3>
|
||||
struct QxConvert_ToVariant<boost::tuple<T1, T2, T3>>
|
||||
{
|
||||
static inline QVariant toVariant(const boost::tuple<T1, T2, T3> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE_TO_VARIANT;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T1, typename T2, typename T3, typename T4>
|
||||
struct QxConvert_ToVariant<boost::tuple<T1, T2, T3, T4>>
|
||||
{
|
||||
static inline QVariant toVariant(const boost::tuple<T1, T2, T3, T4> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE_TO_VARIANT;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T1, typename T2, typename T3, typename T4, typename T5>
|
||||
struct QxConvert_ToVariant<boost::tuple<T1, T2, T3, T4, T5>>
|
||||
{
|
||||
static inline QVariant toVariant(const boost::tuple<T1, T2, T3, T4, T5> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE_TO_VARIANT;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
|
||||
struct QxConvert_ToVariant<boost::tuple<T1, T2, T3, T4, T5, T6>>
|
||||
{
|
||||
static inline QVariant toVariant(const boost::tuple<T1, T2, T3, T4, T5, T6> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE_TO_VARIANT;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7>
|
||||
struct QxConvert_ToVariant<boost::tuple<T1, T2, T3, T4, T5, T6, T7>>
|
||||
{
|
||||
static inline QVariant toVariant(const boost::tuple<T1, T2, T3, T4, T5, T6, T7> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE_TO_VARIANT;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8>
|
||||
struct QxConvert_ToVariant<boost::tuple<T1, T2, T3, T4, T5, T6, T7, T8>>
|
||||
{
|
||||
static inline QVariant toVariant(const boost::tuple<T1, T2, T3, T4, T5, T6, T7, T8> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE_TO_VARIANT;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9>
|
||||
struct QxConvert_ToVariant<boost::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9>>
|
||||
{
|
||||
static inline QVariant toVariant(const boost::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE_TO_VARIANT;
|
||||
}
|
||||
};
|
||||
|
||||
#endif // _QX_ENABLE_BOOST
|
||||
|
||||
template <typename T1>
|
||||
struct QxConvert_ToVariant<std::tuple<T1>>
|
||||
{
|
||||
static inline QVariant toVariant(const std::tuple<T1> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE_TO_VARIANT;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T1, typename T2>
|
||||
struct QxConvert_ToVariant<std::tuple<T1, T2>>
|
||||
{
|
||||
static inline QVariant toVariant(const std::tuple<T1, T2> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE_TO_VARIANT;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T1, typename T2, typename T3>
|
||||
struct QxConvert_ToVariant<std::tuple<T1, T2, T3>>
|
||||
{
|
||||
static inline QVariant toVariant(const std::tuple<T1, T2, T3> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE_TO_VARIANT;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T1, typename T2, typename T3, typename T4>
|
||||
struct QxConvert_ToVariant<std::tuple<T1, T2, T3, T4>>
|
||||
{
|
||||
static inline QVariant toVariant(const std::tuple<T1, T2, T3, T4> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE_TO_VARIANT;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T1, typename T2, typename T3, typename T4, typename T5>
|
||||
struct QxConvert_ToVariant<std::tuple<T1, T2, T3, T4, T5>>
|
||||
{
|
||||
static inline QVariant toVariant(const std::tuple<T1, T2, T3, T4, T5> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE_TO_VARIANT;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
|
||||
struct QxConvert_ToVariant<std::tuple<T1, T2, T3, T4, T5, T6>>
|
||||
{
|
||||
static inline QVariant toVariant(const std::tuple<T1, T2, T3, T4, T5, T6> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE_TO_VARIANT;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7>
|
||||
struct QxConvert_ToVariant<std::tuple<T1, T2, T3, T4, T5, T6, T7>>
|
||||
{
|
||||
static inline QVariant toVariant(const std::tuple<T1, T2, T3, T4, T5, T6, T7> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE_TO_VARIANT;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8>
|
||||
struct QxConvert_ToVariant<std::tuple<T1, T2, T3, T4, T5, T6, T7, T8>>
|
||||
{
|
||||
static inline QVariant toVariant(const std::tuple<T1, T2, T3, T4, T5, T6, T7, T8> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE_TO_VARIANT;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9>
|
||||
struct QxConvert_ToVariant<std::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9>>
|
||||
{
|
||||
static inline QVariant toVariant(const std::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9> &t, const QString &format, int index, qx::cvt::context::ctx_type ctx)
|
||||
{
|
||||
Q_UNUSED(format);
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(ctx);
|
||||
return QX_CVT_DEFAULT_ARCHIVE_TO_VARIANT;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
} // namespace cvt
|
||||
} // namespace qx
|
||||
1015
inl/QxConvert/QxConvert_WithIndex.inl
Normal file
1015
inl/QxConvert/QxConvert_WithIndex.inl
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user