summaryrefslogtreecommitdiffstats
path: root/src/core5/serialization/qbinaryjsonobject_p.h
blob: 1877bbed8e7ba63119fd7b3cbc479beac69e14a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// Copyright (C) 2019 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only

#ifndef QBINARYJSONOBJECT_H
#define QBINARYJSONOBJECT_H

//
//  W A R N I N G
//  -------------
//
// This file is not part of the Qt API.  It exists purely as an
// implementation detail.  This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//

#include "qbinaryjsonvalue_p.h"

QT_BEGIN_NAMESPACE

class QBinaryJsonObject
{
    Q_DISABLE_COPY(QBinaryJsonObject)
public:
    QBinaryJsonObject() = default;
    ~QBinaryJsonObject();

    QBinaryJsonObject(QBinaryJsonObject &&other) noexcept
        : d(other.d), o(other.o)
    {
        other.d = nullptr;
        other.o = nullptr;
    }

    QBinaryJsonObject &operator =(QBinaryJsonObject &&other) noexcept
    {
        qSwap(d, other.d);
        qSwap(o, other.o);
        return *this;
    }

    static QBinaryJsonObject fromJsonObject(const QJsonObject &object);
    char *takeRawData(uint *size) const;

private:
    friend class QBinaryJsonValue;

    void insert(const QString &key, const QBinaryJsonValue &value);
    bool detach(uint reserve = 0);
    void compact();

    QBinaryJsonPrivate::MutableData *d = nullptr;
    QBinaryJsonPrivate::Object *o = nullptr;
};

QT_END_NAMESPACE

#endif // QBINARYJSONOBJECT_P_H