BDE 4.39.x Production Release
Loading...
Searching...
No Matches
s_baltst_mysequencewithdefault.h
Go to the documentation of this file.
1/// @file s_baltst_mysequencewithdefault.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// s_baltst_mysequencewithdefault.h *DO NOT EDIT* @generated -*-C++-*-
8#ifndef INCLUDED_S_BALTST_MYSEQUENCEWITHDEFAULT
9#define INCLUDED_S_BALTST_MYSEQUENCEWITHDEFAULT
10
11#include <bsls_ident.h>
12BSLS_IDENT_RCSID(s_baltst_mysequencewithdefault_h, "$Id$ $CSID$")
14
15/// @defgroup s_baltst_mysequencewithdefault s_baltst_mysequencewithdefault
16/// @brief Provide value-semantic attribute classes
17/// @addtogroup Standalones
18/// @{
19/// @addtogroup s_baltst
20/// @{
21/// @addtogroup s_baltst_mysequencewithdefault
22/// @{
23///
24/// <h1> Outline </h1>
25/// * <a href="#s_baltst_mysequencewithdefault-purpose"> Purpose</a>
26///
27/// # Purpose {#s_baltst_mysequencewithdefault-purpose}
28/// Provide value-semantic attribute classes
29/// @}
30/** @} */
31/** @} */
32
33/** @addtogroup Standalones
34 * @{
35 */
36/** @addtogroup s_baltst
37 * @{
38 */
39/** @addtogroup s_baltst_mysequencewithdefault
40 * @{
41 */
42
43#include <bslalg_typetraits.h>
44
45#include <bdlat_attributeinfo.h>
46
47#include <bdlat_selectioninfo.h>
48
49#include <bdlat_typetraits.h>
50
51#include <bsls_objectbuffer.h>
52
53#include <bsls_assert.h>
54
55#include <bsl_iosfwd.h>
56#include <bsl_limits.h>
57
58
59
60namespace s_baltst { class MySequenceWithDefault; }
61namespace s_baltst {
62
63 // ===========================
64 // class MySequenceWithDefault
65 // ===========================
66
68
69 // INSTANCE DATA
70 int d_attribute1;
71 int d_attribute2;
72
73 public:
74 // TYPES
75 enum {
78 };
79
80 enum {
82 };
83
84 enum {
87 };
88
89 // CONSTANTS
90 static const char CLASS_NAME[];
91
93
95
96 public:
97 // CLASS METHODS
98
99 /// Return attribute information for the attribute indicated by the
100 /// specified `id` if the attribute exists, and 0 otherwise.
102
103 /// Return attribute information for the attribute indicated by the
104 /// specified `name` of the specified `nameLength` if the attribute
105 /// exists, and 0 otherwise.
107 const char *name,
108 int nameLength);
109
110 // CREATORS
111
112 /// Create an object of type `MySequenceWithDefault` having the default
113 /// value.
115
116
117 // MANIPULATORS
118
119 /// Reset this object to the default value (i.e., its value upon
120 /// default construction).
121 void reset();
122
123 /// Invoke the specified `manipulator` sequentially on the address of
124 /// each (modifiable) attribute of this object, supplying `manipulator`
125 /// with the corresponding attribute information structure until such
126 /// invocation returns a non-zero value. Return the value from the
127 /// last invocation of `manipulator` (i.e., the invocation that
128 /// terminated the sequence).
129 template <typename t_MANIPULATOR>
130 int manipulateAttributes(t_MANIPULATOR& manipulator);
131
132 /// Invoke the specified `manipulator` on the address of
133 /// the (modifiable) attribute indicated by the specified `id`,
134 /// supplying `manipulator` with the corresponding attribute
135 /// information structure. Return the value returned from the
136 /// invocation of `manipulator` if `id` identifies an attribute of this
137 /// class, and -1 otherwise.
138 template <typename t_MANIPULATOR>
139 int manipulateAttribute(t_MANIPULATOR& manipulator, int id);
140
141 /// Invoke the specified `manipulator` on the address of
142 /// the (modifiable) attribute indicated by the specified `name` of the
143 /// specified `nameLength`, supplying `manipulator` with the
144 /// corresponding attribute information structure. Return the value
145 /// returned from the invocation of `manipulator` if `name` identifies
146 /// an attribute of this class, and -1 otherwise.
147 template <typename t_MANIPULATOR>
148 int manipulateAttribute(t_MANIPULATOR& manipulator,
149 const char *name,
150 int nameLength);
151
152 /// Return a reference to the modifiable "Attribute1" attribute of this
153 /// object.
154 int& attribute1();
155
156 /// Return a reference to the modifiable "Attribute2" attribute of this
157 /// object.
158 int& attribute2();
159
160 // ACCESSORS
161
162 /// Format this object to the specified output `stream` at the
163 /// optionally specified indentation `level` and return a reference to
164 /// the modifiable `stream`. If `level` is specified, optionally
165 /// specify `spacesPerLevel`, the number of spaces per indentation level
166 /// for this and all of its nested objects. Each line is indented by
167 /// the absolute value of `level * spacesPerLevel`. If `level` is
168 /// negative, suppress indentation of the first line. If
169 /// `spacesPerLevel` is negative, suppress line breaks and format the
170 /// entire output on one line. If `stream` is initially invalid, this operation has no effect.
171 ///
172 /// \note Note that a trailing newline is provided
173 /// in multiline mode only.
174 bsl::ostream& print(bsl::ostream& stream,
175 int level = 0,
176 int spacesPerLevel = 4) const;
177
178 /// Invoke the specified `accessor` sequentially on each
179 /// (non-modifiable) attribute of this object, supplying `accessor`
180 /// with the corresponding attribute information structure until such
181 /// invocation returns a non-zero value. Return the value from the
182 /// last invocation of `accessor` (i.e., the invocation that terminated
183 /// the sequence).
184 template <typename t_ACCESSOR>
185 int accessAttributes(t_ACCESSOR& accessor) const;
186
187 /// Invoke the specified `accessor` on the (non-modifiable) attribute
188 /// of this object indicated by the specified `id`, supplying `accessor`
189 /// with the corresponding attribute information structure. Return the
190 /// value returned from the invocation of `accessor` if `id` identifies
191 /// an attribute of this class, and -1 otherwise.
192 template <typename t_ACCESSOR>
193 int accessAttribute(t_ACCESSOR& accessor, int id) const;
194
195 /// Invoke the specified `accessor` on the (non-modifiable) attribute
196 /// of this object indicated by the specified `name` of the specified
197 /// `nameLength`, supplying `accessor` with the corresponding attribute
198 /// information structure. Return the value returned from the
199 /// invocation of `accessor` if `name` identifies an attribute of this
200 /// class, and -1 otherwise.
201 template <typename t_ACCESSOR>
202 int accessAttribute(t_ACCESSOR& accessor,
203 const char *name,
204 int nameLength) const;
205
206 /// Return the value of the "Attribute1" attribute of this object.
207 int attribute1() const;
208
209 /// Return the value of the "Attribute2" attribute of this object.
210 int attribute2() const;
211
212 // HIDDEN FRIENDS
213
214 /// Return `true` if the specified `lhs` and `rhs` attribute objects
215 /// have the same value, and `false` otherwise. Two attribute objects
216 /// have the same value if each respective attribute has the same value.
217 friend bool operator==(const MySequenceWithDefault& lhs,
218 const MySequenceWithDefault& rhs)
219 {
220 return lhs.attribute1() == rhs.attribute1() &&
221 lhs.attribute2() == rhs.attribute2();
222 }
223
224 /// Returns `!(lhs == rhs)`
225 friend bool operator!=(const MySequenceWithDefault& lhs,
226 const MySequenceWithDefault& rhs)
227 {
228 return !(lhs == rhs);
229 }
230
231 /// Format the specified `rhs` to the specified output `stream` and
232 /// return a reference to the modifiable `stream`.
233 friend bsl::ostream& operator<<(bsl::ostream& stream,
234 const MySequenceWithDefault& rhs)
235 {
236 return rhs.print(stream, 0, -1);
237 }
238};
239
240} // close package namespace
241
242// TRAITS
243
245template <>
246struct bdlat_UsesDefaultValueFlag<s_baltst::MySequenceWithDefault> : bsl::true_type {};
247
248
249// ============================================================================
250// INLINE DEFINITIONS
251// ============================================================================
252
253namespace s_baltst {
254
255 // ---------------------------
256 // class MySequenceWithDefault
257 // ---------------------------
258
259// CLASS METHODS
260// MANIPULATORS
261template <typename t_MANIPULATOR>
262int MySequenceWithDefault::manipulateAttributes(t_MANIPULATOR& manipulator)
263{
264 int ret;
265
266 ret = manipulator(&d_attribute1, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE1]);
267 if (ret) {
268 return ret;
269 }
270
271 ret = manipulator(&d_attribute2, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE2]);
272 if (ret) {
273 return ret;
274 }
275
276 return 0;
277}
278
279template <typename t_MANIPULATOR>
280int MySequenceWithDefault::manipulateAttribute(t_MANIPULATOR& manipulator, int id)
281{
282 enum { NOT_FOUND = -1 };
283
284 switch (id) {
286 return manipulator(&d_attribute1, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE1]);
287 }
289 return manipulator(&d_attribute2, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE2]);
290 }
291 default:
292 return NOT_FOUND;
293 }
294}
295
296template <typename t_MANIPULATOR>
298 t_MANIPULATOR& manipulator,
299 const char *name,
300 int nameLength)
301{
302 enum { NOT_FOUND = -1 };
303
304 const bdlat_AttributeInfo *attributeInfo =
305 lookupAttributeInfo(name, nameLength);
306 if (0 == attributeInfo) {
307 return NOT_FOUND;
308 }
309
310 return manipulateAttribute(manipulator, attributeInfo->d_id);
311}
312
313inline
315{
316 return d_attribute1;
317}
318
319inline
321{
322 return d_attribute2;
323}
324
325// ACCESSORS
326template <typename t_ACCESSOR>
327int MySequenceWithDefault::accessAttributes(t_ACCESSOR& accessor) const
328{
329 int ret;
330
331 ret = accessor(d_attribute1, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE1]);
332 if (ret) {
333 return ret;
334 }
335
336 ret = accessor(d_attribute2, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE2]);
337 if (ret) {
338 return ret;
339 }
340
341 return 0;
342}
343
344template <typename t_ACCESSOR>
345int MySequenceWithDefault::accessAttribute(t_ACCESSOR& accessor, int id) const
346{
347 enum { NOT_FOUND = -1 };
348
349 switch (id) {
351 return accessor(d_attribute1, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE1]);
352 }
354 return accessor(d_attribute2, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE2]);
355 }
356 default:
357 return NOT_FOUND;
358 }
359}
360
361template <typename t_ACCESSOR>
363 t_ACCESSOR& accessor,
364 const char *name,
365 int nameLength) const
366{
367 enum { NOT_FOUND = -1 };
368
369 const bdlat_AttributeInfo *attributeInfo =
370 lookupAttributeInfo(name, nameLength);
371 if (0 == attributeInfo) {
372 return NOT_FOUND;
373 }
374
375 return accessAttribute(accessor, attributeInfo->d_id);
376}
377
378inline
380{
381 return d_attribute1;
382}
383
384inline
386{
387 return d_attribute2;
388}
389
390} // close package namespace
391
392// FREE FUNCTIONS
393
394
395#endif
396
397// GENERATED BY BLP_BAS_CODEGEN_2025.06.26
398// USING bas_codegen.pl s_baltst_mysequencewithdefault.xsd --mode msg --includedir . --msgComponent mysequencewithdefault --noRecurse --noExternalization --noHashSupport --noAggregateConversion
399// ----------------------------------------------------------------------------
400// NOTICE:
401// Copyright 2025 Bloomberg Finance L.P. All rights reserved.
402// Property of Bloomberg Finance L.P. (BFLP)
403// This software is made available solely pursuant to the
404// terms of a BFLP license agreement which governs its use.
405// ------------------------------- END-OF-FILE --------------------------------
406
407/** @} */
408/** @} */
409/** @} */
Definition s_baltst_mysequencewithdefault.h:67
static const char CLASS_NAME[]
Definition s_baltst_mysequencewithdefault.h:90
static const int DEFAULT_INITIALIZER_ATTRIBUTE2
Definition s_baltst_mysequencewithdefault.h:92
int accessAttribute(t_ACCESSOR &accessor, int id) const
Definition s_baltst_mysequencewithdefault.h:345
int accessAttributes(t_ACCESSOR &accessor) const
Definition s_baltst_mysequencewithdefault.h:327
friend bool operator==(const MySequenceWithDefault &lhs, const MySequenceWithDefault &rhs)
Definition s_baltst_mysequencewithdefault.h:217
int manipulateAttributes(t_MANIPULATOR &manipulator)
Definition s_baltst_mysequencewithdefault.h:262
@ ATTRIBUTE_INDEX_ATTRIBUTE1
Definition s_baltst_mysequencewithdefault.h:85
@ ATTRIBUTE_INDEX_ATTRIBUTE2
Definition s_baltst_mysequencewithdefault.h:86
friend bool operator!=(const MySequenceWithDefault &lhs, const MySequenceWithDefault &rhs)
Returns !(lhs == rhs)
Definition s_baltst_mysequencewithdefault.h:225
friend bsl::ostream & operator<<(bsl::ostream &stream, const MySequenceWithDefault &rhs)
Definition s_baltst_mysequencewithdefault.h:233
static const bdlat_AttributeInfo * lookupAttributeInfo(const char *name, int nameLength)
int & attribute2()
Definition s_baltst_mysequencewithdefault.h:320
@ NUM_ATTRIBUTES
Definition s_baltst_mysequencewithdefault.h:81
bsl::ostream & print(bsl::ostream &stream, int level=0, int spacesPerLevel=4) const
static const bdlat_AttributeInfo * lookupAttributeInfo(int id)
static const bdlat_AttributeInfo ATTRIBUTE_INFO_ARRAY[]
Definition s_baltst_mysequencewithdefault.h:94
@ ATTRIBUTE_ID_ATTRIBUTE1
Definition s_baltst_mysequencewithdefault.h:76
@ ATTRIBUTE_ID_ATTRIBUTE2
Definition s_baltst_mysequencewithdefault.h:77
int manipulateAttribute(t_MANIPULATOR &manipulator, int id)
Definition s_baltst_mysequencewithdefault.h:280
int & attribute1()
Definition s_baltst_mysequencewithdefault.h:314
#define BDLAT_DECL_SEQUENCE_WITH_BITWISEMOVEABLE_TRAITS(ClassName)
Definition bdlat_typetraits.h:294
#define BSLS_IDENT_RCSID(tag, str)
BSLS_IDENT_RCSID() - insert ident str (specific to platform/compiler)
Definition bsls_ident.h:244
#define BSLS_IDENT_PRAGMA_ONCE
BSLS_IDENT_PRAGMA_ONCE - macro to avoid multiple inclusion
Definition bsls_ident.h:263
Definition s_baltst_address.h:66
Definition bdlat_attributeinfo.h:139
int d_id
Definition bdlat_attributeinfo.h:142
Definition bdlat_typetraits.h:146