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