tetengo 1.8.2
A multipurpose library set
Loading...
Searching...
No Matches
value_serializer.hpp
Go to the documentation of this file.
1
7#if !defined(TETENGO_TRIE_VALUESERIALIZER_HPP)
8#define TETENGO_TRIE_VALUESERIALIZER_HPP
9
10#include <any>
11#include <cstddef>
12#include <functional>
13#include <vector>
14
15
16namespace tetengo::trie
17{
22 {
23 public:
24 // constructors and destructor
25
32 value_serializer(std::function<std::vector<char>(const std::any&)> serialize, std::size_t fixed_value_size);
33
34
35 // functions
36
44 std::vector<char> operator()(const std::any& value) const;
45
52 std::size_t fixed_value_size() const;
53
54
55 private:
56 // variables
57
58 std::function<std::vector<char>(const std::any&)> m_serialize;
59
60 std::size_t m_fixed_value_size;
61 };
62
63
68 {
69 public:
70 // constructors and destructor
71
77 explicit value_deserializer(std::function<std::any(const std::vector<char>&)> deserialize);
78
79
80 // functions
81
89 std::any operator()(const std::vector<char>& serialized) const;
90
91
92 private:
93 // variables
94
95 std::function<std::any(const std::vector<char>&)> m_deserialize;
96 };
97
98
99}
100
101
102#endif
A value deserializer.
Definition value_serializer.hpp:68
value_deserializer(std::function< std::any(const std::vector< char > &)> deserialize)
Creates a value deserializer.
std::any operator()(const std::vector< char > &serialized) const
Deserializes a value.
A value serializer.
Definition value_serializer.hpp:22
std::size_t fixed_value_size() const
Returns the fixed value size.
value_serializer(std::function< std::vector< char >(const std::any &)> serialize, std::size_t fixed_value_size)
Creates a value serializer.
std::vector< char > operator()(const std::any &value) const
Serializes a value.
A trie library.