LMDBAL 0.6.0
LMDB (Lightning Memory-Mapped Database Manager) Abstraction Layer
Loading...
Searching...
No Matches
serializer.h
1/*
2 * LMDB Abstraction Layer.
3 * Copyright (C) 2023 Yury Gubich <blue@macaw.me>
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#pragma once
20
21
22#include <cstring>
23
24#include <QByteArray>
25#include <QBuffer>
26#include <QDataStream>
27
28#include <lmdb.h>
29
30namespace LMDBAL {
31
32template<class T>
34public:
35 Serializer();
36 Serializer(const T& value);
38
39 T deserialize(const MDB_val& value);
40 void deserialize(const MDB_val& value, T& result);
41 MDB_val setData(const T& value);
42 MDB_val getData();
43 void clear();
44
45private:
46 void _setData(const T& value);
47
48
49private:
50 QByteArray bytes;
51 QBuffer buffer;
52 QDataStream stream;
53};
54
55}
56
57#include "serializer.hpp"
58#include "serializer_uint64.hpp"
59#include "serializer_uint32.hpp"
60#include "serializer_uint16.hpp"
61#include "serializer_uint8.hpp"
62#include "serializer_int64.hpp"
63#include "serializer_int32.hpp"
64#include "serializer_int16.hpp"
65#include "serializer_int8.hpp"
66#include "serializer_float.hpp"
67#include "serializer_double.hpp"
68#include "serializer_stdstring.hpp"
69#include "serializer_qstring.hpp"
70#include "serializer_qbytearray.hpp"
A class handling serialization/deserialization.
Definition serializer.h:33
~Serializer()
Destoys the serializer.
Definition serializer.hpp:69
Serializer()
Creates an empty Serializer.
Definition serializer.hpp:40
MDB_val getData()
Returns the data if it already was serialized.
Definition serializer.hpp:153
T deserialize(const MDB_val &value)
Deserializes value.
Definition serializer.hpp:99
void clear()
Clears the state of serializer.
Definition serializer.hpp:137
MDB_val setData(const T &value)
Sets the data to the seriazer.
Definition serializer.hpp:83