BDE 4.39.x Production Release
Loading...
Searching...
No Matches
bdlar_nullablevaluevtableutil.h
Go to the documentation of this file.
1/// @file bdlar_nullablevaluevtableutil.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// bdlar_nullablevaluevtableutil.h -*-C++-*-
8#ifndef INCLUDED_BDLAR_NULLABLEVALUEVTABLEUTIL
9#define INCLUDED_BDLAR_NULLABLEVALUEVTABLEUTIL
10
11#include <bsls_ident.h>
12BSLS_IDENT("$Id: $")
13
14/// @defgroup bdlar_nullablevaluevtableutil bdlar_nullablevaluevtableutil
15/// @brief Provide ...
16/// @addtogroup bdl
17/// @{
18/// @addtogroup bdlar
19/// @{
20/// @addtogroup bdlar_nullablevaluevtableutil
21/// @{
22///
23/// <h1> Outline </h1>
24/// * <a href="#bdlar_nullablevaluevtableutil-purpose"> Purpose</a>
25/// * <a href="#bdlar_nullablevaluevtableutil-classes"> Classes </a>
26/// * <a href="#bdlar_nullablevaluevtableutil-description"> Description </a>
27///
28/// # Purpose {#bdlar_nullablevaluevtableutil-purpose}
29/// Provide ...
30///
31/// # Classes {#bdlar_nullablevaluevtableutil-classes}
32///
33/// - bdlar::NullableValueVtableUtil: ...
34///
35/// # Description {#bdlar_nullablevaluevtableutil-description}
36/// This component provides ...
37///
38/// @}
39/** @} */
40/** @} */
41
42/** @addtogroup bdl
43 * @{
44 */
45/** @addtogroup bdlar
46 * @{
47 */
48/** @addtogroup bdlar_nullablevaluevtableutil
49 * @{
50 */
51
52#include <bdlar_nullablevaluevtable.h>
53#include <bdlar_typecategory.h>
54
56#include <bdlat_typename.h>
58
59
60namespace bdlar {
61
62 // =============================
63 // class NullableValueVtableUtil
64 // =============================
65
67 // PRIVATE CLASS METHODS
68
69 /// Invoke the specified `accessor` on non-null value of the specified
70 /// `object`. Return the value from the invocation of `accessor`.
71 ///
72 /// \pre The behavior is undefined if the referred object is null.
73 template <class t_NULLABLE>
74 static int accessValue(const void *object, AccessorRef& accessor);
75
76 /// Return `true` if the specified "nullable" `object` contains a null
77 /// value, and `false` otherwise.
78 template <class t_NULLABLE>
79 static bool isNull(const void *object);
80
81 /// Assign to the specified "nullable" `object` the default value for the
82 /// contained type.
83 template <class t_NULLABLE>
84 static void makeValue(void *object);
85
86 /// Invoke the specified `manipulator` on non-null value of the specified
87 /// `object`. Return the value from the invocation of `manipulator`.
88 ///
89 /// \pre The behavior is undefined if the referred object is null.
90 template <class t_NULLABLE>
91 static int manipulateValue(void *object, ManipulatorRef& manipulator);
92
93 /// Reset the object pointed by the specified `object` to the default
94 /// value.
95 template <class t_NULLABLE>
96 static void reset(void *object);
97
98 /// Return the value type category of the specified `t_NULLABLE` type.
99 template <class t_NULLABLE>
100 static bdlat_TypeCategory::Value valueCategory();
101
102 /// Return the `bdlat_TypeName::xsdName` value for `object`.
103 template <class t_NULLABLE>
104 static const char *xsdName(const void *object, int format);
105
106 public:
107 // TYPES
110
111 // CLASS METHODS
112
113 /// Construct and return a `NullableValueConstVtable` object with a series
114 /// of function pointers that implement the "nullable value" type category.
115 template <class t_NULLABLE>
117
118 /// Construct and return a `NullableValueVtable` object with a series of
119 /// function pointers that implement the "nullable value" type category.
120 template <class t_NULLABLE>
121 static const NullableValueVtable *getVtable();
122};
123
124// ============================================================================
125// INLINE DEFINITIONS
126// ============================================================================
127
128 // -----------------------------
129 // class NullableValueVtableUtil
130 // -----------------------------
131
132// PRIVATE CLASS METHODS
133template <class t_NULLABLE>
134int NullableValueVtableUtil::accessValue(const void *object,
135 AccessorRef& accessor)
136{
138 *static_cast<const t_NULLABLE *>(object),
139 accessor);
140}
141
142template <class t_NULLABLE>
143bool NullableValueVtableUtil::isNull(const void *object)
144{
146 *static_cast<const t_NULLABLE *>(object));
147}
148
149template <class t_NULLABLE>
150void NullableValueVtableUtil::makeValue(void *object)
151{
152 bdlat_NullableValueFunctions::makeValue(static_cast<t_NULLABLE *>(object));
153}
154
155template <class t_NULLABLE>
156int NullableValueVtableUtil::manipulateValue(void *object,
157 ManipulatorRef& manipulator)
158{
160 static_cast<t_NULLABLE *>(object),
161 manipulator);
162}
163
164template <class t_NULLABLE>
165void NullableValueVtableUtil::reset(void *object)
166{
167 bdlat_ValueTypeFunctions::reset(static_cast<t_NULLABLE *>(object));
168}
169
170template <class t_NULLABLE>
171bdlat_TypeCategory::Value NullableValueVtableUtil::valueCategory()
172{
173 typedef typename bdlat_NullableValueFunctions::
174 ValueType<t_NULLABLE>::Type ValueType;
176}
177
178template <class t_NULLABLE>
179const char *NullableValueVtableUtil::xsdName(const void *object, int format)
180{
181 return bdlat_TypeName::xsdName(*static_cast<const t_NULLABLE *>(object),
182 format);
183}
184
185// CLASS METHODS
186template <class t_NULLABLE>
188{
189 static const NullableValueConstVtable vtable = {
190 &valueCategory<t_NULLABLE>,
191 &accessValue<t_NULLABLE>,
192 &isNull<t_NULLABLE>,
193 &xsdName<t_NULLABLE>
194 };
195 return &vtable;
196}
197
198template <class t_NULLABLE>
200{
201 static const NullableValueVtable vtable = {
202 {
203 &valueCategory<t_NULLABLE>,
204 &accessValue<t_NULLABLE>,
205 &isNull<t_NULLABLE>,
206 &xsdName<t_NULLABLE>
207 },
208 &manipulateValue<t_NULLABLE>,
209 &makeValue<t_NULLABLE>,
210 &reset<t_NULLABLE>
211 };
212 return &vtable;
213}
214
215} // close package namespace
216
217
218#endif
219
220// ----------------------------------------------------------------------------
221// Copyright 2024 Bloomberg Finance L.P.
222//
223// Licensed under the Apache License, Version 2.0 (the "License");
224// you may not use this file except in compliance with the License.
225// You may obtain a copy of the License at
226//
227// http://www.apache.org/licenses/LICENSE-2.0
228//
229// Unless required by applicable law or agreed to in writing, software
230// distributed under the License is distributed on an "AS IS" BASIS,
231// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
232// See the License for the specific language governing permissions and
233// limitations under the License.
234// ----------------------------- END-OF-FILE ----------------------------------
235
236/** @} */
237/** @} */
238/** @} */
Definition bdlar_accessorref.h:65
Definition bdlar_manipulatorref.h:65
Definition bdlar_nullablevaluevtableutil.h:66
static const NullableValueVtable * getVtable()
Definition bdlar_nullablevaluevtableutil.h:199
NullableValueConstVtable ConstVtableType
Definition bdlar_nullablevaluevtableutil.h:109
static const NullableValueConstVtable * getConstVtable()
Definition bdlar_nullablevaluevtableutil.h:187
NullableValueVtable VtableType
Definition bdlar_nullablevaluevtableutil.h:108
static const char * xsdName(const TYPE &object, int format)
Definition bdlat_typename.h:1047
#define BSLS_IDENT(str)
BSLS_IDENT() - insert string into .comment binary segment (if supported)
Definition bsls_ident.h:238
Definition bdlar_accessorref.h:59
bool isNull(const TYPE &object)
int manipulateValue(TYPE *object, MANIPULATOR &manipulator)
int accessValue(const TYPE &object, ACCESSOR &accessor)
void makeValue(TYPE *object)
void reset(TYPE *object)
Reset the value of the specified object to its default value.
Definition bdlar_nullablevaluevtable.h:71
Definition bdlar_nullablevaluevtable.h:94
static const BSLS_KEYWORD_CONSTEXPR bdlat_TypeCategory::Value e_SELECTION
Definition bdlar_typecategory.h:156
Value
Definition bdlat_typecategory.h:1046