Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
cbor.qdoc
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
3
4/*!
5 \group cbor
6 \title CBOR Support in Qt
7 \ingroup qt-basic-concepts
8 \brief An overview of CBOR support in Qt.
9
10 \ingroup frameworks-technologies
11
12 \keyword CBOR
13
14 Qt provides support for dealing with CBOR data. CBOR is a binary format to
15 store data that has a superset of the types available in JSON, but is more
16 compact.
17
18 The CBOR support in Qt provides an easy to use C++ API to parse,
19 modify and save CBOR data.
20
21 More details about the CBOR data format can be found in \l {RFC 7049}.
22
23 \tableofcontents
24
25 \section1 Overview
26
27 CBOR is a format to store structured data. It has three groups of built-in types:
28
29 \list
30 \li Basic types: integers, floating point, boolean, null, etc.
31 \li String-like types: strings and byte arrays
32 \li Containers: arrays and maps
33 \endlist
34
35 In addition, CBOR can add a "tag" to extend the meaning of the type. The
36 container types can contain basic types, string-like types and containers.
37
38 \sa {Parsing and displaying CBOR data}, {Convert Example}, {JSON Save Game Example}
39
40 \section1 The CBOR Classes
41
42 \section2 The QCborValue Class
43
44 The QCborValue class represents any CBOR type. It also has a simple API for
45 reading and writing to QCborStreamReader and QCborStreamWriter objects, as
46 well as manipulating such objects in memory, with the help of QCborArray
47 and QCborMap. The CborValue API is simplified from the full CBOR data type
48 and always represents all integers as \l qint64 and all floating-point as
49 \c double. This means QCborValue is unable to represent CBOR integer values
50 outside of the range of \l qint64 (-2^63 to 2^63-1). When creating a CBOR
51 stream, QCborValue::toCbor() can be configured to attempt to write the
52 shorter single- and half-precision floating-point representations.
53
54 \section2 The QCborArray Class
55
56 The QCborArray class is used to hold an array of QCborValue objects. A
57 QCborValue object can contain a QCborArray object. It has functions for
58 converting to and from QVariantList, QStringList, QJsonArray.
59
60 \section2 The QCborMap Class
61
62 The QCborMap class is used to hold an map of QCborValue objects. A
63 QCborValue object can contain a QCborMap object. It has functions for
64 converting to and from QVariantMap, QVariantMap, and QJsonObject, but it
65 can have keys of any type, not just QString.
66
67 \section2 The QCborStreamReader Class
68
69 The QCborStreamReader class is a low level API for reading CBOR data from a
70 QIODevice, a QByteArray, or a pointer to memory. It has an API similar to
71 the QXmlStreamReader class.
72
73 \section2 The QCborStreamWriter Class
74
75 The QCborStreamWriter class is a low level API for writing CBOR data to a
76 QIODevice or a QByteArray. It has an API similar to the QXmlStreamWriter
77 class.
78*/