Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qcborcommon.cpp
Go to the documentation of this file.
1// Copyright (C) 2018 Intel Corporation.
2// Copyright (C) 2019 The Qt Company Ltd.
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
4
5#define CBOR_NO_ENCODER_API
6#define CBOR_NO_PARSER_API
7#include "qcborcommon_p.h"
8
9#include <QtCore/qdatastream.h>
10
12
14
15#include <cborerrorstrings.c>
16
57#if !defined(QT_NO_DATASTREAM)
59{
60 return ds << quint8(st);
61}
62
64{
65 quint8 v;
66 ds >> v;
67 st = QCborSimpleType(v);
68 return ds;
69}
70#endif
71
240{
241 switch (c) {
242 case NoError:
243 static_assert(int(NoError) == int(CborNoError));
244 return QString();
245
246 case UnknownError:
247 static_assert(int(UnknownError) == int(CborUnknownError));
248 return QStringLiteral("Unknown error");
249 case AdvancePastEnd:
250 static_assert(int(AdvancePastEnd) == int(CborErrorAdvancePastEOF));
251 return QStringLiteral("Read past end of buffer (more bytes needed)");
252 case InputOutputError:
253 static_assert(int(InputOutputError) == int(CborErrorIO));
254 return QStringLiteral("Input/Output error");
255 case GarbageAtEnd:
256 static_assert(int(GarbageAtEnd) == int(CborErrorGarbageAtEnd));
257 return QStringLiteral("Data found after the end of the stream");
258 case EndOfFile:
259 static_assert(int(EndOfFile) == int(CborErrorUnexpectedEOF));
260 return QStringLiteral("Unexpected end of input data (more bytes needed)");
261 case UnexpectedBreak:
262 static_assert(int(UnexpectedBreak) == int(CborErrorUnexpectedBreak));
263 return QStringLiteral("Invalid CBOR stream: unexpected 'break' byte");
264 case UnknownType:
265 static_assert(int(UnknownType) == int(CborErrorUnknownType));
266 return QStringLiteral("Invalid CBOR stream: unknown type");
267 case IllegalType:
268 static_assert(int(IllegalType) == int(CborErrorIllegalType));
269 return QStringLiteral("Invalid CBOR stream: illegal type found");
270 case IllegalNumber:
271 static_assert(int(IllegalNumber) == int(CborErrorIllegalNumber));
272 return QStringLiteral("Invalid CBOR stream: illegal number encoding (future extension)");
274 static_assert(int(IllegalSimpleType) == int(CborErrorIllegalSimpleType));
275 return QStringLiteral("Invalid CBOR stream: illegal simple type");
277 static_assert(int(InvalidUtf8String) == int(CborErrorInvalidUtf8TextString));
278 return QStringLiteral("Invalid CBOR stream: invalid UTF-8 text string");
279 case DataTooLarge:
280 static_assert(int(DataTooLarge) == int(CborErrorDataTooLarge));
281 return QStringLiteral("Internal limitation: data set too large");
282 case NestingTooDeep:
283 static_assert(int(NestingTooDeep) == int(CborErrorNestingTooDeep));
284 return QStringLiteral("Internal limitation: data nesting too deep");
285 case UnsupportedType:
286 static_assert(int(UnsupportedType) == int(CborErrorUnsupportedType));
287 return QStringLiteral("Internal limitation: unsupported type");
288 }
289
290 // get the error string from TinyCBOR
291 CborError err = CborError(int(c));
292 return QString::fromLatin1(cbor_error_string(err));
293}
294
296
297#ifndef QT_BOOTSTRAPPED
298#include "moc_qcborcommon.cpp"
299#endif
\inmodule QtCore\reentrant
Definition qdatastream.h:46
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
static QString fromLatin1(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qstring.cpp:5871
Combined button and popup list for selecting options.
QDataStream & operator<<(QDataStream &ds, QCborSimpleType st)
QDataStream & operator>>(QDataStream &ds, QCborSimpleType &st)
QCborTag
Definition qcborcommon.h:30
QCborSimpleType
Definition qcborcommon.h:23
#define QT_IMPL_METATYPE_EXTERN(TYPE)
Definition qmetatype.h:1390
GLsizei const GLfloat * v
[13]
const GLubyte * c
#define QStringLiteral(str)
unsigned char quint8
Definition qtypes.h:46
QString toString() const
Returns a text string that matches the error code in this QCborError object.
@ IllegalSimpleType
Definition qcborcommon.h:76
@ InvalidUtf8String
Definition qcborcommon.h:78