Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:07:18

0001 // Copyright (C) 2018 Intel Corporation.
0002 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
0003 
0004 #ifndef QCBORSTREAMWRITER_H
0005 #define QCBORSTREAMWRITER_H
0006 
0007 #include <QtCore/qbytearray.h>
0008 #include <QtCore/qcborcommon.h>
0009 #include <QtCore/qscopedpointer.h>
0010 #include <QtCore/qstring.h>
0011 #include <QtCore/qstringview.h>
0012 #ifndef QT_BOOTSTRAPPED
0013 #include <QtCore/qfloat16.h>
0014 #endif
0015 
0016 QT_REQUIRE_CONFIG(cborstreamwriter);
0017 
0018 /* X11 headers use these values too, but as defines */
0019 #if defined(False) && defined(True)
0020 #  undef True
0021 #  undef False
0022 #endif
0023 
0024 QT_BEGIN_NAMESPACE
0025 
0026 class QIODevice;
0027 
0028 class QCborStreamWriterPrivate;
0029 class Q_CORE_EXPORT QCborStreamWriter
0030 {
0031 public:
0032     explicit QCborStreamWriter(QIODevice *device);
0033     explicit QCborStreamWriter(QByteArray *data);
0034     ~QCborStreamWriter();
0035     Q_DISABLE_COPY(QCborStreamWriter)
0036 
0037     void setDevice(QIODevice *device);
0038     QIODevice *device() const;
0039 
0040     void append(quint64 u);
0041     void append(qint64 i);
0042     void append(QCborNegativeInteger n);
0043     void append(const QByteArray &ba)       { appendByteString(ba.constData(), ba.size()); }
0044     void append(QLatin1StringView str);
0045     void append(QStringView str);
0046     void append(QCborTag tag);
0047     void append(QCborKnownTags tag)         { append(QCborTag(tag)); }
0048     void append(QCborSimpleType st);
0049     void append(std::nullptr_t)             { append(QCborSimpleType::Null); }
0050 #ifndef QT_BOOTSTRAPPED
0051     void append(qfloat16 f);
0052 #endif
0053     void append(float f);
0054     void append(double d);
0055 
0056     void appendByteString(const char *data, qsizetype len);
0057     void appendTextString(const char *utf8, qsizetype len);
0058 
0059     // convenience
0060     void append(bool b)     { append(b ? QCborSimpleType::True : QCborSimpleType::False); }
0061     void appendNull()       { append(QCborSimpleType::Null); }
0062     void appendUndefined()  { append(QCborSimpleType::Undefined); }
0063 
0064 #ifndef Q_QDOC
0065     // overloads to make normal code not complain
0066     void append(int i)      { append(qint64(i)); }
0067     void append(uint u)     { append(quint64(u)); }
0068 #endif
0069 #ifndef QT_NO_CAST_FROM_ASCII
0070     void append(const char *str, qsizetype size = -1)
0071     { appendTextString(str, (str && size == -1)  ? int(strlen(str)) : size); }
0072 #endif
0073 
0074     void startArray();
0075     void startArray(quint64 count);
0076     bool endArray();
0077     void startMap();
0078     void startMap(quint64 count);
0079     bool endMap();
0080 
0081     // no API for encoding chunked strings
0082 
0083 private:
0084     QScopedPointer<QCborStreamWriterPrivate> d;
0085 };
0086 
0087 QT_END_NAMESPACE
0088 
0089 #if defined(QT_X11_DEFINES_FOUND)
0090 #  define True  1
0091 #  define False 0
0092 #endif
0093 
0094 #endif // QCBORSTREAMWRITER_H