BDE 4.39.x Production Release
Loading...
Searching...
No Matches
bdlar_sequencevtableutil.h
Go to the documentation of this file.
1/// @file bdlar_sequencevtableutil.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// bdlar_sequencevtableutil.h -*-C++-*-
8#ifndef INCLUDED_BDLAR_SEQUENCEVTABLEUTIL
9#define INCLUDED_BDLAR_SEQUENCEVTABLEUTIL
10
11#include <bsls_ident.h>
12BSLS_IDENT("$Id: $")
13
14/// @defgroup bdlar_sequencevtableutil bdlar_sequencevtableutil
15/// @brief Provide ...
16/// @addtogroup bdl
17/// @{
18/// @addtogroup bdlar
19/// @{
20/// @addtogroup bdlar_sequencevtableutil
21/// @{
22///
23/// <h1> Outline </h1>
24/// * <a href="#bdlar_sequencevtableutil-purpose"> Purpose</a>
25/// * <a href="#bdlar_sequencevtableutil-classes"> Classes </a>
26/// * <a href="#bdlar_sequencevtableutil-description"> Description </a>
27///
28/// # Purpose {#bdlar_sequencevtableutil-purpose}
29/// Provide ...
30///
31/// # Classes {#bdlar_sequencevtableutil-classes}
32///
33/// - bdlar::SequenceVtableUtil: ...
34///
35/// # Description {#bdlar_sequencevtableutil-description}
36/// This component provides ...
37///
38/// @}
39/** @} */
40/** @} */
41
42/** @addtogroup bdl
43 * @{
44 */
45/** @addtogroup bdlar
46 * @{
47 */
48/** @addtogroup bdlar_sequencevtableutil
49 * @{
50 */
51
52#include <bdlar_sequencevtable.h>
53
55#include <bdlat_typename.h>
57
58
59namespace bdlar {
60
61 // ========================
62 // class SequenceVtableUtil
63 // ========================
64
66 // PRIVATE CLASS METHODS
67
68 /// Invoke the specified `accessor` on the (non-modifiable) attribute of
69 /// the referred sequence object with the given `attributeId`, supplying
70 /// `accessor` with the corresponding attribute information structure.
71 /// Return non-zero if the attribute is not found, and the value returned
72 /// from the invocation of `accessor` otherwise.
73 template <class t_SEQUENCE>
74 static int accessAttribute(const void *object,
75 AccessorWithInfoRef& accessor,
76 int attributeId);
77
78 /// Invoke the specified `accessor` on the (non-modifiable) attribute of
79 /// the referred sequence object indicated by the specified `attributeName`
80 /// and `attributeNameLength`, supplying `accessor` with the corresponding
81 /// attribute information structure. Return non-zero value if the
82 /// attribute is not found, and the value returned from the invocation of
83 /// `accessor` otherwise.
84 template <class t_SEQUENCE>
85 static int accessAttribute(const void *object,
86 AccessorWithInfoRef& accessor,
87 const char *attributeName,
88 int attributeNameLength);
89
90 /// Invoke the specified `accessor` sequentially on each attribute,
91 /// supplying `accessor` with the corresponding attribute information
92 /// structure until such invocation returns a non-zero value. Return the
93 /// value from the last invocation of `accessor` (i.e., the invocation that
94 /// terminated the sequence).
95 template <class t_SEQUENCE>
96 static int accessAttributes(const void *object,
97 AccessorWithInfoRef& accessor);
98
99 /// Return `true` if the specified `object` has an attribute with the
100 /// specified `attributeId`, and `false` otherwise.
101 template <class t_SEQUENCE>
102 static bool hasAttributeId(const void *object, int attributeId);
103
104 /// Return `true` if the specified `object` has an attribute with the
105 /// specified `attributeName` of the specified `attributeNameLength`,
106 /// and `false` otherwise.
107 template <class t_SEQUENCE>
108 static bool hasAttributeName(const void *object,
109 const char *attributeName,
110 int attributeNameLength);
111
112 /// Invoke the specified `manipulator` on the (modifiable) attribute
113 /// indicated by the specified `attributeId`, supplying `manipulator` with
114 /// the corresponding attribute information structure. Return non-zero
115 /// value if the attribute is not found, and the value returned from the
116 /// invocation of `manipulator` otherwise.
117 template <class t_SEQUENCE>
118 static int manipulateAttribute(void *object,
119 ManipulatorWithInfoRef& manipulator,
120 int attributeId);
121
122 /// Invoke the specified `manipulator` on the (modifiable) attribute
123 /// indicated by the specified `attributeName` and `attributeNameLength`,
124 /// supplying `manipulator` with the corresponding attribute information
125 /// structure. Return non-zero value if the attribute is not found, and
126 /// the value returned from the invocation of `manipulator` otherwise.
127 template <class t_SEQUENCE>
128 static int manipulateAttribute(
129 void *object,
130 ManipulatorWithInfoRef& manipulator,
131 const char *attributeName,
132 int attributeNameLength);
133
134 /// Invoke the specified `manipulator` sequentially on each (modifiable)
135 /// attribute, supplying `manipulator` with the corresponding attribute
136 /// information structure until such invocation returns non-zero value.
137 /// Return the value from the last invocation of `manipulator` (i.e., the
138 /// invocation that terminated the sequence).
139 template <class t_SEQUENCE>
140 static int manipulateAttributes(void *object,
141 ManipulatorWithInfoRef& manipulator);
142
143 /// Reset the object pointed by the specified `object` to the default
144 /// value.
145 template <class t_SEQUENCE>
146 static void reset(void *object);
147
148 /// Return the `bdlat_TypeName::xsdName` value for `object`.
149 template <class t_SEQUENCE>
150 static const char *xsdName(const void *object, int format);
151
152 public:
153 // TYPES
156
157 // CLASS METHODS
158
159 /// Construct and return a `SequenceConstVtable` object with a series of
160 /// function pointers that implement the "sequence" type category.
161 template <class t_SEQUENCE>
162 static const SequenceConstVtable *getConstVtable();
163
164 /// Construct and return a `SequenceVtable` object with a series of
165 /// function pointers that implement the "sequence" type category.
166 template <class t_SEQUENCE>
167 static const SequenceVtable *getVtable();
168};
169
170// ============================================================================
171// INLINE DEFINITIONS
172// ============================================================================
173
174 // ------------------------
175 // class SequenceVtableUtil
176 // ------------------------
177
178// PRIVATE CLASS METHODS
179template <class t_SEQUENCE>
180int SequenceVtableUtil::accessAttribute(const void *object,
181 AccessorWithInfoRef& accessor,
182 int attributeId)
183{
185 *static_cast<const t_SEQUENCE *>(object),
186 accessor,
187 attributeId);
188}
189
190template <class t_SEQUENCE>
191int SequenceVtableUtil::accessAttribute(
192 const void *object,
193 AccessorWithInfoRef& accessor,
194 const char *attributeName,
195 int attributeNameLength)
196{
198 *static_cast<const t_SEQUENCE *>(object),
199 accessor,
200 attributeName,
201 attributeNameLength);
202}
203
204template <class t_SEQUENCE>
205int SequenceVtableUtil::accessAttributes(const void *object,
206 AccessorWithInfoRef& accessor)
207{
209 *static_cast<const t_SEQUENCE *>(object),
210 accessor);
211}
212
213template <class t_SEQUENCE>
214bool SequenceVtableUtil::hasAttributeId(const void *object, int attributeId)
215{
217 *static_cast<const t_SEQUENCE *>(object),
218 attributeId);
219}
220
221template <class t_SEQUENCE>
222bool SequenceVtableUtil::hasAttributeName(const void *object,
223 const char *attributeName,
224 int attributeNameLength)
225{
227 *static_cast<const t_SEQUENCE *>(object),
228 attributeName,
229 attributeNameLength);
230}
231
232template <class t_SEQUENCE>
233int SequenceVtableUtil::manipulateAttribute(
234 void *object,
235 ManipulatorWithInfoRef& manipulator,
236 int attributeId)
237{
239 static_cast<t_SEQUENCE *>(object),
240 manipulator,
241 attributeId);
242}
243
244template <class t_SEQUENCE>
245int SequenceVtableUtil::manipulateAttribute(
246 void *object,
247 ManipulatorWithInfoRef& manipulator,
248 const char *attributeName,
249 int attributeNameLength)
250{
252 static_cast<t_SEQUENCE *>(object),
253 manipulator,
254 attributeName,
255 attributeNameLength);
256}
257
258template <class t_SEQUENCE>
259int SequenceVtableUtil::manipulateAttributes(
260 void *object,
261 ManipulatorWithInfoRef& manipulator)
262{
264 static_cast<t_SEQUENCE *>(object),
265 manipulator);
266}
267
268template <class t_SEQUENCE>
269void SequenceVtableUtil::reset(void *object)
270{
271 bdlat_ValueTypeFunctions::reset(static_cast<t_SEQUENCE *>(object));
272}
273
274template <class t_SEQUENCE>
275const char *SequenceVtableUtil::xsdName(const void *object, int format)
276{
277 return bdlat_TypeName::xsdName(*static_cast<const t_SEQUENCE *>(object),
278 format);
279}
280
281// CLASS METHODS
282template <class t_SEQUENCE>
284{
285 static const SequenceConstVtable vtable = {
286 &hasAttributeName<t_SEQUENCE>,
287 &hasAttributeId<t_SEQUENCE>,
288 &accessAttribute<t_SEQUENCE>,
289 &accessAttribute<t_SEQUENCE>,
290 &accessAttributes<t_SEQUENCE>,
291 &xsdName<t_SEQUENCE>
292 };
293 return &vtable;
294}
295
296template <class t_SEQUENCE>
298{
299 static const SequenceVtable vtable = {
300 {
301 &hasAttributeName<t_SEQUENCE>,
302 &hasAttributeId<t_SEQUENCE>,
303 &accessAttribute<t_SEQUENCE>,
304 &accessAttribute<t_SEQUENCE>,
305 &accessAttributes<t_SEQUENCE>,
306 &xsdName<t_SEQUENCE>
307 },
308 &manipulateAttribute<t_SEQUENCE>,
309 &manipulateAttribute<t_SEQUENCE>,
310 &manipulateAttributes<t_SEQUENCE>,
311 &reset<t_SEQUENCE>
312 };
313 return &vtable;
314}
315
316} // close package namespace
317
318
319#endif
320
321// ----------------------------------------------------------------------------
322// Copyright 2024 Bloomberg Finance L.P.
323//
324// Licensed under the Apache License, Version 2.0 (the "License");
325// you may not use this file except in compliance with the License.
326// You may obtain a copy of the License at
327//
328// http://www.apache.org/licenses/LICENSE-2.0
329//
330// Unless required by applicable law or agreed to in writing, software
331// distributed under the License is distributed on an "AS IS" BASIS,
332// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
333// See the License for the specific language governing permissions and
334// limitations under the License.
335// ----------------------------- END-OF-FILE ----------------------------------
336
337/** @} */
338/** @} */
339/** @} */
Definition bdlar_accessorref.h:109
Definition bdlar_manipulatorref.h:109
Definition bdlar_sequencevtableutil.h:65
static const SequenceVtable * getVtable()
Definition bdlar_sequencevtableutil.h:297
SequenceConstVtable ConstVtableType
Definition bdlar_sequencevtableutil.h:155
static const SequenceConstVtable * getConstVtable()
Definition bdlar_sequencevtableutil.h:283
SequenceVtable VtableType
Definition bdlar_sequencevtableutil.h:154
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
int accessAttribute(const TYPE &object, ACCESSOR &accessor, const char *attributeName, int attributeNameLength)
int accessAttributes(const TYPE &object, ACCESSOR &accessor)
int manipulateAttribute(TYPE *object, MANIPULATOR &manipulator, const char *attributeName, int attributeNameLength)
int manipulateAttributes(TYPE *object, MANIPULATOR &manipulator)
bool hasAttribute(const TYPE &object, const char *attributeName, int attributeNameLength)
void reset(TYPE *object)
Reset the value of the specified object to its default value.
Definition bdlar_sequencevtable.h:69
Definition bdlar_sequencevtable.h:105