cpp-msgpack-light
0.3.0
A light library to serialize MessagePack.
Toggle main menu visibility
Loading...
Searching...
No Matches
object_ref.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/allocator_wrapper.h
"
23
#include "
msgpack_light/details/object_base.h
"
24
#include "
msgpack_light/details/object_data.h
"
25
#include "
msgpack_light/details/object_ref_decl.h
"
// IWYU pragma: keep
26
27
namespace
msgpack_light
{
28
45
template
<
typename
Allocator>
46
class
mutable_object_ref
47
:
public
details::mutable_object_base
<mutable_object_ref<Allocator>,
48
Allocator> {
49
public
:
51
using
base_type
=
52
details::mutable_object_base<mutable_object_ref<Allocator>
, Allocator>;
53
54
using
typename
base_type::allocator_type
;
55
60
67
mutable_object_ref
(
details::object_data
&
data
,
68
details::allocator_wrapper<Allocator>
&
allocator
)
69
:
data_
(&
data
),
allocator_
(&
allocator
) {}
70
72
79
85
[[nodiscard]]
details::object_data
&
data
() noexcept {
return
*
data_
; }
86
92
[[nodiscard]]
const
details::object_data
&
data
() const noexcept {
93
return
*
data_
;
94
}
95
101
[[nodiscard]]
details::allocator_wrapper<Allocator>
&
allocator
() noexcept {
102
return
*
allocator_
;
103
}
104
106
107
private
:
109
details::object_data
*
data_
;
110
112
details::allocator_wrapper<Allocator>
*
allocator_
;
113
};
114
129
class
const_object_ref
:
public
details::const_object_base
<const_object_ref> {
130
public
:
132
using
base_type
=
details::const_object_base<const_object_ref>
;
133
138
144
explicit
const_object_ref
(
const
details::object_data
&
data
)
145
:
data_
(&
data
) {}
146
148
155
161
[[nodiscard]]
const
details::object_data
&
data
() const noexcept {
162
return
*
data_
;
163
}
164
166
167
private
:
169
const
details::object_data
*
data_
;
170
};
171
172
}
// namespace msgpack_light
allocator_wrapper.h
Definition of allocator_wrapper class.
msgpack_light::const_object_ref::data
const details::object_data & data() const noexcept
Get the internal data.
Definition
object_ref.h:161
msgpack_light::const_object_ref::const_object_ref
const_object_ref(const details::object_data &data)
Constructor.
Definition
object_ref.h:144
msgpack_light::const_object_ref::base_type
details::const_object_base< const_object_ref > base_type
Type of the base class.
Definition
object_ref.h:132
msgpack_light::const_object_ref::data_
const details::object_data * data_
Data.
Definition
object_ref.h:169
msgpack_light::details::allocator_wrapper
Class to wrap allocators.
Definition
allocator_wrapper.h:35
msgpack_light::details::const_object_base
Base class of constant objects in MessagePack.
Definition
object_base.h:48
msgpack_light::details::mutable_object_base
Base class of non-constant objects in MessagePack.
Definition
object_base.h:230
msgpack_light::details::mutable_object_base< mutable_object_ref< Allocator >, Allocator >::allocator_type
Allocator allocator_type
Definition
object_base.h:233
msgpack_light::mutable_object_ref::allocator_
details::allocator_wrapper< Allocator > * allocator_
Allocator.
Definition
object_ref.h:112
msgpack_light::mutable_object_ref::data
details::object_data & data() noexcept
Get the internal data.
Definition
object_ref.h:85
msgpack_light::mutable_object_ref::data
const details::object_data & data() const noexcept
Get the internal data.
Definition
object_ref.h:92
msgpack_light::mutable_object_ref::base_type
details::mutable_object_base< mutable_object_ref< Allocator >, Allocator > base_type
Type of the base class.
Definition
object_ref.h:51
msgpack_light::mutable_object_ref::allocator
details::allocator_wrapper< Allocator > & allocator() noexcept
Get the allocator.
Definition
object_ref.h:101
msgpack_light::mutable_object_ref::data_
details::object_data * data_
Data.
Definition
object_ref.h:109
msgpack_light::mutable_object_ref::mutable_object_ref
mutable_object_ref(details::object_data &data, details::allocator_wrapper< Allocator > &allocator)
Constructor.
Definition
object_ref.h:67
msgpack_light
Namespace of this project.
Definition
binary.h:33
object_base.h
Definition of base classes of objects.
object_data.h
Definition of object_data struct.
object_ref_decl.h
Declaration of classes of references to objects.
msgpack_light::details::object_data
Struct of data of objects in MessagePack.
Definition
object_data.h:94
include
msgpack_light
details
object_ref.h
Generated on
for cpp-msgpack-light by
1.18.0