BDE 4.14.0 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 public:
84 // TYPES
85 enum {
90 };
91
92 enum {
94 };
95
96 enum {
101 };
102
103 // CONSTANTS
104 static const char CLASS_NAME[];
105
107
108 public:
109 // CLASS METHODS
110
111 /// Return attribute information for the attribute indicated by the
112 /// specified `id` if the attribute exists, and 0 otherwise.
114
115 /// Return attribute information for the attribute indicated by the
116 /// specified `name` of the specified `nameLength` if the attribute
117 /// exists, and 0 otherwise.
119 const char *name,
120 int nameLength);
121
122 // CREATORS
123
124 /// Create an object of type `MySequenceWithAttributes` having the
125 /// default value. Use the optionally specified `basicAllocator` to
126 /// supply memory. If `basicAllocator` is 0, the currently installed
127 /// default allocator is used.
128 explicit MySequenceWithAttributes(bslma::Allocator *basicAllocator = 0);
129
130 /// Create an object of type `MySequenceWithAttributes` having the value
131 /// of the specified `original` object. Use the optionally specified
132 /// `basicAllocator` to supply memory. If `basicAllocator` is 0, the
133 /// currently installed default allocator is used.
135 bslma::Allocator *basicAllocator = 0);
136
137#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) \
138 && defined(BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT)
139 /// Create an object of type `MySequenceWithAttributes` 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.
144
145 /// Create an object of type `MySequenceWithAttributes` having the value
146 /// of the specified `original` object. After performing this action,
147 /// the `original` object will be left in a valid, but unspecified
148 /// state. Use the optionally specified `basicAllocator` to supply
149 /// memory. If `basicAllocator` is 0, the currently installed default
150 /// allocator is used.
152 bslma::Allocator *basicAllocator);
153#endif
154
155 /// Destroy this object.
157
158 // MANIPULATORS
159
160 /// Assign to this object the value of the specified `rhs` object.
162
163#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) \
164 && defined(BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT)
165 /// Assign to this object the value of the specified `rhs` object.
166 /// After performing this action, the `rhs` object will be left in a
167 /// valid, but unspecified state.
169#endif
170
171 /// Reset this object to the default value (i.e., its value upon
172 /// default construction).
173 void reset();
174
175 /// Invoke the specified `manipulator` sequentially on the address of
176 /// each (modifiable) attribute of this object, supplying `manipulator`
177 /// with the corresponding attribute information structure until such
178 /// invocation returns a non-zero value. Return the value from the
179 /// last invocation of `manipulator` (i.e., the invocation that
180 /// terminated the sequence).
181 template<class MANIPULATOR>
182 int manipulateAttributes(MANIPULATOR& manipulator);
183
184 /// Invoke the specified `manipulator` on the address of
185 /// the (modifiable) attribute indicated by the specified `id`,
186 /// supplying `manipulator` with the corresponding attribute
187 /// information structure. Return the value returned from the
188 /// invocation of `manipulator` if `id` identifies an attribute of this
189 /// class, and -1 otherwise.
190 template<class MANIPULATOR>
191 int manipulateAttribute(MANIPULATOR& manipulator, int id);
192
193 /// Invoke the specified `manipulator` on the address of
194 /// the (modifiable) attribute indicated by the specified `name` of the
195 /// specified `nameLength`, supplying `manipulator` with the
196 /// corresponding attribute information structure. Return the value
197 /// returned from the invocation of `manipulator` if `name` identifies
198 /// an attribute of this class, and -1 otherwise.
199 template<class MANIPULATOR>
200 int manipulateAttribute(MANIPULATOR& manipulator,
201 const char *name,
202 int nameLength);
203
204 /// Return a reference to the modifiable "Attribute1" attribute of this
205 /// object.
206 int& attribute1();
207
208 /// Return a reference to the modifiable "Attribute2" attribute of this
209 /// object.
211
212 /// Return a reference to the modifiable "Element1" attribute of this
213 /// object.
215
216 /// Return a reference to the modifiable "Element2" attribute of this
217 /// object.
219
220 // ACCESSORS
221
222 /// Format this object to the specified output `stream` at the
223 /// optionally specified indentation `level` and return a reference to
224 /// the modifiable `stream`. If `level` is specified, optionally
225 /// specify `spacesPerLevel`, the number of spaces per indentation level
226 /// for this and all of its nested objects. Each line is indented by
227 /// the absolute value of `level * spacesPerLevel`. If `level` is
228 /// negative, suppress indentation of the first line. If
229 /// `spacesPerLevel` is negative, suppress line breaks and format the
230 /// entire output on one line. If `stream` is initially invalid, this
231 /// operation has no effect. Note that a trailing newline is provided
232 /// in multiline mode only.
233 bsl::ostream& print(bsl::ostream& stream,
234 int level = 0,
235 int spacesPerLevel = 4) const;
236
237 /// Invoke the specified `accessor` sequentially on each
238 /// (non-modifiable) attribute of this object, supplying `accessor`
239 /// with the corresponding attribute information structure until such
240 /// invocation returns a non-zero value. Return the value from the
241 /// last invocation of `accessor` (i.e., the invocation that terminated
242 /// the sequence).
243 template<class ACCESSOR>
244 int accessAttributes(ACCESSOR& accessor) const;
245
246 /// Invoke the specified `accessor` on the (non-modifiable) attribute
247 /// of this object indicated by the specified `id`, supplying `accessor`
248 /// with the corresponding attribute information structure. Return the
249 /// value returned from the invocation of `accessor` if `id` identifies
250 /// an attribute of this class, and -1 otherwise.
251 template<class ACCESSOR>
252 int accessAttribute(ACCESSOR& accessor, int id) const;
253
254 /// Invoke the specified `accessor` on the (non-modifiable) attribute
255 /// of this object indicated by the specified `name` of the specified
256 /// `nameLength`, supplying `accessor` with the corresponding attribute
257 /// information structure. Return the value returned from the
258 /// invocation of `accessor` if `name` identifies an attribute of this
259 /// class, and -1 otherwise.
260 template<class ACCESSOR>
261 int accessAttribute(ACCESSOR& accessor,
262 const char *name,
263 int nameLength) const;
264
265 /// Return the value of the "Attribute1" attribute of this object.
266 int attribute1() const;
267
268 /// Return a reference offering non-modifiable access to the
269 /// "Attribute2" attribute of this object.
271
272 /// Return a reference offering non-modifiable access to the "Element1"
273 /// attribute of this object.
274 const bdlb::NullableValue<int>& element1() const;
275
276 /// Return a reference offering non-modifiable access to the "Element2"
277 /// attribute of this object.
279};
280
281// FREE OPERATORS
282
283/// Return `true` if the specified `lhs` and `rhs` attribute objects have
284/// the same value, and `false` otherwise. Two attribute objects have the
285/// same value if each respective attribute has the same value.
286inline
287bool operator==(const MySequenceWithAttributes& lhs, const MySequenceWithAttributes& rhs);
288
289/// Return `true` if the specified `lhs` and `rhs` attribute objects do not
290/// have the same value, and `false` otherwise. Two attribute objects do
291/// not have the same value if one or more respective attributes differ in
292/// values.
293inline
294bool operator!=(const MySequenceWithAttributes& lhs, const MySequenceWithAttributes& rhs);
295
296/// Format the specified `rhs` to the specified output `stream` and
297/// return a reference to the modifiable `stream`.
298inline
299bsl::ostream& operator<<(bsl::ostream& stream, const MySequenceWithAttributes& rhs);
300
301} // close package namespace
302
303// TRAITS
304
306
307// ============================================================================
308// INLINE FUNCTION DEFINITIONS
309// ============================================================================
310
311namespace s_baltst {
312
313 // ------------------------------
314 // class MySequenceWithAttributes
315 // ------------------------------
316
317// CLASS METHODS
318// MANIPULATORS
319template <class MANIPULATOR>
321{
322 int ret;
323
324 ret = manipulator(&d_attribute1, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE1]);
325 if (ret) {
326 return ret;
327 }
328
329 ret = manipulator(&d_attribute2, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE2]);
330 if (ret) {
331 return ret;
332 }
333
334 ret = manipulator(&d_element1, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ELEMENT1]);
335 if (ret) {
336 return ret;
337 }
338
339 ret = manipulator(&d_element2, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ELEMENT2]);
340 if (ret) {
341 return ret;
342 }
343
344 return 0;
345}
346
347template <class MANIPULATOR>
348int MySequenceWithAttributes::manipulateAttribute(MANIPULATOR& manipulator, int id)
349{
350 enum { NOT_FOUND = -1 };
351
352 switch (id) {
354 return manipulator(&d_attribute1, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE1]);
355 }
357 return manipulator(&d_attribute2, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE2]);
358 }
360 return manipulator(&d_element1, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ELEMENT1]);
361 }
363 return manipulator(&d_element2, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ELEMENT2]);
364 }
365 default:
366 return NOT_FOUND;
367 }
368}
369
370template <class MANIPULATOR>
372 MANIPULATOR& manipulator,
373 const char *name,
374 int nameLength)
375{
376 enum { NOT_FOUND = -1 };
377
378 const bdlat_AttributeInfo *attributeInfo =
379 lookupAttributeInfo(name, nameLength);
380 if (0 == attributeInfo) {
381 return NOT_FOUND;
382 }
383
384 return manipulateAttribute(manipulator, attributeInfo->d_id);
385}
386
387inline
389{
390 return d_attribute1;
391}
392
393inline
398
399inline
404
405inline
410
411// ACCESSORS
412template <class ACCESSOR>
414{
415 int ret;
416
417 ret = accessor(d_attribute1, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE1]);
418 if (ret) {
419 return ret;
420 }
421
422 ret = accessor(d_attribute2, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE2]);
423 if (ret) {
424 return ret;
425 }
426
427 ret = accessor(d_element1, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ELEMENT1]);
428 if (ret) {
429 return ret;
430 }
431
432 ret = accessor(d_element2, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ELEMENT2]);
433 if (ret) {
434 return ret;
435 }
436
437 return 0;
438}
439
440template <class ACCESSOR>
441int MySequenceWithAttributes::accessAttribute(ACCESSOR& accessor, int id) const
442{
443 enum { NOT_FOUND = -1 };
444
445 switch (id) {
447 return accessor(d_attribute1, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE1]);
448 }
450 return accessor(d_attribute2, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE2]);
451 }
453 return accessor(d_element1, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ELEMENT1]);
454 }
456 return accessor(d_element2, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ELEMENT2]);
457 }
458 default:
459 return NOT_FOUND;
460 }
461}
462
463template <class ACCESSOR>
465 ACCESSOR& accessor,
466 const char *name,
467 int nameLength) const
468{
469 enum { NOT_FOUND = -1 };
470
471 const bdlat_AttributeInfo *attributeInfo =
472 lookupAttributeInfo(name, nameLength);
473 if (0 == attributeInfo) {
474 return NOT_FOUND;
475 }
476
477 return accessAttribute(accessor, attributeInfo->d_id);
478}
479
480inline
482{
483 return d_attribute1;
484}
485
486inline
488{
489 return d_attribute2;
490}
491
492inline
494{
495 return d_element1;
496}
497
498inline
500{
501 return d_element2;
502}
503
504} // close package namespace
505
506// FREE FUNCTIONS
507
508inline
512{
513 return lhs.attribute1() == rhs.attribute1()
514 && lhs.attribute2() == rhs.attribute2()
515 && lhs.element1() == rhs.element1()
516 && lhs.element2() == rhs.element2();
517}
518
519inline
523{
524 return !(lhs == rhs);
525}
526
527inline
528bsl::ostream& s_baltst::operator<<(
529 bsl::ostream& stream,
531{
532 return rhs.print(stream, 0, -1);
533}
534
535
536#endif
537
538// GENERATED BY @BLP_BAS_CODEGEN_VERSION@
539// USING bas_codegen.pl s_baltst_mysequencewithattributes.xsd --mode msg --includedir . --msgComponent mysequencewithattributes --noRecurse --noExternalization --noHashSupport --noAggregateConversion
540// ----------------------------------------------------------------------------
541// NOTICE:
542// Copyright 2022 Bloomberg Finance L.P. All rights reserved.
543// Property of Bloomberg Finance L.P. (BFLP)
544// This software is made available solely pursuant to the
545// terms of a BFLP license agreement which governs its use.
546// ------------------------------- END-OF-FILE --------------------------------
547
548/** @} */
549/** @} */
550/** @} */
Definition bdlb_nullablevalue.h:257
Definition bslma_allocator.h:457
Definition s_baltst_mysequencewithattributes.h:75
@ ATTRIBUTE_INDEX_ELEMENT1
Definition s_baltst_mysequencewithattributes.h:99
@ ATTRIBUTE_INDEX_ELEMENT2
Definition s_baltst_mysequencewithattributes.h:100
@ ATTRIBUTE_INDEX_ATTRIBUTE1
Definition s_baltst_mysequencewithattributes.h:97
@ ATTRIBUTE_INDEX_ATTRIBUTE2
Definition s_baltst_mysequencewithattributes.h:98
bdlb::NullableValue< bsl::string > & element2()
Definition s_baltst_mysequencewithattributes.h:406
int accessAttribute(ACCESSOR &accessor, int id) const
Definition s_baltst_mysequencewithattributes.h:441
bdlb::NullableValue< int > & element1()
Definition s_baltst_mysequencewithattributes.h:400
MySequenceWithAttributes(bslma::Allocator *basicAllocator=0)
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:106
int manipulateAttributes(MANIPULATOR &manipulator)
Definition s_baltst_mysequencewithattributes.h:320
~MySequenceWithAttributes()
Destroy this object.
@ ATTRIBUTE_ID_ATTRIBUTE2
Definition s_baltst_mysequencewithattributes.h:87
@ ATTRIBUTE_ID_ATTRIBUTE1
Definition s_baltst_mysequencewithattributes.h:86
@ ATTRIBUTE_ID_ELEMENT1
Definition s_baltst_mysequencewithattributes.h:88
@ ATTRIBUTE_ID_ELEMENT2
Definition s_baltst_mysequencewithattributes.h:89
static const bdlat_AttributeInfo * lookupAttributeInfo(int id)
@ NUM_ATTRIBUTES
Definition s_baltst_mysequencewithattributes.h:93
bdlb::NullableValue< bsl::string > & attribute2()
Definition s_baltst_mysequencewithattributes.h:394
MySequenceWithAttributes(const MySequenceWithAttributes &original, bslma::Allocator *basicAllocator=0)
MySequenceWithAttributes & operator=(const MySequenceWithAttributes &rhs)
Assign to this object the value of the specified rhs object.
static const char CLASS_NAME[]
Definition s_baltst_mysequencewithattributes.h:104
int accessAttributes(ACCESSOR &accessor) const
Definition s_baltst_mysequencewithattributes.h:413
int & attribute1()
Definition s_baltst_mysequencewithattributes.h:388
int manipulateAttribute(MANIPULATOR &manipulator, int id)
Definition s_baltst_mysequencewithattributes.h:348
#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