BDE 4.39.x Production Release
Loading...
Searching...
No Matches
bdlar_anycastutil.h
Go to the documentation of this file.
1/// @file bdlar_anycastutil.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// bdlar_anycastutil.h -*-C++-*-
8#ifndef INCLUDED_BDLAR_ANYCASTUTIL
9#define INCLUDED_BDLAR_ANYCASTUTIL
10
11#include <bsls_ident.h>
12BSLS_IDENT("$Id: $")
13
14/// @defgroup bdlar_anycastutil bdlar_anycastutil
15/// @brief Provide ...
16/// @addtogroup bdl
17/// @{
18/// @addtogroup bdlar
19/// @{
20/// @addtogroup bdlar_anycastutil
21/// @{
22///
23/// <h1> Outline </h1>
24/// * <a href="#bdlar_anycastutil-purpose"> Purpose</a>
25/// * <a href="#bdlar_anycastutil-classes"> Classes </a>
26/// * <a href="#bdlar_anycastutil-description"> Description </a>
27///
28/// # Purpose {#bdlar_anycastutil-purpose}
29/// Provide ...
30///
31/// # Classes {#bdlar_anycastutil-classes}
32///
33/// - bdlar::AnyCastUtil: ...
34///
35/// # Description {#bdlar_anycastutil-description}
36/// This component provides ...
37///
38/// @}
39/** @} */
40/** @} */
41
42/** @addtogroup bdl
43 * @{
44 */
45/** @addtogroup bdlar
46 * @{
47 */
48/** @addtogroup bdlar_anycastutil
49 * @{
50 */
51
52#include <bdlar_anyref.h>
53#include <bdlar_arrayref.h>
54#include <bdlar_choiceref.h>
57#include <bdlar_enumref.h>
59#include <bdlar_sequenceref.h>
60#include <bdlar_simpletyperef.h>
61
62#include <bdlar_accessorref.h>
64
65
66namespace bdlar {
67
68 // ==================
69 // struct AnyCastUtil
70 // ==================
71
73 // CLASS METHODS
74
75 /// Cast the specified `ref` to `AnyConstRef`.
76 static AnyConstRef toAnyConstRef(const ArrayConstRef& ref);
77 static AnyConstRef toAnyConstRef(const ChoiceConstRef& ref);
80 static AnyConstRef toAnyConstRef(const EnumConstRef& ref);
84
85 /// Cast the specified `ref` to `AnyRef`.
86 static AnyRef toAnyRef(const ArrayRef& ref);
87 static AnyRef toAnyRef(const ChoiceRef& ref);
88 static AnyRef toAnyRef(const CustomizedTypeRef& ref);
89 static AnyRef toAnyRef(const DynamicTypeRef& ref);
90 static AnyRef toAnyRef(const EnumRef& ref);
91 static AnyRef toAnyRef(const NullableValueRef& ref);
92 static AnyRef toAnyRef(const SequenceRef& ref);
93 static AnyRef toAnyRef(const SimpleTypeRef& ref);
94
95 /// Cast the specified `any` to `ArrayConstRef`.
96 ///
97 /// \pre The behaviour is undefined unless
98 /// `any.typeCategory() == bdlat_TypeCategory::e_ARRAY_CATEGORY`.
99 static ArrayConstRef toArrayConstRef(const AnyConstRef& any);
100
101 /// Cast the specified `any` to `ArrayRef`.
102 ///
103 /// \pre The behaviour is undefined unless `any.typeCategory() == bdlat_TypeCategory::e_ARRAY_CATEGORY`.
104 static ArrayRef toArrayRef(const AnyRef& any);
105
106 /// Cast the specified `any` to `ChoiceConstRef`.
107 ///
108 /// \pre The behaviour is undefined unless
109 /// `any.typeCategory() == bdlat_TypeCategory::e_CHOICE_CATEGORY`.
111
112 /// Cast the specified `any` to `ChoiceRef`.
113 ///
114 /// \pre The behaviour is undefined unless
115 /// `any.typeCategory() == bdlat_TypeCategory::e_CUSTOMIZED_TYPE_CATEGORY`.
116 static ChoiceRef toChoiceRef(const AnyRef& any);
117
118 /// Cast the specified `any` to `CustomizedTypeConstRef`.
119 ///
120 /// \pre The behaviour is undefined unless
121 /// `any.typeCategory() == bdlat_TypeCategory::e_CUSTOMIZED_TYPE_CATEGORY`.
123 const AnyConstRef& any);
124
125 /// Cast the specified `any` to `CustomizedTypeRef`.
126 ///
127 /// \pre The behaviour is undefined unless
128 /// `any.typeCategory() == bdlat_TypeCategory::e_CHOICE_CATEGORY`.
130
131 /// Cast the specified `any` to `DynamicTypeConstRef`.
132 ///
133 /// \pre The behaviour is undefined unless
134 /// `any.typeCategory() == bdlat_TypeCategory::e_DYNAMIC_CATEGORY`.
136
137 /// Cast the specified `any` to `DynamicTypeRef`.
138 ///
139 /// \pre The behaviour is undefined unless
140 /// `any.typeCategory() == bdlat_TypeCategory::e_DYNAMIC_CATEGORY`.
141 static DynamicTypeRef toDynamicTypeRef(const AnyRef& any);
142
143 /// Cast the specified `any` to `EnumConstRef`.
144 ///
145 /// \pre The behaviour is undefined unless
146 /// `any.typeCategory() == bdlat_TypeCategory::e_ENUMERATION_CATEGORY`.
147 static EnumConstRef toEnumConstRef(const AnyConstRef& any);
148
149 /// Cast the specified `any` to `EnumRef`.
150 ///
151 /// \pre The behaviour is undefined unless
152 /// `any.typeCategory() == bdlat_TypeCategory::e_ENUMERATION_CATEGORY`.
153 static EnumRef toEnumRef(const AnyRef& any);
154
155 /// Cast the specified `any` to `NullableValueConstRef`.
156 ///
157 /// \pre The behaviour is undefined unless
158 /// `any.typeCategory()==bdlat_TypeCategory::e_NULLABLE_VALUE_CATEGORY`.
160 const AnyConstRef& any);
161
162 /// Cast the specified `any` to `NullableValueRef`.
163 ///
164 /// \pre The behaviour is undefined unless
165 /// `any.typeCategory()==bdlat_TypeCategory::e_NULLABLE_VALUE_CATEGORY`.
166 static NullableValueRef toNullableValueRef(const AnyRef& any);
167
168 /// Cast the specified `any` to `SequenceConstRef`.
169 ///
170 /// \pre The behaviour is undefined unless
171 /// `any.typeCategory() == bdlat_TypeCategory::e_SEQUENCE_CATEGORY`.
173
174 /// Cast the specified `any` to `SequenceRef`.
175 ///
176 /// \pre The behaviour is undefined unless
177 /// `any.typeCategory() == bdlat_TypeCategory::e_SEQUENCE_CATEGORY`.
178 static SequenceRef toSequenceRef(const AnyRef& any);
179
180 /// Cast the specified `any` to `SimpleTypeConstRef`.
181 ///
182 /// \pre The behaviour is undefined unless
183 /// `any.typeCategory() == bdlat_TypeCategory::e_SIMPLE_CATEGORY`.
185
186 /// Cast the specified `any` to `SimpleTypeRef`.
187 ///
188 /// \pre The behaviour is undefined unless
189 /// `any.typeCategory() == bdlat_TypeCategory::e_SIMPLE_CATEGORY`.
190 static SimpleTypeRef toSimpleTypeRef(const AnyRef& any);
191};
192
193// ============================================================================
194// INLINE DEFINITIONS
195// ============================================================================
196
197 // ------------------
198 // struct AnyCastUtil
199 // ------------------
200
201inline
203{
204 return AnyConstRef(ref.objectAddress(), ref.vtable());
205}
206
207inline
209{
210 return AnyConstRef(ref.objectAddress(), ref.vtable());
211}
212
213inline
215{
216 return AnyConstRef(ref.objectAddress(), ref.vtable());
217}
218
219inline
221{
222 return AnyConstRef(ref.objectAddress(), ref.vtable());
223}
224
225inline
227{
228 return AnyConstRef(ref.objectAddress(), ref.vtable());
229}
230
231inline
233{
234 return AnyConstRef(ref.objectAddress(), ref.vtable());
235}
236
237inline
239{
240 return AnyConstRef(ref.objectAddress(), ref.vtable());
241}
242
243inline
245{
246 return AnyConstRef(ref.objectAddress(), ref.vtable());
247}
248
249inline
251{
252 return AnyRef(ref.objectAddress(), ref.vtable());
253}
254
255inline
257{
258 return AnyRef(ref.objectAddress(), ref.vtable());
259}
260
261inline
263{
264 return AnyRef(ref.objectAddress(), ref.vtable());
265}
266
267inline
269{
270 return AnyRef(ref.objectAddress(), ref.vtable());
271}
272
273inline
275{
276 return AnyRef(ref.objectAddress(), ref.vtable());
277}
278
279inline
281{
282 return AnyRef(ref.objectAddress(), ref.vtable());
283}
284
285inline
287{
288 return AnyRef(ref.objectAddress(), ref.vtable());
289}
290
291inline
293{
294 return AnyRef(ref.objectAddress(), ref.vtable());
295}
296
297inline
302
303inline
305{
306 return ArrayRef(any.objectAddress(), any.arrayVtable());
307}
308
309inline
314
315inline
317{
318 return ChoiceRef(any.objectAddress(), any.choiceVtable());
319}
320
321inline
328
329inline
334
335inline
340
341inline
346
347inline
352
353inline
355{
356 return EnumRef(any.objectAddress(), any.enumVtable());
357}
358
359inline
366
367inline
372
373inline
378
379inline
384
385inline
390
391inline
396
397} // close package namespace
398
399
400#endif
401
402// ----------------------------------------------------------------------------
403// Copyright 2024 Bloomberg Finance L.P.
404//
405// Licensed under the Apache License, Version 2.0 (the "License");
406// you may not use this file except in compliance with the License.
407// You may obtain a copy of the License at
408//
409// http://www.apache.org/licenses/LICENSE-2.0
410//
411// Unless required by applicable law or agreed to in writing, software
412// distributed under the License is distributed on an "AS IS" BASIS,
413// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
414// See the License for the specific language governing permissions and
415// limitations under the License.
416// ----------------------------- END-OF-FILE ----------------------------------
417
418/** @} */
419/** @} */
420/** @} */
Definition bdlar_anyref.h:247
const EnumConstVtable * enumVtable() const
Definition bdlar_anyref.h:678
const CustomizedTypeConstVtable * customizedTypeVtable() const
Definition bdlar_anyref.h:666
const ChoiceConstVtable * choiceVtable() const
Definition bdlar_anyref.h:660
const void * objectAddress() const
Return a pointer to the wrapped object.
Definition bdlar_anyref.h:702
const SimpleTypeConstVtable * simpleTypeVtable() const
Definition bdlar_anyref.h:696
const DynamicTypeConstVtable * dynamicTypeVtable() const
Definition bdlar_anyref.h:672
const NullableValueConstVtable * nullableValueVtable() const
Definition bdlar_anyref.h:684
const SequenceConstVtable * sequenceVtable() const
Definition bdlar_anyref.h:690
const ArrayConstVtable * arrayVtable() const
Definition bdlar_anyref.h:654
Definition bdlar_anyref.h:85
const NullableValueVtable * nullableValueVtable() const
Definition bdlar_anyref.h:512
void * objectAddress() const
Return a pointer to the wrapped object.
Definition bdlar_anyref.h:530
const SequenceVtable * sequenceVtable() const
Definition bdlar_anyref.h:518
const SimpleTypeVtable * simpleTypeVtable() const
Definition bdlar_anyref.h:524
const ArrayVtable * arrayVtable() const
Definition bdlar_anyref.h:482
const CustomizedTypeVtable * customizedTypeVtable() const
Definition bdlar_anyref.h:494
const ChoiceVtable * choiceVtable() const
Definition bdlar_anyref.h:488
const EnumVtable * enumVtable() const
Definition bdlar_anyref.h:506
const DynamicTypeVtable * dynamicTypeVtable() const
Definition bdlar_anyref.h:500
Definition bdlar_arrayref.h:147
Definition bdlar_arrayref.h:72
Definition bdlar_choiceref.h:160
Definition bdlar_choiceref.h:68
Definition bdlar_customizedtyperef.h:136
Definition bdlar_customizedtyperef.h:73
Definition bdlar_dynamictyperef.h:128
Definition bdlar_dynamictyperef.h:77
Definition bdlar_enumref.h:138
Definition bdlar_enumref.h:68
Definition bdlar_nullablevalueref.h:147
Definition bdlar_nullablevalueref.h:72
Definition bdlar_sequenceref.h:205
Definition bdlar_sequenceref.h:68
Definition bdlar_simpletyperef.h:216
Definition bdlar_simpletyperef.h:68
#define BSLS_IDENT(str)
BSLS_IDENT() - insert string into .comment binary segment (if supported)
Definition bsls_ident.h:238
Definition bdlar_accessorref.h:59
Definition bdlar_anycastutil.h:72
static AnyConstRef toAnyConstRef(const ArrayConstRef &ref)
Cast the specified ref to AnyConstRef.
Definition bdlar_anycastutil.h:202
static ArrayConstRef toArrayConstRef(const AnyConstRef &any)
Definition bdlar_anycastutil.h:298
static SimpleTypeConstRef toSimpleTypeConstRef(const AnyConstRef &any)
Definition bdlar_anycastutil.h:386
static ChoiceConstRef toChoiceConstRef(const AnyConstRef &any)
Definition bdlar_anycastutil.h:310
static DynamicTypeConstRef toDynamicTypeConstRef(const AnyConstRef &any)
Definition bdlar_anycastutil.h:336
static CustomizedTypeConstRef toCustomizedTypeConstRef(const AnyConstRef &any)
Definition bdlar_anycastutil.h:322
static NullableValueRef toNullableValueRef(const AnyRef &any)
Definition bdlar_anycastutil.h:368
static EnumConstRef toEnumConstRef(const AnyConstRef &any)
Definition bdlar_anycastutil.h:348
static SequenceRef toSequenceRef(const AnyRef &any)
Definition bdlar_anycastutil.h:380
static SimpleTypeRef toSimpleTypeRef(const AnyRef &any)
Definition bdlar_anycastutil.h:392
static ChoiceRef toChoiceRef(const AnyRef &any)
Definition bdlar_anycastutil.h:316
static NullableValueConstRef toNullableValueConstRef(const AnyConstRef &any)
Definition bdlar_anycastutil.h:360
static EnumRef toEnumRef(const AnyRef &any)
Definition bdlar_anycastutil.h:354
static DynamicTypeRef toDynamicTypeRef(const AnyRef &any)
Definition bdlar_anycastutil.h:342
static ArrayRef toArrayRef(const AnyRef &any)
Definition bdlar_anycastutil.h:304
static SequenceConstRef toSequenceConstRef(const AnyConstRef &any)
Definition bdlar_anycastutil.h:374
static CustomizedTypeRef toCustomizedTypeRef(const AnyRef &any)
Definition bdlar_anycastutil.h:330
static AnyRef toAnyRef(const ArrayRef &ref)
Cast the specified ref to AnyRef.
Definition bdlar_anycastutil.h:250