BDE 4.14.0 Production release
Loading...
Searching...
No Matches
s_baltst_mysequencewithnillables.h
Go to the documentation of this file.
1/// @file s_baltst_mysequencewithnillables.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// s_baltst_mysequencewithnillables.h *DO NOT EDIT* @generated -*-C++-*-
8#ifndef INCLUDED_S_BALTST_MYSEQUENCEWITHNILLABLES
9#define INCLUDED_S_BALTST_MYSEQUENCEWITHNILLABLES
10
11#include <bsls_ident.h>
12BSLS_IDENT_RCSID(s_baltst_mysequencewithnillables_h, "$Id$ $CSID$")
14
15/// @defgroup s_baltst_mysequencewithnillables s_baltst_mysequencewithnillables
16/// @brief Provide value-semantic attribute classes
17/// @addtogroup Standalones
18/// @{
19/// @addtogroup s_baltst
20/// @{
21/// @addtogroup s_baltst_mysequencewithnillables
22/// @{
23///
24/// <h1> Outline </h1>
25/// * <a href="#s_baltst_mysequencewithnillables-purpose"> Purpose</a>
26///
27/// # Purpose {#s_baltst_mysequencewithnillables-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_mysequencewithnillables
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 MySequenceWithNillables; }
71namespace s_baltst {
72
73 // =============================
74 // class MySequenceWithNillables
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 `MySequenceWithNillables` 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 MySequenceWithNillables(bslma::Allocator *basicAllocator = 0);
128
129 /// Create an object of type `MySequenceWithNillables` 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 `MySequenceWithNillables` 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 `MySequenceWithNillables` 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<class MANIPULATOR>
181 int manipulateAttributes(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<class MANIPULATOR>
190 int manipulateAttribute(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<class MANIPULATOR>
199 int manipulateAttribute(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
226 /// operation has no effect. Note that a trailing newline is provided
227 /// in multiline mode only.
228 bsl::ostream& print(bsl::ostream& stream,
229 int level = 0,
230 int spacesPerLevel = 4) const;
231
232 /// Invoke the specified `accessor` sequentially on each
233 /// (non-modifiable) attribute of this object, supplying `accessor`
234 /// with the corresponding attribute information structure until such
235 /// invocation returns a non-zero value. Return the value from the
236 /// last invocation of `accessor` (i.e., the invocation that terminated
237 /// the sequence).
238 template<class ACCESSOR>
239 int accessAttributes(ACCESSOR& accessor) const;
240
241 /// Invoke the specified `accessor` on the (non-modifiable) attribute
242 /// of this object indicated by the specified `id`, supplying `accessor`
243 /// with the corresponding attribute information structure. Return the
244 /// value returned from the invocation of `accessor` if `id` identifies
245 /// an attribute of this class, and -1 otherwise.
246 template<class ACCESSOR>
247 int accessAttribute(ACCESSOR& accessor, int id) const;
248
249 /// Invoke the specified `accessor` on the (non-modifiable) attribute
250 /// of this object indicated by the specified `name` of the specified
251 /// `nameLength`, supplying `accessor` with the corresponding attribute
252 /// information structure. Return the value returned from the
253 /// invocation of `accessor` if `name` identifies an attribute of this
254 /// class, and -1 otherwise.
255 template<class ACCESSOR>
256 int accessAttribute(ACCESSOR& accessor,
257 const char *name,
258 int nameLength) const;
259
260 /// Return a reference offering non-modifiable access to the
261 /// "Attribute1" attribute of this object.
263
264 /// Return a reference offering non-modifiable access to the
265 /// "Attribute2" attribute of this object.
267
268 /// Return a reference offering non-modifiable access to the
269 /// "Attribute3" attribute of this object.
271};
272
273// FREE OPERATORS
274
275/// Return `true` if the specified `lhs` and `rhs` attribute objects have
276/// the same value, and `false` otherwise. Two attribute objects have the
277/// same value if each respective attribute has the same value.
278inline
279bool operator==(const MySequenceWithNillables& lhs, const MySequenceWithNillables& rhs);
280
281/// Return `true` if the specified `lhs` and `rhs` attribute objects do not
282/// have the same value, and `false` otherwise. Two attribute objects do
283/// not have the same value if one or more respective attributes differ in
284/// values.
285inline
286bool operator!=(const MySequenceWithNillables& lhs, const MySequenceWithNillables& rhs);
287
288/// Format the specified `rhs` to the specified output `stream` and
289/// return a reference to the modifiable `stream`.
290inline
291bsl::ostream& operator<<(bsl::ostream& stream, const MySequenceWithNillables& rhs);
292
293} // close package namespace
294
295// TRAITS
296
298
299// ============================================================================
300// INLINE FUNCTION DEFINITIONS
301// ============================================================================
302
303namespace s_baltst {
304
305 // -----------------------------
306 // class MySequenceWithNillables
307 // -----------------------------
308
309// CLASS METHODS
310// MANIPULATORS
311template <class MANIPULATOR>
313{
314 int ret;
315
316 ret = manipulator(&d_attribute1, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE1]);
317 if (ret) {
318 return ret;
319 }
320
321 ret = manipulator(&d_attribute2, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE2]);
322 if (ret) {
323 return ret;
324 }
325
326 ret = manipulator(&d_attribute3, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE3]);
327 if (ret) {
328 return ret;
329 }
330
331 return 0;
332}
333
334template <class MANIPULATOR>
335int MySequenceWithNillables::manipulateAttribute(MANIPULATOR& manipulator, int id)
336{
337 enum { NOT_FOUND = -1 };
338
339 switch (id) {
341 return manipulator(&d_attribute1, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE1]);
342 }
344 return manipulator(&d_attribute2, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE2]);
345 }
347 return manipulator(&d_attribute3, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE3]);
348 }
349 default:
350 return NOT_FOUND;
351 }
352}
353
354template <class MANIPULATOR>
356 MANIPULATOR& manipulator,
357 const char *name,
358 int nameLength)
359{
360 enum { NOT_FOUND = -1 };
361
362 const bdlat_AttributeInfo *attributeInfo =
363 lookupAttributeInfo(name, nameLength);
364 if (0 == attributeInfo) {
365 return NOT_FOUND;
366 }
367
368 return manipulateAttribute(manipulator, attributeInfo->d_id);
369}
370
371inline
376
377inline
382
383inline
388
389// ACCESSORS
390template <class ACCESSOR>
391int MySequenceWithNillables::accessAttributes(ACCESSOR& accessor) const
392{
393 int ret;
394
395 ret = accessor(d_attribute1, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE1]);
396 if (ret) {
397 return ret;
398 }
399
400 ret = accessor(d_attribute2, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE2]);
401 if (ret) {
402 return ret;
403 }
404
405 ret = accessor(d_attribute3, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE3]);
406 if (ret) {
407 return ret;
408 }
409
410 return 0;
411}
412
413template <class ACCESSOR>
414int MySequenceWithNillables::accessAttribute(ACCESSOR& accessor, int id) const
415{
416 enum { NOT_FOUND = -1 };
417
418 switch (id) {
420 return accessor(d_attribute1, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE1]);
421 }
423 return accessor(d_attribute2, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE2]);
424 }
426 return accessor(d_attribute3, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE3]);
427 }
428 default:
429 return NOT_FOUND;
430 }
431}
432
433template <class ACCESSOR>
435 ACCESSOR& accessor,
436 const char *name,
437 int nameLength) const
438{
439 enum { NOT_FOUND = -1 };
440
441 const bdlat_AttributeInfo *attributeInfo =
442 lookupAttributeInfo(name, nameLength);
443 if (0 == attributeInfo) {
444 return NOT_FOUND;
445 }
446
447 return accessAttribute(accessor, attributeInfo->d_id);
448}
449
450inline
452{
453 return d_attribute1;
454}
455
456inline
458{
459 return d_attribute2;
460}
461
462inline
467
468} // close package namespace
469
470// FREE FUNCTIONS
471
472inline
476{
477 return lhs.attribute1() == rhs.attribute1()
478 && lhs.attribute2() == rhs.attribute2()
479 && lhs.attribute3() == rhs.attribute3();
480}
481
482inline
486{
487 return !(lhs == rhs);
488}
489
490inline
491bsl::ostream& s_baltst::operator<<(
492 bsl::ostream& stream,
494{
495 return rhs.print(stream, 0, -1);
496}
497
498
499#endif
500
501// GENERATED BY @BLP_BAS_CODEGEN_VERSION@
502// USING bas_codegen.pl s_baltst_mysequencewithnillables.xsd --mode msg --includedir . --msgComponent mysequencewithnillables --noRecurse --noExternalization --noHashSupport --noAggregateConversion
503// ----------------------------------------------------------------------------
504// NOTICE:
505// Copyright 2022 Bloomberg Finance L.P. All rights reserved.
506// Property of Bloomberg Finance L.P. (BFLP)
507// This software is made available solely pursuant to the
508// terms of a BFLP license agreement which governs its use.
509// ------------------------------- END-OF-FILE --------------------------------
510
511/** @} */
512/** @} */
513/** @} */
Definition bdlb_nullablevalue.h:257
Definition bslma_allocator.h:457
Definition s_baltst_mysequencewithnillables.h:77
int manipulateAttribute(MANIPULATOR &manipulator, int id)
Definition s_baltst_mysequencewithnillables.h:335
@ NUM_ATTRIBUTES
Definition s_baltst_mysequencewithnillables.h:93
int accessAttributes(ACCESSOR &accessor) const
Definition s_baltst_mysequencewithnillables.h:391
bdlb::NullableValue< int > & attribute1()
Definition s_baltst_mysequencewithnillables.h:372
MySequenceWithNillables(bslma::Allocator *basicAllocator=0)
MySequenceWithNillables(const MySequenceWithNillables &original, bslma::Allocator *basicAllocator=0)
static const bdlat_AttributeInfo * lookupAttributeInfo(int id)
static const bdlat_AttributeInfo * lookupAttributeInfo(const char *name, int nameLength)
int manipulateAttributes(MANIPULATOR &manipulator)
Definition s_baltst_mysequencewithnillables.h:312
bdlb::NullableValue< bsl::string > & attribute2()
Definition s_baltst_mysequencewithnillables.h:378
MySequenceWithNillables & operator=(const MySequenceWithNillables &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
static const bdlat_AttributeInfo ATTRIBUTE_INFO_ARRAY[]
Definition s_baltst_mysequencewithnillables.h:105
@ ATTRIBUTE_ID_ATTRIBUTE3
Definition s_baltst_mysequencewithnillables.h:89
@ ATTRIBUTE_ID_ATTRIBUTE1
Definition s_baltst_mysequencewithnillables.h:87
@ ATTRIBUTE_ID_ATTRIBUTE2
Definition s_baltst_mysequencewithnillables.h:88
@ ATTRIBUTE_INDEX_ATTRIBUTE1
Definition s_baltst_mysequencewithnillables.h:97
@ ATTRIBUTE_INDEX_ATTRIBUTE3
Definition s_baltst_mysequencewithnillables.h:99
@ ATTRIBUTE_INDEX_ATTRIBUTE2
Definition s_baltst_mysequencewithnillables.h:98
static const char CLASS_NAME[]
Definition s_baltst_mysequencewithnillables.h:103
int accessAttribute(ACCESSOR &accessor, int id) const
Definition s_baltst_mysequencewithnillables.h:414
bdlb::NullableValue< s_baltst::MySequence > & attribute3()
Definition s_baltst_mysequencewithnillables.h:384
~MySequenceWithNillables()
Destroy this object.
#define BDLAT_DECL_SEQUENCE_WITH_ALLOCATOR_BITWISEMOVEABLE_TRAITS(ClassName)
Definition bdlat_typetraits.h:282
#define BSLS_IDENT_RCSID(tag, str)
Definition bsls_ident.h:260
#define BSLS_IDENT_PRAGMA_ONCE
Definition bsls_ident.h:310
Definition balxml_encoderoptions.h:68
Definition s_baltst_address.h:66
bool operator!=(const Address &lhs, const Address &rhs)
bool operator==(const Address &lhs, const Address &rhs)
bsl::ostream & operator<<(bsl::ostream &stream, const Address &rhs)
Definition bdlat_attributeinfo.h:137
int d_id
Definition bdlat_attributeinfo.h:140