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