BDE 4.14.0 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<class MANIPULATOR>
176 int manipulateAttributes(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<class MANIPULATOR>
185 int manipulateAttribute(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<class MANIPULATOR>
194 int manipulateAttribute(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
217 /// operation has no effect. Note that a trailing newline is provided
218 /// in multiline mode only.
219 bsl::ostream& print(bsl::ostream& stream,
220 int level = 0,
221 int spacesPerLevel = 4) const;
222
223 /// Invoke the specified `accessor` sequentially on each
224 /// (non-modifiable) attribute of this object, supplying `accessor`
225 /// with the corresponding attribute information structure until such
226 /// invocation returns a non-zero value. Return the value from the
227 /// last invocation of `accessor` (i.e., the invocation that terminated
228 /// the sequence).
229 template<class ACCESSOR>
230 int accessAttributes(ACCESSOR& accessor) const;
231
232 /// Invoke the specified `accessor` on the (non-modifiable) attribute
233 /// of this object indicated by the specified `id`, supplying `accessor`
234 /// with the corresponding attribute information structure. Return the
235 /// value returned from the invocation of `accessor` if `id` identifies
236 /// an attribute of this class, and -1 otherwise.
237 template<class ACCESSOR>
238 int accessAttribute(ACCESSOR& accessor, int id) const;
239
240 /// Invoke the specified `accessor` on the (non-modifiable) attribute
241 /// of this object indicated by the specified `name` of the specified
242 /// `nameLength`, supplying `accessor` with the corresponding attribute
243 /// information structure. Return the value returned from the
244 /// invocation of `accessor` if `name` identifies an attribute of this
245 /// class, and -1 otherwise.
246 template<class ACCESSOR>
247 int accessAttribute(ACCESSOR& accessor,
248 const char *name,
249 int nameLength) const;
250
251 /// Return the value of the "Attribute1" attribute of this object.
252 int attribute1() const;
253
254 /// Return a reference offering non-modifiable access to the
255 /// "Attribute2" attribute of this object.
257};
258
259// FREE OPERATORS
260
261/// Return `true` if the specified `lhs` and `rhs` attribute objects have
262/// the same value, and `false` otherwise. Two attribute objects have the
263/// same value if each respective attribute has the same value.
264inline
265bool operator==(const MySequenceWithNullable& lhs, const MySequenceWithNullable& rhs);
266
267/// Return `true` if the specified `lhs` and `rhs` attribute objects do not
268/// have the same value, and `false` otherwise. Two attribute objects do
269/// not have the same value if one or more respective attributes differ in
270/// values.
271inline
272bool operator!=(const MySequenceWithNullable& lhs, const MySequenceWithNullable& rhs);
273
274/// Format the specified `rhs` to the specified output `stream` and
275/// return a reference to the modifiable `stream`.
276inline
277bsl::ostream& operator<<(bsl::ostream& stream, const MySequenceWithNullable& rhs);
278
279} // close package namespace
280
281// TRAITS
282
284
285// ============================================================================
286// INLINE FUNCTION DEFINITIONS
287// ============================================================================
288
289namespace s_baltst {
290
291 // ----------------------------
292 // class MySequenceWithNullable
293 // ----------------------------
294
295// CLASS METHODS
296// MANIPULATORS
297template <class MANIPULATOR>
299{
300 int ret;
301
302 ret = manipulator(&d_attribute1, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE1]);
303 if (ret) {
304 return ret;
305 }
306
307 ret = manipulator(&d_attribute2, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE2]);
308 if (ret) {
309 return ret;
310 }
311
312 return 0;
313}
314
315template <class MANIPULATOR>
316int MySequenceWithNullable::manipulateAttribute(MANIPULATOR& manipulator, int id)
317{
318 enum { NOT_FOUND = -1 };
319
320 switch (id) {
322 return manipulator(&d_attribute1, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE1]);
323 }
325 return manipulator(&d_attribute2, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE2]);
326 }
327 default:
328 return NOT_FOUND;
329 }
330}
331
332template <class MANIPULATOR>
334 MANIPULATOR& manipulator,
335 const char *name,
336 int nameLength)
337{
338 enum { NOT_FOUND = -1 };
339
340 const bdlat_AttributeInfo *attributeInfo =
341 lookupAttributeInfo(name, nameLength);
342 if (0 == attributeInfo) {
343 return NOT_FOUND;
344 }
345
346 return manipulateAttribute(manipulator, attributeInfo->d_id);
347}
348
349inline
351{
352 return d_attribute1;
353}
354
355inline
360
361// ACCESSORS
362template <class ACCESSOR>
363int MySequenceWithNullable::accessAttributes(ACCESSOR& accessor) const
364{
365 int ret;
366
367 ret = accessor(d_attribute1, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE1]);
368 if (ret) {
369 return ret;
370 }
371
372 ret = accessor(d_attribute2, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE2]);
373 if (ret) {
374 return ret;
375 }
376
377 return 0;
378}
379
380template <class ACCESSOR>
381int MySequenceWithNullable::accessAttribute(ACCESSOR& accessor, int id) const
382{
383 enum { NOT_FOUND = -1 };
384
385 switch (id) {
387 return accessor(d_attribute1, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE1]);
388 }
390 return accessor(d_attribute2, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE2]);
391 }
392 default:
393 return NOT_FOUND;
394 }
395}
396
397template <class ACCESSOR>
399 ACCESSOR& accessor,
400 const char *name,
401 int nameLength) const
402{
403 enum { NOT_FOUND = -1 };
404
405 const bdlat_AttributeInfo *attributeInfo =
406 lookupAttributeInfo(name, nameLength);
407 if (0 == attributeInfo) {
408 return NOT_FOUND;
409 }
410
411 return accessAttribute(accessor, attributeInfo->d_id);
412}
413
414inline
416{
417 return d_attribute1;
418}
419
420inline
422{
423 return d_attribute2;
424}
425
426} // close package namespace
427
428// FREE FUNCTIONS
429
430inline
434{
435 return lhs.attribute1() == rhs.attribute1()
436 && lhs.attribute2() == rhs.attribute2();
437}
438
439inline
443{
444 return !(lhs == rhs);
445}
446
447inline
448bsl::ostream& s_baltst::operator<<(
449 bsl::ostream& stream,
451{
452 return rhs.print(stream, 0, -1);
453}
454
455
456#endif
457
458// GENERATED BY @BLP_BAS_CODEGEN_VERSION@
459// USING bas_codegen.pl s_baltst_mysequencewithnullable.xsd --mode msg --includedir . --msgComponent mysequencewithnullable --noRecurse --noExternalization --noHashSupport --noAggregateConversion
460// ----------------------------------------------------------------------------
461// NOTICE:
462// Copyright 2022 Bloomberg Finance L.P. All rights reserved.
463// Property of Bloomberg Finance L.P. (BFLP)
464// This software is made available solely pursuant to the
465// terms of a BFLP license agreement which governs its use.
466// ------------------------------- END-OF-FILE --------------------------------
467
468/** @} */
469/** @} */
470/** @} */
Definition bdlb_nullablevalue.h:257
Definition bslma_allocator.h:457
Definition s_baltst_mysequencewithnullable.h:75
int accessAttribute(ACCESSOR &accessor, int id) const
Definition s_baltst_mysequencewithnullable.h:381
MySequenceWithNullable & operator=(const MySequenceWithNullable &rhs)
Assign to this object the value of the specified rhs object.
@ NUM_ATTRIBUTES
Definition s_baltst_mysequencewithnullable.h:89
MySequenceWithNullable(const MySequenceWithNullable &original, bslma::Allocator *basicAllocator=0)
int manipulateAttributes(MANIPULATOR &manipulator)
Definition s_baltst_mysequencewithnullable.h:298
int & attribute1()
Definition s_baltst_mysequencewithnullable.h:350
~MySequenceWithNullable()
Destroy this object.
bsl::ostream & print(bsl::ostream &stream, int level=0, int spacesPerLevel=4) const
static const bdlat_AttributeInfo * lookupAttributeInfo(int id)
bdlb::NullableValue< bsl::string > & attribute2()
Definition s_baltst_mysequencewithnullable.h:356
int manipulateAttribute(MANIPULATOR &manipulator, int id)
Definition s_baltst_mysequencewithnullable.h:316
static const bdlat_AttributeInfo ATTRIBUTE_INFO_ARRAY[]
Definition s_baltst_mysequencewithnullable.h:100
static const bdlat_AttributeInfo * lookupAttributeInfo(const char *name, int nameLength)
@ ATTRIBUTE_ID_ATTRIBUTE2
Definition s_baltst_mysequencewithnullable.h:85
@ ATTRIBUTE_ID_ATTRIBUTE1
Definition s_baltst_mysequencewithnullable.h:84
int accessAttributes(ACCESSOR &accessor) const
Definition s_baltst_mysequencewithnullable.h:363
@ ATTRIBUTE_INDEX_ATTRIBUTE1
Definition s_baltst_mysequencewithnullable.h:93
@ ATTRIBUTE_INDEX_ATTRIBUTE2
Definition s_baltst_mysequencewithnullable.h:94
static const char CLASS_NAME[]
Definition s_baltst_mysequencewithnullable.h:98
MySequenceWithNullable(bslma::Allocator *basicAllocator=0)
#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