cpp-msgpack-light 0.3.0
A light library to serialize MessagePack.
Loading...
Searching...
No Matches
non_buffered_serialization_buffer_impl.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 <array>
23#include <cstddef> // IWYU pragma: keep
24
27#include "msgpack_light/details/total_size_of.h" // IWYU pragma: keep
29
30namespace msgpack_light::details {
31
37public:
47
56
61
65 void flush() {
66 // No operation.
67 }
68
75 void write(const unsigned char* data, std::size_t size) {
76 stream_.write(data, size);
77 }
78
84 void put(unsigned char data) { write(&data, 1U); }
85
92 template <typename... T>
93 void write_in_big_endian(T... values) {
94 std::array<unsigned char, total_size_of<T...>> buffer{};
97 values...);
98 write(buffer.data(), buffer.size());
99 }
100
101private:
104};
105
106} // namespace msgpack_light::details
Class of views of mutable buffers with static sizes.
Class to implement internal implementation of serialization_buffer class without buffers.
void write(const unsigned char *data, std::size_t size)
Write data.
Interface of streams to write data.
Definition of mutable_static_binary_view class.
Namespace of internal implementations.
Definition binary.h:35
void pack_in_big_endian(mutable_static_binary_view< total_size_of< T, Remaining... > > buffer, T value, Remaining... remaining_values) noexcept
Pack some values in big endian.
constexpr std::size_t total_size_of
Get the total size of types in template arguments.
Definition of output_stream class.
Definition of pack_in_big_endian function.
Definition of total_size_of variable.