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