cpp-msgpack-light
0.3.0
A light library to serialize MessagePack.
Toggle main menu visibility
Loading...
Searching...
No Matches
pack_in_big_endian.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/details/mutable_static_binary_view.h
"
23
#include "
msgpack_light/details/to_big_endian.h
"
24
#include "
msgpack_light/details/total_size_of.h
"
// IWYU pragma: keep
25
26
namespace
msgpack_light::details
{
27
37
template
<
typename
T,
typename
... Remaining>
38
void
pack_in_big_endian
(
39
mutable_static_binary_view
<
total_size_of<T, Remaining...>
> buffer, T value,
40
Remaining... remaining_values)
noexcept
{
41
if
constexpr
(
sizeof
(T) == 1U) {
42
buffer[0] =
static_cast<
unsigned
char
>
(value);
43
}
else
{
44
if
constexpr
(
sizeof
...(Remaining) == 0U) {
45
to_big_endian
(&value, buffer);
46
}
else
{
47
to_big_endian
(&value, buffer.template sub_buffer<0U,
sizeof
(T)>());
48
}
49
}
50
if
constexpr
(
sizeof
...(Remaining) > 0U) {
51
pack_in_big_endian
(
52
buffer.template sub_buffer<
sizeof
(T)>(), remaining_values...);
53
}
54
}
55
56
}
// namespace msgpack_light::details
msgpack_light::details::mutable_static_binary_view
Class of views of mutable buffers with static sizes.
Definition
mutable_static_binary_view.h:32
mutable_static_binary_view.h
Definition of mutable_static_binary_view class.
msgpack_light::details
Namespace of internal implementations.
Definition
binary.h:35
msgpack_light::details::pack_in_big_endian
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.
Definition
pack_in_big_endian.h:38
msgpack_light::details::total_size_of
constexpr std::size_t total_size_of
Get the total size of types in template arguments.
Definition
total_size_of.h:64
msgpack_light::details::to_big_endian
void to_big_endian(const void *from, mutable_static_binary_view< N > to) noexcept
Convert to big endian.
to_big_endian.h
Definition of to_big_endian function.
total_size_of.h
Definition of total_size_of variable.
include
msgpack_light
details
pack_in_big_endian.h
Generated on
for cpp-msgpack-light by
1.18.0