cpp-msgpack-light
0.3.0
A light library to serialize MessagePack.
Toggle main menu visibility
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
25
#include "
msgpack_light/details/allocator_wrapper.h
"
26
#include "
msgpack_light/details/object_data.h
"
27
#include "
msgpack_light/details/object_ref_decl.h
"
28
#include "
msgpack_light/standard_allocator.h
"
29
30
namespace
msgpack_light
{
31
44
template
<
typename
Allocator = standard_allocator>
45
class
mutable_map_iterator
{
46
public
:
48
using
difference_type
= std::ptrdiff_t;
49
51
using
value_type
=
52
std::pair<mutable_object_ref<Allocator>,
mutable_object_ref<Allocator>
>;
53
55
using
reference
=
value_type
;
56
60
mutable_map_iterator
() noexcept :
pointer_
(
nullptr
),
allocator_
(
nullptr
) {}
61
68
mutable_map_iterator
(
details::key_value_pair_data
* pointer,
69
details::allocator_wrapper<Allocator>
* allocator) noexcept
70
:
pointer_
(pointer),
allocator_
(allocator) {}
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
102
private
:
104
details::key_value_pair_data
*
pointer_
;
105
107
details::allocator_wrapper<Allocator>
*
allocator_
;
108
};
109
120
class
const_map_iterator
{
121
public
:
123
using
difference_type
= std::ptrdiff_t;
124
126
using
value_type
= std::pair<const_object_ref, const_object_ref>;
127
129
using
reference
=
value_type
;
130
134
const_map_iterator
() noexcept :
pointer_
(
nullptr
) {}
135
141
explicit
const_map_iterator
(
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
174
private
:
176
const
details::key_value_pair_data
*
pointer_
;
177
};
178
179
}
// namespace msgpack_light
allocator_wrapper.h
Definition of allocator_wrapper class.
msgpack_light::const_map_iterator
Class of iterators of maps to access constant objects.
Definition
map_iterator.h:120
msgpack_light::const_map_iterator::operator++
const const_map_iterator operator++(int) noexcept
Increment this iterator.
Definition
map_iterator.h:168
msgpack_light::const_map_iterator::const_map_iterator
const_map_iterator() noexcept
Constructor.
Definition
map_iterator.h:134
msgpack_light::const_map_iterator::operator*
std::pair< const_object_ref, const_object_ref > operator*() const noexcept
Dereference this iterator.
Definition
map_iterator_impl.h:76
msgpack_light::const_map_iterator::reference
value_type reference
Type of references.
Definition
map_iterator.h:129
msgpack_light::const_map_iterator::pointer_
const details::key_value_pair_data * pointer_
Pointer to the current data.
Definition
map_iterator.h:176
msgpack_light::const_map_iterator::value_type
std::pair< const_object_ref, const_object_ref > value_type
Type of values.
Definition
map_iterator.h:126
msgpack_light::const_map_iterator::const_map_iterator
const_map_iterator(const details::key_value_pair_data *pointer) noexcept
Constructor.
Definition
map_iterator.h:141
msgpack_light::const_map_iterator::difference_type
std::ptrdiff_t difference_type
Type of differences.
Definition
map_iterator.h:123
msgpack_light::details::allocator_wrapper
Class to wrap allocators.
Definition
allocator_wrapper.h:35
msgpack_light::mutable_map_iterator
Class of iterators of maps to access non-constant objects.
Definition
map_iterator.h:45
msgpack_light::mutable_map_iterator::reference
value_type reference
Type of references.
Definition
map_iterator.h:55
msgpack_light::mutable_map_iterator::difference_type
std::ptrdiff_t difference_type
Type of differences.
Definition
map_iterator.h:48
msgpack_light::mutable_map_iterator::mutable_map_iterator
mutable_map_iterator(details::key_value_pair_data *pointer, details::allocator_wrapper< Allocator > *allocator) noexcept
Constructor.
Definition
map_iterator.h:68
msgpack_light::mutable_map_iterator< Allocator >::allocator_
details::allocator_wrapper< Allocator > * allocator_
Definition
map_iterator.h:107
msgpack_light::mutable_map_iterator::operator*
std::pair< mutable_object_ref< Allocator >, mutable_object_ref< Allocator > > operator*() const noexcept
Dereference this iterator.
Definition
map_iterator_impl.h:36
msgpack_light::mutable_map_iterator::mutable_map_iterator
mutable_map_iterator() noexcept
Constructor.
Definition
map_iterator.h:60
msgpack_light::mutable_map_iterator< Allocator >::pointer_
details::key_value_pair_data * pointer_
Definition
map_iterator.h:104
msgpack_light::mutable_map_iterator::value_type
std::pair< mutable_object_ref< Allocator >, mutable_object_ref< Allocator > > value_type
Type of values.
Definition
map_iterator.h:51
msgpack_light::mutable_map_iterator::operator++
const mutable_map_iterator operator++(int) noexcept
Increment this iterator.
Definition
map_iterator.h:96
msgpack_light::mutable_object_ref
Class to access non-constant objects.
Definition
object_ref.h:48
msgpack_light
Namespace of this project.
Definition
binary.h:33
object_data.h
Definition of object_data struct.
object_ref_decl.h
Declaration of classes of references to objects.
standard_allocator.h
Definition of standard_allocator class.
msgpack_light::details::key_value_pair_data
Struct of data of key-value pairs in maps.
Definition
object_data.h:135
include
msgpack_light
details
map_iterator.h
Generated on
for cpp-msgpack-light by
1.18.0