BDE 4.39.x Production Release
Loading...
Searching...
No Matches
s_baltst_mysequencewithnullables.h
Go to the documentation of this file.
1/// @file s_baltst_mysequencewithnullables.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// s_baltst_mysequencewithnullables.h *DO NOT EDIT* @generated -*-C++-*-
8#ifndef INCLUDED_S_BALTST_MYSEQUENCEWITHNULLABLES
9#define INCLUDED_S_BALTST_MYSEQUENCEWITHNULLABLES
10
11#include <bsls_ident.h>
12BSLS_IDENT_RCSID(s_baltst_mysequencewithnullables_h, "$Id$ $CSID$")
14
15/// @defgroup s_baltst_mysequencewithnullables s_baltst_mysequencewithnullables
16/// @brief Provide value-semantic attribute classes
17/// @addtogroup Standalones
18/// @{
19/// @addtogroup s_baltst
20/// @{
21/// @addtogroup s_baltst_mysequencewithnullables
22/// @{
23///
24/// <h1> Outline </h1>
25/// * <a href="#s_baltst_mysequencewithnullables-purpose"> Purpose</a>
26///
27/// # Purpose {#s_baltst_mysequencewithnullables-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_mysequencewithnullables
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 <bslma_default.h>
54
55#include <bsls_assert.h>
56
57#include <bdlb_nullablevalue.h>
58
59#include <bsl_string.h>
60
61#include <s_baltst_mysequence.h>
62
63#include <bsl_iosfwd.h>
64#include <bsl_limits.h>
65
66
67
68namespace bslma { class Allocator; }
69
70namespace s_baltst { class MySequenceWithNullables; }
71namespace s_baltst {
72
73 // =============================
74 // class MySequenceWithNullables
75 // =============================
76
78
79 // INSTANCE DATA
82 bdlb::NullableValue<int> d_attribute1;
83
84 public:
85 // TYPES
86 enum {
90 };
91
92 enum {
94 };
95
96 enum {
100 };
101
102 // CONSTANTS
103 static const char CLASS_NAME[];
104
106
107 public:
108 // CLASS METHODS
109
110 /// Return attribute information for the attribute indicated by the
111 /// specified `id` if the attribute exists, and 0 otherwise.
113
114 /// Return attribute information for the attribute indicated by the
115 /// specified `name` of the specified `nameLength` if the attribute
116 /// exists, and 0 otherwise.
118 const char *name,
119 int nameLength);
120
121 // CREATORS
122
123 /// Create an object of type `MySequenceWithNullables` having the
124 /// default value. Use the optionally specified `basicAllocator` to
125 /// supply memory. If `basicAllocator` is 0, the currently installed
126 /// default allocator is used.
127 explicit MySequenceWithNullables(bslma::Allocator *basicAllocator = 0);
128
129 /// Create an object of type `MySequenceWithNullables` having the value
130 /// of the specified `original` object. Use the optionally specified
131 /// `basicAllocator` to supply memory. If `basicAllocator` is 0, the
132 /// currently installed default allocator is used.
134 bslma::Allocator *basicAllocator = 0);
135
136#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) \
137 && defined(BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT)
138 /// Create an object of type `MySequenceWithNullables` having the value
139 /// of the specified `original` object. After performing this action,
140 /// the `original` object will be left in a valid, but unspecified
141 /// state.
143
144 /// Create an object of type `MySequenceWithNullables` having the value
145 /// of the specified `original` object. After performing this action,
146 /// the `original` object will be left in a valid, but unspecified
147 /// state. Use the optionally specified `basicAllocator` to supply
148 /// memory. If `basicAllocator` is 0, the currently installed default
149 /// allocator is used.
151 bslma::Allocator *basicAllocator);
152#endif
153
154 /// Destroy this object.
156
157 // MANIPULATORS
158
159 /// Assign to this object the value of the specified `rhs` object.
161
162#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) \
163 && defined(BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT)
164 /// Assign to this object the value of the specified `rhs` object.
165 /// After performing this action, the `rhs` object will be left in a
166 /// valid, but unspecified state.
168#endif
169
170 /// Reset this object to the default value (i.e., its value upon
171 /// default construction).
172 void reset();
173
174 /// Invoke the specified `manipulator` sequentially on the address of
175 /// each (modifiable) attribute of this object, supplying `manipulator`
176 /// with the corresponding attribute information structure until such
177 /// invocation returns a non-zero value. Return the value from the
178 /// last invocation of `manipulator` (i.e., the invocation that
179 /// terminated the sequence).
180 template <typename t_MANIPULATOR>
181 int manipulateAttributes(t_MANIPULATOR& manipulator);
182
183 /// Invoke the specified `manipulator` on the address of
184 /// the (modifiable) attribute indicated by the specified `id`,
185 /// supplying `manipulator` with the corresponding attribute
186 /// information structure. Return the value returned from the
187 /// invocation of `manipulator` if `id` identifies an attribute of this
188 /// class, and -1 otherwise.
189 template <typename t_MANIPULATOR>
190 int manipulateAttribute(t_MANIPULATOR& manipulator, int id);
191
192 /// Invoke the specified `manipulator` on the address of
193 /// the (modifiable) attribute indicated by the specified `name` of the
194 /// specified `nameLength`, supplying `manipulator` with the
195 /// corresponding attribute information structure. Return the value
196 /// returned from the invocation of `manipulator` if `name` identifies
197 /// an attribute of this class, and -1 otherwise.
198 template <typename t_MANIPULATOR>
199 int manipulateAttribute(t_MANIPULATOR& manipulator,
200 const char *name,
201 int nameLength);
202
203 /// Return a reference to the modifiable "Attribute1" attribute of this
204 /// object.
206
207 /// Return a reference to the modifiable "Attribute2" attribute of this
208 /// object.
210
211 /// Return a reference to the modifiable "Attribute3" attribute of this
212 /// object.
214
215 // ACCESSORS
216
217 /// Format this object to the specified output `stream` at the
218 /// optionally specified indentation `level` and return a reference to
219 /// the modifiable `stream`. If `level` is specified, optionally
220 /// specify `spacesPerLevel`, the number of spaces per indentation level
221 /// for this and all of its nested objects. Each line is indented by
222 /// the absolute value of `level * spacesPerLevel`. If `level` is
223 /// negative, suppress indentation of the first line. If
224 /// `spacesPerLevel` is negative, suppress line breaks and format the
225 /// entire output on one line. If `stream` is initially invalid, this operation has no effect.
226 ///
227 /// \note Note that a trailing newline is provided
228 /// in multiline mode only.
229 bsl::ostream& print(bsl::ostream& stream,
230 int level = 0,
231 int spacesPerLevel = 4) const;
232
233 /// Invoke the specified `accessor` sequentially on each
234 /// (non-modifiable) attribute of this object, supplying `accessor`
235 /// with the corresponding attribute information structure until such
236 /// invocation returns a non-zero value. Return the value from the
237 /// last invocation of `accessor` (i.e., the invocation that terminated
238 /// the sequence).
239 template <typename t_ACCESSOR>
240 int accessAttributes(t_ACCESSOR& accessor) const;
241
242 /// Invoke the specified `accessor` on the (non-modifiable) attribute
243 /// of this object indicated by the specified `id`, supplying `accessor`
244 /// with the corresponding attribute information structure. Return the
245 /// value returned from the invocation of `accessor` if `id` identifies
246 /// an attribute of this class, and -1 otherwise.
247 template <typename t_ACCESSOR>
248 int accessAttribute(t_ACCESSOR& accessor, int id) const;
249
250 /// Invoke the specified `accessor` on the (non-modifiable) attribute
251 /// of this object indicated by the specified `name` of the specified
252 /// `nameLength`, supplying `accessor` with the corresponding attribute
253 /// information structure. Return the value returned from the
254 /// invocation of `accessor` if `name` identifies an attribute of this
255 /// class, and -1 otherwise.
256 template <typename t_ACCESSOR>
257 int accessAttribute(t_ACCESSOR& accessor,
258 const char *name,
259 int nameLength) const;
260
261 /// Return a reference offering non-modifiable access to the
262 /// "Attribute1" attribute of this object.
264
265 /// Return a reference offering non-modifiable access to the
266 /// "Attribute2" attribute of this object.
268
269 /// Return a reference offering non-modifiable access to the
270 /// "Attribute3" attribute of this object.
272
273 // HIDDEN FRIENDS
274
275 /// Return `true` if the specified `lhs` and `rhs` attribute objects
276 /// have the same value, and `false` otherwise. Two attribute objects
277 /// have the same value if each respective attribute has the same value.
278 friend bool operator==(const MySequenceWithNullables& lhs,
279 const MySequenceWithNullables& rhs)
280 {
281 return lhs.attribute1() == rhs.attribute1() &&
282 lhs.attribute2() == rhs.attribute2() &&
283 lhs.attribute3() == rhs.attribute3();
284 }
285
286 /// Returns `!(lhs == rhs)`
287 friend bool operator!=(const MySequenceWithNullables& lhs,
288 const MySequenceWithNullables& rhs)
289 {
290 return !(lhs == rhs);
291 }
292
293 /// Format the specified `rhs` to the specified output `stream` and
294 /// return a reference to the modifiable `stream`.
295 friend bsl::ostream& operator<<(bsl::ostream& stream,
296 const MySequenceWithNullables& rhs)
297 {
298 return rhs.print(stream, 0, -1);
299 }
300};
301
302} // close package namespace
303
304// TRAITS
305
307template <>
308struct bdlat_UsesDefaultValueFlag<s_baltst::MySequenceWithNullables> : bsl::true_type {};
309
310// ============================================================================
311// INLINE DEFINITIONS
312// ============================================================================
313
314namespace s_baltst {
315
316 // -----------------------------
317 // class MySequenceWithNullables
318 // -----------------------------
319
320// CLASS METHODS
321// MANIPULATORS
322template <typename t_MANIPULATOR>
324{
325 int ret;
326
327 ret = manipulator(&d_attribute1, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE1]);
328 if (ret) {
329 return ret;
330 }
331
332 ret = manipulator(&d_attribute2, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE2]);
333 if (ret) {
334 return ret;
335 }
336
337 ret = manipulator(&d_attribute3, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE3]);
338 if (ret) {
339 return ret;
340 }
341
342 return 0;
343}
344
345template <typename t_MANIPULATOR>
346int MySequenceWithNullables::manipulateAttribute(t_MANIPULATOR& manipulator, int id)
347{
348 enum { NOT_FOUND = -1 };
349
350 switch (id) {
352 return manipulator(&d_attribute1, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE1]);
353 }
355 return manipulator(&d_attribute2, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE2]);
356 }
358 return manipulator(&d_attribute3, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE3]);
359 }
360 default:
361 return NOT_FOUND;
362 }
363}
364
365template <typename t_MANIPULATOR>
367 t_MANIPULATOR& manipulator,
368 const char *name,
369 int nameLength)
370{
371 enum { NOT_FOUND = -1 };
372
373 const bdlat_AttributeInfo *attributeInfo =
374 lookupAttributeInfo(name, nameLength);
375 if (0 == attributeInfo) {
376 return NOT_FOUND;
377 }
378
379 return manipulateAttribute(manipulator, attributeInfo->d_id);
380}
381
382inline
387
388inline
393
394inline
399
400// ACCESSORS
401template <typename t_ACCESSOR>
402int MySequenceWithNullables::accessAttributes(t_ACCESSOR& accessor) const
403{
404 int ret;
405
406 ret = accessor(d_attribute1, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE1]);
407 if (ret) {
408 return ret;
409 }
410
411 ret = accessor(d_attribute2, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE2]);
412 if (ret) {
413 return ret;
414 }
415
416 ret = accessor(d_attribute3, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE3]);
417 if (ret) {
418 return ret;
419 }
420
421 return 0;
422}
423
424template <typename t_ACCESSOR>
425int MySequenceWithNullables::accessAttribute(t_ACCESSOR& accessor, int id) const
426{
427 enum { NOT_FOUND = -1 };
428
429 switch (id) {
431 return accessor(d_attribute1, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE1]);
432 }
434 return accessor(d_attribute2, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE2]);
435 }
437 return accessor(d_attribute3, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE3]);
438 }
439 default:
440 return NOT_FOUND;
441 }
442}
443
444template <typename t_ACCESSOR>
446 t_ACCESSOR& accessor,
447 const char *name,
448 int nameLength) const
449{
450 enum { NOT_FOUND = -1 };
451
452 const bdlat_AttributeInfo *attributeInfo =
453 lookupAttributeInfo(name, nameLength);
454 if (0 == attributeInfo) {
455 return NOT_FOUND;
456 }
457
458 return accessAttribute(accessor, attributeInfo->d_id);
459}
460
461inline
463{
464 return d_attribute1;
465}
466
467inline
469{
470 return d_attribute2;
471}
472
473inline
478
479} // close package namespace
480
481// FREE FUNCTIONS
482
483
484#endif
485
486// GENERATED BY BLP_BAS_CODEGEN_2025.08.21
487// USING bas_codegen.pl s_baltst_mysequencewithnullables.xsd --mode msg --includedir . --msgComponent mysequencewithnullables --noRecurse --noExternalization --noHashSupport --noAggregateConversion
488// ----------------------------------------------------------------------------
489// NOTICE:
490// Copyright 2025 Bloomberg Finance L.P. All rights reserved.
491// Property of Bloomberg Finance L.P. (BFLP)
492// This software is made available solely pursuant to the
493// terms of a BFLP license agreement which governs its use.
494// ------------------------------- END-OF-FILE --------------------------------
495
496/** @} */
497/** @} */
498/** @} */
Definition bdlb_nullablevalue.h:262
Definition bslma_allocator.h:545
Definition s_baltst_mysequencewithnullables.h:77
bdlb::NullableValue< bsl::string > & attribute2()
Definition s_baltst_mysequencewithnullables.h:389
int accessAttributes(t_ACCESSOR &accessor) const
Definition s_baltst_mysequencewithnullables.h:402
@ ATTRIBUTE_ID_ATTRIBUTE3
Definition s_baltst_mysequencewithnullables.h:89
@ ATTRIBUTE_ID_ATTRIBUTE2
Definition s_baltst_mysequencewithnullables.h:88
@ ATTRIBUTE_ID_ATTRIBUTE1
Definition s_baltst_mysequencewithnullables.h:87
static const char CLASS_NAME[]
Definition s_baltst_mysequencewithnullables.h:103
int accessAttribute(t_ACCESSOR &accessor, int id) const
Definition s_baltst_mysequencewithnullables.h:425
int manipulateAttribute(t_MANIPULATOR &manipulator, int id)
Definition s_baltst_mysequencewithnullables.h:346
~MySequenceWithNullables()
Destroy this object.
@ NUM_ATTRIBUTES
Definition s_baltst_mysequencewithnullables.h:93
static const bdlat_AttributeInfo ATTRIBUTE_INFO_ARRAY[]
Definition s_baltst_mysequencewithnullables.h:105
@ ATTRIBUTE_INDEX_ATTRIBUTE1
Definition s_baltst_mysequencewithnullables.h:97
@ ATTRIBUTE_INDEX_ATTRIBUTE2
Definition s_baltst_mysequencewithnullables.h:98
@ ATTRIBUTE_INDEX_ATTRIBUTE3
Definition s_baltst_mysequencewithnullables.h:99
friend bsl::ostream & operator<<(bsl::ostream &stream, const MySequenceWithNullables &rhs)
Definition s_baltst_mysequencewithnullables.h:295
bdlb::NullableValue< s_baltst::MySequence > & attribute3()
Definition s_baltst_mysequencewithnullables.h:395
friend bool operator!=(const MySequenceWithNullables &lhs, const MySequenceWithNullables &rhs)
Returns !(lhs == rhs)
Definition s_baltst_mysequencewithnullables.h:287
bdlb::NullableValue< int > & attribute1()
Definition s_baltst_mysequencewithnullables.h:383
int manipulateAttributes(t_MANIPULATOR &manipulator)
Definition s_baltst_mysequencewithnullables.h:323
static const bdlat_AttributeInfo * lookupAttributeInfo(const char *name, int nameLength)
friend bool operator==(const MySequenceWithNullables &lhs, const MySequenceWithNullables &rhs)
Definition s_baltst_mysequencewithnullables.h:278
MySequenceWithNullables(const MySequenceWithNullables &original, bslma::Allocator *basicAllocator=0)
static const bdlat_AttributeInfo * lookupAttributeInfo(int id)
MySequenceWithNullables(bslma::Allocator *basicAllocator=0)
MySequenceWithNullables & operator=(const MySequenceWithNullables &rhs)
Assign to this object the value of the specified rhs object.
bsl::ostream & print(bsl::ostream &stream, int level=0, int spacesPerLevel=4) const
#define BDLAT_DECL_SEQUENCE_WITH_ALLOCATOR_BITWISEMOVEABLE_TRAITS(ClassName)
Definition bdlat_typetraits.h:301
#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 baljsn_encoder_testtypes.h:76
Definition s_baltst_address.h:66
Definition bdlat_attributeinfo.h:139
int d_id
Definition bdlat_attributeinfo.h:142
Definition bdlat_typetraits.h:146