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

Enforced explicit QSequence/QRecord::out() whereas QVal::operator

QValueEnd() is useful to handle UnexpectedValue vs a value that can be
ignored using any/end
parent 1941b69c
......@@ -495,7 +495,7 @@ struct QTransmogrifier<QCborArray> {
for (QCborValue item : j) {
s = s.bind(item);
}
return s;
return s.out();
}
else { Q_ASSERT_X(false, Q_FUNC_INFO, "Unsupported v->mode()"); return v.any(); }
}
......@@ -511,7 +511,7 @@ struct QTransmogrifier<QCborArray> {
if ((s = i.bind(json)))
j.append(json);
}
return s;
return s.out();
}
else { Q_ASSERT_X(!v, Q_FUNC_INFO, "Unsupported v->mode()"); return v.any(); }
}
......@@ -530,7 +530,7 @@ struct QTransmogrifier<QCborMap> {
r = r.item(id).bind(QCborValue(j[key]));
}
}
return r;
return r.out();
}
else { Q_ASSERT_X(false, Q_FUNC_INFO, "Unsupported v->mode()"); return v.any(); }
}
......@@ -546,7 +546,7 @@ struct QTransmogrifier<QCborMap> {
if ((s = i.bind(json)))
j.insert(k.latin1(),json);
}
return s;
return s.out();
}
else { Q_ASSERT_X(!v, Q_FUNC_INFO, "Unsupported v->mode()"); return v.any(); }
}
......
......@@ -571,7 +571,7 @@ struct QTransmogrifier<QJsonArray> {
for (QJsonValue item : j) {
s = s.bind(item);
}
return s;
return s.out();
}
else { Q_ASSERT_X(false, Q_FUNC_INFO, "Unsupported v->mode()"); return v.any(); }
}
......@@ -587,7 +587,7 @@ struct QTransmogrifier<QJsonArray> {
if ((s = i.bind(json)))
j.append(json);
}
return s;
return s.out();
}
else { Q_ASSERT_X(!v, Q_FUNC_INFO, "Unsupported v->mode()"); return v.any(); }
}
......@@ -603,7 +603,7 @@ struct QTransmogrifier<QJsonObject> {
QIdentifier n(key.toLatin1());
s = s.item(n).bind(QJsonValue(j[key]));
}
return s;
return s.out();
}
else { Q_ASSERT_X(false, Q_FUNC_INFO, "Unsupported v->mode()"); return v.any(); }
}
......@@ -619,7 +619,7 @@ struct QTransmogrifier<QJsonObject> {
if ((s = i.bind(json)))
j.insert(k.latin1(),json);
}
return s;
return s.out();
}
else { Q_ASSERT_X(!v, Q_FUNC_INFO, "Unsupported v->mode()"); return v.any(); }
}
......
......@@ -498,7 +498,6 @@ public:
bool isValid() const noexcept { return outer.isValid(); } //!< Drives QTransmogrifier<T>::bind() traversal
QCur* operator->() noexcept { return outer.operator->(); }
operator QValueEnd() { return end(); }
QValueEnd end() { return out(); /* calls T_::operator QValueEnd() if T_ != QValueEnd */ }
T_ out() { return outer->tryOut() ? std::move(outer) : T_(); }
......@@ -555,7 +554,6 @@ public:
bool isValid() const noexcept { return outer.isValid(); } //!< Drives QTransmogrifier<T>::bind() traversal
QCur* operator->() noexcept { return outer.operator->(); }
operator QValueEnd() { return end(); }
QValueEnd end() { return out(); /* calls T_::operator QValueEnd() if T_ != QValueEnd */ }
T_ out() { return outer->tryOut() ? std::move(outer) : T_(); }
......@@ -1043,7 +1041,7 @@ QValueEnd qMetaZap(QValue&& v, T* t) {
else { Q_ASSERT_X(!v, Q_FUNC_INFO, "Unsupported v->mode()"); return v.any(); }
}
}
return r;
return r.out();
}
//! Default bind(QValue&&) based on static QMetaObject reflection
......@@ -1108,7 +1106,7 @@ struct QTransmogrifier<T[Size]> {
for (auto&& t : ts) {
s = s.bind(t);
}
return s;
return s.out();
}
else if (v->mode()==Read) {
auto s(v.sequence());
......@@ -1121,7 +1119,7 @@ struct QTransmogrifier<T[Size]> {
if((s = i.bind(t))) // gives back control to s, enabling the next s.item() call // TODO || (i->isErrorFiltered(qBindUnexpectedValue) && (s = i.any()))
ts[j++] = t;
}
return s;
return s.out();
}
else { Q_ASSERT_X(!v, Q_FUNC_INFO, "Unsupported v->mode()"); return v.any(); }
}
......
......@@ -169,12 +169,12 @@ struct PersonsTable {
persons.append(orphans[parentId]);
}
}
return s;
return s.out();
}
else if (v->mode()==Write) {
parentIds.clear();
ids.clear();
return flatten(persons, v.sequence());
return flatten(persons, v.sequence()).out();
}
else { Q_ASSERT_X(!v, Q_FUNC_INFO, "Unsupported v->mode()"); return v.any(); }
}
......@@ -271,7 +271,7 @@ struct QTransmogrifier<QColor> {
return v.null();
}
QRgba64 c64 = c.rgba64();
return v.sequence().bind(quint8(c.spec())).bind(quint16(c64.alpha())).bind(quint16(c64.red())).bind(quint16(c64.green())).bind(quint16(c64.blue())).bind(quint16(0)); // TODO pad
return v.sequence().bind(quint8(c.spec())).bind(quint16(c64.alpha())).bind(quint16(c64.red())).bind(quint16(c64.green())).bind(quint16(c64.blue())).bind(quint16(0)).out(); // TODO pad
}
} while (!n.isNull());
QRecord r = v.record();
......@@ -283,8 +283,8 @@ struct QTransmogrifier<QColor> {
default: Q_ASSERT(false);
}
if (c.alpha()<255) { r = r.bind("alpha",quint8(c.alpha())); }
return r.bind("base",quint8(255)); // Explicits ARGBCMYKSLV components' base (H base is 360 corresponding to color wheel degrees, with -1 used for gray in addition to S being 0)
// QDebug use of float values removes need for base but may lose precision
return r.bind("base",quint8(255)).out(); // Explicits ARGBCMYKSLV components' base (H base is 360 corresponding to color wheel degrees, with -1 used for gray in addition to S being 0)
// QDebug use of float values removes need for base but may lose precision
}
};
......@@ -1241,7 +1241,7 @@ void doGuiExample() {
.out();
}
return std::move(s); // So caller stops calling QAbstractValue if user function was unable to keep track of the active QCur
});}},
}).out();}},
// The same design allows flattening trees into a sequence
{ new QStandardItemModel(&dlg), new QTableView(&dlg), "bind(PersonsTable{persons})", [&](QValue&& v) {
......
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