summaryrefslogtreecommitdiffstats
path: root/src/corelib/serialization/qcborvalue.h
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2018-05-19 17:21:38 -0500
committerThiago Macieira <thiago.macieira@intel.com>2018-07-05 14:56:12 +0000
commit340472534cec2bccd634b1e366c2f654a3448fac (patch)
tree75fdf562dc9484d3e27365eed1eaf8ab6f0c94b9 /src/corelib/serialization/qcborvalue.h
parent22c1a46a03bc3347afc0e7462e19558283d0e1b7 (diff)
QCborValue: refactor extended types so isTag() is true
This makes QCborValue more future compatible, as code written today for tags that QCborValue does not recognize will continue to work if QCborValue gains support for it in the future. This change also obviates the need for reinterpretAsTag(), which I had not written unit tests for as I knew this change was coming. Change-Id: I052407b777ec43f78378fffd15302bdc34f66755 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'src/corelib/serialization/qcborvalue.h')
-rw-r--r--src/corelib/serialization/qcborvalue.h10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/corelib/serialization/qcborvalue.h b/src/corelib/serialization/qcborvalue.h
index 8411830835..717b123e68 100644
--- a/src/corelib/serialization/qcborvalue.h
+++ b/src/corelib/serialization/qcborvalue.h
@@ -192,7 +192,7 @@ public:
bool isString() const { return type() == String; }
bool isArray() const { return type() == Array; }
bool isMap() const { return type() == Map; }
- bool isTag() const { return type() == Tag; }
+ bool isTag() const { return isTag_helper(type()); }
bool isFalse() const { return type() == False; }
bool isTrue() const { return type() == True; }
bool isBool() const { return isFalse() || isTrue(); }
@@ -228,7 +228,6 @@ public:
QCborTag tag(QCborTag defaultValue = QCborTag(-1)) const;
QCborValue taggedValue(const QCborValue &defaultValue = QCborValue()) const;
- QCborValue reinterpretAsTag() const;
QByteArray toByteArray(const QByteArray &defaultValue = {}) const;
QString toString(const QString &defaultValue = {}) const;
@@ -311,6 +310,11 @@ private:
{
return Type(quint8(st) | SimpleType);
}
+
+ Q_DECL_CONSTEXPR static bool isTag_helper(Type t)
+ {
+ return t == Tag || t >= 0x10000;
+ }
};
Q_DECLARE_SHARED(QCborValue)
@@ -328,7 +332,7 @@ public:
bool isString() const { return type() == QCborValue::String; }
bool isArray() const { return type() == QCborValue::Array; }
bool isMap() const { return type() == QCborValue::Map; }
- bool isTag() const { return type() == QCborValue::Tag; }
+ bool isTag() const { return QCborValue::isTag_helper(type()); }
bool isFalse() const { return type() == QCborValue::False; }
bool isTrue() const { return type() == QCborValue::True; }
bool isBool() const { return isFalse() || isTrue(); }