From 975bdfa4a6ff07d64e76fd2ff7af22194658a772 Mon Sep 17 00:00:00 2001 From: "arnaud.clere" Date: Tue, 19 Nov 2019 23:39:47 +0100 Subject: [PATCH] Renaming _isOk > isValid --- tests/QBind/QCbor_impl.h | 6 +++--- tests/QBind/QData_impl.h | 2 +- tests/QBind/QJson_impl.h | 4 ++-- tests/QBind/QModel_impl.h | 4 ++-- tests/QBind/QSettings_impl.h | 2 +- tests/QBind/QValue.h | 6 +++--- tests/QBind/QVariant_impl.h | 28 ++++++++++++++-------------- tests/QBind/QXml_impl.h | 2 +- 8 files changed, 27 insertions(+), 27 deletions(-) diff --git a/tests/QBind/QCbor_impl.h b/tests/QBind/QCbor_impl.h index c0b52a0106..1cc37e0176 100644 --- a/tests/QBind/QCbor_impl.h +++ b/tests/QBind/QCbor_impl.h @@ -112,7 +112,7 @@ public: /**/ QSequence sequence(quint32* s=nullptr) { return QValueStatus(this).value().sequence(s); } template QValueStatus bind ( T&& t) { return QValueStatus(this).value().bind(std::forward(t)); } protected: - bool _isOk() const noexcept { return io; } + bool isValid() const noexcept { return io; } bool trySequence(quint32* rows=nullptr) { levels.push_back(rows); if (Q_LIKELY(rows)) { putInteger (*rows , cbor::ArrayType); } @@ -264,7 +264,7 @@ protected: bool tryItem( ) { steps.last().idx++; return !(steps.last().item = current(1).toArray(). at(steps.last().idx )).isUndefined(); } bool tryOut ( ) { steps.pop() ; return true; } - bool _isOk() const noexcept { return cbor; } + bool isValid() const noexcept { return cbor; } void reportError(QIdentifierLiteral e, QString context = QString()) { if (errorHandler) errorHandler(e, QString(currentPath().latin1()).append(context)); } private: const QCborValue& current(int outer=0) const { Q_ASSERT(0<=outer); return steps.size()-outer <= 0 ? *cbor : steps[steps.size()-outer-1].item; } @@ -419,7 +419,7 @@ protected: return leaveContainer(); } bool tryAny() { return next(); } - bool _isOk() const noexcept { return const_cast(this)->lastError()==QCborError::NoError; } + bool isValid() const noexcept { return const_cast(this)->lastError()==QCborError::NoError; } void reportError(QIdentifierLiteral e, QString context = QString()) { if (errorHandler) errorHandler(e, QString("at index:%1 ").arg(currentOffset()).append(context)); } private: void skipTag() { if (isTag()) next(); } diff --git a/tests/QBind/QData_impl.h b/tests/QBind/QData_impl.h index 401e53c916..e3addf748e 100644 --- a/tests/QBind/QData_impl.h +++ b/tests/QBind/QData_impl.h @@ -89,7 +89,7 @@ protected: bool tryBind ( QByteArray&& t) { *io << t; return true; } bool tryBind ( QVariant&& t) { *io << t; return true; } - bool _isOk() const noexcept { return io && io->status()==QDataStream::Ok; } + bool isValid() const noexcept { return io && io->status()==QDataStream::Ok; } bool tryOut ( ) { return true; } bool tryItem( ) { return true; } diff --git a/tests/QBind/QJson_impl.h b/tests/QBind/QJson_impl.h index e27615cca7..4416a07fa1 100644 --- a/tests/QBind/QJson_impl.h +++ b/tests/QBind/QJson_impl.h @@ -136,7 +136,7 @@ protected: bool tryItem( ) { steps.last().idx++; return !(steps.last().item = current(1).toArray (). at(steps.last().idx )).isUndefined(); } bool tryOut ( ) { steps.removeLast(); return true; } - bool _isOk() const noexcept { return true; } + bool isValid() const noexcept { return true; } void reportError(QIdentifierLiteral e, QString context = QString()) { if (errorHandler) errorHandler(e, QString(currentPath().latin1()).append(context)); } private: const QJsonValue& current(int outer=0) const { Q_ASSERT(0<=outer && json); return steps.size()-outer <= 0 ? *json : steps[steps.size()-outer-1].item; } @@ -374,7 +374,7 @@ protected: level.index++; return true; } - bool _isOk() const noexcept { return io; } + bool isValid() const noexcept { return io; } void reportError(QIdentifierLiteral e, QString context = QString()) { if (errorHandler) errorHandler(e, QString("at (%1,%2) ").arg(line).arg(column).append(context)); } private: CachedNumber getNumber() { diff --git a/tests/QBind/QModel_impl.h b/tests/QBind/QModel_impl.h index 91877d8525..973e6a2a27 100644 --- a/tests/QBind/QModel_impl.h +++ b/tests/QBind/QModel_impl.h @@ -229,7 +229,7 @@ public: QModelWriter(QAbstractItemModel* m, bool rowFirst=true) : QModelBind(m, rowFirst), w(&ba) {} virtual QValueMode mode() const noexcept { return QValueMode::Write; } - virtual bool _isOk() const noexcept { return true; } //!< Write status ignored by default (no need to test intermediate status to choose between trySequence(), etc. + virtual bool isValid() const noexcept { return true; } //!< Write status ignored by default (no need to test intermediate status to choose between trySequence(), etc. protected: virtual bool tryOut() { d--; @@ -418,7 +418,7 @@ public: QModelReader(QAbstractItemModel* m, bool rowFirst=true) : QModelBind(m, rowFirst), r(&io) { io.open(QIODevice::ReadOnly); } virtual QValueMode mode() const noexcept { return QValueMode::Read; } - virtual bool _isOk() const noexcept { return true; } //!< Read status ignored by default (QAbstractItemModel is not sequential) + virtual bool isValid() const noexcept { return true; } //!< Read status ignored by default (QAbstractItemModel is not sequential) protected: virtual bool tryOut() { if (I<=d) { diff --git a/tests/QBind/QSettings_impl.h b/tests/QBind/QSettings_impl.h index c2161535b8..28a7e3d15e 100644 --- a/tests/QBind/QSettings_impl.h +++ b/tests/QBind/QSettings_impl.h @@ -135,7 +135,7 @@ protected: bool tryItem( ) { levels.last().idx++ ; return true; } bool tryOut ( ) { levels.pop(); settings->endGroup(); return true; } - bool _isOk() const noexcept { return settings; } + bool isValid() const noexcept { return settings; } void reportError(QIdentifierLiteral error, QString context = QString()) { if (errorHandler) errorHandler(error, QString(currentPath().latin1()).append(context)); } private: template diff --git a/tests/QBind/QValue.h b/tests/QBind/QValue.h index 0e2b5f1b86..e09dcc70b7 100644 --- a/tests/QBind/QValue.h +++ b/tests/QBind/QValue.h @@ -154,7 +154,7 @@ struct QAbstractValue { virtual QValueMode mode() const noexcept = 0; //!< \remark a static constexpr QValueMode Mode did not exhibit noticeable performance improvements and may trigger twice more code generation for Read/Write independant QTransmogrifier like Person::bind - virtual bool _isOk() const noexcept = 0; //!< Current operation status + virtual bool isValid() const noexcept = 0; //!< Current operation status virtual bool trySequence(quint32* size=nullptr) = 0; virtual bool tryRecord (quint32* size=nullptr) = 0; @@ -262,7 +262,7 @@ public: explicit QValueStatus(QAbstractValue* i) : impl(i) { Q_ASSERT(impl); } QValueMode mode() const noexcept { return impl ? impl->mode() : QValueMode::Invalid; } - operator bool() const noexcept { return impl && impl->_isOk(); } //!< Drives QTransmogrifier::bind() traversal + operator bool() const noexcept { return impl && impl->isValid(); } //!< Drives QTransmogrifier::bind() traversal QValueStatus* operator ->() noexcept { return this; } QVal value() noexcept ; @@ -517,7 +517,7 @@ struct QAbstractValueWriter : public QAbstractValue virtual QValueMode mode() const noexcept { return QValueMode::Write; } - virtual bool _isOk() const noexcept { return true; } //!< Write status ignored by default (no need to test intermediate status to choose between trySequence(), etc. + virtual bool isValid() const noexcept { return true; } //!< Write status ignored by default (no need to test intermediate status to choose between trySequence(), etc. virtual bool tryItem( ) = 0; virtual bool tryItem(QIdentifier& n) = 0; diff --git a/tests/QBind/QVariant_impl.h b/tests/QBind/QVariant_impl.h index 4e69ffaec2..83f96c6325 100644 --- a/tests/QBind/QVariant_impl.h +++ b/tests/QBind/QVariant_impl.h @@ -144,27 +144,27 @@ protected: // Convert numerical types to strictly larger ones // TODO convert all compatible values bool tryBind( qint8& t) { if (current()->type()==qMetaTypeId< qint8>()) { t = current()->value< qint8>(); return true; } reportError(qBindExpectedInteger ); return false; } bool tryBind( qint16& t) { if (current()->type()==qMetaTypeId< qint8>()|| - current()->type()==qMetaTypeId< qint16>()) { t = current()->value< qint16>(); return true; } reportError(qBindExpectedInteger ); return false; } + current()->type()==qMetaTypeId< qint16>()) { t = current()->value< qint16>(); return true; } reportError(qBindExpectedInteger ); return false; } bool tryBind( qint32& t) { if (current()->type()==qMetaTypeId< qint8>()|| - current()->type()==qMetaTypeId< qint16>()|| - current()->type()==qMetaTypeId< qint32>()) { t = current()->value< qint32>(); return true; } reportError(qBindExpectedInteger ); return false; } + current()->type()==qMetaTypeId< qint16>()|| + current()->type()==qMetaTypeId< qint32>()) { t = current()->value< qint32>(); return true; } reportError(qBindExpectedInteger ); return false; } bool tryBind( qint64& t) { if (current()->type()==qMetaTypeId< qint8>()|| - current()->type()==qMetaTypeId< qint16>()|| - current()->type()==qMetaTypeId< qint32>()|| - current()->type()==qMetaTypeId< qint64>()) { t = current()->value< qint64>(); return true; } reportError(qBindExpectedInteger ); return false; } + current()->type()==qMetaTypeId< qint16>()|| + current()->type()==qMetaTypeId< qint32>()|| + current()->type()==qMetaTypeId< qint64>()) { t = current()->value< qint64>(); return true; } reportError(qBindExpectedInteger ); return false; } bool tryBind( quint8& t) { if (current()->type()==qMetaTypeId< quint8>()) { t = current()->value< quint8>(); return true; } reportError(qBindExpectedPositiveInteger); return false; } bool tryBind( quint16& t) { if (current()->type()==qMetaTypeId< quint8>()|| - current()->type()==qMetaTypeId< quint16>()) { t = current()->value< quint16>(); return true; } reportError(qBindExpectedPositiveInteger); return false; } + current()->type()==qMetaTypeId< quint16>()) { t = current()->value< quint16>(); return true; } reportError(qBindExpectedPositiveInteger); return false; } bool tryBind( quint32& t) { if (current()->type()==qMetaTypeId< quint8>()|| - current()->type()==qMetaTypeId< quint16>()|| - current()->type()==qMetaTypeId< quint32>()) { t = current()->value< quint32>(); return true; } reportError(qBindExpectedPositiveInteger); return false; } + current()->type()==qMetaTypeId< quint16>()|| + current()->type()==qMetaTypeId< quint32>()) { t = current()->value< quint32>(); return true; } reportError(qBindExpectedPositiveInteger); return false; } bool tryBind( quint64& t) { if (current()->type()==qMetaTypeId< quint8>()|| - current()->type()==qMetaTypeId< quint16>()|| - current()->type()==qMetaTypeId< quint32>()|| - current()->type()==qMetaTypeId< quint64>()) { t = current()->value< quint64>(); return true; } reportError(qBindExpectedPositiveInteger); return false; } + current()->type()==qMetaTypeId< quint16>()|| + current()->type()==qMetaTypeId< quint32>()|| + current()->type()==qMetaTypeId< quint64>()) { t = current()->value< quint64>(); return true; } reportError(qBindExpectedPositiveInteger); return false; } bool tryBind( float& t) { if (current()->type()==qMetaTypeId< float>()) { t = current()->value< float>(); return true; } reportError(qBindExpectedDecimal ); return false; } bool tryBind( double& t) { if (current()->type()==qMetaTypeId< float>()|| - current()->type()==qMetaTypeId< double>()) { t = current()->value< double>(); return true; } reportError(qBindExpectedDecimal ); return false; } + current()->type()==qMetaTypeId< double>()) { t = current()->value< double>(); return true; } reportError(qBindExpectedDecimal ); return false; } bool trySequence(quint32* =nullptr) { if (current()->type()==QVariant::List ) { levels.push(Level()); return true; } reportError(qBindExpectedSequence); return false; } bool tryRecord (quint32* =nullptr) { if (current()->type()==QVariant::Map ) { levels.push(Level()); return true; } reportError(qBindExpectedRecord ); return false; } @@ -174,7 +174,7 @@ protected: bool tryItem( ) { levels.last().idx++; return (levels.last().item = current(1)->toList().value( levels.last().idx , QVariant())).isValid(); } bool tryOut ( ) { levels.pop() ; return true; } - bool _isOk() const noexcept { return value; } + bool isValid() const noexcept { return value; } void reportError(QIdentifierLiteral error, QString context = QString()) { if (errorHandler) errorHandler(error, QString(currentPath().latin1()).append(context)); } private: const QVariant* current(unsigned outer=0) const { return unsigned(levels.size())-outer <= 0 ? value : &(levels[unsigned(levels.size())-outer-1].item); } diff --git a/tests/QBind/QXml_impl.h b/tests/QBind/QXml_impl.h index f4c19786a0..915da035a1 100644 --- a/tests/QBind/QXml_impl.h +++ b/tests/QBind/QXml_impl.h @@ -85,7 +85,7 @@ protected: bool tryBind ( double&& n) { static QString s; s.setNum( n ,'g',std::numeric_limits::max_digits10); writeText("decimal" , s); return true; } // with specific precision bool tryBind ( QByteArray&& s) { QString h; h.reserve(s.size()*2+2+1); h.append("0x").append(s.toHex().toUpper()) ; writeText("hexBinary", h); return true; } - bool _isOk() const noexcept { return !io->hasError(); } + bool isValid() const noexcept { return !io->hasError(); } bool tryOut ( ) { io->writeEndElement(); return true; } bool tryItem( ) { return true; } -- GitLab