forked from KDE/okteta
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbytearraychange.hpp
79 lines (59 loc) · 2.21 KB
/
bytearraychange.hpp
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/*
This file is part of the Okteta Core library, made within the KDE community.
SPDX-FileCopyrightText: 2008 Friedrich W. H. Kossebau <[email protected]>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#ifndef OKTETA_BYTEARRAYCHANGE_HPP
#define OKTETA_BYTEARRAYCHANGE_HPP
// lib
#include "oktetacore_export.hpp"
#include "arraychangemetrics.hpp"
// Qt
#include <QByteArray>
namespace Okteta {
// TODO: do we need the invalid status?
// TODO: what about grouped changes
// TODO: use change names from original? Only if local are not available
class OKTETACORE_EXPORT ByteArrayChange
{
friend QDataStream& operator<<(QDataStream& outStream, const ByteArrayChange& change);
friend QDataStream& operator>>(QDataStream& inStream, ByteArrayChange& change);
public:
ByteArrayChange();
explicit ByteArrayChange(const ArrayChangeMetrics& metrics, const QByteArray& data = QByteArray());
ByteArrayChange(const ByteArrayChange&) = default;
~ByteArrayChange() = default;
ByteArrayChange& operator=(const ByteArrayChange&) = default;
public:
[[nodiscard]]
const ArrayChangeMetrics& metrics() const;
[[nodiscard]]
const QByteArray& data() const;
private:
ArrayChangeMetrics mMetrics;
QByteArray mData;
// UserId mUserId;
// mTime;
};
inline ByteArrayChange::ByteArrayChange() = default;
inline ByteArrayChange::ByteArrayChange(const ArrayChangeMetrics& metrics, const QByteArray& data)
: mMetrics(metrics)
, mData(data)
{}
inline const ArrayChangeMetrics& ByteArrayChange::metrics() const { return mMetrics; }
inline const QByteArray& ByteArrayChange::data() const { return mData; }
QDataStream& operator<<(QDataStream& outStream, const ByteArrayChange& change);
QDataStream& operator>>(QDataStream& inStream, ByteArrayChange& change);
inline QDataStream& operator<<(QDataStream& outStream, const ByteArrayChange& change)
{
outStream << change.mMetrics << change.mData;
return outStream;
}
inline QDataStream& operator>>(QDataStream& inStream, ByteArrayChange& change)
{
inStream >> change.mMetrics >> change.mData;
return inStream;
}
}
Q_DECLARE_TYPEINFO(Okteta::ByteArrayChange, Q_MOVABLE_TYPE);
#endif