BDE 4.39.x Production Release
Loading...
Searching...
No Matches
bdlar_refutil.h
Go to the documentation of this file.
1/// @file bdlar_refutil.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// bdlar_refutil.h -*-C++-*-
8#ifndef INCLUDED_BDLAR_REFUTIL
9#define INCLUDED_BDLAR_REFUTIL
10
11#include <bsls_ident.h>
12BSLS_IDENT("$Id: $")
13
14/// @defgroup bdlar_refutil bdlar_refutil
15/// @brief Provide ...
16/// @addtogroup bdl
17/// @{
18/// @addtogroup bdlar
19/// @{
20/// @addtogroup bdlar_refutil
21/// @{
22///
23/// <h1> Outline </h1>
24/// * <a href="#bdlar_refutil-purpose"> Purpose</a>
25/// * <a href="#bdlar_refutil-classes"> Classes </a>
26/// * <a href="#bdlar_refutil-description"> Description </a>
27///
28/// # Purpose {#bdlar_refutil-purpose}
29/// Provide ...
30///
31/// # Classes {#bdlar_refutil-classes}
32///
33/// - bdlar::RefUtil: ...
34///
35/// # Description {#bdlar_refutil-description}
36/// This component provides ...
37///
38/// @}
39/** @} */
40/** @} */
41
42/** @addtogroup bdl
43 * @{
44 */
45/** @addtogroup bdlar
46 * @{
47 */
48/** @addtogroup bdlar_refutil
49 * @{
50 */
51
52#include <bdlar_anyref.h>
53#include <bdlar_arrayref.h>
54#include <bdlar_choiceref.h>
58#include <bdlar_enumref.h>
60#include <bdlar_sequenceref.h>
61#include <bdlar_simpletyperef.h>
62
63#include <bdlar_anycastutil.h>
64#include <bdlar_anymanipulators.h> // not used here, included for bdlar users
65
66#include <bdlar_typecategory.h>
67
71#include <bdlat_enumfunctions.h>
74
75#include <bsls_assert.h>
76
77#include <bsl_type_traits.h>
78
79
80namespace bdlar {
81
82 // =============
83 // class RefUtil
84 // =============
85
86class RefUtil {
87 public:
88 // CLASS METHODS
89
90 /// Make `AnyConstRef` to the specified `object`.
91 template <class t_TYPE>
93 makeAnyConstRef(const t_TYPE& object);
94
95 /// Make `AnyConstRef` to the specified dynamic `object`.
96 template <class t_TYPE>
98 makeAnyConstRef(const t_TYPE& object);
99
100 /// Make `AnyRef` to the specified `object`.
101 template <class t_TYPE>
103 makeAnyRef(t_TYPE& object);
104
105 /// Make `AnyRef` to the specified dynamic `object`.
106 template <class t_TYPE>
107 static typename bsl::enable_if<IsDynamic<t_TYPE>::value, AnyRef>::type
108 makeAnyRef(t_TYPE& object);
109
110 /// Make `ArrayRef` to the specified "array" `object`.
111 template <class t_TYPE>
113 ArrayRef>::type wrap(t_TYPE& object);
114
115 /// Make `ArrayConstRef` to the specified "array" `object`.
116 template <class t_TYPE>
118 ArrayConstRef>::type wrap(const t_TYPE& object);
119
120 /// Make `ChoiceRef` to the specified "choice" `object`.
121 template <class t_TYPE>
123 ChoiceRef>::type wrap(t_TYPE& object);
124
125 /// Make `ChoiceConstRef` to the specified "choice" `object`.
126 template <class t_TYPE>
128 ChoiceConstRef>::type wrap(const t_TYPE& object);
129
130 /// Make `CustomizedTypeRef` to the specified "customized type" `object`.
131 template <class t_TYPE>
133 CustomizedTypeRef>::type wrap(t_TYPE& object);
134
135 /// Make `CustomizedTypeConstRef` to the specified "customized type"
136 /// `object`.
137 template <class t_TYPE>
139 CustomizedTypeConstRef>::type wrap(const t_TYPE& object);
140
141 /// Make `EnumRef` to the specified "enumeration" `object`.
142 template <class t_TYPE>
144 EnumRef>::type wrap(t_TYPE& object);
145
146 /// Make `EnumConstRef` to the specified "enumeration" `object`.
147 template <class t_TYPE>
149 EnumConstRef>::type wrap(const t_TYPE& object);
150
151 /// Make `NullableValueRef` to the specified "nullable value" `object`.
152 template <class t_TYPE>
154 NullableValueRef>::type wrap(t_TYPE& object);
155
156 /// Make `NullableValueConstRef` to the specified "nullable value"
157 /// `object`.
158 template <class t_TYPE>
160 NullableValueConstRef>::type wrap(const t_TYPE& object);
161
162 /// Make `SequenceRef` to the specified "sequence" `object`.
163 template <class t_TYPE>
165 SequenceRef>::type wrap(t_TYPE& object);
166
167 /// Make `SequenceConstRef` to the specified "sequence" `object`.
168 template <class t_TYPE>
170 SequenceConstRef>::type wrap(const t_TYPE& object);
171
172 /// Make `SimpleTypeRef` to the specified "simple" `object`.
173 template <class t_TYPE>
175 SimpleTypeRef>::type wrap(t_TYPE& object);
176
177 /// Make `SimpleTypeConstRef` to the specified "simple" `object`.
178 template <class t_TYPE>
180 SimpleTypeConstRef>::type wrap(const t_TYPE& object);
181};
182
183// ============================================================================
184// INLINE DEFINITIONS
185// ============================================================================
186
187 // -------------
188 // class RefUtil
189 // -------------
190
191template <class t_TYPE>
192inline
194RefUtil::makeAnyConstRef(const t_TYPE& object)
195{
196 return AnyCastUtil::toAnyConstRef(wrap(object));
197}
198
199template <class t_TYPE>
201RefUtil::makeAnyConstRef(const t_TYPE& object)
202{
204}
205
206template <class t_TYPE>
207inline
208typename bsl::enable_if<!IsDynamic<t_TYPE>::value, AnyRef>::type
209RefUtil::makeAnyRef(t_TYPE& object)
210{
211 return AnyCastUtil::toAnyRef(wrap(object));
212}
213
214template <class t_TYPE>
216RefUtil::makeAnyRef(t_TYPE& object)
217{
219}
220
221template <class t_TYPE>
222inline
224ArrayRef>::type RefUtil::wrap(t_TYPE& object)
225{
226 return ArrayRef(object);
227}
228
229template <class t_TYPE>
230inline
232ArrayConstRef>::type RefUtil::wrap(const t_TYPE& object)
233{
234 return ArrayConstRef(object);
235}
236
237template <class t_TYPE>
238inline
240ChoiceRef>::type RefUtil::wrap(t_TYPE& object)
241{
242 return ChoiceRef(object);
243}
244
245template <class t_TYPE>
246inline
248ChoiceConstRef>::type RefUtil::wrap(const t_TYPE& object)
249{
250 return ChoiceConstRef(object);
251}
252
253template <class t_TYPE>
254inline
256CustomizedTypeRef>::type RefUtil::wrap(t_TYPE& object)
257{
258 return CustomizedTypeRef(object);
259}
260
261template <class t_TYPE>
262inline
264CustomizedTypeConstRef>::type RefUtil::wrap(const t_TYPE& object)
265{
266 return CustomizedTypeConstRef(object);
267}
268
269template <class t_TYPE>
270inline
272EnumRef>::type RefUtil::wrap(t_TYPE& object)
273{
274 return EnumRef(object);
275}
276
277template <class t_TYPE>
278inline
280EnumConstRef>::type RefUtil::wrap(const t_TYPE& object)
281{
282 return EnumConstRef(object);
283}
284
285template <class t_TYPE>
286inline
288NullableValueRef>::type RefUtil::wrap(t_TYPE& object)
289{
290 return NullableValueRef(object);
291}
292
293template <class t_TYPE>
294inline
296NullableValueConstRef>::type RefUtil::wrap(const t_TYPE& object)
297{
298 return NullableValueConstRef(object);
299}
300
301template <class t_TYPE>
302inline
304SequenceRef>::type RefUtil::wrap(t_TYPE& object)
305{
306 return SequenceRef(object);
307}
308
309template <class t_TYPE>
310inline
312SequenceConstRef>::type RefUtil::wrap(const t_TYPE& object)
313{
314 return SequenceConstRef(object);
315}
316
317template <class t_TYPE>
318inline
320SimpleTypeRef>::type RefUtil::wrap(t_TYPE& object)
321{
322 return SimpleTypeRef(object);
323}
324
325template <class t_TYPE>
326inline
328SimpleTypeConstRef>::type RefUtil::wrap(const t_TYPE& object)
329{
330 return SimpleTypeConstRef(object);
331}
332
333} // close package namespace
334
335
336#endif
337
338// ----------------------------------------------------------------------------
339// Copyright 2024 Bloomberg Finance L.P.
340//
341// Licensed under the Apache License, Version 2.0 (the "License");
342// you may not use this file except in compliance with the License.
343// You may obtain a copy of the License at
344//
345// http://www.apache.org/licenses/LICENSE-2.0
346//
347// Unless required by applicable law or agreed to in writing, software
348// distributed under the License is distributed on an "AS IS" BASIS,
349// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
350// See the License for the specific language governing permissions and
351// limitations under the License.
352// ----------------------------- END-OF-FILE ----------------------------------
353
354/** @} */
355/** @} */
356/** @} */
Definition bdlar_anyref.h:247
Definition bdlar_anyref.h:85
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_refutil.h:86
static bsl::enable_if< IsDynamic< t_TYPE >::value, AnyConstRef >::type makeAnyConstRef(const t_TYPE &object)
Make AnyConstRef to the specified dynamic object.
static bsl::enable_if< IsSequence< t_TYPE >::value, SequenceConstRef >::type wrap(const t_TYPE &object)
Make SequenceConstRef to the specified "sequence" object.
static bsl::enable_if< IsCustomized< t_TYPE >::value, CustomizedTypeConstRef >::type wrap(const t_TYPE &object)
static bsl::enable_if< IsNullable< t_TYPE >::value, NullableValueConstRef >::type wrap(const t_TYPE &object)
static bsl::enable_if< IsCustomized< t_TYPE >::value, CustomizedTypeRef >::type wrap(t_TYPE &object)
Make CustomizedTypeRef to the specified "customized type" object.
static bsl::enable_if<!IsDynamic< t_TYPE >::value, AnyConstRef >::type makeAnyConstRef(const t_TYPE &object)
Make AnyConstRef to the specified object.
Definition bdlar_refutil.h:194
static bsl::enable_if< IsDynamic< t_TYPE >::value, AnyRef >::type makeAnyRef(t_TYPE &object)
Make AnyRef to the specified dynamic object.
static bsl::enable_if< IsEnum< t_TYPE >::value, EnumRef >::type wrap(t_TYPE &object)
Make EnumRef to the specified "enumeration" object.
static bsl::enable_if< IsEnum< t_TYPE >::value, EnumConstRef >::type wrap(const t_TYPE &object)
Make EnumConstRef to the specified "enumeration" object.
static bsl::enable_if< IsSimple< t_TYPE >::value, SimpleTypeRef >::type wrap(t_TYPE &object)
Make SimpleTypeRef to the specified "simple" object.
static bsl::enable_if< IsChoice< t_TYPE >::value, ChoiceRef >::type wrap(t_TYPE &object)
Make ChoiceRef to the specified "choice" object.
static bsl::enable_if< IsSimple< t_TYPE >::value, SimpleTypeConstRef >::type wrap(const t_TYPE &object)
Make SimpleTypeConstRef to the specified "simple" object.
static bsl::enable_if< IsChoice< t_TYPE >::value, ChoiceConstRef >::type wrap(const t_TYPE &object)
Make ChoiceConstRef to the specified "choice" object.
static bsl::enable_if< IsSequence< t_TYPE >::value, SequenceRef >::type wrap(t_TYPE &object)
Make SequenceRef to the specified "sequence" object.
static bsl::enable_if<!IsDynamic< t_TYPE >::value, AnyRef >::type makeAnyRef(t_TYPE &object)
Make AnyRef to the specified object.
Definition bdlar_refutil.h:209
static bsl::enable_if< IsNullable< t_TYPE >::value, NullableValueRef >::type wrap(t_TYPE &object)
Make NullableValueRef to the specified "nullable value" object.
static bsl::enable_if< IsArray< t_TYPE >::value, ArrayRef >::type wrap(t_TYPE &object)
Make ArrayRef to the specified "array" object.
Definition bdlar_refutil.h:224
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
static AnyConstRef toAnyConstRef(const ArrayConstRef &ref)
Cast the specified ref to AnyConstRef.
Definition bdlar_anycastutil.h:202
static AnyRef toAnyRef(const ArrayRef &ref)
Cast the specified ref to AnyRef.
Definition bdlar_anycastutil.h:250
Definition bslmf_enableif.h:530