diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-01-19 12:39:45 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-01-19 12:39:45 +0100 |
commit | d5b28efe4d7fc2a984243417d923ff5727234e94 (patch) | |
tree | 1546145760eb0fa2d8d606e3332e1bab92e63161 /common/bufferutils.h | |
parent | 4922555a38af32fc94e56aeb208b9fda31dab1b2 (diff) | |
download | sink-d5b28efe4d7fc2a984243417d923ff5727234e94.tar.gz sink-d5b28efe4d7fc2a984243417d923ff5727234e94.zip |
Added bufferutils.h
Diffstat (limited to 'common/bufferutils.h')
-rw-r--r-- | common/bufferutils.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/common/bufferutils.h b/common/bufferutils.h new file mode 100644 index 0000000..b0fb75a --- /dev/null +++ b/common/bufferutils.h | |||
@@ -0,0 +1,26 @@ | |||
1 | #pragma once | ||
2 | |||
3 | #include <flatbuffers/flatbuffers.h> | ||
4 | #include <QByteArray> | ||
5 | |||
6 | namespace Akonadi2 { | ||
7 | namespace BufferUtils { | ||
8 | template<typename T> | ||
9 | static QByteArray extractBuffer(const T *data) | ||
10 | { | ||
11 | return QByteArray::fromRawData(reinterpret_cast<char const *>(data->Data()), data->size()); | ||
12 | } | ||
13 | |||
14 | template<typename T> | ||
15 | static QByteArray extractBufferCopy(const T *data) | ||
16 | { | ||
17 | return QByteArray(reinterpret_cast<char const *>(data->Data()), data->size()); | ||
18 | } | ||
19 | |||
20 | static QByteArray extractBuffer(const flatbuffers::FlatBufferBuilder &fbb) | ||
21 | { | ||
22 | return QByteArray::fromRawData(reinterpret_cast<char const *>(fbb.GetBufferPointer()), fbb.GetSize()); | ||
23 | } | ||
24 | } | ||
25 | } | ||
26 | |||