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

Renamed as in Qt proposal

parent bd379ac7
......@@ -108,9 +108,9 @@ public:
QCborWriter(QByteArray* io) : io(io) { Q_ASSERT(io); }
// Shortcuts
/**/ QValue value ( ) { return QValueStatus(this).value(); }
/**/ QSeq<QValueStatus> sequence(quint32* s=nullptr) { return QValueStatus(this).value().sequence(s); }
template<typename T> QValueStatus bind ( T&& t) { return QValueStatus(this).value().bind(std::forward<T>(t)); }
/**/ QValue value ( ) { return QValueStatus(this).value(); }
/**/ QSequence sequence(quint32* s=nullptr) { return QValueStatus(this).value().sequence(s); }
template<typename T> QValueStatus bind ( T&& t) { return QValueStatus(this).value().bind(std::forward<T>(t)); }
protected:
bool _isOk() const noexcept { return io; }
......@@ -185,9 +185,9 @@ public:
QCborBuilder(QCborValue* v) : cbor(v) { Q_ASSERT(v); }
// Shortcuts
/**/ QValue value ( ) { return QValueStatus(this).value(); }
/**/ QSeq<QValueStatus> sequence(quint32* s=nullptr) { return QValueStatus(this).value().sequence(s); }
template<typename T> QValueStatus bind ( T&& t) { return QValueStatus(this).value().bind(std::forward<T>(t)); }
/**/ QValue value ( ) { return QValueStatus(this).value(); }
/**/ QSequence sequence(quint32* s=nullptr) { return QValueStatus(this).value().sequence(s); }
template<typename T> QValueStatus bind ( T&& t) { return QValueStatus(this).value().bind(std::forward<T>(t)); }
protected:
bool trySequence(quint32* =nullptr) { levels.push(Step( )); return true; }
bool tryRecord (quint32* =nullptr) { levels.push(Step(qBindExpectedItem)); return true; }
......@@ -199,7 +199,7 @@ protected:
bool tryBind ( float&& d) { set(QCborValue(double(d))); return true; }
bool tryBind ( double&& d) { set(QCborValue( d )); return true; }
bool tryBind ( quint64&& n) { if (std::numeric_limits<qint64>::max()<n) { _reportError(qBindExpectedSmallerNumber); return false; }
set(QCborValue(qint64(n))); return true; }
set(QCborValue(qint64(n))); return true; }
bool tryBind ( qint64&& n) { set(QCborValue( n )); return true; }
bool tryBind ( QByteArray&& s) { set(QCborValue( s )); return true; }
......@@ -233,7 +233,7 @@ public:
QCborVisitor(QCborValue* v) : cbor(v) { Q_ASSERT(v); }
void reset(QCborValue* v) { cbor=v; Q_ASSERT(v); steps.resize(0); errors.resize(0); }
struct Error { QIdentifierLiteral error; QAsciiData path; template<class T> T bind(QVal<T>&& value) { return value.bind(QUtf8Data(error.utf8()+' '+path.utf8())); } };
struct Error { QIdentifierLiteral error; QAsciiData path; QValueStatus zap(QValue&& value) { return value.bind(QUtf8Data(error.utf8()+' '+path.utf8())); } };
QVector<Error> errors;
QAsciiData currentPath() {
......@@ -246,9 +246,9 @@ public:
}
// Shortcuts
/**/ QValue value ( ) { return QValueStatus(this).value(); }
/**/ QSeq<QValueStatus> sequence(quint32* s=nullptr) { return QValueStatus(this).value().sequence ( s); }
template<typename T> QValueStatus bind ( T&& t) { return QValueStatus(this).value().bind(std::forward<T>(t)); }
/**/ QValue value ( ) { return QValueStatus(this).value(); }
/**/ QSequence sequence(quint32* s=nullptr) { return QValueStatus(this).value().sequence(s); }
template<typename T> QValueStatus bind ( T&& t) { return QValueStatus(this).value().bind(std::forward<T>(t)); }
protected:
bool trySequence(quint32* =nullptr) { if (current().isArray ()) { steps.push(Step()); return true; } _reportError(qBindExpectedSequence); return false; }
bool tryRecord (quint32* =nullptr) { if (current().isMap ()) { steps.push(Step()); return true; } _reportError(qBindExpectedRecord ); return false; }
......@@ -290,12 +290,12 @@ class QCborReader : public QAbstractValueReader, public QCborStreamReader
public:
QCborReader(QIODevice* io) : QCborStreamReader(io), cacheVisitor(&cachedValue) { Q_ASSERT(io); }
struct Error { QIdentifierLiteral error; qint64 index; QCborError cborError; template<class T> T bind(QVal<T>&& value) { QByteArray utf8(error.utf8()); utf8.append(' ').append(QByteArray::number(index)); return value.bind(utf8.constData()); } };
struct Error { QIdentifierLiteral error; qint64 index; QCborError cborError; QValueStatus zap(QValue&& value) { QByteArray utf8(error.utf8()); utf8.append(' ').append(QByteArray::number(index)); return value.bind(utf8.constData()); } };
QVector<Error> errors;
// Shortcuts
/**/ QValue value ( ) { return QValueStatus(this).value(); }
/**/ QSeq<QValueStatus> sequence(quint32* s=nullptr) { return QValueStatus(this).value().sequence(s); }
/**/ QValue value ( ) { return QValueStatus(this).value(); }
/**/ QSequence sequence(quint32* s=nullptr) { return QValueStatus(this).value().sequence(s); }
template<typename T> QValueStatus bind ( T&& t) { return QValueStatus(this).value().bind(std::forward<T>(t)); }
protected:
bool trySequence(quint32* s=nullptr) { if (caching) { cacheLevel++; return caching->trySequence(s); }
......@@ -475,7 +475,7 @@ private:
template<>
struct QTransmogrifier<QCborValue> {
static QValueStatus bind(QValue&& v, QCborValue&& j) {
static QValueStatus zap(QValue&& v, QCborValue&& j) {
if (v->mode()==Write) {
if (j.isMap ()) return v.bind(j.toMap ());
if (j.isArray ()) return v.bind(j.toArray ());
......@@ -488,9 +488,9 @@ struct QTransmogrifier<QCborValue> {
}
else { Q_ASSERT_X(false, Q_FUNC_INFO, "Unsupported v->mode()"); return v.null(); }
}
static QValueStatus bind(QValue&& v, QCborValue& j) {
static QValueStatus zap(QValue&& v, QCborValue& j) {
if (v->mode()==Write) {
return bind(std::move(v),std::move(j));
return zap(std::move(v),std::move(j));
}
else if (v->mode()==Read) {
QValueStatus r;
......@@ -515,7 +515,7 @@ struct QTransmogrifier<QCborValue> {
template<>
struct QTransmogrifier<QCborArray> {
static QValueStatus bind(QValue&& v, QCborArray&& j) {
static QValueStatus zap(QValue&& v, QCborArray&& j) {
if (v->mode()==Write) {
quint32 size=quint32(j.size());
auto s(v.sequence(&size));
......@@ -526,13 +526,13 @@ struct QTransmogrifier<QCborArray> {
}
else { Q_ASSERT_X(false, Q_FUNC_INFO, "Unsupported v->mode()"); return v.null(); }
}
static QValueStatus bind(QValue&& v, QCborArray& j) {
static QValueStatus zap(QValue&& v, QCborArray& j) {
if (v->mode()==Write) {
return bind(std::move(v),std::move(j));
return zap(std::move(v),std::move(j));
}
else if (v->mode()==Read) {
auto s(v.sequence());
QVal<QSeq<QValueStatus>> i;
QVal<QSequence> i;
while ((i = s.item())) {
QCborValue json;
if ((s = i.bind(json)))
......@@ -546,7 +546,7 @@ struct QTransmogrifier<QCborArray> {
template<>
struct QTransmogrifier<QCborMap> {
static QValueStatus bind(QValue&& v, QCborMap&& j) {
static QValueStatus zap(QValue&& v, QCborMap&& j) {
if (v->mode()==Write) {
quint32 size=quint32(j.size());
auto r(v.record(&size));
......@@ -561,13 +561,13 @@ struct QTransmogrifier<QCborMap> {
}
else { Q_ASSERT_X(false, Q_FUNC_INFO, "Unsupported v->mode()"); return v.null(); }
}
static QValueStatus bind(QValue&& v, QCborMap& j) {
static QValueStatus zap(QValue&& v, QCborMap& j) {
if (v->mode()==Write) {
return bind(std::move(v),std::move(j));
return zap(std::move(v),std::move(j));
}
else if (v->mode()==Read) {
auto s(v.record());
QIdentifier k; QVal<QRec<QValueStatus>> i;
QIdentifier k; QVal<QRecord> i;
while ((i = s.item(k))) {
QCborValue json;
if ((s = i.bind(json)))
......
......@@ -47,7 +47,7 @@
#include "QValue.h"
// //////////////////////////////////////////////////////////////////////////
// QTransmogrifier<T,QDataStream*> support
// QDataStream* support
// TODO Use QByteArray directly
......@@ -62,10 +62,10 @@ public:
QValueMode mode() const noexcept { return QValueMode::Write; }
// Shortcuts
QValue value ( ) { return QValueStatus(this).value(); }
QSeq<QValueStatus> sequence(quint32* s=nullptr) { return QValueStatus(this).value().sequence(s); }
QValue value ( ) { return QValueStatus(this).value(); }
QSequence sequence(quint32* s=nullptr) { return QValueStatus(this).value().sequence(s); }
template<typename T> QValueStatus bind(T&& t) { return QValueStatus(this).value().bind(std::forward<T>(t)); }
template<typename T> QValueStatus zap(T&& t) { return QValueStatus(this).value().bind(std::forward<T>(t)); }
protected:
friend class QValueStatus;
bool trySequence(quint32* s=nullptr) { if (s) *io << *s; return true; }
......
......@@ -60,9 +60,9 @@ public:
void reset(QJsonValue* v) { json=v; Q_ASSERT(v); steps.resize(0); }
// Shortcuts
/**/ QValue value ( ) { return QValueStatus(this).value(); }
/**/ QSeq<QValueStatus> sequence(quint32* s=nullptr) { return QValueStatus(this).value().sequence ( s); }
template<typename T> QValueStatus bind ( T&& t) { return QValueStatus(this).value().bind(std::forward<T>(t)); }
/**/ QValue value ( ) { return QValueStatus(this).value(); }
/**/ QSequence sequence(quint32* s=nullptr) { return QValueStatus(this).value().sequence(s); }
template<typename T> QValueStatus bind ( T&& t) { return QValueStatus(this).value().bind(std::forward<T>(t)); }
protected:
friend class QJsonReader; //!< Calls methods below for out-of-order cachedItems
bool trySequence(quint32* s=nullptr) { Q_UNUSED(s); steps.push(Step( )); return true; }
......@@ -104,7 +104,7 @@ public:
QJsonVisitor(const QJsonValue* v) : json(v) { Q_ASSERT(v); }
void reset(QJsonValue* v) { json=v; Q_ASSERT(v); steps.resize(0); errors.resize(0); }
struct Error { QIdentifierLiteral error; QAsciiData path; template<class T> T bind(QVal<T>&& value) { return value.bind(QUtf8Data(error.utf8()+' '+path.utf8())); } };
struct Error { QIdentifierLiteral error; QAsciiData path; QValueStatus zap(QValue&& value) { return value.bind(QUtf8Data(error.utf8()+' '+path.utf8())); } };
QVector<Error> errors;
QAsciiData currentPath() {
......@@ -117,9 +117,9 @@ public:
}
// Shortcuts
/**/ QValue value ( ) { return QValueStatus(this).value(); }
/**/ QSeq<QValueStatus> sequence(quint32* s=nullptr) { return QValueStatus(this).value().sequence ( s); }
template<typename T> QValueStatus bind ( T&& t) { return QValueStatus(this).value().bind(std::forward<T>(t)); }
/**/ QValue value ( ) { return QValueStatus(this).value(); }
/**/ QSequence sequence(quint32* s=nullptr) { return QValueStatus(this).value().sequence(s); }
template<typename T> QValueStatus bind ( T&& t) { return QValueStatus(this).value().bind(std::forward<T>(t)); }
protected:
bool trySequence(quint32* =nullptr) { if (current().isArray ()) { steps.push(Step());
return true; } _reportError(qBindExpectedSequence); return false; }
......@@ -163,9 +163,9 @@ public:
~QJsonWriter() { while (!levels.isEmpty()) write(levels.takeLast().end); }
// Shortcuts
/**/ QValue value ( ) { return QValueStatus(this).value(); }
/**/ QSeq<QValueStatus> sequence(quint32* s=nullptr) { return QValueStatus(this).value().sequence ( s); }
template<typename T> QValueStatus bind ( T&& t) { return QValueStatus(this).value().bind(std::forward<T>(t)); }
/**/ QValue value ( ) { return QValueStatus(this).value(); }
/**/ QSequence sequence(quint32* s=nullptr) { return QValueStatus(this).value().sequence(s); }
template<typename T> QValueStatus bind ( T&& t) { return QValueStatus(this).value().bind(std::forward<T>(t)); }
protected:
template<class T> friend class QModelWriter;
......@@ -245,13 +245,13 @@ public:
}
struct Step { int index; const char* end; QMap<QIdentifier,QJsonValue/*TODO QVariant for meta() support*/> cachedItems; Step(int i=-1, const char* e=nullptr) : index(i), end(e) {} };
struct Error { QIdentifierLiteral error; int line; int column; int index; template<class T> T bind(QVal<T>&& value) { QByteArray u(error.utf8()); u.append(' ').append(QByteArray::number(line)).append(':').append(QByteArray::number(column)); return value.bind(QUtf8Data(u)); } };
struct Error { QIdentifierLiteral error; int line; int column; int index; QValueStatus zap(QValue&& value) { QByteArray u(error.utf8()); u.append(' ').append(QByteArray::number(line)).append(':').append(QByteArray::number(column)); return value.bind(QUtf8Data(u)); } };
QVector<Error> errors;
// Shortcuts
/**/ QValue value ( ) { return QValueStatus(this).value(); }
/**/ QSeq<QValueStatus> sequence(quint32* s=nullptr) { return QValueStatus(this).value().sequence(s); }
template<typename T> QValueStatus bind ( T&& t) { return QValueStatus(this).value().bind(std::forward<T>(t)); }
/**/ QValue value ( ) { return QValueStatus(this).value(); }
/**/ QSequence sequence(quint32* s=nullptr) { return QValueStatus(this).value().sequence(s); }
template<typename T> QValueStatus bind ( T&& t) { return QValueStatus(this).value().bind(std::forward<T>(t)); }
protected:
enum CachedNumber : quint8 { None=0, Integer, FloatingPoint };
......@@ -513,7 +513,7 @@ private:
};
// //////////////////////////////////////////////////////////////////////////
// QTransmogrifier<QJson*,_> support
// QJson* support
#include <QtCore/qjsonvalue.h>
#include <QtCore/qjsonarray.h>
......@@ -521,7 +521,7 @@ private:
template<>
struct QTransmogrifier<QJsonValue> {
static QValueStatus bind(QValue&& v, QJsonValue&& j) {
static QValueStatus zap(QValue&& v, QJsonValue&& j) {
if (v->mode()==Write) {
if (j.isObject()) return v.bind(j.toObject());
if (j.isArray ()) return v.bind(j.toArray ());
......@@ -532,9 +532,9 @@ struct QTransmogrifier<QJsonValue> {
}
else { Q_ASSERT_X(false, Q_FUNC_INFO, "Unsupported v->mode()"); return v.null(); }
}
static QValueStatus bind(QValue&& v, QJsonValue& j) {
static QValueStatus zap(QValue&& v, QJsonValue& j) {
if (v->mode()==Write) {
return bind(std::move(v),std::move(j));
return zap(std::move(v),std::move(j));
}
else if (v->mode()==Read) {
QValueStatus r;
......@@ -557,7 +557,7 @@ struct QTransmogrifier<QJsonValue> {
template<>
struct QTransmogrifier<QJsonArray> {
static QValueStatus bind(QValue&& v, QJsonArray&& j) {
static QValueStatus zap(QValue&& v, QJsonArray&& j) {
if (v->mode()==Write) {
quint32 size=quint32(j.size());
auto s(v.sequence(&size));
......@@ -568,13 +568,13 @@ struct QTransmogrifier<QJsonArray> {
}
else { Q_ASSERT_X(false, Q_FUNC_INFO, "Unsupported v->mode()"); return v.null(); }
}
static QValueStatus bind(QValue&& v, QJsonArray& j) {
static QValueStatus zap(QValue&& v, QJsonArray& j) {
if (v->mode()==Write) {
return bind(std::move(v),std::move(j));
return zap(std::move(v),std::move(j));
}
else if (v->mode()==Read) {
auto s(v.sequence());
QVal<QSeq<QValueStatus>> i;
QVal<QSequence> i;
while ((i = s.item())) {
QJsonValue json;
if ((s = i.bind(json)))
......@@ -588,7 +588,7 @@ struct QTransmogrifier<QJsonArray> {
template<>
struct QTransmogrifier<QJsonObject> {
static QValueStatus bind(QValue&& v, QJsonObject&& j) {
static QValueStatus zap(QValue&& v, QJsonObject&& j) {
if (v->mode()==Write) {
quint32 size=quint32(j.size());
auto s(v.record(&size));
......@@ -600,13 +600,13 @@ struct QTransmogrifier<QJsonObject> {
}
else { Q_ASSERT_X(false, Q_FUNC_INFO, "Unsupported v->mode()"); return v.null(); }
}
static QValueStatus bind(QValue&& v, QJsonObject& j) {
static QValueStatus zap(QValue&& v, QJsonObject& j) {
if (v->mode()==Write) {
return bind(std::move(v),std::move(j));
return zap(std::move(v),std::move(j));
}
else if (v->mode()==Read) {
auto s(v.record());
QIdentifier k; QVal<QRec<QValueStatus>> i;
QIdentifier k; QVal<QRecord> i;
while ((i = s.item(k))) {
QJsonValue json;
if ((s = i.bind(json)))
......
......@@ -51,7 +51,7 @@
#include "QJson_impl.h"
// //////////////////////////////////////////////////////////////////////////
// QTransmogrifier<T,Q*Model> support
// Q*Model support
class QModelBind : public QAbstractValue
{
......@@ -59,7 +59,7 @@ class QModelBind : public QAbstractValue
public:
QModelBind(QAbstractItemModel* m, bool rowFirst=true) : m(m), rowFirst(rowFirst) { Q_ASSERT(m); }
struct Error { QIdentifierLiteral error; QModelIndex index; template<class T> T bind(QVal<T>&& value) { QByteArray u(error.utf8()); for (; index.isValid(); index=index.parent()) u.append('/').append(QByteArray::number(index.row())).append(',').append(QByteArray::number(index.column())); return value.bind(QUtf8Data(u)); } };
struct Error { QIdentifierLiteral error; QModelIndex index; QValueStatus zap(QValue&& value) { QByteArray u(error.utf8()); for (; index.isValid(); index=index.parent()) u.append('/').append(QByteArray::number(index.row())).append(',').append(QByteArray::number(index.column())); return value.bind(QUtf8Data(u)); } };
QVector<Error> errors;
QValue value() { return QValueStatus(this).value(); }
......
......@@ -56,7 +56,7 @@ public:
// Shortcuts
/**/ QValue value ( ) { return QValueStatus(this).value(); }
/**/ QSeq<QValueStatus> sequence(quint32* s=nullptr) { return QValueStatus(this).value().sequence(s); }
/**/ QSequence sequence(quint32* s=nullptr) { return QValueStatus(this).value().sequence(s); }
template<typename T> QValueStatus bind ( T&& t) { return QValueStatus(this).value().bind(std::forward<T>(t)); }
protected:
bool tryBind ( quint8&& t) { settings->setValue(key(), int(t) ); return true; }
......@@ -96,7 +96,7 @@ public:
Q_ENABLE_MOVE(QSettingsReader, std::swap(isChoice, o.isChoice); )
QSettingsReader(QSettings* s) : settings(s) { Q_ASSERT(s); levels.push(Level(qBindExpectedItem)); }
struct Error { QIdentifierLiteral error; QAsciiData path; template<class T> T bind(QVal<T>&& value) { return value.bind(QUtf8Data(error.utf8()+' '+path.utf8())); } };
struct Error { QIdentifierLiteral error; QAsciiData path; QValueStatus zap(QValue&& value) { return value.bind(QUtf8Data(error.utf8()+' '+path.utf8())); } };
QVector<Error> errors;
QAsciiData currentPath() {
......
......@@ -109,7 +109,7 @@ extern QIdentifierLiteral qmColor;
// //////////////////////////////////////////////////////////////////////////
// QTransmogrifier<T>
enum QValueMode { Invalid=0, Read=1, Write=2 }; //!< Specifies QTransmogrifier::bind traversal and processing (the design would support other QValueMode like Append or Diff)
enum QValueMode { Invalid=0, Read=1, Write=2 }; //!< Specifies QTransmogrifier::zap traversal and processing (the design would support other QValueMode like Append or Diff)
struct BindGeneric {};
struct BindNative {};
......@@ -318,8 +318,8 @@ using QRecord = QRec<QValueStatus>;
#include <functional>
#ifndef NO_COMPILER_RTTI_OR_EXCEPTIONS
template<typename T> using QValFunction = QValueStatus (*)(T &,QValue &&) ;
template<class Ts> using QSeqFunction = QSequence (*)(Ts&,QSequence&&) ;
template<typename T> using QValFunction = QValueStatus(*)(T &,QValue &&) ;
template<class Ts> using QSeqFunction = QSequence (*)(Ts&,QSequence&&) ;
#endif
/**/ using QValLambda = std::function<QValueStatus(QValue &&)>;
/**/ using QSeqLambda = std::function<QSequence (QSequence&&)>;
......@@ -338,16 +338,16 @@ public:
QSeq<T_> sequence(quint32* s=nullptr) { return outer->trySequence (s) ? QSeq<T_>(std::move(outer)) : QSeq<T_>(); }
QRec<T_> record (quint32* s=nullptr) { return outer->tryRecord (s) ? QRec<T_>(std::move(outer)) : QRec<T_>(); }
/**/ T_ null ( ) { return outer->tryNull ( ) ? std::move(outer) : T_ (); }
/**/ T_ any ( ) { return outer->tryAny ( ) ? std::move(outer) : T_ (); }
/**/ T_ null ( ) { return outer->tryNull ( ) ? std::move(outer) : T_ (); }
/**/ T_ any ( ) { return outer->tryAny ( ) ? std::move(outer) : T_ (); }
/**/ T_ bind ( const char* u) { return outer->tryBind(QUtf8DataView(u)) ? std::move(outer) : T_ (); }
/**/ T_ bind ( QUtf8DataView u) { return outer->tryBind (u) ? std::move(outer) : T_ (); }
/**/ T_ bind ( QAsciiDataView a) { return outer->tryBind (a) ? std::move(outer) : T_ (); }
/**/ T_ bind ( QLatin1String l) { return outer->tryBind (l) ? std::move(outer) : T_ (); }
/**/ T_ bind ( QStringView u) { return outer->tryBind (u) ? std::move(outer) : T_ (); }
/**/ T_ bind ( const char* u) { return outer->tryBind(QUtf8DataView(u)) ? std::move(outer) : T_ (); }
/**/ T_ bind ( QUtf8DataView u) { return outer->tryBind (u) ? std::move(outer) : T_ (); }
/**/ T_ bind ( QAsciiDataView a) { return outer->tryBind (a) ? std::move(outer) : T_ (); }
/**/ T_ bind ( QLatin1String l) { return outer->tryBind (l) ? std::move(outer) : T_ (); }
/**/ T_ bind ( QStringView u) { return outer->tryBind (u) ? std::move(outer) : T_ (); }
template<typename T> T_ bind ( T&& t) { return outer->tryBind(std::forward<T>(t )) ? std::move(outer) : T_(); }
template<typename T> T_ bind ( T&& t) { return outer->tryBind(std::forward <T>(t )) ? std::move(outer) : T_(); }
template<typename T> T_ bind (T& t, T&& defaultT) { return outer->tryBind(QDefaultValue<T>{t,defaultT}) ? std::move(outer) : T_(); }
// Custom bind support
......@@ -412,8 +412,8 @@ public:
template<typename T> QSeq<T_> operator<<(T&& t) { return item().bind(std::forward<T>(t)); } // stream compatible
private:
template<typename T, typename TEnabledIf> friend struct QTransmogrifier;
QValue unsafeItem() noexcept { return outer->tryItem() ? QValue(outer->_unsafeCopy()) : QValue(); }
QSeq<QValueStatus> unsafeThis() noexcept { return QSeq<QValueStatus>(outer->_unsafeCopy()) ; }
QValue unsafeItem() noexcept { return outer->tryItem() ? QValue(outer->_unsafeCopy()) : QValue(); }
QSequence unsafeThis() noexcept { return QSequence(outer->_unsafeCopy()) ; }
T_ outer = T_();
};
......@@ -472,13 +472,13 @@ private:
//!
template<typename T, typename TEnabledIf=void>
struct QTransmogrifier {
static QValueStatus bind(QValue&& value, T& t) { return t .bind(std::move(value)); } // In case of error, define a T::bind(QValue) method or external QTransmogrifier<T>::bind(QValue,T&)
static QValueStatus bind(QValue&& value,const T& t) { return const_cast<T&>(t).bind(std::move(value)); } // In case of error, define a T::bind(QValue) method or external QTransmogrifier<T>::bind(QValue,const T&)
static QValueStatus bind(QValue&& value, T&& t) { return t .bind(std::move(value)); } // In case of error, define a T::bind(QValue) method or external QTransmogrifier<T>::bind(QValue,T&&)
static QValueStatus zap(QValue&& value, T& t) { return t .zap(std::move(value)); } // In case of error, define a T::bind(QValue) method or external QTransmogrifier<T>::bind(QValue,T&)
static QValueStatus zap(QValue&& value,const T& t) { return const_cast<T&>(t).zap(std::move(value)); } // In case of error, define a T::bind(QValue) method or external QTransmogrifier<T>::bind(QValue,const T&)
static QValueStatus zap(QValue&& value, T&& t) { return t .zap(std::move(value)); } // In case of error, define a T::bind(QValue) method or external QTransmogrifier<T>::bind(QValue,T&&)
};
template<class T>
bool QValueStatus::tryBind(BindGeneric, T&& t) { return QTransmogrifier<RemoveCvRef<T>>::bind(QValue(_unsafeCopy()),std::forward<T>(t)); }
bool QValueStatus::tryBind(BindGeneric, T&& t) { return QTransmogrifier<RemoveCvRef<T>>::zap(QValue(_unsafeCopy()),std::forward<T>(t)); }
class QScopedChoice //!< for accurate error reporting
{
......@@ -804,7 +804,7 @@ public:
template<typename T> QBindable(T& t) : f(/*captured T ref */[&t] (QValue&& v) { return v.bind(t); } ) {}
template<typename T> QBindable(T&& t) : f(/*captured T copy*/[ t] (QValue&& v) { return v.bind(t); } ) {}
QValueStatus bind(QValue&& v) { return f(std::move(v)); }
QValueStatus zap(QValue&& v) { return f(std::move(v)); }
};
// //////////////////////////////////////////////////////////////////////////
......@@ -921,11 +921,11 @@ QValueStatus qbind(QValue&& v, T* t) {
}
//! Default bind(QValue&&) based on static QMetaObject reflection
#define QBIND_GADGET_WITH_METAOBJECT(Class) QValueStatus bind(QValue&& v) { return qbind<Class>(std::move(v), this); }
#define QBIND_GADGET_WITH_METAOBJECT(Class) QValueStatus zap(QValue&& v) { return qbind<Class>(std::move(v), this); }
template<typename T>
struct QTransmogrifier<QDefaultValue<T>> {
static QValueStatus bind(QValue&& v, QDefaultValue<T>&& t) {
static QValueStatus zap(QValue&& v, QDefaultValue<T>&& t) {
if (v->mode()==Read) {
v->setChoice(true);
auto r=v.null();
......@@ -937,17 +937,17 @@ struct QTransmogrifier<QDefaultValue<T>> {
}
return v.bind(t.value);
}
static QValueStatus bind(QValue&& v, QDefaultValue<T>& t) {
static QValueStatus zap(QValue&& v, QDefaultValue<T>& t) {
return bind(std::move(v),std::move(t));
}
};
template<typename T>
struct QTransmogrifier<T, typename std::enable_if<std::is_unsigned<T>::value && std::is_integral<T>::value && !std::is_same<T,bool>::value>::type> {
static QValueStatus bind(QValue&& v, T&& t) {
static QValueStatus zap(QValue&& v, T&& t) {
return v.bind(quint64(t));
}
static QValueStatus bind(QValue&& v, T& t) {
static QValueStatus zap(QValue&& v, T& t) {
if (v->mode()==Write) {
return bind(std::move(v),T(t));
}
......@@ -959,10 +959,10 @@ struct QTransmogrifier<T, typename std::enable_if<std::is_unsigned<T>::value &&
};
template<typename T>
struct QTransmogrifier<T, typename std::enable_if<std::is_signed<T>::value && std::is_integral<T>::value && !std::is_same<T,bool>::value>::type> {
static QValueStatus bind(QValue&& v, T&& t) {
static QValueStatus zap(QValue&& v, T&& t) {
return v.bind(qint64(t));
}
static QValueStatus bind(QValue&& v, T& t) {
static QValueStatus zap(QValue&& v, T& t) {
if (v->mode()==Write) {
return bind(std::move(v),T(t));
}
......@@ -977,7 +977,7 @@ struct QTransmogrifier<T, typename std::enable_if<std::is_signed<T>::value && st
template<typename T, unsigned Size>
struct QTransmogrifier<T[Size]> {
static QValueStatus bind(QValue&& v, T(& ts)[Size]) {
static QValueStatus zap(QValue&& v, T(& ts)[Size]) {
if (v->mode()==Write) {
quint32 size=Size;
auto s(v.sequence(&size));
......@@ -988,7 +988,7 @@ struct QTransmogrifier<T[Size]> {
}
else if (v->mode()==Read) {
auto s(v.sequence());
QVal<QSeq<QValueStatus>> i; unsigned j=0;
QVal<QSequence> i; unsigned j=0;
while ((i = s.item())) {
if (j== Size) {
i->reportError(qBindIgnoredItem);
......@@ -1008,7 +1008,7 @@ struct QTransmogrifier<T[Size]> {
template<typename T>
struct QTransmogrifier<QVector<T>> {
static QValueStatus bind(QValue&& v, QVector<T>&& ts) {
static QValueStatus zap(QValue&& v, QVector<T>&& ts) {
if (v->mode()==Write) {
quint32 size=ts.size();
auto s(v.sequence(&size));
......@@ -1019,7 +1019,7 @@ struct QTransmogrifier<QVector<T>> {
}
else { Q_ASSERT_X(!v, Q_FUNC_INFO, "Unsupported v->mode()"); return v.null(); }
}
static QValueStatus bind(QValue&& v, QVector<T>& ts) {
static QValueStatus zap(QValue&& v, QVector<T>& ts) {
if (v->mode()==Write) {
quint32 size=ts.size();
auto s(v.sequence(&size));
......@@ -1030,7 +1030,7 @@ struct QTransmogrifier<QVector<T>> {
}
else if (v->mode()==Read) {
auto s(v.sequence());
QVal<QSeq<QValueStatus>> i; int it = 0;
QVal<QSequence> i; int it = 0;
while ((i = s.item())) {
if (it==ts.size()) {
T t;
......@@ -1054,7 +1054,7 @@ struct QTransmogrifier<QVector<T>> {
template<typename T>
struct QTransmogrifier<QList<T>> {
static QValueStatus bind(QValue&& v, QList<T>&& ts) {
static QValueStatus zap(QValue&& v, QList<T>&& ts) {
if (v->mode()==Write) {
quint32 size=quint32(ts.size());
auto s(v.sequence(&size));
......@@ -1065,7 +1065,7 @@ struct QTransmogrifier<QList<T>> {
}
else { Q_ASSERT_X(!v, Q_FUNC_INFO, "Unsupported v->mode()"); return v.null(); }
}
static QValueStatus bind(QValue&& v, QList<T>& ts) {
static QValueStatus zap(QValue&& v, QList<T>& ts) {
if (v->mode()==Write) {
quint32 size=quint32(ts.size());
auto s(v.sequence(&size));
......@@ -1076,7 +1076,7 @@ struct QTransmogrifier<QList<T>> {
}
else if (v->mode()==Read) {
auto s(v.sequence());
QVal<QSeq<QValueStatus>> i; int it = 0;
QVal<QSequence> i; int it = 0;
while ((i = s.item())) {
if (it==ts.size()) {
T t;
......@@ -1101,7 +1101,7 @@ struct QTransmogrifier<QList<T>> {
template<typename T>
struct QTransmogrifier<QMap<QString,T>> {
static QValueStatus bind(QValue&& v, QMap<QString,T>&& ts) {
static QValueStatus zap(QValue&& v, QMap<QString,T>&& ts) {
if (v->mode()==Write) {
quint32 size=quint32(ts.size());
auto s(v.record(&size));
......@@ -1112,7 +1112,7 @@ struct QTransmogrifier<QMap<QString,T>> {
}
else { Q_ASSERT_X(!v, Q_FUNC_INFO, "Unsupported v->mode()"); return v.null(); }
}