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

const correct _isOk()

parent 915b93fc
......@@ -148,9 +148,9 @@ template<> struct BindSupport< QVariant> : BindNative {};
struct IBind {
virtual ~IBind() = default;
virtual BindMode mode() const = 0; //!< \remark a static constexpr BindMode Mode did not exhibit noticeable performance improvements and may trigger twice more code generation for Read/Write independant QBind like Person::bind
virtual BindMode mode() const noexcept = 0; //!< \remark a static constexpr BindMode Mode did not exhibit noticeable performance improvements and may trigger twice more code generation for Read/Write independant QBind like Person::bind
virtual bool _isOk() = 0; //!< Current operation status
virtual bool _isOk() const noexcept = 0; //!< Current operation status
virtual bool _sequence(quint32* size=nullptr) = 0;
virtual bool _record (quint32* size=nullptr) = 0;
......@@ -515,7 +515,7 @@ struct IWriter : public IBind
virtual BindMode mode() const noexcept { return BindMode::Write; }
virtual bool _isOk() noexcept { return true; } //!< Write status ignored by default (no need to test intermediate status to choose between _sequence(), etc.
virtual bool _isOk() const noexcept { return true; } //!< Write status ignored by default (no need to test intermediate status to choose between _sequence(), etc.
virtual bool _item( ) = 0;
virtual bool _item(QIdentifier& n) = 0;
......
......@@ -112,7 +112,7 @@ public:
/**/ Seq<Cursor> sequence(quint32* s=nullptr) { return Cursor(this).value().sequence(s); }
template<typename T> Cursor bind ( T&& t) { return Cursor(this).value().bind(std::forward<T>(t)); }
protected:
bool _isOk() noexcept { return io; }
bool _isOk() const noexcept { return io; }
bool _sequence(quint32* rows=nullptr) { levels.push_back(rows);
if (Q_LIKELY(rows)) { putInteger (*rows , cbor::ArrayType); }
......@@ -267,7 +267,7 @@ protected:
bool _item( ) { steps.last().idx++; return !(steps.last().item = current(1).toArray(). at(steps.last().idx )).isUndefined(); }
bool _out ( ) { steps.pop() ; return true; }
bool _isOk() { return cbor; }
bool _isOk() const noexcept { return cbor; }
void _setChoice(bool v) { isChoice=v; }
void _reportError(QIdentifierLiteral e) { if (!isChoice) errors.append(Error{ e, currentPath() }); }
private:
......@@ -427,7 +427,7 @@ protected:
return leaveContainer(); }
bool _any() { return next(); }
bool _isOk() { return lastError()==QCborError::NoError; }
bool _isOk() const noexcept { return const_cast<QCborReader*>(this)->lastError()==QCborError::NoError; }
void _setChoice(bool b) { isChoice = b; }
void _reportError(QIdentifierLiteral e) { if (!isChoice) errors.append(Error{ e, currentOffset(), lastError() }); }
private:
......
......@@ -89,7 +89,7 @@ protected:
bool _bind ( QByteArray&& t) { *io << t; return true; }
bool _bind ( QVariant&& t) { *io << t; return true; }
bool _isOk() noexcept { return io && io->status()==QDataStream::Ok; }
bool _isOk() const noexcept { return io && io->status()==QDataStream::Ok; }
bool _out ( ) { return true; }
bool _item( ) { return true; }
......
......@@ -139,7 +139,7 @@ protected:
bool _item( ) { steps.last().idx++; return !(steps.last().item = current(1).toArray (). at(steps.last().idx )).isUndefined(); }
bool _out ( ) { steps.removeLast(); return true; }
bool _isOk() { return true; }
bool _isOk() const noexcept { return true; }
void _setChoice(bool v) { isChoice=v; }
void _reportError(QIdentifierLiteral e) { if (!isChoice) errors.append(Error{ e, currentPath() }); }
private:
......@@ -379,7 +379,7 @@ protected:
level.index++;
return true; }
bool _isOk() { return io; }
bool _isOk() const noexcept { return io; }
void _setChoice(bool v) { isChoice=v; }
void _reportError(QIdentifierLiteral e) { if (!isChoice) errors.append(Error{ e, line, column, index }); }
private:
......
......@@ -222,7 +222,7 @@ public:
QModelWriter(QAbstractItemModel* m, bool rowFirst=true) : QModelBind(m, rowFirst), w(&ba) {}
virtual BindMode mode() const noexcept { return BindMode::Write; }
virtual bool _isOk() noexcept { return true; } //!< Write status ignored by default (no need to test intermediate status to choose between _sequence(), etc.
virtual bool _isOk() const noexcept { return true; } //!< Write status ignored by default (no need to test intermediate status to choose between _sequence(), etc.
protected:
virtual bool _out() {
d--;
......@@ -410,7 +410,7 @@ public:
QModelReader(QAbstractItemModel* m, bool rowFirst=true) : QModelBind(m, rowFirst), r(&io) { io.open(QIODevice::ReadOnly); }
virtual BindMode mode() const noexcept { return BindMode::Read; }
virtual bool _isOk() noexcept { return true; } //!< Read status ignored by default (QAbstractItemModel is not sequential)
virtual bool _isOk() const noexcept { return true; } //!< Read status ignored by default (QAbstractItemModel is not sequential)
protected:
virtual bool _out() {
if (I<=d) {
......
......@@ -138,7 +138,7 @@ protected:
bool _item( ) { levels.last().idx++ ; return true; }
bool _out ( ) { levels.pop(); settings->endGroup(); return true; }
bool _isOk() { return settings; }
bool _isOk() const noexcept { return settings; }
void _setChoice(bool v) { isChoice=v; }
void _reportError(QIdentifierLiteral error) { if (!isChoice) errors.append(Error{ error, currentPath() }); }
private:
......
......@@ -177,7 +177,7 @@ protected:
bool _item( ) { levels.last().idx++; return (levels.last().item = current(1)->toList().value( levels.last().idx , QVariant())).isValid(); }
bool _out ( ) { levels.pop() ; return true; }
bool _isOk() { return value; }
bool _isOk() const noexcept { return value; }
void _setChoice(bool v) { isChoice=v; }
void _reportError(QIdentifierLiteral error) { if (!isChoice) errors.append(Error{ error, currentPath() }); }
private:
......
......@@ -85,7 +85,7 @@ protected:
bool _bind ( double&& n) { static QString s; s.setNum( n ,'g',std::numeric_limits<double>::max_digits10); writeText("decimal" , s); return true; } // with specific precision
bool _bind ( 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() noexcept { return !io->hasError(); }
bool _isOk() const noexcept { return !io->hasError(); }
bool _out ( ) { io->writeEndElement(); return true; }
bool _item( ) { return true; }
......
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