/**************************************************************************** ** ** 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 { 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 { 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 { 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 { 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 { 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 { 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 { 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 { 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(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 { 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 { 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 { 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 { 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 { 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 { 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 { 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 { 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 { 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 { 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 { 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 { 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 { 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 { 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 { 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 { 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 { 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 { 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 { 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 struct QxConvert_ToString> { static inline QString toString(const boost::optional &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 struct QxConvert_ToString> { static inline QString toString(const std::pair &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 struct QxConvert_ToString> { static inline QString toString(const QPair &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 struct QxConvert_ToString> { static inline QString toString(const std::vector &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 struct QxConvert_ToString> { static inline QString toString(const std::list &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 struct QxConvert_ToString> { static inline QString toString(const std::set &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 struct QxConvert_ToString> { static inline QString toString(const boost::unordered_set &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 struct QxConvert_ToString> { static inline QString toString(const boost::unordered_multiset &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 struct QxConvert_ToString> { static inline QString toString(const std::unordered_set &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 struct QxConvert_ToString> { static inline QString toString(const std::unordered_multiset &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 struct QxConvert_ToString> { static inline QString toString(const QVector &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 struct QxConvert_ToString> { static inline QString toString(const QList &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 struct QxConvert_ToString> { static inline QString toString(const QLinkedList &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 struct QxConvert_ToString> { static inline QString toString(const QFlags &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(t)); } }; template struct QxConvert_ToString> { static inline QString toString(const std::map &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 struct QxConvert_ToString> { static inline QString toString(const boost::unordered_map &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 struct QxConvert_ToString> { static inline QString toString(const boost::unordered_multimap &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 struct QxConvert_ToString> { static inline QString toString(const std::unordered_map &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 struct QxConvert_ToString> { static inline QString toString(const std::unordered_multimap &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 struct QxConvert_ToString> { static inline QString toString(const QHash &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 struct QxConvert_ToString> { static inline QString toString(const QMultiHash &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 struct QxConvert_ToString> { static inline QString toString(const QMap &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 struct QxConvert_ToString> { static inline QString toString(const QMultiMap &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 struct QxConvert_ToString> { static inline QString toString(const qx::QxCollection &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 struct QxConvert_ToString> { static inline QString toString(const boost::tuple &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 struct QxConvert_ToString> { static inline QString toString(const boost::tuple &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 struct QxConvert_ToString> { static inline QString toString(const boost::tuple &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 struct QxConvert_ToString> { static inline QString toString(const boost::tuple &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 struct QxConvert_ToString> { static inline QString toString(const boost::tuple &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 struct QxConvert_ToString> { static inline QString toString(const boost::tuple &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 struct QxConvert_ToString> { static inline QString toString(const boost::tuple &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 struct QxConvert_ToString> { static inline QString toString(const boost::tuple &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 struct QxConvert_ToString> { static inline QString toString(const boost::tuple &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 struct QxConvert_ToString> { static inline QString toString(const std::tuple &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 struct QxConvert_ToString> { static inline QString toString(const std::tuple &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 struct QxConvert_ToString> { static inline QString toString(const std::tuple &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 struct QxConvert_ToString> { static inline QString toString(const std::tuple &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 struct QxConvert_ToString> { static inline QString toString(const std::tuple &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 struct QxConvert_ToString> { static inline QString toString(const std::tuple &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 struct QxConvert_ToString> { static inline QString toString(const std::tuple &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 struct QxConvert_ToString> { static inline QString toString(const std::tuple &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 struct QxConvert_ToString> { static inline QString toString(const std::tuple &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