Commit c50b87ac authored by EXT Arnaud Clère's avatar EXT Arnaud Clère

Fixed warnings

parent b20a8a10
......@@ -355,8 +355,8 @@ protected:
bool tryBind ( qint64& t) { if (caching) { return caching->tryBind(t) && cacheOut(); }
quint64 i; bool neg;
if (!getInteger(i,neg)) { handleError(qBindExpectedInteger ); return false; }
if ( neg ) { if (quint64(-std::numeric_limits<qint64>::min())<i) { handleError(qBindExpectedSmallerNumber); return false; } t=-qint64(i); return true; }
else { if (quint64( std::numeric_limits<qint64>::max())<i) { handleError(qBindExpectedSmallerNumber); return false; } t= qint64(i); return true; }
if ( neg ) { if (-quint64(std::numeric_limits<qint64>::max())-1<i) { handleError(qBindExpectedSmallerNumber); return false; } t=-qint64(i); return true; }
else { if ( quint64(std::numeric_limits<qint64>::max()) <i) { handleError(qBindExpectedSmallerNumber); return false; } t= qint64(i); return true; }
}
bool tryItem( QIdentifierLiteral u) { if (caching) { return caching->tryItem(u); }
......
......@@ -175,8 +175,8 @@ class QAsciiData : public QData<Ascii>
public:
using QData::QData;
const QByteArray utf8() const noexcept { return m_bytes; }
constexpr QLatin1String latin1() const noexcept { return QLatin1String(m_bytes.data(), m_bytes.size()); }
const QByteArray utf8() const noexcept { return m_bytes; }
const QLatin1String latin1() const noexcept { return QLatin1String(m_bytes.data(), m_bytes.size()); }
};
Q_DECLARE_METATYPE(QAsciiData)
......@@ -198,8 +198,8 @@ public:
explicit QIdentifier( QByteArray&& b) : QData(b) {}
explicit QIdentifier(const QByteArray& b) : QData(b) {}
const QByteArray& utf8() const noexcept { return m_bytes; }
constexpr QLatin1String latin1() const noexcept { return QLatin1String(m_bytes.data(), m_bytes.size()); }
const QByteArray& utf8() const noexcept { return m_bytes; }
const QLatin1String latin1() const noexcept { return QLatin1String(m_bytes.data(), m_bytes.size()); }
};
Q_DECLARE_METATYPE(QIdentifier)
......
......@@ -302,8 +302,8 @@ protected:
auto r=getNumber();
if (r==None) return false; // already reported qBindExpectedDecimal
if (r==FloatingPoint) { handleError(qBindExpectedInteger); return false; }
if (!neg && i<quint64( std::numeric_limits<qint64>::max())) { t = qint64(i); cachedNumber=None; return true; }
if ( neg && i<quint64(-std::numeric_limits<qint64>::min())) { t = -qint64(i); cachedNumber=None; return true; }
if (!neg && i<quint64( std::numeric_limits<qint64>::max()) ) { t = qint64(i); cachedNumber=None; return true; }
if ( neg && i<quint64(-std::numeric_limits<qint64>::max())-1) { t = -qint64(i); cachedNumber=None; return true; }
handleError(qBindExpectedSmallerNumber); return false; }
bool tryBind ( QVariant& dst) { if (caching) { return caching->tryBind(dst) && cacheOut(); }
auto suspended = setErrorHandler();
......
......@@ -583,17 +583,17 @@ struct QAbstractValueWriter : public QAbstractValue
if (src.type()==QVariant::Bool ) return tryBind(src.value< bool>());
if (src.type()==QVariant::LongLong ) return tryBind(src.value< qlonglong>()); // or qint64 to be sure to call the good tryBind()?
if (src.type()==QVariant::ULongLong ) return tryBind(src.value< qulonglong>()); // or quint64 to be sure to call the good tryBind()?
if (src.type()==QMetaType::ULong ) return tryBind(src.value< quint32>());
if (src.type()==QMetaType::Long ) return tryBind(src.value< qint32>());
if (src.type()==QMetaType::Short ) return tryBind(src.value< short>());
if (src.type()==QMetaType::Char ) return tryBind(src.value< char>());
if (src.type()==QMetaType::UShort ) return tryBind(src.value< ushort>());
if (src.type()==QMetaType::UChar ) return tryBind(src.value< uchar>());
if (src.type()==QMetaType::SChar ) return tryBind(src.value<signed char>());
if (src.type()==int(QMetaType::ULong )) return tryBind(src.value< quint32>());
if (src.type()==int(QMetaType::Long )) return tryBind(src.value< qint32>());
if (src.type()==int(QMetaType::Short )) return tryBind(src.value< short>());
if (src.type()==int(QMetaType::Char )) return tryBind(src.value< char>());
if (src.type()==int(QMetaType::UShort )) return tryBind(src.value< ushort>());
if (src.type()==int(QMetaType::UChar )) return tryBind(src.value< uchar>());
if (src.type()==int(QMetaType::SChar )) return tryBind(src.value<signed char>());
if (src.type()==QVariant::UInt ) return tryBind(src.value< uint>());
if (src.type()==QVariant::Int ) return tryBind(src.value< int>());
if (src.type()==QVariant::Double ) return tryBind(src.value< double>());
if (src.type()==QMetaType::Float ) return tryBind(src.value< float>());
if (src.type()==int(QMetaType::Float )) return tryBind(src.value< float>());
// See QT_FOR_EACH_STATIC_PRIMITIVE_TYPE in qmetatype.h
// QDataStream format is the only Qt data format that is read-write and easily extensible by users
......@@ -665,8 +665,10 @@ struct QAbstractValueReader : public QAbstractValue
virtual bool tryBind( QUtf8Data& s) = 0;
virtual bool tryBind( QString& s) { QUtf8Data u; if (!tryBind(u)) return false; s=QString::fromUtf8(u.utf8()); return true; }
virtual bool tryBind( bool& b) { QUtf8Data u; if (!tryBind(u)) return false; if (u.utf8().compare("true" , Qt::CaseInsensitive)==0) { b=true ; } else
if (u.utf8().compare("false", Qt::CaseInsensitive)==0) { b=false; } else { handleError(qBindExpectedBoolean ); return false; } return true; }
virtual bool tryBind( bool& b) { QUtf8Data u; if (!tryBind(u)) return false;
if (u.utf8().compare("true" , Qt::CaseInsensitive)==0) { b=true ; }
else if (u.utf8().compare("false", Qt::CaseInsensitive)==0) { b=false; }
else { handleError(qBindExpectedBoolean); return false; } return true; }
virtual bool tryBind( qint8& n) { qint64 l; if (!tryBind(l)) return false; if (l<std::numeric_limits< qint8>::min() || std::numeric_limits< qint8>::max()<l) { handleError(qBindExpectedSmallerNumber); return false; } n= qint8(l); return true; }
virtual bool tryBind( quint8& n) { quint64 l; if (!tryBind(l)) return false; if ( std::numeric_limits< quint8>::max()<l) { handleError(qBindExpectedSmallerNumber); return false; } n= quint8(l); return true; }
virtual bool tryBind( qint16& n) { qint64 l; if (!tryBind(l)) return false; if (l<std::numeric_limits< qint16>::min() || std::numeric_limits< qint16>::max()<l) { handleError(qBindExpectedSmallerNumber); return false; } n= qint16(l); return true; }
......@@ -890,27 +892,27 @@ QValueStatus qMetaZap(QValue&& v, T* t) {
QAsciiData(p.enumerator().valueToKey (pv.value<int>())));
}
if (pv.userType()==qMetaTypeId<QUtf8Data>() // TODO pv.type if QUtf8Data becomes a Qt type
) r = i.bind(pv.value< QUtf8Data>());
else if (pv.type()==QVariant::String ) r = i.bind(pv.value< QString>());
else if (pv.type()==QVariant::Char ) r = i.bind(pv. toString());
else if (pv.type()==QVariant::Bool ) r = i.bind(pv.value< bool>());
else if (pv.type()==QVariant::LongLong ) r = i.bind(pv.value< qlonglong>()); // or qint64 to be sure to call the good tryBind()?
else if (pv.type()==QVariant::ULongLong) r = i.bind(pv.value< qulonglong>()); // or quint64 to be sure to call the good tryBind()?
else if (pv.type()==QMetaType::ULong ) r = i.bind(pv.value< quint32>());
else if (pv.type()==QMetaType::Long ) r = i.bind(pv.value< qint32>());
else if (pv.type()==QMetaType::Short ) r = i.bind(pv.value< short>());
else if (pv.type()==QMetaType::Char ) r = i.bind(pv.value< char>());
else if (pv.type()==QMetaType::UShort ) r = i.bind(pv.value< ushort>());
else if (pv.type()==QMetaType::UChar ) r = i.bind(pv.value< uchar>());
else if (pv.type()==QMetaType::SChar ) r = i.bind(pv.value< signed char>());
else if (pv.type()==QVariant::UInt ) r = i.bind(pv.value< uint>());
else if (pv.type()==QVariant::Int ) r = i.bind(pv.value< int>());
else if (pv.type()==QVariant::Double ) r = i.bind(pv.value< double>());
else if (pv.type()==QMetaType::Float ) r = i.bind(pv.value< float>());
) r = i.bind(pv.value< QUtf8Data>());
else if (pv.type()==QVariant::String ) r = i.bind(pv.value< QString>());
else if (pv.type()==QVariant::Char ) r = i.bind(pv. toString());
else if (pv.type()==QVariant::Bool ) r = i.bind(pv.value< bool>());
else if (pv.type()==QVariant::LongLong ) r = i.bind(pv.value< qlonglong>()); // or qint64 to be sure to call the good tryBind()?
else if (pv.type()==QVariant::ULongLong ) r = i.bind(pv.value< qulonglong>()); // or quint64 to be sure to call the good tryBind()?
else if (pv.type()==int(QMetaType::ULong )) r = i.bind(pv.value< quint32>());
else if (pv.type()==int(QMetaType::Long )) r = i.bind(pv.value< qint32>());
else if (pv.type()==int(QMetaType::Short )) r = i.bind(pv.value< short>());
else if (pv.type()==int(QMetaType::Char )) r = i.bind(pv.value< char>());
else if (pv.type()==int(QMetaType::UShort)) r = i.bind(pv.value< ushort>());
else if (pv.type()==int(QMetaType::UChar )) r = i.bind(pv.value< uchar>());
else if (pv.type()==int(QMetaType::SChar )) r = i.bind(pv.value< signed char>());
else if (pv.type()==QVariant::UInt ) r = i.bind(pv.value< uint>());
else if (pv.type()==QVariant::Int ) r = i.bind(pv.value< int>());
else if (pv.type()==QVariant::Double ) r = i.bind(pv.value< double>());
else if (pv.type()==int(QMetaType::Float )) r = i.bind(pv.value< float>());
// See QT_FOR_EACH_STATIC_PRIMITIVE_TYPE in qmetatype.h
else if (pv.canConvert<QVariantList>() ) r = i.bind(pv.value<QVariantList>()); // TODO avoid interim data structure
else if (pv.canConvert<QVariantMap >() ) r = i.bind(pv.value<QVariantMap >()); // TODO avoid interim data structure
else if (pv.isNull() ) r = i.null();
else if (pv.canConvert<QVariantList>() ) r = i.bind(pv.value<QVariantList>()); // TODO avoid interim data structure
else if (pv.canConvert<QVariantMap >() ) r = i.bind(pv.value<QVariantMap >()); // TODO avoid interim data structure
else if (pv.isNull() ) r = i.null();
else if (!pv.isValid() || v->handleError(qBindUnexpectedValue)) r = i.any();
}
}
......
#include "data.h"
#include<QtCore/qdebug.h>
QDebug &operator<<(QDebug &out, const Phone &p) { return out.nospace() << "Phone(" << p._t << ", " << p._n << ")" ; }
QDebug &operator<<(QDebug &out, const Phone &p) { out.nospace() << "Phone(" << p._t << ", " << p._n << ")"; return out; }
#include<QtCore/qdatastream.h>
QDataStream &operator<<(QDataStream &out, const Phone &p) { return out << quint8(p._t) << p._n ; }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment