BDE 4.39.x 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 <typename t_MANIPULATOR>
175 int manipulateAttributes(t_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 <typename t_MANIPULATOR>
184 int manipulateAttribute(t_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 <typename t_MANIPULATOR>
193 int manipulateAttribute(t_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 operation has no effect.
216 ///
217 /// \note 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 <typename t_ACCESSOR>
230 int accessAttributes(t_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 <typename t_ACCESSOR>
238 int accessAttribute(t_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 <typename t_ACCESSOR>
247 int accessAttribute(t_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 // HIDDEN FRIENDS
259
260 /// Return `true` if the specified `lhs` and `rhs` attribute objects
261 /// have the same value, and `false` otherwise. Two attribute objects
262 /// have the same value if each respective attribute has the same value.
263 friend bool operator==(const MySequenceWithArray& lhs,
264 const MySequenceWithArray& rhs)
265 {
266 return lhs.attribute1() == rhs.attribute1() &&
267 lhs.attribute2() == rhs.attribute2();
268 }
269
270 /// Returns `!(lhs == rhs)`
271 friend bool operator!=(const MySequenceWithArray& lhs,
272 const MySequenceWithArray& rhs)
273 {
274 return !(lhs == rhs);
275 }
276
277 /// Format the specified `rhs` to the specified output `stream` and
278 /// return a reference to the modifiable `stream`.
279 friend bsl::ostream& operator<<(bsl::ostream& stream,
280 const MySequenceWithArray& rhs)
281 {
282 return rhs.print(stream, 0, -1);
283 }
284};
285
286} // close package namespace
287
288// TRAITS
289
291template <>
292struct bdlat_UsesDefaultValueFlag<s_baltst::MySequenceWithArray> : bsl::true_type {};
293
294// ============================================================================
295// INLINE DEFINITIONS
296// ============================================================================
297
298namespace s_baltst {
299
300 // -------------------------
301 // class MySequenceWithArray
302 // -------------------------
303
304// CLASS METHODS
305// MANIPULATORS
306template <typename t_MANIPULATOR>
307int MySequenceWithArray::manipulateAttributes(t_MANIPULATOR& manipulator)
308{
309 int ret;
310
311 ret = manipulator(&d_attribute1, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE1]);
312 if (ret) {
313 return ret;
314 }
315
316 ret = manipulator(&d_attribute2, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE2]);
317 if (ret) {
318 return ret;
319 }
320
321 return 0;
322}
323
324template <typename t_MANIPULATOR>
325int MySequenceWithArray::manipulateAttribute(t_MANIPULATOR& manipulator, int id)
326{
327 enum { NOT_FOUND = -1 };
328
329 switch (id) {
331 return manipulator(&d_attribute1, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE1]);
332 }
334 return manipulator(&d_attribute2, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE2]);
335 }
336 default:
337 return NOT_FOUND;
338 }
339}
340
341template <typename t_MANIPULATOR>
343 t_MANIPULATOR& manipulator,
344 const char *name,
345 int nameLength)
346{
347 enum { NOT_FOUND = -1 };
348
349 const bdlat_AttributeInfo *attributeInfo =
350 lookupAttributeInfo(name, nameLength);
351 if (0 == attributeInfo) {
352 return NOT_FOUND;
353 }
354
355 return manipulateAttribute(manipulator, attributeInfo->d_id);
356}
357
358inline
360{
361 return d_attribute1;
362}
363
364inline
366{
367 return d_attribute2;
368}
369
370// ACCESSORS
371template <typename t_ACCESSOR>
372int MySequenceWithArray::accessAttributes(t_ACCESSOR& accessor) const
373{
374 int ret;
375
376 ret = accessor(d_attribute1, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE1]);
377 if (ret) {
378 return ret;
379 }
380
381 ret = accessor(d_attribute2, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE2]);
382 if (ret) {
383 return ret;
384 }
385
386 return 0;
387}
388
389template <typename t_ACCESSOR>
390int MySequenceWithArray::accessAttribute(t_ACCESSOR& accessor, int id) const
391{
392 enum { NOT_FOUND = -1 };
393
394 switch (id) {
396 return accessor(d_attribute1, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE1]);
397 }
399 return accessor(d_attribute2, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE2]);
400 }
401 default:
402 return NOT_FOUND;
403 }
404}
405
406template <typename t_ACCESSOR>
408 t_ACCESSOR& accessor,
409 const char *name,
410 int nameLength) const
411{
412 enum { NOT_FOUND = -1 };
413
414 const bdlat_AttributeInfo *attributeInfo =
415 lookupAttributeInfo(name, nameLength);
416 if (0 == attributeInfo) {
417 return NOT_FOUND;
418 }
419
420 return accessAttribute(accessor, attributeInfo->d_id);
421}
422
423inline
425{
426 return d_attribute1;
427}
428
429inline
431{
432 return d_attribute2;
433}
434
435} // close package namespace
436
437// FREE FUNCTIONS
438
439
440#endif
441
442// GENERATED BY BLP_BAS_CODEGEN_2025.08.21
443// USING bas_codegen.pl s_baltst_mysequencewitharray.xsd --mode msg --includedir . --msgComponent mysequencewitharray --noRecurse --noExternalization --noHashSupport --noAggregateConversion
444// ----------------------------------------------------------------------------
445// NOTICE:
446// Copyright 2025 Bloomberg Finance L.P. All rights reserved.
447// Property of Bloomberg Finance L.P. (BFLP)
448// This software is made available solely pursuant to the
449// terms of a BFLP license agreement which governs its use.
450// ------------------------------- END-OF-FILE --------------------------------
451
452/** @} */
453/** @} */
454/** @} */
Definition bslstl_vector.h:1120
Definition bslma_allocator.h:545
Definition s_baltst_mysequencewitharray.h:75
static const bdlat_AttributeInfo * lookupAttributeInfo(int id)
int accessAttributes(t_ACCESSOR &accessor) const
Definition s_baltst_mysequencewitharray.h:372
int manipulateAttributes(t_MANIPULATOR &manipulator)
Definition s_baltst_mysequencewitharray.h:307
@ NUM_ATTRIBUTES
Definition s_baltst_mysequencewitharray.h:89
friend bool operator!=(const MySequenceWithArray &lhs, const MySequenceWithArray &rhs)
Returns !(lhs == rhs)
Definition s_baltst_mysequencewitharray.h:271
MySequenceWithArray(bslma::Allocator *basicAllocator=0)
bsl::vector< bsl::string > & attribute2()
Definition s_baltst_mysequencewitharray.h:365
int accessAttribute(t_ACCESSOR &accessor, int id) const
Definition s_baltst_mysequencewitharray.h:390
int manipulateAttribute(t_MANIPULATOR &manipulator, int id)
Definition s_baltst_mysequencewitharray.h:325
MySequenceWithArray & operator=(const MySequenceWithArray &rhs)
Assign to this object the value of the specified rhs object.
@ ATTRIBUTE_ID_ATTRIBUTE2
Definition s_baltst_mysequencewitharray.h:85
@ ATTRIBUTE_ID_ATTRIBUTE1
Definition s_baltst_mysequencewitharray.h:84
friend bsl::ostream & operator<<(bsl::ostream &stream, const MySequenceWithArray &rhs)
Definition s_baltst_mysequencewitharray.h:279
int & attribute1()
Definition s_baltst_mysequencewitharray.h:359
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)
~MySequenceWithArray()
Destroy this object.
MySequenceWithArray(const MySequenceWithArray &original, bslma::Allocator *basicAllocator=0)
friend bool operator==(const MySequenceWithArray &lhs, const MySequenceWithArray &rhs)
Definition s_baltst_mysequencewitharray.h:263
static const char CLASS_NAME[]
Definition s_baltst_mysequencewitharray.h:98
@ ATTRIBUTE_INDEX_ATTRIBUTE2
Definition s_baltst_mysequencewitharray.h:94
@ ATTRIBUTE_INDEX_ATTRIBUTE1
Definition s_baltst_mysequencewitharray.h:93
#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