Commit 51dab6dc authored by EXT Arnaud Clère's avatar EXT Arnaud Clère

minor changes

parent 9a5fc2a4
...@@ -539,8 +539,8 @@ struct QTransmogrifier<QJsonValue> { ...@@ -539,8 +539,8 @@ struct QTransmogrifier<QJsonValue> {
quint64 u; if ((r = v.bind(u))) { j = QJsonValue(double(u)); return r; } quint64 u; if ((r = v.bind(u))) { j = QJsonValue(double(u)); return r; }
double d; if ((r = v.bind(d))) { j = QJsonValue( d ); return r; } double d; if ((r = v.bind(d))) { j = QJsonValue( d ); return r; }
v->setErrorHandler(suspended); v->setErrorHandler(suspended);
if (!(r = v.null())) r.handleError("ExpectedBoolDoubleQStringQJsonArrayQJsonOnjectNull"); if (!(r = v.null())) r.handleError(qBindExpectedValue);
/**/ j = QJsonValue( ); return r; /**/ j = QJsonValue( ); return r;
} }
else { Q_ASSERT_X(!v, Q_FUNC_INFO, "Unsupported v->mode()"); return v.null(); } else { Q_ASSERT_X(!v, Q_FUNC_INFO, "Unsupported v->mode()"); return v.null(); }
} }
......
#include "QValue.h" #include "QValue.h"
QIdentifierLiteral qBindExpectedItem ("ExpectedItem" ); QIdentifierLiteral qBindExpectedValue ("ExpectedValue" );
QIdentifierLiteral qBindExpectedNull ("ExpectedNull" ); QIdentifierLiteral qBindExpectedItem ("ExpectedItem" );
QIdentifierLiteral qBindExpectedSequence ("ExpectedSequence" ); QIdentifierLiteral qBindExpectedNull ("ExpectedNull" );
QIdentifierLiteral qBindExpectedRecord ("ExpectedRecord" ); QIdentifierLiteral qBindExpectedSequence ("ExpectedSequence" );
QIdentifierLiteral qBindExpectedText ("ExpectedText" ); QIdentifierLiteral qBindExpectedRecord ("ExpectedRecord" );
QIdentifierLiteral qBindExpectedBytes ("ExpectedBytes" ); QIdentifierLiteral qBindExpectedText ("ExpectedText" );
QIdentifierLiteral qBindExpectedInteger ("ExpectedInteger" ); QIdentifierLiteral qBindExpectedBytes ("ExpectedBytes" );
QIdentifierLiteral qBindExpectedDecimal ("ExpectedDecimal" ); QIdentifierLiteral qBindExpectedInteger ("ExpectedInteger" );
QIdentifierLiteral qBindExpectedSmallerNumber ("ExpectedSmallerNumber" ); QIdentifierLiteral qBindExpectedDecimal ("ExpectedDecimal" );
QIdentifierLiteral qBindExpectedSmallerNumber ("ExpectedSmallerNumber" );
QIdentifierLiteral qBindExpectedPositiveInteger("ExpectedPositiveInteger"); QIdentifierLiteral qBindExpectedPositiveInteger("ExpectedPositiveInteger");
QIdentifierLiteral qBindExpectedBoolean ("ExpectedBoolean" ); QIdentifierLiteral qBindExpectedBoolean ("ExpectedBoolean" );
QIdentifierLiteral qBindExpectedConstant ("ExpectedConstant" ); QIdentifierLiteral qBindExpectedConstant ("ExpectedConstant" );
QIdentifierLiteral qBindIgnoredItem ("IgnoredItem" ); QIdentifierLiteral qBindIgnoredItem ("IgnoredItem" );
QIdentifierLiteral qBindIgnoredItemName ("IgnoredItemName" ); QIdentifierLiteral qBindIgnoredItemName ("IgnoredItemName" );
QIdentifierLiteral qBindIgnoredCharacter ("IgnoredCharacter" ); QIdentifierLiteral qBindIgnoredCharacter ("IgnoredCharacter" );
QIdentifierLiteral qBindIgnoredBytes ("IgnoredBytes" ); QIdentifierLiteral qBindIgnoredBytes ("IgnoredBytes" );
QIdentifierLiteral qmDataStreamVersion ("qmDataStreamVersion" ); QIdentifierLiteral qmDataStreamVersion ("qmDataStreamVersion" );
QIdentifierLiteral qmColumns ("columns" ); QIdentifierLiteral qmColumns ("columns" );
QIdentifierLiteral qmSizes ("sizes" ); QIdentifierLiteral qmSizes ("sizes" );
QIdentifierLiteral qmChildren ("children" ); QIdentifierLiteral qmChildren ("children" );
QIdentifierLiteral qmName ("name" ); QIdentifierLiteral qmName ("name" );
QIdentifierLiteral qmColor ("color" ); QIdentifierLiteral qmColor ("color" );
QValue QValueStatus::value() noexcept { return QValue(std::move(*this)); } QValue QValueStatus::value() noexcept { return QValue(std::move(*this)); }
...@@ -52,23 +52,24 @@ ...@@ -52,23 +52,24 @@
// ////////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////////
// Standard error names // Standard error names
extern QIdentifierLiteral qBindExpectedItem ; extern QIdentifierLiteral qBindExpectedValue;
extern QIdentifierLiteral qBindExpectedNull ; extern QIdentifierLiteral qBindExpectedItem;
extern QIdentifierLiteral qBindExpectedSequence ; extern QIdentifierLiteral qBindExpectedNull;
extern QIdentifierLiteral qBindExpectedRecord ; extern QIdentifierLiteral qBindExpectedSequence;
extern QIdentifierLiteral qBindExpectedText ; extern QIdentifierLiteral qBindExpectedRecord;
extern QIdentifierLiteral qBindExpectedBytes ; extern QIdentifierLiteral qBindExpectedText;
extern QIdentifierLiteral qBindExpectedInteger ; extern QIdentifierLiteral qBindExpectedBytes;
extern QIdentifierLiteral qBindExpectedDecimal ; extern QIdentifierLiteral qBindExpectedInteger;
extern QIdentifierLiteral qBindExpectedSmallerNumber ; extern QIdentifierLiteral qBindExpectedDecimal;
extern QIdentifierLiteral qBindExpectedSmallerNumber;
extern QIdentifierLiteral qBindExpectedPositiveInteger; extern QIdentifierLiteral qBindExpectedPositiveInteger;
extern QIdentifierLiteral qBindExpectedBoolean ; extern QIdentifierLiteral qBindExpectedBoolean;
extern QIdentifierLiteral qBindExpectedConstant ; extern QIdentifierLiteral qBindExpectedConstant;
extern QIdentifierLiteral qBindIgnoredItem ; extern QIdentifierLiteral qBindIgnoredItem;
extern QIdentifierLiteral qBindIgnoredItemName ; extern QIdentifierLiteral qBindIgnoredItemName;
extern QIdentifierLiteral qBindIgnoredCharacter ; extern QIdentifierLiteral qBindIgnoredCharacter;
extern QIdentifierLiteral qBindIgnoredBytes ; extern QIdentifierLiteral qBindIgnoredBytes;
// ////////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////////
// Standard meta data names // Standard meta data names
...@@ -262,7 +263,7 @@ public: ...@@ -262,7 +263,7 @@ public:
QValueStatus* operator ->() noexcept { return this; } QValueStatus* operator ->() noexcept { return this; }
QVal<QValueStatus> value() noexcept ; QVal<QValueStatus> value() noexcept ;
QValueErrorHandler setErrorHandler(QValueErrorHandler newHandler = nullptr) { return Q_LIKELY(impl) ? impl->setErrorHandler(newHandler) : nullptr; } QValueErrorHandler setErrorHandler(QValueErrorHandler newHandler = nullptr) { return Q_LIKELY(impl) ? impl->setErrorHandler(newHandler) : nullptr; }
bool handleError(QIdentifierLiteral name, QString context = QString()) { return Q_LIKELY(impl) ? impl->handleError(name, context) : false; } bool handleError(QIdentifierLiteral name, QString context = QString()) { return Q_LIKELY(impl) ? impl->handleError(name, context) : false; }
bool handleError(const char* asciiName, QString context = QString()) { return handleError(QIdentifierLiteral(asciiName), context); } bool handleError(const char* asciiName, QString context = QString()) { return handleError(QIdentifierLiteral(asciiName), context); }
protected: protected:
...@@ -557,7 +558,7 @@ struct QAbstractValueWriter : public QAbstractValue ...@@ -557,7 +558,7 @@ struct QAbstractValueWriter : public QAbstractValue
} }
return tryOut(); return tryOut();
} }
if (src.canConvert<QVariantMap >() ) { // TODO _meta({{qmColumns,"key,value"}}) trySequence() ... if (src.canConvert<QVariantMap >()) { // TODO _meta(qmColumns,"key,value") trySequence() ...
QAssociativeIterable ts = src.value<QAssociativeIterable>(); QAssociativeIterable ts = src.value<QAssociativeIterable>();
quint32 size=quint32(ts.size()); quint32 size=quint32(ts.size());
if (!tryRecord(&size)) { if (!tryRecord(&size)) {
...@@ -730,16 +731,16 @@ struct QAbstractValueReader : public QAbstractValue ...@@ -730,16 +731,16 @@ struct QAbstractValueReader : public QAbstractValue
||(tryRecord () && tryOut())) { ||(tryRecord () && tryOut())) {
return true; return true;
} }
bool b; // usually easier to check than types below bool b; // usually easier to check than types below
double d; // matches most used numbers more easily than types below double d; // matches most used numbers more easily than types below
qint64 i; // matches most used integrals more easily than types below qint64 i; // matches most used integrals more easily than types below
quint64 u; quint64 u;
QVariant v; QVariant v;
QByteArray bytes; QByteArray bytes;
QString s; // matches any type with usually less encoding work than QUtf8Data (which only captures efficiently utf-8 whereas QChar easily captures Latin1 in addition to ASCII) QString s; // matches any type with usually less encoding work than QUtf8Data (which only captures efficiently utf-8 whereas QChar easily captures Latin1 in addition to ASCII)
tryBind(b) || tryBind(d) || tryBind(i) || tryBind(u) || tryBind(v) || tryBind(bytes) || tryNull(); bool bound = tryBind(b) || tryBind(d) || tryBind(i) || tryBind(u) || tryBind(v) || tryBind(bytes) || tryNull();
setErrorHandler(suspended); setErrorHandler(suspended);
return true; return bound || handleError(qBindExpectedValue);
} }
QValueErrorHandler setErrorHandler(QValueErrorHandler newHandler = nullptr) { auto previousHandler = errorHandler; errorHandler = newHandler; return previousHandler; } QValueErrorHandler setErrorHandler(QValueErrorHandler newHandler = nullptr) { auto previousHandler = errorHandler; errorHandler = newHandler; return previousHandler; }
...@@ -1186,7 +1187,7 @@ struct QTransmogrifier<QValue> { ...@@ -1186,7 +1187,7 @@ struct QTransmogrifier<QValue> {
double d; if ((srcRes = src.bind( d))) { dst.bind( d); return srcRes; } //! \remark Double-precision floating point numeric types can only be handled if QAbstractValue refuses to lose leading digits or precision double d; if ((srcRes = src.bind( d))) { dst.bind( d); return srcRes; } //! \remark Double-precision floating point numeric types can only be handled if QAbstractValue refuses to lose leading digits or precision
// TODO Other BindNative types we do not want to treat as text: QDateTime, QUuid // TODO Other BindNative types we do not want to treat as text: QDateTime, QUuid
src->setErrorHandler(suspended); src->setErrorHandler(suspended);
srcRes.handleError("ExpectedSequenceRecordNullTextBytesBooleanIntegerDecimal"); srcRes.handleError(qBindExpectedValue);
return srcRes; return srcRes;
} }
else if (src->mode()==Write && dst->mode()==Read) { return zap(std::move(dst),std::move(src)); } // To return reader's QValueStatus instead of writer's QValueStatus since it should contain more information (mismatches, etc.) else if (src->mode()==Write && dst->mode()==Read) { return zap(std::move(dst),std::move(src)); } // To return reader's QValueStatus instead of writer's QValueStatus since it should contain more information (mismatches, etc.)
......
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