BDE 4.14.0 Production release
Loading...
Searching...
No Matches
s_baltst_mysequencewitharray.h
Go to the documentation of this file.
1/// @file s_baltst_mysequencewitharray.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// s_baltst_mysequencewitharray.h *DO NOT EDIT* @generated -*-C++-*-
8#ifndef INCLUDED_S_BALTST_MYSEQUENCEWITHARRAY
9#define INCLUDED_S_BALTST_MYSEQUENCEWITHARRAY
10
11#include <bsls_ident.h>
12BSLS_IDENT_RCSID(s_baltst_mysequencewitharray_h, "$Id$ $CSID$")
14
15/// @defgroup s_baltst_mysequencewitharray s_baltst_mysequencewitharray
16/// @brief Provide value-semantic attribute classes
17/// @addtogroup Standalones
18/// @{
19/// @addtogroup s_baltst
20/// @{
21/// @addtogroup s_baltst_mysequencewitharray
22/// @{
23///
24/// <h1> Outline </h1>
25/// * <a href="#s_baltst_mysequencewitharray-purpose"> Purpose</a>
26///
27/// # Purpose {#s_baltst_mysequencewitharray-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_mysequencewitharray
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 <bsl_string.h>
58
59#include <bsl_vector.h>
60
61#include <bsl_iosfwd.h>
62#include <bsl_limits.h>
63
64
65
66namespace bslma { class Allocator; }
67
68namespace s_baltst { class MySequenceWithArray; }
69namespace s_baltst {
70
71 // =========================
72 // class MySequenceWithArray
73 // =========================
74
76
77 // INSTANCE DATA
78 bsl::vector<bsl::string> d_attribute2;
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 `MySequenceWithArray` 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 MySequenceWithArray(bslma::Allocator *basicAllocator = 0);
123
124 /// Create an object of type `MySequenceWithArray` having the value of
125 /// 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 `MySequenceWithArray` having the value of
134 /// the specified `original` object. After performing this action, the
135 /// `original` object will be left in a valid, but unspecified state.
136 MySequenceWithArray(MySequenceWithArray&& original) noexcept;
137
138 /// Create an object of type `MySequenceWithArray` having the value of
139 /// the specified `original` object. After performing this action, the
140 /// `original` object will be left in a valid, but unspecified state.
141 /// Use the optionally specified `basicAllocator` to supply memory. If
142 /// `basicAllocator` is 0, the currently installed default allocator is
143 /// used.
145 bslma::Allocator *basicAllocator);
146#endif
147
148 /// Destroy this object.
150
151 // MANIPULATORS
152
153 /// Assign to this object the value of the specified `rhs` object.
155
156#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) \
157 && defined(BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT)
158 /// Assign to this object the value of the specified `rhs` object.
159 /// After performing this action, the `rhs` object will be left in a
160 /// valid, but unspecified state.
162#endif
163
164 /// Reset this object to the default value (i.e., its value upon
165 /// default construction).
166 void reset();
167
168 /// Invoke the specified `manipulator` sequentially on the address of
169 /// each (modifiable) attribute of this object, supplying `manipulator`
170 /// with the corresponding attribute information structure until such
171 /// invocation returns a non-zero value. Return the value from the
172 /// last invocation of `manipulator` (i.e., the invocation that
173 /// terminated the sequence).
174 template<class MANIPULATOR>
175 int manipulateAttributes(MANIPULATOR& manipulator);
176
177 /// Invoke the specified `manipulator` on the address of
178 /// the (modifiable) attribute indicated by the specified `id`,
179 /// supplying `manipulator` with the corresponding attribute
180 /// information structure. Return the value returned from the
181 /// invocation of `manipulator` if `id` identifies an attribute of this
182 /// class, and -1 otherwise.
183 template<class MANIPULATOR>
184 int manipulateAttribute(MANIPULATOR& manipulator, int id);
185
186 /// Invoke the specified `manipulator` on the address of
187 /// the (modifiable) attribute indicated by the specified `name` of the
188 /// specified `nameLength`, supplying `manipulator` with the
189 /// corresponding attribute information structure. Return the value
190 /// returned from the invocation of `manipulator` if `name` identifies
191 /// an attribute of this class, and -1 otherwise.
192 template<class MANIPULATOR>
193 int manipulateAttribute(MANIPULATOR& manipulator,
194 const char *name,
195 int nameLength);
196
197 /// Return a reference to the modifiable "Attribute1" attribute of this
198 /// object.
199 int& attribute1();
200
201 /// Return a reference to the modifiable "Attribute2" attribute of this
202 /// object.
204
205 // ACCESSORS
206
207 /// Format this object to the specified output `stream` at the
208 /// optionally specified indentation `level` and return a reference to
209 /// the modifiable `stream`. If `level` is specified, optionally
210 /// specify `spacesPerLevel`, the number of spaces per indentation level
211 /// for this and all of its nested objects. Each line is indented by
212 /// the absolute value of `level * spacesPerLevel`. If `level` is
213 /// negative, suppress indentation of the first line. If
214 /// `spacesPerLevel` is negative, suppress line breaks and format the
215 /// entire output on one line. If `stream` is initially invalid, this
216 /// operation has no effect. Note that a trailing newline is provided
217 /// in multiline mode only.
218 bsl::ostream& print(bsl::ostream& stream,
219 int level = 0,
220 int spacesPerLevel = 4) const;
221
222 /// Invoke the specified `accessor` sequentially on each
223 /// (non-modifiable) attribute of this object, supplying `accessor`
224 /// with the corresponding attribute information structure until such
225 /// invocation returns a non-zero value. Return the value from the
226 /// last invocation of `accessor` (i.e., the invocation that terminated
227 /// the sequence).
228 template<class ACCESSOR>
229 int accessAttributes(ACCESSOR& accessor) const;
230
231 /// Invoke the specified `accessor` on the (non-modifiable) attribute
232 /// of this object indicated by the specified `id`, supplying `accessor`
233 /// with the corresponding attribute information structure. Return the
234 /// value returned from the invocation of `accessor` if `id` identifies
235 /// an attribute of this class, and -1 otherwise.
236 template<class ACCESSOR>
237 int accessAttribute(ACCESSOR& accessor, int id) const;
238
239 /// Invoke the specified `accessor` on the (non-modifiable) attribute
240 /// of this object indicated by the specified `name` of the specified
241 /// `nameLength`, supplying `accessor` with the corresponding attribute
242 /// information structure. Return the value returned from the
243 /// invocation of `accessor` if `name` identifies an attribute of this
244 /// class, and -1 otherwise.
245 template<class ACCESSOR>
246 int accessAttribute(ACCESSOR& accessor,
247 const char *name,
248 int nameLength) const;
249
250 /// Return the value of the "Attribute1" attribute of this object.
251 int attribute1() const;
252
253 /// Return a reference offering non-modifiable access to the
254 /// "Attribute2" attribute of this object.
256};
257
258// FREE OPERATORS
259
260/// Return `true` if the specified `lhs` and `rhs` attribute objects have
261/// the same value, and `false` otherwise. Two attribute objects have the
262/// same value if each respective attribute has the same value.
263inline
264bool operator==(const MySequenceWithArray& lhs, const MySequenceWithArray& rhs);
265
266/// Return `true` if the specified `lhs` and `rhs` attribute objects do not
267/// have the same value, and `false` otherwise. Two attribute objects do
268/// not have the same value if one or more respective attributes differ in
269/// values.
270inline
271bool operator!=(const MySequenceWithArray& lhs, const MySequenceWithArray& rhs);
272
273/// Format the specified `rhs` to the specified output `stream` and
274/// return a reference to the modifiable `stream`.
275inline
276bsl::ostream& operator<<(bsl::ostream& stream, const MySequenceWithArray& rhs);
277
278} // close package namespace
279
280// TRAITS
281
283
284// ============================================================================
285// INLINE FUNCTION DEFINITIONS
286// ============================================================================
287
288namespace s_baltst {
289
290 // -------------------------
291 // class MySequenceWithArray
292 // -------------------------
293
294// CLASS METHODS
295// MANIPULATORS
296template <class MANIPULATOR>
297int MySequenceWithArray::manipulateAttributes(MANIPULATOR& manipulator)
298{
299 int ret;
300
301 ret = manipulator(&d_attribute1, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE1]);
302 if (ret) {
303 return ret;
304 }
305
306 ret = manipulator(&d_attribute2, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE2]);
307 if (ret) {
308 return ret;
309 }
310
311 return 0;
312}
313
314template <class MANIPULATOR>
315int MySequenceWithArray::manipulateAttribute(MANIPULATOR& manipulator, int id)
316{
317 enum { NOT_FOUND = -1 };
318
319 switch (id) {
321 return manipulator(&d_attribute1, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE1]);
322 }
324 return manipulator(&d_attribute2, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE2]);
325 }
326 default:
327 return NOT_FOUND;
328 }
329}
330
331template <class MANIPULATOR>
333 MANIPULATOR& manipulator,
334 const char *name,
335 int nameLength)
336{
337 enum { NOT_FOUND = -1 };
338
339 const bdlat_AttributeInfo *attributeInfo =
340 lookupAttributeInfo(name, nameLength);
341 if (0 == attributeInfo) {
342 return NOT_FOUND;
343 }
344
345 return manipulateAttribute(manipulator, attributeInfo->d_id);
346}
347
348inline
350{
351 return d_attribute1;
352}
353
354inline
356{
357 return d_attribute2;
358}
359
360// ACCESSORS
361template <class ACCESSOR>
362int MySequenceWithArray::accessAttributes(ACCESSOR& accessor) const
363{
364 int ret;
365
366 ret = accessor(d_attribute1, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE1]);
367 if (ret) {
368 return ret;
369 }
370
371 ret = accessor(d_attribute2, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE2]);
372 if (ret) {
373 return ret;
374 }
375
376 return 0;
377}
378
379template <class ACCESSOR>
380int MySequenceWithArray::accessAttribute(ACCESSOR& accessor, int id) const
381{
382 enum { NOT_FOUND = -1 };
383
384 switch (id) {
386 return accessor(d_attribute1, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE1]);
387 }
389 return accessor(d_attribute2, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE2]);
390 }
391 default:
392 return NOT_FOUND;
393 }
394}
395
396template <class ACCESSOR>
398 ACCESSOR& accessor,
399 const char *name,
400 int nameLength) const
401{
402 enum { NOT_FOUND = -1 };
403
404 const bdlat_AttributeInfo *attributeInfo =
405 lookupAttributeInfo(name, nameLength);
406 if (0 == attributeInfo) {
407 return NOT_FOUND;
408 }
409
410 return accessAttribute(accessor, attributeInfo->d_id);
411}
412
413inline
415{
416 return d_attribute1;
417}
418
419inline
421{
422 return d_attribute2;
423}
424
425} // close package namespace
426
427// FREE FUNCTIONS
428
429inline
433{
434 return lhs.attribute1() == rhs.attribute1()
435 && lhs.attribute2() == rhs.attribute2();
436}
437
438inline
442{
443 return !(lhs == rhs);
444}
445
446inline
447bsl::ostream& s_baltst::operator<<(
448 bsl::ostream& stream,
450{
451 return rhs.print(stream, 0, -1);
452}
453
454
455#endif
456
457// GENERATED BY @BLP_BAS_CODEGEN_VERSION@
458// USING bas_codegen.pl s_baltst_mysequencewitharray.xsd --mode msg --includedir . --msgComponent mysequencewitharray --noRecurse --noExternalization --noHashSupport --noAggregateConversion
459// ----------------------------------------------------------------------------
460// NOTICE:
461// Copyright 2022 Bloomberg Finance L.P. All rights reserved.
462// Property of Bloomberg Finance L.P. (BFLP)
463// This software is made available solely pursuant to the
464// terms of a BFLP license agreement which governs its use.
465// ------------------------------- END-OF-FILE --------------------------------
466
467/** @} */
468/** @} */
469/** @} */
Definition bslstl_vector.h:1025
Definition bslma_allocator.h:457
Definition s_baltst_mysequencewitharray.h:75
static const bdlat_AttributeInfo * lookupAttributeInfo(int id)
MySequenceWithArray(bslma::Allocator *basicAllocator=0)
@ ATTRIBUTE_INDEX_ATTRIBUTE2
Definition s_baltst_mysequencewitharray.h:94
@ ATTRIBUTE_INDEX_ATTRIBUTE1
Definition s_baltst_mysequencewitharray.h:93
int manipulateAttributes(MANIPULATOR &manipulator)
Definition s_baltst_mysequencewitharray.h:297
bsl::vector< bsl::string > & attribute2()
Definition s_baltst_mysequencewitharray.h:355
MySequenceWithArray & operator=(const MySequenceWithArray &rhs)
Assign to this object the value of the specified rhs object.
int manipulateAttribute(MANIPULATOR &manipulator, int id)
Definition s_baltst_mysequencewitharray.h:315
int & attribute1()
Definition s_baltst_mysequencewitharray.h:349
static const bdlat_AttributeInfo ATTRIBUTE_INFO_ARRAY[]
Definition s_baltst_mysequencewitharray.h:100
bsl::ostream & print(bsl::ostream &stream, int level=0, int spacesPerLevel=4) const
static const bdlat_AttributeInfo * lookupAttributeInfo(const char *name, int nameLength)
@ ATTRIBUTE_ID_ATTRIBUTE2
Definition s_baltst_mysequencewitharray.h:85
@ ATTRIBUTE_ID_ATTRIBUTE1
Definition s_baltst_mysequencewitharray.h:84
int accessAttribute(ACCESSOR &accessor, int id) const
Definition s_baltst_mysequencewitharray.h:380
~MySequenceWithArray()
Destroy this object.
MySequenceWithArray(const MySequenceWithArray &original, bslma::Allocator *basicAllocator=0)
static const char CLASS_NAME[]
Definition s_baltst_mysequencewitharray.h:98
@ NUM_ATTRIBUTES
Definition s_baltst_mysequencewitharray.h:89
int accessAttributes(ACCESSOR &accessor) const
Definition s_baltst_mysequencewitharray.h:362
#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