Make QCborValue::toCbor() const

Those methods don't modify the CBOR value, they should be const.

Change-Id: I213984ed82e43429413344999a22ad1c4c3beac8
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Lars Knoll 2020-03-17 14:46:35 +01:00
parent fe275c75ae
commit 6fea5b4dd8
2 changed files with 4 additions and 4 deletions

View File

@ -2506,7 +2506,7 @@ QCborValue QCborValue::fromCbor(const QByteArray &ba, QCborParserError *error)
\sa fromCbor(), fromVariant(), fromJsonValue()
*/
QByteArray QCborValue::toCbor(EncodingOptions opt)
QByteArray QCborValue::toCbor(EncodingOptions opt) const
{
QByteArray result;
QCborStreamWriter writer(&result);
@ -2543,7 +2543,7 @@ QByteArray QCborValue::toCbor(EncodingOptions opt)
\sa fromCbor(), fromVariant(), fromJsonValue()
*/
Q_NEVER_INLINE void QCborValue::toCbor(QCborStreamWriter &writer, EncodingOptions opt)
Q_NEVER_INLINE void QCborValue::toCbor(QCborStreamWriter &writer, EncodingOptions opt) const
{
if (isContainer() || isTag())
return encodeToCbor(writer, container, -type(), opt);

View File

@ -298,8 +298,8 @@ public:
{ return fromCbor(QByteArray(reinterpret_cast<const char *>(data), int(len)), error); }
#endif // QT_CONFIG(cborstreamreader)
#if QT_CONFIG(cborstreamwriter)
QByteArray toCbor(EncodingOptions opt = NoTransformation);
void toCbor(QCborStreamWriter &writer, EncodingOptions opt = NoTransformation);
QByteArray toCbor(EncodingOptions opt = NoTransformation) const;
void toCbor(QCborStreamWriter &writer, EncodingOptions opt = NoTransformation) const;
#endif
QString toDiagnosticNotation(DiagnosticNotationOptions opts = Compact) const;