BDE 4.39.x Production Release
Loading...
Searching...
No Matches
bdlar_manipulatorvtableutil.h
Go to the documentation of this file.
1/// @file bdlar_manipulatorvtableutil.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// bdlar_manipulatorvtableutil.h -*-C++-*-
8#ifndef INCLUDED_BDLAR_MANIPULATORVTABLEUTIL
9#define INCLUDED_BDLAR_MANIPULATORVTABLEUTIL
10
11#include <bsls_ident.h>
12BSLS_IDENT("$Id: $")
13
14/// @defgroup bdlar_manipulatorvtableutil bdlar_manipulatorvtableutil
15/// @brief Provide ...
16/// @addtogroup bdl
17/// @{
18/// @addtogroup bdlar
19/// @{
20/// @addtogroup bdlar_manipulatorvtableutil
21/// @{
22///
23/// <h1> Outline </h1>
24/// * <a href="#bdlar_manipulatorvtableutil-purpose"> Purpose</a>
25/// * <a href="#bdlar_manipulatorvtableutil-classes"> Classes </a>
26/// * <a href="#bdlar_manipulatorvtableutil-description"> Description </a>
27///
28/// # Purpose {#bdlar_manipulatorvtableutil-purpose}
29/// Provide ...
30///
31/// # Classes {#bdlar_manipulatorvtableutil-classes}
32///
33/// - bdlar::ManipulatorVtableUtil: ...
34///
35/// # Description {#bdlar_manipulatorvtableutil-description}
36/// This component provides ...
37///
38/// @}
39/** @} */
40/** @} */
41
42/** @addtogroup bdl
43 * @{
44 */
45/** @addtogroup bdlar
46 * @{
47 */
48/** @addtogroup bdlar_manipulatorvtableutil
49 * @{
50 */
51
52#include <bdlar_manipulatorvtable.h>
53#include <bdlar_simpletyperef.h>
54
55
56namespace bdlar {
57
58 // ===========================
59 // class ManipulatorVtableUtil
60 // ===========================
61
63 // PRIVATE CLASS METHODS
64
65 /// Invoke the specified manipulator on the specified `ref`.
66 template <class t_MANIPULATOR, class t_REF>
67 static int manipulate(const void *manipulatorPtr, t_REF *ref);
68
69 /// Invoke the specified manipulator on the specified simple type `ref`.
70 template <class t_MANIPULATOR>
71 static int manipulateSimple(const void *manipulatorPtr,
72 SimpleTypeRef *ref);
73
74 /// Invoke the specified manipulator on the specified simple type `ref`
75 /// with the specified `info`.
76 template <class t_MANIPULATOR>
77 static int manipulateSimpleWithInfo(const void *manipulatorPtr,
78 SimpleTypeRef *ref,
79 const FieldInfoRef& info);
80
81 /// Invoke the specified manipulator on the specified `ref` with the
82 /// specified `info`.
83 template <class t_MANIPULATOR, class t_REF>
84 static int manipulateWithInfo(const void *manipulatorPtr,
85 t_REF *ref,
86 const FieldInfoRef& info);
87
88 public:
89 // CLASS METHODS
90
91 /// Construct and return a `ManipulatorVtable` object with a series of
92 /// function pointers that implement the manipulators.
93 template <class t_MANIPULATOR>
94 static const ManipulatorVtable *getVtable();
95
96 /// Construct and return a `ManipulatorWithInfoVtable` object with a series
97 /// of function pointers that implement the manipulators.
98 template <class t_MANIPULATOR>
100};
101
102// ============================================================================
103// INLINE DEFINITIONS
104// ============================================================================
105
106 // ---------------------------
107 // class ManipulatorVtableUtil
108 // ---------------------------
109
110// PRIVATE CLASS METHODS
111template <class t_MANIPULATOR, class t_REF>
112int ManipulatorVtableUtil::manipulate(const void *manipulatorPtr, t_REF *ref)
113{
114 t_MANIPULATOR& manipulator = *reinterpret_cast<t_MANIPULATOR *>(
115 const_cast<void *>(manipulatorPtr));
116 return manipulator(ref);
117}
118
119template <class t_MANIPULATOR>
120int ManipulatorVtableUtil::manipulateSimple(const void *manipulatorPtr,
121 SimpleTypeRef *ref)
122{
123 return ref->manipulate(*reinterpret_cast<t_MANIPULATOR *>(
124 const_cast<void *>(manipulatorPtr)));
125}
126
127template <class t_MANIPULATOR>
128int ManipulatorVtableUtil::manipulateSimpleWithInfo(
129 const void *manipulatorPtr,
130 SimpleTypeRef *ref,
131 const FieldInfoRef& info)
132{
133 return ref->manipulate(*reinterpret_cast<t_MANIPULATOR *>(
134 const_cast<void *>(manipulatorPtr)),
135 info);
136}
137
138template <class t_MANIPULATOR, class t_REF>
139int ManipulatorVtableUtil::manipulateWithInfo(
140 const void *manipulatorPtr,
141 t_REF *ref,
142 const FieldInfoRef& info)
143{
144 t_MANIPULATOR& manipulator = *reinterpret_cast<t_MANIPULATOR *>(
145 const_cast<void *>(manipulatorPtr));
146 return manipulator(ref, info);
147}
148
149// CLASS METHODS
150template <class t_MANIPULATOR>
152{
153 static const ManipulatorVtable vtable = {
154 &manipulate<t_MANIPULATOR, DynamicTypeRef>,
155 &manipulate<t_MANIPULATOR, ArrayRef>,
156 &manipulate<t_MANIPULATOR, ChoiceRef>,
157 &manipulate<t_MANIPULATOR, CustomizedTypeRef>,
158 &manipulate<t_MANIPULATOR, EnumRef>,
159 &manipulate<t_MANIPULATOR, NullableValueRef>,
160 &manipulate<t_MANIPULATOR, SequenceRef>,
161 &manipulateSimple<t_MANIPULATOR>
162 };
163 return &vtable;
164}
165
166template <class t_MANIPULATOR>
168{
169 static const ManipulatorWithInfoVtable vtable = {
170 &manipulateWithInfo<t_MANIPULATOR, DynamicTypeRef>,
171 &manipulateWithInfo<t_MANIPULATOR, ArrayRef>,
172 &manipulateWithInfo<t_MANIPULATOR, ChoiceRef>,
173 &manipulateWithInfo<t_MANIPULATOR, CustomizedTypeRef>,
174 &manipulateWithInfo<t_MANIPULATOR, EnumRef>,
175 &manipulateWithInfo<t_MANIPULATOR, NullableValueRef>,
176 &manipulateWithInfo<t_MANIPULATOR, SequenceRef>,
177 &manipulateSimpleWithInfo<t_MANIPULATOR>
178 };
179 return &vtable;
180}
181
182} // close package namespace
183
184
185#endif
186
187// ----------------------------------------------------------------------------
188// Copyright 2024 Bloomberg Finance L.P.
189//
190// Licensed under the Apache License, Version 2.0 (the "License");
191// you may not use this file except in compliance with the License.
192// You may obtain a copy of the License at
193//
194// http://www.apache.org/licenses/LICENSE-2.0
195//
196// Unless required by applicable law or agreed to in writing, software
197// distributed under the License is distributed on an "AS IS" BASIS,
198// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
199// See the License for the specific language governing permissions and
200// limitations under the License.
201// ----------------------------- END-OF-FILE ----------------------------------
202
203/** @} */
204/** @} */
205/** @} */
Definition bdlar_fieldinfo.h:102
Definition bdlar_manipulatorvtableutil.h:62
static const ManipulatorVtable * getVtable()
Definition bdlar_manipulatorvtableutil.h:151
static const ManipulatorWithInfoVtable * getWithInfoVtable()
Definition bdlar_manipulatorvtableutil.h:167
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
reference_wrapper< T > ref(T &object)
Return a reference wrapper that represents the specified object.
Definition bdlar_manipulatorvtable.h:72
Definition bdlar_manipulatorvtable.h:101