Commit 6caa52f2 authored by EXT Arnaud Clère's avatar EXT Arnaud Clère

Renamed Ignored* > UnexpectedItem

parent ac7350c2
......@@ -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 ( 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 ( qint64& t) { if (current().isInteger ()) { t = current().toInteger (); return true; } isErrorFiltered(qBindExpectedInteger); 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 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(); }
......@@ -313,7 +313,7 @@ protected:
if (!s.isEmpty()) {
s.resize(0);
}
return isErrorFiltered(qBindIgnoredBytes);
return isErrorFiltered(qBindUnexpectedData);
}
return true;
} else { return false; } }
......@@ -329,7 +329,7 @@ protected:
if (!s.isEmpty()) {
s.resize(0);
}
return isErrorFiltered(qBindIgnoredBytes);
return isErrorFiltered(qBindUnexpectedData);
}
return true;
} else { isErrorFiltered(qBindExpectedBytes); return false; } }
......
......@@ -490,7 +490,7 @@ private:
while (!(nextChar() == expected || strchr(validChars, nextChar()) || nextChar() == '\0')) {
char ignored = getChar();
if (!isspace(ignored)) {
if (!isErrorFiltered(qBindIgnoredCharacter)) {
if (!isErrorFiltered(qBindUnexpectedData)) {
return false;
}
}
......
......@@ -305,7 +305,7 @@ protected:
row++; col=0;
return true;
}
isErrorFiltered(qBindIgnoredItem);
isErrorFiltered(qBindUnexpectedItem);
return false;
}
return true;
......@@ -320,7 +320,7 @@ protected:
row=0; col++;
return true;
}
isErrorFiltered(qBindIgnoredItem);
isErrorFiltered(qBindUnexpectedItem);
return false;
}
return true;
......@@ -350,7 +350,7 @@ protected:
else {
col=columnNames.indexOf(n.utf8());
// TODO if (max(dimension())<=col) col=-1;
if (col<0 && !isErrorFiltered(qBindIgnoredItem)) {
if (col<0 && !isErrorFiltered(qBindUnexpectedItem)) {
return false;
}
}
......@@ -368,7 +368,7 @@ protected:
}
else {
// TODO if (rowNames...
return isErrorFiltered(qBindIgnoredItemName);
return isErrorFiltered(qBindUnexpectedItem);
}
}
else { Q_ASSERT(I<=d);
......@@ -500,7 +500,7 @@ protected:
if (col < m->columnCount()) {
return true;
}
isErrorFiltered(qBindIgnoredItem);
isErrorFiltered(qBindUnexpectedItem);
return false;
}
return true;
......@@ -518,7 +518,7 @@ protected:
row=0; col++;
return true;
}
isErrorFiltered(qBindIgnoredItem);
isErrorFiltered(qBindUnexpectedItem);
return false;
}
return true;
......@@ -550,7 +550,7 @@ protected:
col=columnNames.indexOf(n.utf8());
}
// TODO if (max(dimension())<=col) col=-1;
if (col<0 && !isErrorFiltered(qBindIgnoredItem)) {
if (col<0 && !isErrorFiltered(qBindUnexpectedItem)) {
return false;
}
return true;
......@@ -564,7 +564,7 @@ protected:
}
else if (n!=childrenName) {
// TODO if (rowNames...
return isErrorFiltered(qBindIgnoredItemName);
return isErrorFiltered(qBindUnexpectedItem);
}
else { return true; }
}
......
......@@ -17,10 +17,8 @@ QIdentifierLiteral qBindExpectedPositiveInteger("ExpectedPositiveInteger");
QIdentifierLiteral qBindExpectedBoolean ("ExpectedBoolean" );
QIdentifierLiteral qBindExpectedConstant ("ExpectedConstant" );
QIdentifierLiteral qBindIgnoredItem ("IgnoredItem" );
QIdentifierLiteral qBindIgnoredItemName ("IgnoredItemName" );
QIdentifierLiteral qBindIgnoredCharacter ("IgnoredCharacter" );
QIdentifierLiteral qBindIgnoredBytes ("IgnoredBytes" );
QIdentifierLiteral qBindUnexpectedItem ("UnexpectedItem" );
QIdentifierLiteral qBindUnexpectedData ("UnexpectedData" );
QIdentifierLiteral qmDataStreamVersion ("qmDataStreamVersion" );
QIdentifierLiteral qmColumns ("columns" );
......
......@@ -69,10 +69,8 @@ extern QIdentifierLiteral qBindExpectedPositiveInteger;
extern QIdentifierLiteral qBindExpectedBoolean;
extern QIdentifierLiteral qBindExpectedConstant;
extern QIdentifierLiteral qBindIgnoredItem;
extern QIdentifierLiteral qBindIgnoredItemName;
extern QIdentifierLiteral qBindIgnoredCharacter;
extern QIdentifierLiteral qBindIgnoredBytes;
extern QIdentifierLiteral qBindUnexpectedItem;
extern QIdentifierLiteral qBindUnexpectedData;
// //////////////////////////////////////////////////////////////////////////
// Standard meta data names
......@@ -565,14 +563,14 @@ public:
QVal<QRec<T_>> item(const char* n) { return outer->tryItem(QIdentifierLiteral(n)) ? QVal<QRec<T_>>(std::move(*this)) : QVal<QRec<T_>>(); }
// Shortcuts
QSeq<QRec<T_>> sequence(const char* n, quint32* s=nullptr) { auto i = item(n); if (i) { return i.sequence (s) ; } Q_UNUSED(outer->isErrorFiltered(qBindIgnoredItem, n)); return QSeq<QRec<T_>>(); }
QRec<QRec<T_>> record (const char* n, quint32* s=nullptr) { auto i = item(n); if (i) { return i.record (s) ; } Q_UNUSED(outer->isErrorFiltered(qBindIgnoredItem, n)); return QRec<QRec<T_>>(); }
/**/ QRec<T_> null (const char* n ) { auto i = item(n); if (i) { return i.null ( ) ; } Q_UNUSED(outer->isErrorFiltered(qBindIgnoredItem, n)); return QRec<T_> (); }
/**/ QRec<T_> bind (const char* n, const char* u) { auto i = item(n); if (i) { return i.bind(QUtf8DataView(u)); } Q_UNUSED(outer->isErrorFiltered(qBindIgnoredItem, n)); return QRec<T_> (); }
/**/ QRec<T_> bind (const char* n, QUtf8DataView u) { auto i = item(n); if (i) { return i.bind (u) ; } Q_UNUSED(outer->isErrorFiltered(qBindIgnoredItem, n)); return QRec<T_> (); }
/**/ QRec<T_> bind (const char* n, QAsciiDataView a) { auto i = item(n); if (i) { return i.bind (a) ; } Q_UNUSED(outer->isErrorFiltered(qBindIgnoredItem, n)); return QRec<T_> (); }
/**/ QRec<T_> bind (const char* n, QLatin1String l) { auto i = item(n); if (i) { return i.bind (l) ; } Q_UNUSED(outer->isErrorFiltered(qBindIgnoredItem, n)); return QRec<T_> (); }
/**/ QRec<T_> bind (const char* n, QStringView u) { auto i = item(n); if (i) { return i.bind (u) ; } Q_UNUSED(outer->isErrorFiltered(qBindIgnoredItem, n)); return QRec<T_> (); }
QSeq<QRec<T_>> sequence(const char* n, quint32* s=nullptr) { auto i = item(n); if (i) { return i.sequence (s) ; } Q_UNUSED(outer->isErrorFiltered(qBindUnexpectedItem, n)); return QSeq<QRec<T_>>(); }
QRec<QRec<T_>> record (const char* n, quint32* s=nullptr) { auto i = item(n); if (i) { return i.record (s) ; } Q_UNUSED(outer->isErrorFiltered(qBindUnexpectedItem, n)); return QRec<QRec<T_>>(); }
/**/ QRec<T_> null (const char* n ) { auto i = item(n); if (i) { return i.null ( ) ; } Q_UNUSED(outer->isErrorFiltered(qBindUnexpectedItem, n)); return QRec<T_> (); }
/**/ QRec<T_> bind (const char* n, const char* u) { auto i = item(n); if (i) { return i.bind(QUtf8DataView(u)); } Q_UNUSED(outer->isErrorFiltered(qBindUnexpectedItem, n)); return QRec<T_> (); }
/**/ QRec<T_> bind (const char* n, QUtf8DataView u) { auto i = item(n); if (i) { return i.bind (u) ; } Q_UNUSED(outer->isErrorFiltered(qBindUnexpectedItem, n)); return QRec<T_> (); }
/**/ QRec<T_> bind (const char* n, QAsciiDataView a) { auto i = item(n); if (i) { return i.bind (a) ; } Q_UNUSED(outer->isErrorFiltered(qBindUnexpectedItem, n)); return QRec<T_> (); }
/**/ QRec<T_> bind (const char* n, QLatin1String l) { auto i = item(n); if (i) { return i.bind (l) ; } Q_UNUSED(outer->isErrorFiltered(qBindUnexpectedItem, n)); return QRec<T_> (); }
/**/ QRec<T_> bind (const char* n, QStringView u) { auto i = item(n); if (i) { return i.bind (u) ; } Q_UNUSED(outer->isErrorFiltered(qBindUnexpectedItem, n)); return QRec<T_> (); }
template<typename T> QRec<T_> bind (const char* n, T&& t) {
auto i = item(n);
......@@ -580,14 +578,14 @@ public:
auto r = i.bind( std::forward<T>( t));
return r;
}
Q_UNUSED(outer->isErrorFiltered(qBindIgnoredItem, n));
Q_UNUSED(outer->isErrorFiltered(qBindUnexpectedItem, n));
return QRec<T_>();
}
template<typename T> QRec<T_> bind (const char* n, T& t, T&& defaultT) { auto i = item(n); if (i) { return i.bind(t, std::forward<T>(defaultT)); } Q_UNUSED(outer->isErrorFiltered(qBindIgnoredItem, n)); return QRec<T_>(); }
template<typename T> QRec<T_> bind (const char* n, T& t, T&& defaultT) { auto i = item(n); if (i) { return i.bind(t, std::forward<T>(defaultT)); } Q_UNUSED(outer->isErrorFiltered(qBindUnexpectedItem, n)); return QRec<T_>(); }
// Custom bind support
/**/ QRec<T_> with (const char* n, QValLambda customBind) { auto i = item(n); if (i) { return i.with( customBind); } Q_UNUSED(outer->isErrorFiltered(qBindIgnoredItem, n)); return QRec<T_>(); }
template<typename T> QRec<T_> with (const char* n, T& t, QValFunction<T> customBind) { auto i = item(n); if (i) { return i.bind(t, customBind); } Q_UNUSED(outer->isErrorFiltered(qBindIgnoredItem, n)); return QRec<T_>(); }
/**/ QRec<T_> with (const char* n, QValLambda customBind) { auto i = item(n); if (i) { return i.with( customBind); } Q_UNUSED(outer->isErrorFiltered(qBindUnexpectedItem, n)); return QRec<T_>(); }
template<typename T> QRec<T_> with (const char* n, T& t, QValFunction<T> customBind) { auto i = item(n); if (i) { return i.bind(t, customBind); } Q_UNUSED(outer->isErrorFiltered(qBindUnexpectedItem, n)); return QRec<T_>(); }
private:
template<class T> friend class QVal;
explicit QRec(T_&& out) noexcept { outer = std::move(out); }
......@@ -991,7 +989,7 @@ QValueEnd qMetaZap(QValue&& v, T* t) {
QIdentifier id(p.name());
r = r.item(id).bind(pv);
if (!r || !pv.isValid() || pv.isNull()) {
if (p.isResettable() && !p.resetOnGadget(t) && !v->isErrorFiltered(qBindIgnoredItem)) {
if (p.isResettable() && !p.resetOnGadget(t) && !v->isErrorFiltered(qBindUnexpectedItem)) {
return QValueEnd();
}
}
......@@ -999,14 +997,14 @@ QValueEnd qMetaZap(QValue&& v, T* t) {
if (p.isEnumType()) {
pv.convert(QVariant::Int);
}
if (!p.writeOnGadget(t, pv) && !v->isErrorFiltered(qBindIgnoredItem)) {
if (!p.writeOnGadget(t, pv) && !v->isErrorFiltered(qBindUnexpectedItem)) {
return QValueEnd();
}
}
}
else if (rw==Write) {
QVariant pv = p.readOnGadget(t);
if (!pv.isValid() && !v->isErrorFiltered(qBindIgnoredItem)) {
if (!pv.isValid() && !v->isErrorFiltered(qBindUnexpectedItem)) {
return QValueEnd();
}
else {
......@@ -1116,7 +1114,7 @@ struct QTransmogrifier<T[Size]> {
auto s(v.sequence());
QVal<QSequence> i; unsigned j=0;
while ((i = s.item())) {
if (j== Size && !i->isErrorFiltered(qBindIgnoredItem)) {
if (j== Size && !i->isErrorFiltered(qBindUnexpectedItem)) {
return QValueEnd();
}
T t;
......
......@@ -56,7 +56,7 @@ 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:IgnoredCharacter, 0 15:IgnoredCharacter, 0 23:IgnoredCharacter, 0 40:IgnoredCharacter, 0 58:IgnoredCharacter, 0x0000000001:ExpectedDecimal, 0 102:IgnoredCharacter, comments [ 0 102]:IgnoredItem, 0 102:UnexpectedEnd, 0 103:UnexpectedValue, 0 104:Stopped
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:[] |
P>JsonValue |{"age":-1,"children":[],"comments":"","height":1.7500000000000004,"names":["John","Doe"],"phones":[]}
......@@ -65,7 +65,7 @@ Json>JsonValue|{"age":-1,"children":[],"comments":"","height":1.7500000000000004
JsonValue>Json|{"age":-1,"children":[],"comments":"","height":1.7500000000000004,"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:IgnoredItem, 41:UnexpectedEnd, 58:UnexpectedValue, 58:Stopped
Cbor>P |(Person) names:[ John Doe] height:1.75 age:-1 phones:[] comments: children:[] | comments 41:UnexpectedItem, 41:UnexpectedEnd, 58:UnexpectedValue, 58:Stopped
P>Cbor |bf656e616d65739f644a6f686e63446f65ff66686569676874fb3ffc00000000000063616765206670686f6e65738068636f6d6d656e747360686368696c6472656e80ff
Cbor>P |(Person) names:[ John Doe] height:1.75 age:-1 phones:[] comments: children:[] |
QCborStream>P |(Person) names:[ John Doe] height:1.75 age:-1 phones:[] comments: children:[] | true
......@@ -76,5 +76,5 @@ CborValue>Cbor|a6656e616d657382644a6f686e63446f6566686569676874fb3ffc00000000000
Cbor>Json |{"names":["John","Doe"],"height":1.75,"age":-1,"phones":[],"comments":"","children":[]} |
Person-Settings|================================================================================
P>Settings |(Person) names:[ John Doe] height:1.75 age:18 phones:[] comments:unicode is likely U+01  + U+1F  + U+A4 ¤ U+B0 ° U+D8 Ø U+FF ÿ children:[]
Settings>P |(Person) names:[ John Doe] height:1.75 age:18 phones:[] comments:unicode is likely U+01  + U+1F  + U+A4 ¤ U+B0 ° U+D8 Ø U+FF ÿ children:[] | names /ExpectedItem/-1:IgnoredItem, /ExpectedItem/-1:UnexpectedEnd, /ExpectedItem:UnexpectedValue
Settings>P |(Person) names:[ John Doe] height:1.75 age:18 phones:[] comments:unicode is likely U+01  + U+1F  + U+A4 ¤ U+B0 ° U+D8 Ø U+FF ÿ children:[] | names /ExpectedItem/-1:UnexpectedItem, /ExpectedItem/-1:UnexpectedEnd, /ExpectedItem:UnexpectedValue
P>Settings |QBind
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