1 | /* |
2 | This file is part of the KDE Baloo project. |
3 | SPDX-FileCopyrightText: 2015 Vishesh Handa <vhanda@kde.org> |
4 | |
5 | SPDX-License-Identifier: LGPL-2.1-or-later |
6 | */ |
7 | |
8 | #include "postingcodec.h" |
9 | |
10 | using namespace Baloo; |
11 | |
12 | QByteArray PostingCodec::encode(const QVector<quint64>& list) |
13 | { |
14 | uint size = list.size() * sizeof(quint64); |
15 | const char* ptr = reinterpret_cast<const char*>(list.constData()); |
16 | |
17 | return QByteArray(ptr, size); |
18 | } |
19 | |
20 | QVector<quint64> PostingCodec::decode(const QByteArray& arr) |
21 | { |
22 | QVector<quint64> vec; |
23 | vec.resize(size: arr.size() / sizeof(quint64)); |
24 | |
25 | memcpy(dest: vec.data(), src: arr.constData(), n: arr.size()); |
26 | return vec; |
27 | } |
28 | |