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