1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
6 \title CBOR Support in Qt
7 \ingroup qt-basic-concepts
8 \brief An overview of CBOR support in Qt.
10 \ingroup frameworks-technologies
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
18 The CBOR support in Qt provides an easy to use C++ API to parse,
19 modify and save CBOR data.
21 More details about the CBOR data format can be found in \l {RFC 7049}.
27 CBOR is a format to store structured data. It has three groups of built-in types:
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
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.
38 \sa {Parsing and displaying CBOR data}, {Convert Example}, {JSON Save Game Example}
40 \section1 The CBOR Classes
42 \section2 The QCborValue Class
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.
54 \section2 The QCborArray Class
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.
60 \section2 The QCborMap Class
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.
67 \section2 The QCborStreamReader Class
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.
73 \section2 The QCborStreamWriter Class
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