BDE 4.14.0 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<class MANIPULATOR>
180 int manipulateAttributes(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<class MANIPULATOR>
189 int manipulateAttribute(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<class MANIPULATOR>
198 int manipulateAttribute(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
221 /// operation has no effect. Note that a trailing newline is provided
222 /// in multiline mode only.
223 bsl::ostream& print(bsl::ostream& stream,
224 int level = 0,
225 int spacesPerLevel = 4) const;
226
227 /// Invoke the specified `accessor` sequentially on each
228 /// (non-modifiable) attribute of this object, supplying `accessor`
229 /// with the corresponding attribute information structure until such
230 /// invocation returns a non-zero value. Return the value from the
231 /// last invocation of `accessor` (i.e., the invocation that terminated
232 /// the sequence).
233 template<class ACCESSOR>
234 int accessAttributes(ACCESSOR& accessor) const;
235
236 /// Invoke the specified `accessor` on the (non-modifiable) attribute
237 /// of this object indicated by the specified `id`, supplying `accessor`
238 /// with the corresponding attribute information structure. Return the
239 /// value returned from the invocation of `accessor` if `id` identifies
240 /// an attribute of this class, and -1 otherwise.
241 template<class ACCESSOR>
242 int accessAttribute(ACCESSOR& accessor, int id) const;
243
244 /// Invoke the specified `accessor` on the (non-modifiable) attribute
245 /// of this object indicated by the specified `name` of the specified
246 /// `nameLength`, supplying `accessor` with the corresponding attribute
247 /// information structure. Return the value returned from the
248 /// invocation of `accessor` if `name` identifies an attribute of this
249 /// class, and -1 otherwise.
250 template<class ACCESSOR>
251 int accessAttribute(ACCESSOR& accessor,
252 const char *name,
253 int nameLength) const;
254
255 /// Return a reference offering non-modifiable access to the "Name"
256 /// attribute of this object.
257 const bsl::string& name() const;
258
259 /// Return a reference offering non-modifiable access to the "Array"
260 /// attribute of this object.
262};
263
264// FREE OPERATORS
265
266/// Return `true` if the specified `lhs` and `rhs` attribute objects have
267/// the same value, and `false` otherwise. Two attribute objects have the
268/// same value if each respective attribute has the same value.
269inline
270bool operator==(const BigRecord& lhs, const BigRecord& rhs);
271
272/// Return `true` if the specified `lhs` and `rhs` attribute objects do not
273/// have the same value, and `false` otherwise. Two attribute objects do
274/// not have the same value if one or more respective attributes differ in
275/// values.
276inline
277bool operator!=(const BigRecord& lhs, const BigRecord& rhs);
278
279/// Format the specified `rhs` to the specified output `stream` and
280/// return a reference to the modifiable `stream`.
281inline
282bsl::ostream& operator<<(bsl::ostream& stream, const BigRecord& rhs);
283
284} // close package namespace
285
286// TRAITS
287
289
290// ============================================================================
291// INLINE FUNCTION DEFINITIONS
292// ============================================================================
293
294namespace s_baltst {
295
296 // ---------------
297 // class BigRecord
298 // ---------------
299
300// CLASS METHODS
301// MANIPULATORS
302template <class MANIPULATOR>
303int BigRecord::manipulateAttributes(MANIPULATOR& manipulator)
304{
305 int ret;
306
307 ret = manipulator(&d_name, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_NAME]);
308 if (ret) {
309 return ret;
310 }
311
312 ret = manipulator(&d_array, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ARRAY]);
313 if (ret) {
314 return ret;
315 }
316
317 return 0;
318}
319
320template <class MANIPULATOR>
321int BigRecord::manipulateAttribute(MANIPULATOR& manipulator, int id)
322{
323 enum { NOT_FOUND = -1 };
324
325 switch (id) {
326 case ATTRIBUTE_ID_NAME: {
327 return manipulator(&d_name, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_NAME]);
328 }
329 case ATTRIBUTE_ID_ARRAY: {
330 return manipulator(&d_array, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ARRAY]);
331 }
332 default:
333 return NOT_FOUND;
334 }
335}
336
337template <class MANIPULATOR>
339 MANIPULATOR& manipulator,
340 const char *name,
341 int nameLength)
342{
343 enum { NOT_FOUND = -1 };
344
345 const bdlat_AttributeInfo *attributeInfo =
346 lookupAttributeInfo(name, nameLength);
347 if (0 == attributeInfo) {
348 return NOT_FOUND;
349 }
350
351 return manipulateAttribute(manipulator, attributeInfo->d_id);
352}
353
354inline
356{
357 return d_name;
358}
359
360inline
365
366// ACCESSORS
367template <class ACCESSOR>
368int BigRecord::accessAttributes(ACCESSOR& accessor) const
369{
370 int ret;
371
372 ret = accessor(d_name, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_NAME]);
373 if (ret) {
374 return ret;
375 }
376
377 ret = accessor(d_array, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ARRAY]);
378 if (ret) {
379 return ret;
380 }
381
382 return 0;
383}
384
385template <class ACCESSOR>
386int BigRecord::accessAttribute(ACCESSOR& accessor, int id) const
387{
388 enum { NOT_FOUND = -1 };
389
390 switch (id) {
391 case ATTRIBUTE_ID_NAME: {
392 return accessor(d_name, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_NAME]);
393 }
394 case ATTRIBUTE_ID_ARRAY: {
395 return accessor(d_array, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ARRAY]);
396 }
397 default:
398 return NOT_FOUND;
399 }
400}
401
402template <class ACCESSOR>
404 ACCESSOR& accessor,
405 const char *name,
406 int nameLength) const
407{
408 enum { NOT_FOUND = -1 };
409
410 const bdlat_AttributeInfo *attributeInfo =
411 lookupAttributeInfo(name, nameLength);
412 if (0 == attributeInfo) {
413 return NOT_FOUND;
414 }
415
416 return accessAttribute(accessor, attributeInfo->d_id);
417}
418
419inline
421{
422 return d_name;
423}
424
425inline
427{
428 return d_array;
429}
430
431} // close package namespace
432
433// FREE FUNCTIONS
434
435inline
437 const s_baltst::BigRecord& lhs,
438 const s_baltst::BigRecord& rhs)
439{
440 return lhs.name() == rhs.name()
441 && lhs.array() == rhs.array();
442}
443
444inline
446 const s_baltst::BigRecord& lhs,
447 const s_baltst::BigRecord& rhs)
448{
449 return !(lhs == rhs);
450}
451
452inline
453bsl::ostream& s_baltst::operator<<(
454 bsl::ostream& stream,
455 const s_baltst::BigRecord& rhs)
456{
457 return rhs.print(stream, 0, -1);
458}
459
460
461#endif
462
463// GENERATED BY @BLP_BAS_CODEGEN_VERSION@
464// USING bas_codegen.pl s_baltst_bigrecord.xsd --mode msg --includedir . --msgComponent bigrecord --noRecurse --noExternalization --noHashSupport --noAggregateConversion
465// ----------------------------------------------------------------------------
466// NOTICE:
467// Copyright 2022 Bloomberg Finance L.P. All rights reserved.
468// Property of Bloomberg Finance L.P. (BFLP)
469// This software is made available solely pursuant to the
470// terms of a BFLP license agreement which governs its use.
471// ------------------------------- END-OF-FILE --------------------------------
472
473/** @} */
474/** @} */
475/** @} */
Definition bslstl_string.h:1281
Definition bslstl_vector.h:1025
Definition bslma_allocator.h:457
Definition s_baltst_bigrecord.h:80
int accessAttribute(ACCESSOR &accessor, int id) const
Definition s_baltst_bigrecord.h:386
BigRecord(const BigRecord &original, bslma::Allocator *basicAllocator=0)
static const bdlat_AttributeInfo * lookupAttributeInfo(const char *name, int nameLength)
@ NUM_ATTRIBUTES
Definition s_baltst_bigrecord.h:94
@ ATTRIBUTE_INDEX_ARRAY
Definition s_baltst_bigrecord.h:99
@ ATTRIBUTE_INDEX_NAME
Definition s_baltst_bigrecord.h:98
static const bdlat_AttributeInfo ATTRIBUTE_INFO_ARRAY[]
Definition s_baltst_bigrecord.h:105
@ ATTRIBUTE_ID_ARRAY
Definition s_baltst_bigrecord.h:90
@ ATTRIBUTE_ID_NAME
Definition s_baltst_bigrecord.h:89
int accessAttributes(ACCESSOR &accessor) const
Definition s_baltst_bigrecord.h:368
~BigRecord()
Destroy this object.
int manipulateAttribute(MANIPULATOR &manipulator, int id)
Definition s_baltst_bigrecord.h:321
bsl::ostream & print(bsl::ostream &stream, int level=0, int spacesPerLevel=4) const
static const char CLASS_NAME[]
Definition s_baltst_bigrecord.h:103
bsl::vector< s_baltst::BasicRecord > & array()
Definition s_baltst_bigrecord.h:361
BigRecord(bslma::Allocator *basicAllocator=0)
int manipulateAttributes(MANIPULATOR &manipulator)
Definition s_baltst_bigrecord.h:303
bsl::string & name()
Definition s_baltst_bigrecord.h:355
BigRecord & operator=(const BigRecord &rhs)
Assign to this object the value of the specified rhs object.
static const bdlat_AttributeInfo * lookupAttributeInfo(int id)
#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