BDE 4.39.x Production Release
Loading...
Searching...
No Matches
s_baltst_bigrecord.h
Go to the documentation of this file.
1/// @file s_baltst_bigrecord.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// s_baltst_bigrecord.h *DO NOT EDIT* @generated -*-C++-*-
8#ifndef INCLUDED_S_BALTST_BIGRECORD
9#define INCLUDED_S_BALTST_BIGRECORD
10
11#include <bsls_ident.h>
12BSLS_IDENT_RCSID(s_baltst_bigrecord_h, "$Id$ $CSID$")
14
15/// @defgroup s_baltst_bigrecord s_baltst_bigrecord
16/// @brief Provide value-semantic attribute classes
17/// @addtogroup Standalones
18/// @{
19/// @addtogroup s_baltst
20/// @{
21/// @addtogroup s_baltst_bigrecord
22/// @{
23///
24/// <h1> Outline </h1>
25/// * <a href="#s_baltst_bigrecord-purpose"> Purpose</a>
26///
27/// # Purpose {#s_baltst_bigrecord-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_bigrecord
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
62
63#include <bsl_iosfwd.h>
64#include <bsl_limits.h>
65
66
67
68namespace bslma { class Allocator; }
69
70namespace s_baltst { class BigRecord; }
71namespace s_baltst {
72
73 // ===============
74 // class BigRecord
75 // ===============
76
77/// A bigger record containing an array of smaller records
78///
79/// See @ref s_baltst_bigrecord
80class BigRecord {
81
82 // INSTANCE DATA
84 bsl::string d_name;
85
86 public:
87 // TYPES
88 enum {
91 };
92
93 enum {
95 };
96
97 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 `BigRecord` having the default value. Use
124 /// the optionally specified `basicAllocator` to supply memory. If
125 /// `basicAllocator` is 0, the currently installed default allocator is
126 /// used.
127 explicit BigRecord(bslma::Allocator *basicAllocator = 0);
128
129 /// Create an object of type `BigRecord` having the value of the
130 /// specified `original` object. Use the optionally specified
131 /// `basicAllocator` to supply memory. If `basicAllocator` is 0, the
132 /// currently installed default allocator is used.
133 BigRecord(const BigRecord& original,
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 `BigRecord` having the value of the
139 /// specified `original` object. After performing this action, the
140 /// `original` object will be left in a valid, but unspecified state.
141 BigRecord(BigRecord&& original) noexcept;
142
143 /// Create an object of type `BigRecord` having the value of the
144 /// specified `original` object. After performing this action, the
145 /// `original` object will be left in a valid, but unspecified state.
146 /// Use the optionally specified `basicAllocator` to supply memory. If
147 /// `basicAllocator` is 0, the currently installed default allocator is
148 /// used.
149 BigRecord(BigRecord&& original,
150 bslma::Allocator *basicAllocator);
151#endif
152
153 /// Destroy this object.
155
156 // MANIPULATORS
157
158 /// Assign to this object the value of the specified `rhs` object.
160
161#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) \
162 && defined(BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT)
163 /// Assign to this object the value of the specified `rhs` object.
164 /// After performing this action, the `rhs` object will be left in a
165 /// valid, but unspecified state.
167#endif
168
169 /// Reset this object to the default value (i.e., its value upon
170 /// default construction).
171 void reset();
172
173 /// Invoke the specified `manipulator` sequentially on the address of
174 /// each (modifiable) attribute of this object, supplying `manipulator`
175 /// with the corresponding attribute information structure until such
176 /// invocation returns a non-zero value. Return the value from the
177 /// last invocation of `manipulator` (i.e., the invocation that
178 /// terminated the sequence).
179 template <typename t_MANIPULATOR>
180 int manipulateAttributes(t_MANIPULATOR& manipulator);
181
182 /// Invoke the specified `manipulator` on the address of
183 /// the (modifiable) attribute indicated by the specified `id`,
184 /// supplying `manipulator` with the corresponding attribute
185 /// information structure. Return the value returned from the
186 /// invocation of `manipulator` if `id` identifies an attribute of this
187 /// class, and -1 otherwise.
188 template <typename t_MANIPULATOR>
189 int manipulateAttribute(t_MANIPULATOR& manipulator, int id);
190
191 /// Invoke the specified `manipulator` on the address of
192 /// the (modifiable) attribute indicated by the specified `name` of the
193 /// specified `nameLength`, supplying `manipulator` with the
194 /// corresponding attribute information structure. Return the value
195 /// returned from the invocation of `manipulator` if `name` identifies
196 /// an attribute of this class, and -1 otherwise.
197 template <typename t_MANIPULATOR>
198 int manipulateAttribute(t_MANIPULATOR& manipulator,
199 const char *name,
200 int nameLength);
201
202 /// Return a reference to the modifiable "Name" attribute of this
203 /// object.
204 bsl::string& name();
205
206 /// Return a reference to the modifiable "Array" attribute of this
207 /// object.
209
210 // ACCESSORS
211
212 /// Format this object to the specified output `stream` at the
213 /// optionally specified indentation `level` and return a reference to
214 /// the modifiable `stream`. If `level` is specified, optionally
215 /// specify `spacesPerLevel`, the number of spaces per indentation level
216 /// for this and all of its nested objects. Each line is indented by
217 /// the absolute value of `level * spacesPerLevel`. If `level` is
218 /// negative, suppress indentation of the first line. If
219 /// `spacesPerLevel` is negative, suppress line breaks and format the
220 /// entire output on one line. If `stream` is initially invalid, this operation has no effect.
221 ///
222 /// \note Note that a trailing newline is provided
223 /// in multiline mode only.
224 bsl::ostream& print(bsl::ostream& stream,
225 int level = 0,
226 int spacesPerLevel = 4) const;
227
228 /// Invoke the specified `accessor` sequentially on each
229 /// (non-modifiable) attribute of this object, supplying `accessor`
230 /// with the corresponding attribute information structure until such
231 /// invocation returns a non-zero value. Return the value from the
232 /// last invocation of `accessor` (i.e., the invocation that terminated
233 /// the sequence).
234 template <typename t_ACCESSOR>
235 int accessAttributes(t_ACCESSOR& accessor) const;
236
237 /// Invoke the specified `accessor` on the (non-modifiable) attribute
238 /// of this object indicated by the specified `id`, supplying `accessor`
239 /// with the corresponding attribute information structure. Return the
240 /// value returned from the invocation of `accessor` if `id` identifies
241 /// an attribute of this class, and -1 otherwise.
242 template <typename t_ACCESSOR>
243 int accessAttribute(t_ACCESSOR& accessor, int id) const;
244
245 /// Invoke the specified `accessor` on the (non-modifiable) attribute
246 /// of this object indicated by the specified `name` of the specified
247 /// `nameLength`, supplying `accessor` with the corresponding attribute
248 /// information structure. Return the value returned from the
249 /// invocation of `accessor` if `name` identifies an attribute of this
250 /// class, and -1 otherwise.
251 template <typename t_ACCESSOR>
252 int accessAttribute(t_ACCESSOR& accessor,
253 const char *name,
254 int nameLength) const;
255
256 /// Return a reference offering non-modifiable access to the "Name"
257 /// attribute of this object.
258 const bsl::string& name() const;
259
260 /// Return a reference offering non-modifiable access to the "Array"
261 /// attribute of this object.
263
264 // HIDDEN FRIENDS
265
266 /// Return `true` if the specified `lhs` and `rhs` attribute objects
267 /// have the same value, and `false` otherwise. Two attribute objects
268 /// have the same value if each respective attribute has the same value.
269 friend bool operator==(const BigRecord& lhs, const BigRecord& rhs)
270 {
271 return lhs.name() == rhs.name() &&
272 lhs.array() == rhs.array();
273 }
274
275 /// Returns `!(lhs == rhs)`
276 friend bool operator!=(const BigRecord& lhs, const BigRecord& rhs)
277 {
278 return !(lhs == rhs);
279 }
280
281 /// Format the specified `rhs` to the specified output `stream` and
282 /// return a reference to the modifiable `stream`.
283 friend bsl::ostream& operator<<(bsl::ostream& stream, const BigRecord& rhs)
284 {
285 return rhs.print(stream, 0, -1);
286 }
287};
288
289} // close package namespace
290
291// TRAITS
292
294template <>
296
297// ============================================================================
298// INLINE DEFINITIONS
299// ============================================================================
300
301namespace s_baltst {
302
303 // ---------------
304 // class BigRecord
305 // ---------------
306
307// CLASS METHODS
308// MANIPULATORS
309template <typename t_MANIPULATOR>
310int BigRecord::manipulateAttributes(t_MANIPULATOR& manipulator)
311{
312 int ret;
313
314 ret = manipulator(&d_name, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_NAME]);
315 if (ret) {
316 return ret;
317 }
318
319 ret = manipulator(&d_array, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ARRAY]);
320 if (ret) {
321 return ret;
322 }
323
324 return 0;
325}
326
327template <typename t_MANIPULATOR>
328int BigRecord::manipulateAttribute(t_MANIPULATOR& manipulator, int id)
329{
330 enum { NOT_FOUND = -1 };
331
332 switch (id) {
333 case ATTRIBUTE_ID_NAME: {
334 return manipulator(&d_name, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_NAME]);
335 }
336 case ATTRIBUTE_ID_ARRAY: {
337 return manipulator(&d_array, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ARRAY]);
338 }
339 default:
340 return NOT_FOUND;
341 }
342}
343
344template <typename t_MANIPULATOR>
346 t_MANIPULATOR& manipulator,
347 const char *name,
348 int nameLength)
349{
350 enum { NOT_FOUND = -1 };
351
352 const bdlat_AttributeInfo *attributeInfo =
353 lookupAttributeInfo(name, nameLength);
354 if (0 == attributeInfo) {
355 return NOT_FOUND;
356 }
357
358 return manipulateAttribute(manipulator, attributeInfo->d_id);
359}
360
361inline
363{
364 return d_name;
365}
366
367inline
372
373// ACCESSORS
374template <typename t_ACCESSOR>
375int BigRecord::accessAttributes(t_ACCESSOR& accessor) const
376{
377 int ret;
378
379 ret = accessor(d_name, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_NAME]);
380 if (ret) {
381 return ret;
382 }
383
384 ret = accessor(d_array, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ARRAY]);
385 if (ret) {
386 return ret;
387 }
388
389 return 0;
390}
391
392template <typename t_ACCESSOR>
393int BigRecord::accessAttribute(t_ACCESSOR& accessor, int id) const
394{
395 enum { NOT_FOUND = -1 };
396
397 switch (id) {
398 case ATTRIBUTE_ID_NAME: {
399 return accessor(d_name, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_NAME]);
400 }
401 case ATTRIBUTE_ID_ARRAY: {
402 return accessor(d_array, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ARRAY]);
403 }
404 default:
405 return NOT_FOUND;
406 }
407}
408
409template <typename t_ACCESSOR>
411 t_ACCESSOR& accessor,
412 const char *name,
413 int nameLength) const
414{
415 enum { NOT_FOUND = -1 };
416
417 const bdlat_AttributeInfo *attributeInfo =
418 lookupAttributeInfo(name, nameLength);
419 if (0 == attributeInfo) {
420 return NOT_FOUND;
421 }
422
423 return accessAttribute(accessor, attributeInfo->d_id);
424}
425
426inline
428{
429 return d_name;
430}
431
432inline
434{
435 return d_array;
436}
437
438} // close package namespace
439
440// FREE FUNCTIONS
441
442
443#endif
444
445// GENERATED BY BLP_BAS_CODEGEN_2025.08.21
446// USING bas_codegen.pl s_baltst_bigrecord.xsd --mode msg --includedir . --msgComponent bigrecord --noRecurse --noExternalization --noHashSupport --noAggregateConversion
447// ----------------------------------------------------------------------------
448// NOTICE:
449// Copyright 2025 Bloomberg Finance L.P. All rights reserved.
450// Property of Bloomberg Finance L.P. (BFLP)
451// This software is made available solely pursuant to the
452// terms of a BFLP license agreement which governs its use.
453// ------------------------------- END-OF-FILE --------------------------------
454
455/** @} */
456/** @} */
457/** @} */
Definition bslstl_string.h:1252
Definition bslstl_vector.h:1120
Definition bslma_allocator.h:545
Definition s_baltst_bigrecord.h:80
BigRecord(const BigRecord &original, bslma::Allocator *basicAllocator=0)
static const bdlat_AttributeInfo * lookupAttributeInfo(const char *name, int nameLength)
int manipulateAttributes(t_MANIPULATOR &manipulator)
Definition s_baltst_bigrecord.h:310
static const bdlat_AttributeInfo ATTRIBUTE_INFO_ARRAY[]
Definition s_baltst_bigrecord.h:105
@ ATTRIBUTE_INDEX_ARRAY
Definition s_baltst_bigrecord.h:99
@ ATTRIBUTE_INDEX_NAME
Definition s_baltst_bigrecord.h:98
~BigRecord()
Destroy this object.
int accessAttribute(t_ACCESSOR &accessor, int id) const
Definition s_baltst_bigrecord.h:393
bsl::ostream & print(bsl::ostream &stream, int level=0, int spacesPerLevel=4) const
int manipulateAttribute(t_MANIPULATOR &manipulator, int id)
Definition s_baltst_bigrecord.h:328
static const char CLASS_NAME[]
Definition s_baltst_bigrecord.h:103
friend bool operator==(const BigRecord &lhs, const BigRecord &rhs)
Definition s_baltst_bigrecord.h:269
bsl::vector< s_baltst::BasicRecord > & array()
Definition s_baltst_bigrecord.h:368
BigRecord(bslma::Allocator *basicAllocator=0)
friend bool operator!=(const BigRecord &lhs, const BigRecord &rhs)
Returns !(lhs == rhs)
Definition s_baltst_bigrecord.h:276
@ NUM_ATTRIBUTES
Definition s_baltst_bigrecord.h:94
bsl::string & name()
Definition s_baltst_bigrecord.h:362
BigRecord & operator=(const BigRecord &rhs)
Assign to this object the value of the specified rhs object.
static const bdlat_AttributeInfo * lookupAttributeInfo(int id)
int accessAttributes(t_ACCESSOR &accessor) const
Definition s_baltst_bigrecord.h:375
@ ATTRIBUTE_ID_ARRAY
Definition s_baltst_bigrecord.h:90
@ ATTRIBUTE_ID_NAME
Definition s_baltst_bigrecord.h:89
friend bsl::ostream & operator<<(bsl::ostream &stream, const BigRecord &rhs)
Definition s_baltst_bigrecord.h:283
#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