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

Removed useless error handling in QAbstractValu impl and tagged unused

isErrorFiltered for later refactor & removal
parent f7e01a24
......@@ -200,7 +200,7 @@ protected:
bool tryBind ( bool&& b) { set(QCborValue( b )); return true; }
bool tryBind ( float&& d) { set(QCborValue(double(d))); return true; }
bool tryBind ( double&& d) { set(QCborValue( d )); return true; }
bool tryBind ( quint64&& n) { if (quint64(std::numeric_limits<qint64>::max())<n) { isErrorFiltered(qBindExpectedSmallerNumber); return false; }
bool tryBind ( quint64&& n) { if (quint64(std::numeric_limits<qint64>::max())<n) { Q_UNUSED(isErrorFiltered(qBindExpectedSmallerNumber)); return false; }
set(QCborValue(qint64(n))); return true; }
bool tryBind ( qint64&& n) { set(QCborValue( n )); return true; }
bool tryBind ( QByteArray&& s) { set(QCborValue( s )); return true; }
......@@ -255,11 +255,11 @@ protected:
bool tryBind ( QUtf8Data& u) { QString s; if (tryBind(s) ) { u = s .toUtf8 (); return true; } return false; }
bool tryBind ( QString& v) { if (current().isString ()) { v = current().toString (); return true; } return false; }
bool tryBind ( bool& v) { if (current().isBool ()) { v = current().toBool (); return true; } return false; }
bool tryBind ( qint64& t) { if (current().isInteger ()) { t = current().toInteger (); return true; } isErrorFiltered(qBindExpectedInteger); return false; }
bool tryBind ( qint64& t) { if (current().isInteger ()) { t = current().toInteger (); return true; } return false; }
bool tryBind ( quint64& t) { qint64 i; if (tryBind(i) ) { t = quint64(i) ; return true; } return false; }
bool tryBind ( float& v) { double d; if (tryBind(d) ) { v = float(d) ; return true; } return false; }
bool tryBind ( double& v) { if (current().isDouble ()) { v = current().toDouble (); return true; } isErrorFiltered(qBindExpectedDecimal); return false; }
bool tryBind ( QByteArray& v) { QString s; if (current().isByteArray()) { v = current().toByteArray(); return true; } isErrorFiltered(qBindExpectedBytes ); return false; }
bool tryBind ( double& v) { if (current().isDouble ()) { v = current().toDouble (); return true; } return false; }
bool tryBind ( QByteArray& v) { QString s; if (current().isByteArray()) { v = current().toByteArray(); return true; } return false; }
bool tryItem(QIdentifierLiteral u) { steps.last().key=u; return !(steps.last().item = current(1).toMap().value(steps.last().key.latin1())).isUndefined(); }
bool tryItem(QIdentifier& k) { steps.last().key=k; return !(steps.last().item = current(1).toMap().value(steps.last().key.latin1())).isUndefined(); }
......@@ -320,7 +320,7 @@ protected:
r = readByteArray();
}
return r.status == QCborStreamReader::EndOfString || isErrorFiltered(qBindUnexpectedData);
} else { isErrorFiltered(qBindExpectedBytes); return false; } }
} else { return false; } }
bool tryBind ( bool& b) { if (caching) { return caching->tryBind(b) && cacheOut(); }
skipTag(); if (isBool()) {
b=toBool();
......@@ -413,12 +413,12 @@ private:
if (isFloat16()) { d = double(toFloat16()); return next(); }
if (isFloat ()) { d = double(toFloat ()); return next(); }
if (isDouble ()) { d = toDouble () ; return next(); }
isErrorFiltered(qBindExpectedDecimal); return false;
return false;
}
bool getInteger(quint64&i, bool& isNegative) { skipTag();
if (isNegativeInteger()) { i = quint64(toNegativeInteger()); isNegative = true ; return next(); }
if (isUnsignedInteger()) { i = toUnsignedInteger() ; isNegative = false; return next(); }
isErrorFiltered(qBindExpectedInteger); return false;
return false;
}
bool cacheOut() { if (!cacheLevel) {
......
......@@ -128,7 +128,7 @@ protected:
bool tryBind ( qint64& t) { double d; if (tryBind(d) ) { t = qint64(d) ; return true; } return false; }
bool tryBind ( quint64& t) { double d; if (tryBind(d) ) { t = quint64(d) ; return true; } return false; }
bool tryBind ( float& v) { double d; if (tryBind(d) ) { v = float(d) ; return true; } return false; }
bool tryBind ( double& v) { if (current().isDouble()) { v = current().toDouble(); return true; } isErrorFiltered(qBindExpectedDecimal ); return false; }
bool tryBind ( double& v) { if (current().isDouble()) { v = current().toDouble(); return true; } return false; }
bool tryItem(QIdentifierLiteral u) { steps.last().key=u; return !(steps.last().item = current(1).toObject().value(steps.last().key.latin1())).isUndefined(); }
bool tryItem(QIdentifier& k) { steps.last().key=k; return !(steps.last().item = current(1).toObject().value(steps.last().key.latin1())).isUndefined(); }
......@@ -288,26 +288,26 @@ protected:
return true;
} else { return false; } }
bool tryBind ( float& n) { if (caching) { return caching->tryBind(n) && cacheOut(); }
if (getNumber()==None) return false; // already reported qBindExpectedDecimal
if (getNumber()==None) return false;
if (d<double( std::numeric_limits<float >::min())||
double( std::numeric_limits<float >::max())<d) { isErrorFiltered(qBindExpectedSmallerNumber); return false; }
n = float(d); cachedNumber=None; return true; }
bool tryBind ( double& n) { if (caching) { return caching->tryBind(n) && cacheOut(); }
if (getNumber()==None) return false; // already reported qBindExpectedDecimal
if (getNumber()==None) return false;
n = d ; cachedNumber=None; return true; }
bool tryBind ( quint64& t) { if (caching) { return caching->tryBind(t) && cacheOut(); }
auto r=getNumber();
if (r==None) return false; // already reported qBindExpectedDecimal
if (r==FloatingPoint) { isErrorFiltered(qBindExpectedInteger); return false; }
if (r==None) return false;
if (r==FloatingPoint) { Q_UNUSED(isErrorFiltered(qBindExpectedInteger)); return false; }
if (neg) { return false; }
t = i ; cachedNumber=None; return true; }
bool tryBind ( qint64& t) { if (caching) { return caching->tryBind(t) && cacheOut(); }
auto r=getNumber();
if (r==None) return false; // already reported qBindExpectedDecimal
if (r==FloatingPoint) { return false; }
if (r==None) return false;
if (r==FloatingPoint) { Q_UNUSED(isErrorFiltered(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>::max())-1) { t = -qint64(i); cachedNumber=None; return true; }
isErrorFiltered(qBindExpectedSmallerNumber); return false; }
Q_UNUSED(isErrorFiltered(qBindExpectedSmallerNumber)); return false; }
bool tryBind ( QVariant& dst) { if (caching) { return caching->tryBind(dst) && cacheOut(); }
{
QSuspendedValueErrorHandler(this);
......@@ -329,7 +329,7 @@ protected:
}
if (tryNull()) { dst = QVariant::fromValue(nullptr); return true; }
}
return isErrorFiltered(qBindUnexpectedValue) && tryAny();
return false;
}
bool tryOut ( ) { if (caching) { bool out = caching->tryOut(); if (out) { cacheLevel--; cacheOut(); } return out; }
......@@ -395,7 +395,6 @@ private:
neg = get('-', "[{\"ntf-0123456789.");
qint8 digit;
if ((digit = getDigit()) < 0) {
isErrorFiltered(qBindExpectedDecimal);
return None; // do not accept no digit otherwise we may accept an empty mantissa or string!
}
cachedNumber=Integer;
......
......@@ -305,7 +305,7 @@ protected:
row++; col=0;
return true;
}
isErrorFiltered(qBindUnexpectedItem);
Q_UNUSED(isErrorFiltered(qBindUnexpectedItem));
return false;
}
return true;
......@@ -320,7 +320,7 @@ protected:
row=0; col++;
return true;
}
isErrorFiltered(qBindUnexpectedItem);
Q_UNUSED(isErrorFiltered(qBindUnexpectedItem));
return false;
}
return true;
......@@ -500,7 +500,7 @@ protected:
if (col < m->columnCount()) {
return true;
}
isErrorFiltered(qBindUnexpectedItem);
Q_UNUSED(isErrorFiltered(qBindUnexpectedItem));
return false;
}
return true;
......@@ -518,7 +518,7 @@ protected:
row=0; col++;
return true;
}
isErrorFiltered(qBindUnexpectedItem);
Q_UNUSED(isErrorFiltered(qBindUnexpectedItem));
return false;
}
return true;
......
......@@ -134,7 +134,7 @@ protected:
// TODO Support _meta to be able to cache and restitute all metadata as well as data+datatype
template<typename T>
bool tryBind(T& t) { if (current()->type()==qMetaTypeId<T>()) { t = current()->value<T>(); return true; } isErrorFiltered(QIdentifierLiteral("ExpectedDeclaredMetatypeT")); return false; }
bool tryBind(T& t) { if (current()->type()==qMetaTypeId<T>()) { t = current()->value<T>(); return true; } return isErrorFiltered(QIdentifierLiteral("ExpectedDeclaredMetatypeT")); }
bool tryBind( QUtf8Data& t) { if (current()->userType() // TODO ->type() if QUtf8Data lands into Qt
==qMetaTypeId< QUtf8Data>()) { t = current()->value< QUtf8Data>(); return true; } return false; }
......
......@@ -56,13 +56,13 @@ Bindable |
Bindable>Cbor |bf647479706502666e756d6265726b2b34342031323334353637ff
Bindable>Json |{"type":2,"number":"+44 1234567"}
Person-Json |================================================================================
Json>P |(Person) names:[ John Doe] height:1.75 age:-1 phones:[] comments: children:[] | 0 1:UnexpectedData, 0 15:UnexpectedData, 0 23:UnexpectedData, 0 40:UnexpectedData, 0 58:UnexpectedData, 0x0000000001:ExpectedDecimal, 0 102:UnexpectedData, comments [ 0 102]:UnexpectedItem, 0 102:UnexpectedEnd, 0 103:UnexpectedValue, 0 104:Stopped
P>Json |{"names":["John","Doe"],"height":1.7500000000000002,"age":-1,"phones":[],"comments":"","children":[]}
Json>P |(Person) names:[ John Doe] height:1.75 age:-1 phones:[] comments: children:[] | 0 1:UnexpectedData, 0 15:UnexpectedData, 0 23:UnexpectedData, 0 40:UnexpectedData, 0 58:UnexpectedData, 0 102:UnexpectedData, comments [ 0 102]:UnexpectedItem, 0 102:UnexpectedEnd, 0 103:UnexpectedValue, 0 104:Stopped
P>Json |{"names":["John","Doe"],"height":1.75,"age":-1,"phones":[],"comments":"","children":[]}
Json>P |(Person) names:[ John Doe] height:1.75 age:-1 phones:[] comments: children:[] |
P>JsonValue |{"age":-1,"children":[],"comments":"","height":1.7500000000000004,"names":["John","Doe"],"phones":[]}
P>JsonValue |{"age":-1,"children":[],"comments":"","height":1.75,"names":["John","Doe"],"phones":[]}
JsonValue>P |(Person) names:[ John Doe] height:1.75 age:-1 phones:[] comments: children:[] |
Json>JsonValue|{"age":-1,"children":[],"comments":"","height":1.7500000000000004,"names":["John","Doe"],"phones":[]} |
JsonValue>Json|{"age":-1,"children":[],"comments":"","height":1.7500000000000004,"names":["John","Doe"],"phones":[]}
Json>JsonValue|{"age":-1,"children":[],"comments":"","height":1.75,"names":["John","Doe"],"phones":[]} |
JsonValue>Json|{"age":-1,"children":[],"comments":"","height":1.75,"names":["John","Doe"],"phones":[]}
Json>Cbor |bf656e616d65739f644a6f686e63446f65ff66686569676874fa3fe0000063616765206670686f6e65739fff68636f6d6d656e747360686368696c6472656e9fffff
Person-Cbor |================================================================================
Cbor>P |(Person) names:[ John Doe] height:1.75 age:-1 phones:[] comments: children:[] | comments 41:UnexpectedItem, 41:UnexpectedEnd, 58:UnexpectedValue, 58:Stopped
......
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