File indexing completed on 2025-01-18 10:07:18
0001
0002
0003
0004 #ifndef QCBORCOMMON_H
0005 #define QCBORCOMMON_H
0006
0007 #include <QtCore/qobjectdefs.h>
0008 #include <QtCore/qmetatype.h>
0009 #include <QtCore/qdebug.h>
0010
0011 #if 0
0012 #pragma qt_class(QtCborCommon)
0013 #endif
0014
0015
0016 #if defined(False) && defined(True)
0017 # undef True
0018 # undef False
0019 #endif
0020
0021 QT_BEGIN_NAMESPACE
0022
0023 enum class QCborSimpleType : quint8 {
0024 False = 20,
0025 True = 21,
0026 Null = 22,
0027 Undefined = 23
0028 };
0029
0030 enum class QCborTag : quint64 {};
0031 enum class QCborKnownTags {
0032 DateTimeString = 0,
0033 UnixTime_t = 1,
0034 PositiveBignum = 2,
0035 NegativeBignum = 3,
0036 Decimal = 4,
0037 Bigfloat = 5,
0038 COSE_Encrypt0 = 16,
0039 COSE_Mac0 = 17,
0040 COSE_Sign1 = 18,
0041 ExpectedBase64url = 21,
0042 ExpectedBase64 = 22,
0043 ExpectedBase16 = 23,
0044 EncodedCbor = 24,
0045 Url = 32,
0046 Base64url = 33,
0047 Base64 = 34,
0048 RegularExpression = 35,
0049 MimeMessage = 36,
0050 Uuid = 37,
0051 COSE_Encrypt = 96,
0052 COSE_Mac = 97,
0053 COSE_Sign = 98,
0054 Signature = 55799
0055 };
0056
0057 inline bool operator==(QCborTag t, QCborKnownTags kt) { return quint64(t) == quint64(kt); }
0058 inline bool operator==(QCborKnownTags kt, QCborTag t) { return quint64(t) == quint64(kt); }
0059 inline bool operator!=(QCborTag t, QCborKnownTags kt) { return quint64(t) != quint64(kt); }
0060 inline bool operator!=(QCborKnownTags kt, QCborTag t) { return quint64(t) != quint64(kt); }
0061
0062 struct Q_CORE_EXPORT QCborError
0063 {
0064 Q_GADGET
0065 public:
0066 enum Code : int {
0067 UnknownError = 1,
0068 AdvancePastEnd = 3,
0069 InputOutputError = 4,
0070 GarbageAtEnd = 256,
0071 EndOfFile,
0072 UnexpectedBreak,
0073 UnknownType,
0074 IllegalType,
0075 IllegalNumber,
0076 IllegalSimpleType,
0077
0078 InvalidUtf8String = 516,
0079
0080 DataTooLarge = 1024,
0081 NestingTooDeep,
0082 UnsupportedType,
0083
0084 NoError = 0
0085 };
0086 Q_ENUM(Code)
0087
0088 Code c;
0089 operator Code() const { return c; }
0090 QString toString() const;
0091 };
0092
0093 #if !defined(QT_NO_DEBUG_STREAM)
0094 Q_CORE_EXPORT QDebug operator<<(QDebug, QCborSimpleType st);
0095 Q_CORE_EXPORT QDebug operator<<(QDebug, QCborKnownTags tg);
0096 Q_CORE_EXPORT QDebug operator<<(QDebug, QCborTag tg);
0097 #endif
0098
0099 #if !defined(QT_NO_DATASTREAM)
0100 Q_CORE_EXPORT QDataStream &operator<<(QDataStream &ds, QCborSimpleType st);
0101 Q_CORE_EXPORT QDataStream &operator>>(QDataStream &ds, QCborSimpleType &st);
0102 #endif
0103
0104 inline size_t qHash(QCborSimpleType tag, size_t seed = 0)
0105 {
0106 return qHash(quint8(tag), seed);
0107 }
0108
0109 inline size_t qHash(QCborTag tag, size_t seed = 0)
0110 {
0111 return qHash(quint64(tag), seed);
0112 }
0113
0114 enum class QCborNegativeInteger : quint64 {};
0115
0116 QT_END_NAMESPACE
0117
0118 QT_DECL_METATYPE_EXTERN(QCborTag, Q_CORE_EXPORT)
0119
0120
0121
0122 #if defined(QT_X11_DEFINES_FOUND)
0123 # define True 1
0124 # define False 0
0125 #endif
0126
0127 #endif