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