Commit a6d449d8 authored by EXT Arnaud Clère's avatar EXT Arnaud Clère
Browse files

WIP fixed normal use case, need to reactivate benchmarks

parent 41113c07
......@@ -899,7 +899,9 @@ struct QBind<Val<Cursor>> {
/**/ dstRec.out();
return srcRec.out();
}
if ( (srcRes = src.null())) {
return dst.null();
}
QByteArray a; if ((srcRes = src.bind( a))) { dst.bind( a); return srcRes; } //! \remark When IBind does not explicitely tag text values, any text equal to another value text representation will be converted to that type (e.g. QString("0x10") > JSON > QByteArray({16}))
bool b; if ((srcRes = src.bind( b))) { dst.bind( b); return srcRes; }
quint8 u8; if ((srcRes = src.bind( u8))) { dst.bind( u8); return srcRes; } //! \remark quint8 as common values with qint8 but is preferred for convenience and static guarantees (no negative values)
......@@ -913,10 +915,10 @@ struct QBind<Val<Cursor>> {
float f; if ((srcRes = src.bind( f))) { dst.bind( f); return srcRes; } //! \remark Floating point numeric types can only be handled if IBind refuses to lose non zero decimals
double d; if ((srcRes = src.bind( d))) { dst.bind( d); return srcRes; } //! \remark Double-precision floating point numeric types can only be handled if IBind refuses to lose leading digits or precision
// TODO Other BindNative types we do not want to treat as text: QDateTime, QUuid
QString t; if ((srcRes = src.bind( t))) { dst.bind( t); return srcRes; } //! \remark QString handles all QUtf8String values but is preferred for convenience and robustness (less probable character processing errors) as opposed to performance
}
if (!(srcRes = src.null())) srcRes.reportError("Expected sequence|record|boolean|decimal|text|null");
/**/ dst.null();
QString t; //! \remark QString handles all QUtf8String values but is preferred for convenience and robustness (less probable character processing errors) as opposed to performance
if (!(srcRes = src.bind(t))) srcRes.reportError("Expected sequence|record|boolean|decimal|text|null");
/**/ dst.bind(t);
return srcRes;
}
else if (src->mode()==Write && dst->mode()==Read) { return bind(std::move(dst),std::move(src)); } // To return reader's Cursor instead of writer's Cursor since it should contain more information (mismatches, etc.)
......
......@@ -275,7 +275,7 @@ protected:
if ( neg && quint64(-std::numeric_limits<qint64>::min())<i) { t = -qint64(i); return true; } _reportError(qBindExpectedSmallerNumber ); } return false; }
bool cacheOut() { Q_ASSERT(cacheLevel>0);
cacheLevel--;
if (cacheLevel==1) { if (cached==&cacheWriter) { } cached=nullptr; }
if (cacheLevel==1) { cached=nullptr; }
if (cacheLevel==0) { cachedItems.clear(); }
return true; }
......@@ -288,8 +288,6 @@ protected:
bool _item( QName u) { if (cached) { return cached->_item(u); }
QUtf8String s;
while (true) {
if (!_item(s)) return false;
if (u==s) return true;
if (cachedItems.contains(u)) {
cachedValue = cachedItems.take(u);
cacheReader.reset(&cachedValue);
......@@ -297,6 +295,12 @@ protected:
Q_ASSERT(cacheLevel<=1); cacheLevel = 1;
return true;
}
else if (!_item(s)) {
return false;
}
else if (u == s ) {
return true ;
}
else {
cachedValue = QJsonValue();
cacheWriter.reset(&cachedValue);
......
......@@ -492,7 +492,8 @@ int main(int argc, char *argv[])
{
QBuffer json;
json.open(QIODevice::ReadOnly);
json.buffer() = "_{ \"names\": [ _\"John\" _, \"Doe\"] , \"age\":null, \"phones\":[ \"+44 1234567\" , \"+44 2345678\" ], \"\":\"superfluous item\", \"height\":_1.75 _} ";
json.buffer() = "_{ \"names\": [ _\"John\" _, \"Doe\"] , \"age\":null, \"height\":_1.75, \"phones\": [ \"+44 1234567\" , \"+44 2345678\" ], \"\":\"superfluous item\" _} ";
// 0 22 41 55 70
QJsonValue v;
#if QT_VERSION>=QT_VERSION_CHECK(5,12,0)
QCborValue c;
......
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