GMP 0.4.0
Generative Metaprogramming library for C++
Loading...
Searching...
No Matches
serialization.hpp
Go to the documentation of this file.
1// ___ __ __ ___
2// / __| \/ | _ \ GMP(Generative Metaprogramming)
3// | (_ | |\/| | _/ version 0.4.0
4// \___|_| |_|_| https://github.com/lkimuk/gmp
5//
6// SPDX-FileCopyrightText: 2023-2026 Miles Li <https://www.cppmore.com/>
7// SPDX-License-Identifier: MIT
8//
9// This file is part of the GMP (Generative Metaprogramming) library.
10// Full project source: https://github.com/lkimuk/gmp
11
12#ifndef GMP_SERIALIZATION_SERIALIZATION_HPP_
13#define GMP_SERIALIZATION_SERIALIZATION_HPP_
14
23
24namespace gmp {
25
26template <typename T>
28to_serialization_value(const T &value, serialization_options options = {}) {
29 value_writer writer;
30 basic_serializer archive(writer, options);
31 auto status = archive.encode(value);
32 if (!status) {
33 return status.error();
34 }
35 return writer.finish();
36}
37
38template <typename T>
40 deserialization_options options = {}) {
41 value_reader reader(value);
42 basic_deserializer archive(reader, options);
43 return archive.template decode<T>();
44}
45
46} // namespace gmp
47
48#endif // GMP_SERIALIZATION_SERIALIZATION_HPP_
consteval auto enum_values()
Get all enumerator values of an enumeration type at compile-time.
Definition meta.hpp:193
Definition lock.hpp:21
serialization_result< serialization_value > to_serialization_value(const T &value, serialization_options options={})
serialization_result< T > from_serialization_value(const serialization_value &value, deserialization_options options={})