cpp-msgpack-light 0.3.0
A light library to serialize MessagePack.
Loading...
Searching...
No Matches
map_iterator.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 <cstddef>
23#include <utility>
24
29
30namespace msgpack_light {
31
44template <typename Allocator = standard_allocator>
46public:
48 using difference_type = std::ptrdiff_t;
49
51 using value_type =
52 std::pair<mutable_object_ref<Allocator>, mutable_object_ref<Allocator>>;
53
56
60 mutable_map_iterator() noexcept : pointer_(nullptr), allocator_(nullptr) {}
61
71
77 std::pair<mutable_object_ref<Allocator>, mutable_object_ref<Allocator>>
78 operator*() const noexcept;
79
85 mutable_map_iterator& operator++() noexcept {
86 ++pointer_;
87 return *this;
88 }
89
95 const mutable_map_iterator // NOLINT(readability-const-return-type)
96 operator++(int) noexcept {
97 mutable_map_iterator copy{*this};
98 ++(*this);
99 return copy;
100 }
101
102private:
105
108};
109
121public:
123 using difference_type = std::ptrdiff_t;
124
126 using value_type = std::pair<const_object_ref, const_object_ref>;
127
130
134 const_map_iterator() noexcept : pointer_(nullptr) {}
135
142 const details::key_value_pair_data* pointer) noexcept
143 : pointer_(pointer) {}
144
150 std::pair<const_object_ref, const_object_ref> operator*() const noexcept;
151
157 const_map_iterator& operator++() noexcept {
158 ++pointer_;
159 return *this;
160 }
161
167 const const_map_iterator // NOLINT(readability-const-return-type)
168 operator++(int) noexcept {
169 const_map_iterator copy{*this};
170 ++(*this);
171 return copy;
172 }
173
174private:
177};
178
179} // namespace msgpack_light
Definition of allocator_wrapper class.
Class of iterators of maps to access constant objects.
const const_map_iterator operator++(int) noexcept
Increment this iterator.
const_map_iterator() noexcept
Constructor.
std::pair< const_object_ref, const_object_ref > operator*() const noexcept
Dereference this iterator.
value_type reference
Type of references.
const details::key_value_pair_data * pointer_
Pointer to the current data.
std::pair< const_object_ref, const_object_ref > value_type
Type of values.
const_map_iterator(const details::key_value_pair_data *pointer) noexcept
Constructor.
std::ptrdiff_t difference_type
Type of differences.
Class of iterators of maps to access non-constant objects.
value_type reference
Type of references.
std::ptrdiff_t difference_type
Type of differences.
mutable_map_iterator(details::key_value_pair_data *pointer, details::allocator_wrapper< Allocator > *allocator) noexcept
Constructor.
details::allocator_wrapper< Allocator > * allocator_
std::pair< mutable_object_ref< Allocator >, mutable_object_ref< Allocator > > operator*() const noexcept
Dereference this iterator.
mutable_map_iterator() noexcept
Constructor.
std::pair< mutable_object_ref< Allocator >, mutable_object_ref< Allocator > > value_type
Type of values.
const mutable_map_iterator operator++(int) noexcept
Increment this iterator.
Class to access non-constant objects.
Definition object_ref.h:48
Namespace of this project.
Definition binary.h:33
Definition of object_data struct.
Declaration of classes of references to objects.
Definition of standard_allocator class.
Struct of data of key-value pairs in maps.