cpp-msgpack-light
0.3.0
A light library to serialize MessagePack.
Toggle main menu visibility
Loading...
Searching...
No Matches
serialize.h
Go to the documentation of this file.
1
/*
2
* Copyright 2024 MusicScience37 (Kenta Kabashima)
3
*
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
7
*
8
* http://www.apache.org/licenses/LICENSE-2.0
9
*
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
15
*/
20
#pragma once
21
22
#include "
msgpack_light/binary.h
"
23
#include "
msgpack_light/memory_output_stream.h
"
24
#include "
msgpack_light/output_stream.h
"
25
#include "
msgpack_light/serialization_buffer.h
"
26
#include "
msgpack_light/type_support/common.h
"
// IWYU pragma: export
27
28
namespace
msgpack_light
{
29
37
template
<
typename
T>
38
inline
void
serialize_to
(
output_stream
& stream,
const
T& data) {
39
serialization_buffer
buffer(stream);
40
buffer.
serialize
(data);
41
buffer.
flush
();
42
}
43
51
template
<
typename
T>
52
[[nodiscard]]
inline
binary
serialize
(
const
T& data) {
53
memory_output_stream
stream;
54
serialize_to
(stream, data);
55
return
stream.
as_binary
();
56
}
57
58
}
// namespace msgpack_light
binary.h
Definition of binary class.
msgpack_light::binary
Class of binary data.
Definition
binary.h:129
msgpack_light::memory_output_stream
Class of streams to write data to memory.
Definition
memory_output_stream.h:33
msgpack_light::memory_output_stream::as_binary
const binary & as_binary() const
Get the data as msgpack_light::binary instance.
Definition
memory_output_stream.h:76
msgpack_light::output_stream
Interface of streams to write data.
Definition
output_stream.h:32
msgpack_light::serialization_buffer
Class of buffers to serialize data.
Definition
serialization_buffer.h:41
msgpack_light::serialization_buffer::serialize
void serialize(const T &data)
Serialize data.
Definition
serialization_buffer.h:758
msgpack_light::serialization_buffer::flush
void flush()
Flush the internal buffer in this instance.
Definition
serialization_buffer.h:75
common.h
Header to include headers to support common data types.
memory_output_stream.h
Definition of memory_output_stream class.
msgpack_light
Namespace of this project.
Definition
binary.h:33
msgpack_light::serialize_to
void serialize_to(output_stream &stream, const T &data)
Serialize data in memory and return the resulting binary data.
Definition
serialize.h:38
msgpack_light::serialize
binary serialize(const T &data)
Serialize data to an output stream.
Definition
serialize.h:52
output_stream.h
Definition of output_stream class.
serialization_buffer.h
Definition of serialization_buffer class.
include
msgpack_light
serialize.h
Generated on
for cpp-msgpack-light by
1.18.0