Cbeam
Loading...
Searching...
No Matches
nested_map.hpp
Go to the documentation of this file.
1/*
2Copyright (c) 2025 acrion innovations GmbH
3Authors: Stefan Zipproth, s.zipproth@acrion.ch
4
5This file is part of Cbeam, see https://github.com/acrion/cbeam and https://cbeam.org
6
7Cbeam is offered under a commercial and under the AGPL license.
8For commercial licensing, contact us at https://acrion.ch/sales. For AGPL licensing, see below.
9
10AGPL licensing:
11
12Cbeam is free software: you can redistribute it and/or modify
13it under the terms of the GNU Affero General Public License as published by
14the Free Software Foundation, either version 3 of the License, or
15(at your option) any later version.
16
17Cbeam is distributed in the hope that it will be useful,
18but WITHOUT ANY WARRANTY; without even the implied warranty of
19MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20GNU Affero General Public License for more details.
21
22You should have received a copy of the GNU Affero General Public License
23along with Cbeam. If not, see <https://www.gnu.org/licenses/>.
24*/
25
26#pragma once
27
29#include <cbeam/serialization/traits.hpp> // for cbeam::serialization::traits, cbeam::serialization::serialized_object
30
31namespace cbeam::container
32{
33 class buffer;
34}
35
37{
44 template <typename Map>
46 {
53 static void serialize(const Map& map, container::buffer& stream)
54 {
55 traits<decltype(map.data)>::serialize(map.data, stream);
56 traits<decltype(map.sub_tables)>::serialize(map.sub_tables, stream);
57 }
58
65 static void deserialize(serialized_object& it, Map& map)
66 {
67 map.clear();
68
69 traits<decltype(map.data)>::deserialize(it, map.data);
70 traits<decltype(map.sub_tables)>::deserialize(it, map.sub_tables);
71 }
72 };
73
82 template <typename Key, typename Value>
95
99 template <typename Key, typename Value>
107}
Manages memory a byte buffer, offering dynamic appending. This class is designed for scenarios where ...
Definition buffer.hpp:50
Offers advanced container types with unique approaches to stability and interprocess sharing....
Definition buffer.hpp:44
Implements traits-based serialization for complex data types, including standard containers and custo...
Definition direct.hpp:38
void * serialized_object
Represents a serialized value in memory.
Definition traits.hpp:42
The root namespace for the Cbeam library. This namespace unifies cross-platform utilities for concurr...
Definition message_manager.hpp:47
A map structure that can store nested maps of keys and values. By including serialization/nested_map....
Definition nested_map.hpp:44
Provides serialization and deserialization logic for nested_map<Key, Value>.
Definition nested_map.hpp:46
static void deserialize(serialized_object &it, Map &map)
Deserializes the content for map.data and map.sub_tables from the buffer, replacing map’s contents.
Definition nested_map.hpp:65
static void serialize(const Map &map, container::buffer &stream)
Serializes a nested map by serializing map.data and map.sub_tables, appending to stream.
Definition nested_map.hpp:53
static void serialize(const cbeam::container::nested_map< Key, Value > &map, container::buffer &stream)
Definition nested_map.hpp:85
static void deserialize(serialized_object &it, cbeam::container::nested_map< Key, Value > &map)
Definition nested_map.hpp:90
static void serialize(const cbeam::container::nested_map< Key, Value > &map, container::buffer &stream)
Definition nested_map.hpp:102
Defines the traits required for serializing and deserializing objects of type T.
Definition traits.hpp:52
static void serialize(const T &val, container::buffer &stream)
Required to serialize an object of type T into a shared_buffer stream.
Definition traits.hpp:63
static void deserialize(serialized_object &it, T &val)
Required to deserialize an object of type T from a serialized memory block, incrementing the iterator...
Definition traits.hpp:77