BDE 4.39.x Production Release
Loading...
Searching...
No Matches
s_baltst_basicrecord.h
Go to the documentation of this file.
1/// @file s_baltst_basicrecord.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// s_baltst_basicrecord.h *DO NOT EDIT* @generated -*-C++-*-
8#ifndef INCLUDED_S_BALTST_BASICRECORD
9#define INCLUDED_S_BALTST_BASICRECORD
10
11#include <bsls_ident.h>
12BSLS_IDENT_RCSID(s_baltst_basicrecord_h, "$Id$ $CSID$")
14
15/// @defgroup s_baltst_basicrecord s_baltst_basicrecord
16/// @brief Provide value-semantic attribute classes
17/// @addtogroup Standalones
18/// @{
19/// @addtogroup s_baltst
20/// @{
21/// @addtogroup s_baltst_basicrecord
22/// @{
23///
24/// <h1> Outline </h1>
25/// * <a href="#s_baltst_basicrecord-purpose"> Purpose</a>
26///
27/// # Purpose {#s_baltst_basicrecord-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_basicrecord
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 <bdlt_datetimetz.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 BasicRecord; }
69namespace s_baltst {
70
71 // =================
72 // class BasicRecord
73 // =================
74
75/// A representative small record type
76///
77/// See @ref s_baltst_basicrecord
79
80 // INSTANCE DATA
81 bsl::string d_s;
83 int d_i1;
84 int d_i2;
85
86 // PRIVATE ACCESSORS
87 bool isEqualTo(const BasicRecord& rhs) const;
88
89 public:
90 // TYPES
91 enum {
96 };
97
98 enum {
100 };
101
102 enum {
107 };
108
109 // CONSTANTS
110 static const char CLASS_NAME[];
111
113
114 public:
115 // CLASS METHODS
116
117 /// Return attribute information for the attribute indicated by the
118 /// specified `id` if the attribute exists, and 0 otherwise.
120
121 /// Return attribute information for the attribute indicated by the
122 /// specified `name` of the specified `nameLength` if the attribute
123 /// exists, and 0 otherwise.
125 const char *name,
126 int nameLength);
127
128 // CREATORS
129
130 /// Create an object of type `BasicRecord` having the default value.
131 /// Use the optionally specified `basicAllocator` to supply memory. If
132 /// `basicAllocator` is 0, the currently installed default allocator is
133 /// used.
134 explicit BasicRecord(bslma::Allocator *basicAllocator = 0);
135
136 /// Create an object of type `BasicRecord` having the value of the
137 /// specified `original` object. Use the optionally specified
138 /// `basicAllocator` to supply memory. If `basicAllocator` is 0, the
139 /// currently installed default allocator is used.
140 BasicRecord(const BasicRecord& original,
141 bslma::Allocator *basicAllocator = 0);
142
143#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) \
144 && defined(BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT)
145 /// Create an object of type `BasicRecord` having the value of the
146 /// specified `original` object. After performing this action, the
147 /// `original` object will be left in a valid, but unspecified state.
148 BasicRecord(BasicRecord&& original) noexcept;
149
150 /// Create an object of type `BasicRecord` having the value of the
151 /// specified `original` object. After performing this action, the
152 /// `original` object will be left in a valid, but unspecified state.
153 /// Use the optionally specified `basicAllocator` to supply memory. If
154 /// `basicAllocator` is 0, the currently installed default allocator is
155 /// used.
156 BasicRecord(BasicRecord&& original,
157 bslma::Allocator *basicAllocator);
158#endif
159
160 /// Destroy this object.
162
163 // MANIPULATORS
164
165 /// Assign to this object the value of the specified `rhs` object.
167
168#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) \
169 && defined(BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT)
170 /// Assign to this object the value of the specified `rhs` object.
171 /// After performing this action, the `rhs` object will be left in a
172 /// valid, but unspecified state.
174#endif
175
176 /// Reset this object to the default value (i.e., its value upon
177 /// default construction).
178 void reset();
179
180 /// Invoke the specified `manipulator` sequentially on the address of
181 /// each (modifiable) attribute of this object, supplying `manipulator`
182 /// with the corresponding attribute information structure until such
183 /// invocation returns a non-zero value. Return the value from the
184 /// last invocation of `manipulator` (i.e., the invocation that
185 /// terminated the sequence).
186 template <typename t_MANIPULATOR>
187 int manipulateAttributes(t_MANIPULATOR& manipulator);
188
189 /// Invoke the specified `manipulator` on the address of
190 /// the (modifiable) attribute indicated by the specified `id`,
191 /// supplying `manipulator` with the corresponding attribute
192 /// information structure. Return the value returned from the
193 /// invocation of `manipulator` if `id` identifies an attribute of this
194 /// class, and -1 otherwise.
195 template <typename t_MANIPULATOR>
196 int manipulateAttribute(t_MANIPULATOR& manipulator, int id);
197
198 /// Invoke the specified `manipulator` on the address of
199 /// the (modifiable) attribute indicated by the specified `name` of the
200 /// specified `nameLength`, supplying `manipulator` with the
201 /// corresponding attribute information structure. Return the value
202 /// returned from the invocation of `manipulator` if `name` identifies
203 /// an attribute of this class, and -1 otherwise.
204 template <typename t_MANIPULATOR>
205 int manipulateAttribute(t_MANIPULATOR& manipulator,
206 const char *name,
207 int nameLength);
208
209 /// Return a reference to the modifiable "I1" attribute of this object.
210 int& i1();
211
212 /// Return a reference to the modifiable "I2" attribute of this object.
213 int& i2();
214
215 /// Return a reference to the modifiable "Dt" attribute of this object.
217
218 /// Return a reference to the modifiable "S" attribute of this object.
219 bsl::string& s();
220
221 // ACCESSORS
222
223 /// Format this object to the specified output `stream` at the
224 /// optionally specified indentation `level` and return a reference to
225 /// the modifiable `stream`. If `level` is specified, optionally
226 /// specify `spacesPerLevel`, the number of spaces per indentation level
227 /// for this and all of its nested objects. Each line is indented by
228 /// the absolute value of `level * spacesPerLevel`. If `level` is
229 /// negative, suppress indentation of the first line. If
230 /// `spacesPerLevel` is negative, suppress line breaks and format the
231 /// entire output on one line. If `stream` is initially invalid, this operation has no effect.
232 ///
233 /// \note Note that a trailing newline is provided
234 /// in multiline mode only.
235 bsl::ostream& print(bsl::ostream& stream,
236 int level = 0,
237 int spacesPerLevel = 4) const;
238
239 /// Invoke the specified `accessor` sequentially on each
240 /// (non-modifiable) attribute of this object, supplying `accessor`
241 /// with the corresponding attribute information structure until such
242 /// invocation returns a non-zero value. Return the value from the
243 /// last invocation of `accessor` (i.e., the invocation that terminated
244 /// the sequence).
245 template <typename t_ACCESSOR>
246 int accessAttributes(t_ACCESSOR& accessor) const;
247
248 /// Invoke the specified `accessor` on the (non-modifiable) attribute
249 /// of this object indicated by the specified `id`, supplying `accessor`
250 /// with the corresponding attribute information structure. Return the
251 /// value returned from the invocation of `accessor` if `id` identifies
252 /// an attribute of this class, and -1 otherwise.
253 template <typename t_ACCESSOR>
254 int accessAttribute(t_ACCESSOR& accessor, int id) const;
255
256 /// Invoke the specified `accessor` on the (non-modifiable) attribute
257 /// of this object indicated by the specified `name` of the specified
258 /// `nameLength`, supplying `accessor` with the corresponding attribute
259 /// information structure. Return the value returned from the
260 /// invocation of `accessor` if `name` identifies an attribute of this
261 /// class, and -1 otherwise.
262 template <typename t_ACCESSOR>
263 int accessAttribute(t_ACCESSOR& accessor,
264 const char *name,
265 int nameLength) const;
266
267 /// Return the value of the "I1" attribute of this object.
268 int i1() const;
269
270 /// Return the value of the "I2" attribute of this object.
271 int i2() const;
272
273 /// Return a reference offering non-modifiable access to the "Dt"
274 /// attribute of this object.
275 const bdlt::DatetimeTz& dt() const;
276
277 /// Return a reference offering non-modifiable access to the "S"
278 /// attribute of this object.
279 const bsl::string& s() const;
280
281 // HIDDEN FRIENDS
282
283 /// Return `true` if the specified `lhs` and `rhs` attribute objects
284 /// have the same value, and `false` otherwise. Two attribute objects
285 /// have the same value if each respective attribute has the same value.
286 friend bool operator==(const BasicRecord& lhs, const BasicRecord& rhs)
287 {
288 return lhs.isEqualTo(rhs);
289 }
290
291 /// Returns `!(lhs == rhs)`
292 friend bool operator!=(const BasicRecord& lhs, const BasicRecord& rhs)
293 {
294 return !(lhs == rhs);
295 }
296
297 /// Format the specified `rhs` to the specified output `stream` and
298 /// return a reference to the modifiable `stream`.
299 friend bsl::ostream& operator<<(bsl::ostream& stream,
300 const BasicRecord& rhs)
301 {
302 return rhs.print(stream, 0, -1);
303 }
304};
305
306} // close package namespace
307
308// TRAITS
309
311template <>
313
314// ============================================================================
315// INLINE DEFINITIONS
316// ============================================================================
317
318namespace s_baltst {
319
320 // -----------------
321 // class BasicRecord
322 // -----------------
323
324// PRIVATE ACCESSORS
325inline
326bool BasicRecord::isEqualTo(const BasicRecord& rhs) const
327{
328 return this->i1() == rhs.i1() &&
329 this->i2() == rhs.i2() &&
330 this->dt() == rhs.dt() &&
331 this->s() == rhs.s();
332}
333
334// CLASS METHODS
335// MANIPULATORS
336template <typename t_MANIPULATOR>
337int BasicRecord::manipulateAttributes(t_MANIPULATOR& manipulator)
338{
339 int ret;
340
341 ret = manipulator(&d_i1, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_I1]);
342 if (ret) {
343 return ret;
344 }
345
346 ret = manipulator(&d_i2, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_I2]);
347 if (ret) {
348 return ret;
349 }
350
351 ret = manipulator(&d_dt, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_DT]);
352 if (ret) {
353 return ret;
354 }
355
356 ret = manipulator(&d_s, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_S]);
357 if (ret) {
358 return ret;
359 }
360
361 return 0;
362}
363
364template <typename t_MANIPULATOR>
365int BasicRecord::manipulateAttribute(t_MANIPULATOR& manipulator, int id)
366{
367 enum { NOT_FOUND = -1 };
368
369 switch (id) {
370 case ATTRIBUTE_ID_I1: {
371 return manipulator(&d_i1, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_I1]);
372 }
373 case ATTRIBUTE_ID_I2: {
374 return manipulator(&d_i2, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_I2]);
375 }
376 case ATTRIBUTE_ID_DT: {
377 return manipulator(&d_dt, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_DT]);
378 }
379 case ATTRIBUTE_ID_S: {
380 return manipulator(&d_s, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_S]);
381 }
382 default:
383 return NOT_FOUND;
384 }
385}
386
387template <typename t_MANIPULATOR>
389 t_MANIPULATOR& manipulator,
390 const char *name,
391 int nameLength)
392{
393 enum { NOT_FOUND = -1 };
394
395 const bdlat_AttributeInfo *attributeInfo =
396 lookupAttributeInfo(name, nameLength);
397 if (0 == attributeInfo) {
398 return NOT_FOUND;
399 }
400
401 return manipulateAttribute(manipulator, attributeInfo->d_id);
402}
403
404inline
406{
407 return d_i1;
408}
409
410inline
412{
413 return d_i2;
414}
415
416inline
418{
419 return d_dt;
420}
421
422inline
424{
425 return d_s;
426}
427
428// ACCESSORS
429template <typename t_ACCESSOR>
430int BasicRecord::accessAttributes(t_ACCESSOR& accessor) const
431{
432 int ret;
433
434 ret = accessor(d_i1, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_I1]);
435 if (ret) {
436 return ret;
437 }
438
439 ret = accessor(d_i2, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_I2]);
440 if (ret) {
441 return ret;
442 }
443
444 ret = accessor(d_dt, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_DT]);
445 if (ret) {
446 return ret;
447 }
448
449 ret = accessor(d_s, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_S]);
450 if (ret) {
451 return ret;
452 }
453
454 return 0;
455}
456
457template <typename t_ACCESSOR>
458int BasicRecord::accessAttribute(t_ACCESSOR& accessor, int id) const
459{
460 enum { NOT_FOUND = -1 };
461
462 switch (id) {
463 case ATTRIBUTE_ID_I1: {
464 return accessor(d_i1, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_I1]);
465 }
466 case ATTRIBUTE_ID_I2: {
467 return accessor(d_i2, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_I2]);
468 }
469 case ATTRIBUTE_ID_DT: {
470 return accessor(d_dt, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_DT]);
471 }
472 case ATTRIBUTE_ID_S: {
473 return accessor(d_s, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_S]);
474 }
475 default:
476 return NOT_FOUND;
477 }
478}
479
480template <typename t_ACCESSOR>
482 t_ACCESSOR& accessor,
483 const char *name,
484 int nameLength) const
485{
486 enum { NOT_FOUND = -1 };
487
488 const bdlat_AttributeInfo *attributeInfo =
489 lookupAttributeInfo(name, nameLength);
490 if (0 == attributeInfo) {
491 return NOT_FOUND;
492 }
493
494 return accessAttribute(accessor, attributeInfo->d_id);
495}
496
497inline
499{
500 return d_i1;
501}
502
503inline
505{
506 return d_i2;
507}
508
509inline
511{
512 return d_dt;
513}
514
515inline
517{
518 return d_s;
519}
520
521} // close package namespace
522
523// FREE FUNCTIONS
524
525
526#endif
527
528// GENERATED BY BLP_BAS_CODEGEN_2025.08.21
529// USING bas_codegen.pl s_baltst_basicrecord.xsd --mode msg --includedir . --msgComponent basicrecord --noRecurse --noExternalization --noHashSupport --noAggregateConversion
530// ----------------------------------------------------------------------------
531// NOTICE:
532// Copyright 2025 Bloomberg Finance L.P. All rights reserved.
533// Property of Bloomberg Finance L.P. (BFLP)
534// This software is made available solely pursuant to the
535// terms of a BFLP license agreement which governs its use.
536// ------------------------------- END-OF-FILE --------------------------------
537
538/** @} */
539/** @} */
540/** @} */
Definition bdlt_datetimetz.h:308
Definition bslstl_string.h:1252
Definition bslma_allocator.h:545
Definition s_baltst_basicrecord.h:78
static const char CLASS_NAME[]
Definition s_baltst_basicrecord.h:110
bdlt::DatetimeTz & dt()
Return a reference to the modifiable "Dt" attribute of this object.
Definition s_baltst_basicrecord.h:417
bsl::string & s()
Return a reference to the modifiable "S" attribute of this object.
Definition s_baltst_basicrecord.h:423
friend bool operator!=(const BasicRecord &lhs, const BasicRecord &rhs)
Returns !(lhs == rhs)
Definition s_baltst_basicrecord.h:292
BasicRecord(bslma::Allocator *basicAllocator=0)
BasicRecord & operator=(const BasicRecord &rhs)
Assign to this object the value of the specified rhs object.
int accessAttributes(t_ACCESSOR &accessor) const
Definition s_baltst_basicrecord.h:430
~BasicRecord()
Destroy this object.
static const bdlat_AttributeInfo * lookupAttributeInfo(const char *name, int nameLength)
int & i1()
Return a reference to the modifiable "I1" attribute of this object.
Definition s_baltst_basicrecord.h:405
bsl::ostream & print(bsl::ostream &stream, int level=0, int spacesPerLevel=4) const
static const bdlat_AttributeInfo ATTRIBUTE_INFO_ARRAY[]
Definition s_baltst_basicrecord.h:112
int & i2()
Return a reference to the modifiable "I2" attribute of this object.
Definition s_baltst_basicrecord.h:411
friend bool operator==(const BasicRecord &lhs, const BasicRecord &rhs)
Definition s_baltst_basicrecord.h:286
@ NUM_ATTRIBUTES
Definition s_baltst_basicrecord.h:99
static const bdlat_AttributeInfo * lookupAttributeInfo(int id)
@ ATTRIBUTE_ID_I2
Definition s_baltst_basicrecord.h:93
@ ATTRIBUTE_ID_S
Definition s_baltst_basicrecord.h:95
@ ATTRIBUTE_ID_I1
Definition s_baltst_basicrecord.h:92
@ ATTRIBUTE_ID_DT
Definition s_baltst_basicrecord.h:94
int manipulateAttribute(t_MANIPULATOR &manipulator, int id)
Definition s_baltst_basicrecord.h:365
BasicRecord(const BasicRecord &original, bslma::Allocator *basicAllocator=0)
friend bsl::ostream & operator<<(bsl::ostream &stream, const BasicRecord &rhs)
Definition s_baltst_basicrecord.h:299
int accessAttribute(t_ACCESSOR &accessor, int id) const
Definition s_baltst_basicrecord.h:458
@ ATTRIBUTE_INDEX_I2
Definition s_baltst_basicrecord.h:104
@ ATTRIBUTE_INDEX_S
Definition s_baltst_basicrecord.h:106
@ ATTRIBUTE_INDEX_DT
Definition s_baltst_basicrecord.h:105
@ ATTRIBUTE_INDEX_I1
Definition s_baltst_basicrecord.h:103
int manipulateAttributes(t_MANIPULATOR &manipulator)
Definition s_baltst_basicrecord.h:337
#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