LMDBAL 0.6.2
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
30#include "qdatastreamsupport.h"
31
32namespace LMDBAL {
33
34template<class T>
36public:
37 Serializer();
38 Serializer(const T& value);
40
41 T deserialize(const MDB_val& value);
42 void deserialize(const MDB_val& value, T& result);
43 MDB_val setData(const T& value);
44 MDB_val getData();
45 void clear();
46 void setStreamVersion(QDataStream::Version version);
47
48private:
49 void _setData(const T& value);
50
51
52private:
53 QByteArray bytes;
54 QBuffer buffer;
55 QDataStream stream;
56};
57
58}
59
60#include "serializer.hpp"
61#include "serializer_uint64.hpp"
62#include "serializer_uint32.hpp"
63#include "serializer_uint16.hpp"
64#include "serializer_uint8.hpp"
65#include "serializer_int64.hpp"
66#include "serializer_int32.hpp"
67#include "serializer_int16.hpp"
68#include "serializer_int8.hpp"
69#include "serializer_float.hpp"
70#include "serializer_double.hpp"
71#include "serializer_stdstring.hpp"
72#include "serializer_qstring.hpp"
73#include "serializer_qbytearray.hpp"
Serializer()
Creates an empty Serializer.
Definition serializer.hpp:45
MDB_val getData()
Returns the data if it already was serialized.
Definition serializer.hpp:185
T deserialize(const MDB_val &value)
Deserializes value.
Definition serializer.hpp:108
void setStreamVersion(QDataStream::Version version)
Sets QDataStream version for serialization.
Definition serializer.hpp:160
void clear()
Clears the state of serializer.
Definition serializer.hpp:170
MDB_val setData(const T &value)
Sets the data to the serializer.
Definition serializer.hpp:92
Destroys a cache.
Definition base.h:36