cpp-msgpack-light 0.3.0
A light library to serialize MessagePack.
Loading...
Searching...
No Matches
map_ref_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 <cstring>
23
26#include "msgpack_light/details/object_ref.h" // IWYU pragma: keep
27
28namespace msgpack_light {
29
30/*
31 * Definition of some members of mutable_map_ref.
32 */
33
34template <typename Allocator>
36mutable_map_ref<Allocator>::key(std::size_t index) noexcept {
37 return mutable_object_ref_type(data_->data[index].key, *allocator_);
38}
39
40template <typename Allocator>
42mutable_map_ref<Allocator>::key(std::size_t index) const noexcept {
43 return const_object_ref_type{data_->data[index].key};
44}
45
46template <typename Allocator>
48mutable_map_ref<Allocator>::value(std::size_t index) noexcept {
49 return mutable_object_ref_type(data_->data[index].value, *allocator_);
50}
51
52template <typename Allocator>
54mutable_map_ref<Allocator>::value(std::size_t index) const noexcept {
55 return const_object_ref_type{data_->data[index].value};
56}
57
58/*
59 * Definition of some members of const_map_ref.
60 */
61
63 std::size_t index) const noexcept {
64 return const_object_ref_type{data_->data[index].key};
65}
66
68 std::size_t index) const noexcept {
69 return const_object_ref_type{data_->data[index].value};
70}
71
72} // namespace msgpack_light
const_object_ref const_object_ref_type
Type to access constant objects.
Definition map_ref.h:46
const_object_ref_type key(std::size_t index) const noexcept
Get a key.
const_object_ref_type value(std::size_t index) const noexcept
Get a value.
const details::map_data * data_
Data.
Definition map_ref.h:104
mutable_object_ref_type key(std::size_t index) noexcept
Get a key.
const_object_ref const_object_ref_type
Type to access constant objects.
Definition map_ref.h:129
details::allocator_wrapper< Allocator > * allocator_
Allocator.
Definition map_ref.h:228
mutable_object_ref_type value(std::size_t index) noexcept
Get a value.
details::map_data * data_
Data.
Definition map_ref.h:225
mutable_object_ref< Allocator > mutable_object_ref_type
Type to access non-constant objects.
Definition map_ref.h:126
Definition of classes of references to maps.
Namespace of this project.
Definition binary.h:33
Definition of object_data struct.
Definition of classes of references to objects.