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> {
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; }
v->setErrorHandler(suspended);
if (!(r = v.null())) r.handleError("ExpectedBoolDoubleQStringQJsonArrayQJsonOnjectNull");
/**/ j = QJsonValue( ); return r;
if (!(r = v.null())) r.handleError(qBindExpectedValue);
/**/ j = QJsonValue( ); return r;
}
else { Q_ASSERT_X(!v, Q_FUNC_INFO, "Unsupported v->mode()"); return v.null(); }
}
......
#include "QValue.h"
QIdentifierLiteral qBindExpectedItem ("ExpectedItem" );
QIdentifierLiteral qBindExpectedNull ("ExpectedNull" );
QIdentifierLiteral qBindExpectedSequence ("ExpectedSequence" );
QIdentifierLiteral qBindExpectedRecord ("ExpectedRecord" );
QIdentifierLiteral qBindExpectedText ("ExpectedText" );
QIdentifierLiteral qBindExpectedBytes ("ExpectedBytes" );
QIdentifierLiteral qBindExpectedInteger ("ExpectedInteger" );
QIdentifierLiteral qBindExpectedDecimal ("ExpectedDecimal" );
QIdentifierLiteral qBindExpectedSmallerNumber ("ExpectedSmallerNumber" );
QIdentifierLiteral qBindExpectedValue ("ExpectedValue" );
QIdentifierLiteral qBindExpectedItem ("ExpectedItem" );
QIdentifierLiteral qBindExpectedNull ("ExpectedNull" );
QIdentifierLiteral qBindExpectedSequence ("ExpectedSequence" );
QIdentifierLiteral qBindExpectedRecord ("ExpectedRecord" );
QIdentifierLiteral qBindExpectedText ("ExpectedText" );
QIdentifierLiteral qBindExpectedBytes ("ExpectedBytes" );
QIdentifierLiteral qBindExpectedInteger ("ExpectedInteger" );
QIdentifierLiteral qBindExpectedDecimal ("ExpectedDecimal" );
QIdentifierLiteral qBindExpectedSmallerNumber ("ExpectedSmallerNumber" );
QIdentifierLiteral qBindExpectedPositiveInteger("ExpectedPositiveInteger");
QIdentifierLiteral qBindExpectedBoolean ("ExpectedBoolean" );
QIdentifierLiteral qBindExpectedConstant ("ExpectedConstant" );
QIdentifierLiteral qBindExpectedBoolean ("ExpectedBoolean" );
QIdentifierLiteral qBindExpectedConstant ("ExpectedConstant" );
QIdentifierLiteral qBindIgnoredItem ("IgnoredItem" );
QIdentifierLiteral qBindIgnoredItemName ("IgnoredItemName" );
QIdentifierLiteral qBindIgnoredCharacter ("IgnoredCharacter" );
QIdentifierLiteral qBindIgnoredBytes ("IgnoredBytes" );
QIdentifierLiteral qBindIgnoredItem ("IgnoredItem" );
QIdentifierLiteral qBindIgnoredItemName ("IgnoredItemName" );
QIdentifierLiteral qBindIgnoredCharacter ("IgnoredCharacter" );
QIdentifierLiteral qBindIgnoredBytes ("IgnoredBytes" );
QIdentifierLiteral qmDataStreamVersion ("qmDataStreamVersion" );
QIdentifierLiteral qmColumns ("columns" );
QIdentifierLiteral qmSizes ("sizes" );
QIdentifierLiteral qmChildren ("children" );
QIdentifierLiteral qmName ("name" );
QIdentifierLiteral qmColor ("color" );
QIdentifierLiteral qmDataStreamVersion ("qmDataStreamVersion" );
QIdentifierLiteral qmColumns ("columns" );
QIdentifierLiteral qmSizes ("sizes" );
QIdentifierLiteral qmChildren ("children" );
QIdentifierLiteral qmName ("name" );
QIdentifierLiteral qmColor ("color" );
QValue QValueStatus::value() noexcept { return QValue(std::move(*this)); }
......@@ -52,23 +52,24 @@
// //////////////////////////////////////////////////////////////////////////
// Standard error names
extern QIdentifierLiteral qBindExpectedItem ;
extern QIdentifierLiteral qBindExpectedNull ;
extern QIdentifierLiteral qBindExpectedSequence ;
extern QIdentifierLiteral qBindExpectedRecord ;
extern QIdentifierLiteral qBindExpectedText ;
extern QIdentifierLiteral qBindExpectedBytes ;
extern QIdentifierLiteral qBindExpectedInteger ;
extern QIdentifierLiteral qBindExpectedDecimal ;
extern QIdentifierLiteral qBindExpectedSmallerNumber ;
extern QIdentifierLiteral qBindExpectedValue;
extern QIdentifierLiteral qBindExpectedItem;
extern QIdentifierLiteral qBindExpectedNull;
extern QIdentifierLiteral qBindExpectedSequence;
extern QIdentifierLiteral qBindExpectedRecord;
extern QIdentifierLiteral qBindExpectedText;
extern QIdentifierLiteral qBindExpectedBytes;
extern QIdentifierLiteral qBindExpectedInteger;
extern QIdentifierLiteral qBindExpectedDecimal;
extern QIdentifierLiteral qBindExpectedSmallerNumber;
extern QIdentifierLiteral qBindExpectedPositiveInteger;
extern QIdentifierLiteral qBindExpectedBoolean ;
extern QIdentifierLiteral qBindExpectedConstant ;
extern QIdentifierLiteral qBindExpectedBoolean;
extern QIdentifierLiteral qBindExpectedConstant;
extern QIdentifierLiteral qBindIgnoredItem ;
extern QIdentifierLiteral qBindIgnoredItemName ;
extern QIdentifierLiteral qBindIgnoredCharacter ;
extern QIdentifierLiteral qBindIgnoredBytes ;
extern QIdentifierLiteral qBindIgnoredItem;
extern QIdentifierLiteral qBindIgnoredItemName;
extern QIdentifierLiteral qBindIgnoredCharacter;
extern QIdentifierLiteral qBindIgnoredBytes;
// //////////////////////////////////////////////////////////////////////////
// Standard meta data names
......@@ -262,7 +263,7 @@ public:
QValueStatus* operator ->() noexcept { return this; }
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(const char* asciiName, QString context = QString()) { return handleError(QIdentifierLiteral(asciiName), context); }
protected:
......@@ -557,7 +558,7 @@ struct QAbstractValueWriter : public QAbstractValue
}
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>();
quint32 size=quint32(ts.size());
if (!tryRecord(&size)) {
......@@ -730,16 +731,16 @@ struct QAbstractValueReader : public QAbstractValue
||(tryRecord () && tryOut())) {
return true;
}
bool b; // usually easier to check 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
bool b; // usually easier to check 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
quint64 u;
QVariant v;
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)
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);
return true;
return bound || handleError(qBindExpectedValue);
}
QValueErrorHandler setErrorHandler(QValueErrorHandler newHandler = nullptr) { auto previousHandler = errorHandler; errorHandler = newHandler; return previousHandler; }
......@@ -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
// TODO Other BindNative types we do not want to treat as text: QDateTime, QUuid
src->setErrorHandler(suspended);
srcRes.handleError("ExpectedSequenceRecordNullTextBytesBooleanIntegerDecimal");
srcRes.handleError(qBindExpectedValue);
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.)
......
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