BDE 4.39.x Production Release
Loading...
Searching...
No Matches
s_baltst_mysimplecontent.h
Go to the documentation of this file.
1/// @file s_baltst_mysimplecontent.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// s_baltst_mysimplecontent.h *DO NOT EDIT* @generated -*-C++-*-
8#ifndef INCLUDED_S_BALTST_MYSIMPLECONTENT
9#define INCLUDED_S_BALTST_MYSIMPLECONTENT
10
11#include <bsls_ident.h>
12BSLS_IDENT_RCSID(s_baltst_mysimplecontent_h, "$Id$ $CSID$")
14
15/// @defgroup s_baltst_mysimplecontent s_baltst_mysimplecontent
16/// @brief Provide value-semantic attribute classes
17/// @addtogroup Standalones
18/// @{
19/// @addtogroup s_baltst
20/// @{
21/// @addtogroup s_baltst_mysimplecontent
22/// @{
23///
24/// <h1> Outline </h1>
25/// * <a href="#s_baltst_mysimplecontent-purpose"> Purpose</a>
26///
27/// # Purpose {#s_baltst_mysimplecontent-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_mysimplecontent
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 MySimpleContent; }
69namespace s_baltst {
70
71 // =====================
72 // class MySimpleContent
73 // =====================
74
76
77 // INSTANCE DATA
78 bsl::string 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 `MySimpleContent` having the default value.
122 /// Use the optionally specified `basicAllocator` to supply memory. If
123 /// `basicAllocator` is 0, the currently installed default allocator is
124 /// used.
125 explicit MySimpleContent(bslma::Allocator *basicAllocator = 0);
126
127 /// Create an object of type `MySimpleContent` having the value of the
128 /// 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 `MySimpleContent` having the value of the
137 /// specified `original` object. After performing this action, the
138 /// `original` object will be left in a valid, but unspecified state.
139 MySimpleContent(MySimpleContent&& original) noexcept;
140
141 /// Create an object of type `MySimpleContent` having the value of the
142 /// 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.
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 a reference offering non-modifiable access to the
267 /// "TheContent" attribute of this object.
268 const bsl::string& theContent() const;
269
270 // HIDDEN FRIENDS
271
272 /// Return `true` if the specified `lhs` and `rhs` attribute objects
273 /// have the same value, and `false` otherwise. Two attribute objects
274 /// have the same value if each respective attribute has the same value.
275 friend bool operator==(const MySimpleContent& lhs,
276 const MySimpleContent& rhs)
277 {
278 return lhs.attribute1() == rhs.attribute1() &&
279 lhs.attribute2() == rhs.attribute2() &&
280 lhs.theContent() == rhs.theContent();
281 }
282
283 /// Returns `!(lhs == rhs)`
284 friend bool operator!=(const MySimpleContent& lhs,
285 const MySimpleContent& rhs)
286 {
287 return !(lhs == rhs);
288 }
289
290 /// Format the specified `rhs` to the specified output `stream` and
291 /// return a reference to the modifiable `stream`.
292 friend bsl::ostream& operator<<(bsl::ostream& stream,
293 const MySimpleContent& rhs)
294 {
295 return rhs.print(stream, 0, -1);
296 }
297};
298
299} // close package namespace
300
301// TRAITS
302
304template <>
306
307// ============================================================================
308// INLINE DEFINITIONS
309// ============================================================================
310
311namespace s_baltst {
312
313 // ---------------------
314 // class MySimpleContent
315 // ---------------------
316
317// CLASS METHODS
318// MANIPULATORS
319template <typename t_MANIPULATOR>
320int MySimpleContent::manipulateAttributes(t_MANIPULATOR& manipulator)
321{
322 int ret;
323
324 ret = manipulator(&d_attribute1, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE1]);
325 if (ret) {
326 return ret;
327 }
328
329 ret = manipulator(&d_attribute2, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE2]);
330 if (ret) {
331 return ret;
332 }
333
334 ret = manipulator(&d_theContent, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_THE_CONTENT]);
335 if (ret) {
336 return ret;
337 }
338
339 return 0;
340}
341
342template <typename t_MANIPULATOR>
343int MySimpleContent::manipulateAttribute(t_MANIPULATOR& manipulator, int id)
344{
345 enum { NOT_FOUND = -1 };
346
347 switch (id) {
349 return manipulator(&d_attribute1, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE1]);
350 }
352 return manipulator(&d_attribute2, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE2]);
353 }
355 return manipulator(&d_theContent, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_THE_CONTENT]);
356 }
357 default:
358 return NOT_FOUND;
359 }
360}
361
362template <typename t_MANIPULATOR>
364 t_MANIPULATOR& manipulator,
365 const char *name,
366 int nameLength)
367{
368 enum { NOT_FOUND = -1 };
369
370 const bdlat_AttributeInfo *attributeInfo =
371 lookupAttributeInfo(name, nameLength);
372 if (0 == attributeInfo) {
373 return NOT_FOUND;
374 }
375
376 return manipulateAttribute(manipulator, attributeInfo->d_id);
377}
378
379inline
381{
382 return d_attribute1;
383}
384
385inline
390
391inline
393{
394 return d_theContent;
395}
396
397// ACCESSORS
398template <typename t_ACCESSOR>
399int MySimpleContent::accessAttributes(t_ACCESSOR& accessor) const
400{
401 int ret;
402
403 ret = accessor(d_attribute1, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE1]);
404 if (ret) {
405 return ret;
406 }
407
408 ret = accessor(d_attribute2, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE2]);
409 if (ret) {
410 return ret;
411 }
412
413 ret = accessor(d_theContent, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_THE_CONTENT]);
414 if (ret) {
415 return ret;
416 }
417
418 return 0;
419}
420
421template <typename t_ACCESSOR>
422int MySimpleContent::accessAttribute(t_ACCESSOR& accessor, int id) const
423{
424 enum { NOT_FOUND = -1 };
425
426 switch (id) {
428 return accessor(d_attribute1, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE1]);
429 }
431 return accessor(d_attribute2, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE2]);
432 }
434 return accessor(d_theContent, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_THE_CONTENT]);
435 }
436 default:
437 return NOT_FOUND;
438 }
439}
440
441template <typename t_ACCESSOR>
443 t_ACCESSOR& accessor,
444 const char *name,
445 int nameLength) const
446{
447 enum { NOT_FOUND = -1 };
448
449 const bdlat_AttributeInfo *attributeInfo =
450 lookupAttributeInfo(name, nameLength);
451 if (0 == attributeInfo) {
452 return NOT_FOUND;
453 }
454
455 return accessAttribute(accessor, attributeInfo->d_id);
456}
457
458inline
460{
461 return d_attribute1;
462}
463
464inline
466{
467 return d_attribute2;
468}
469
470inline
472{
473 return d_theContent;
474}
475
476} // close package namespace
477
478// FREE FUNCTIONS
479
480
481#endif
482
483// GENERATED BY BLP_BAS_CODEGEN_2025.08.21
484// USING bas_codegen.pl s_baltst_mysimplecontent.xsd --mode msg --includedir . --msgComponent mysimplecontent --noRecurse --noExternalization --noHashSupport --noAggregateConversion
485// ----------------------------------------------------------------------------
486// NOTICE:
487// Copyright 2025 Bloomberg Finance L.P. All rights reserved.
488// Property of Bloomberg Finance L.P. (BFLP)
489// This software is made available solely pursuant to the
490// terms of a BFLP license agreement which governs its use.
491// ------------------------------- END-OF-FILE --------------------------------
492
493/** @} */
494/** @} */
495/** @} */
Definition bdlb_nullablevalue.h:262
Definition bslstl_string.h:1252
Definition bslma_allocator.h:545
Definition s_baltst_mysimplecontent.h:75
static const char CLASS_NAME[]
Definition s_baltst_mysimplecontent.h:101
bdlb::NullableValue< bool > & attribute1()
Definition s_baltst_mysimplecontent.h:380
~MySimpleContent()
Destroy this object.
static const bdlat_AttributeInfo * lookupAttributeInfo(int id)
friend bsl::ostream & operator<<(bsl::ostream &stream, const MySimpleContent &rhs)
Definition s_baltst_mysimplecontent.h:292
static const bdlat_AttributeInfo * lookupAttributeInfo(const char *name, int nameLength)
bsl::string & theContent()
Definition s_baltst_mysimplecontent.h:392
friend bool operator!=(const MySimpleContent &lhs, const MySimpleContent &rhs)
Returns !(lhs == rhs)
Definition s_baltst_mysimplecontent.h:284
int manipulateAttributes(t_MANIPULATOR &manipulator)
Definition s_baltst_mysimplecontent.h:320
int accessAttributes(t_ACCESSOR &accessor) const
Definition s_baltst_mysimplecontent.h:399
bsl::ostream & print(bsl::ostream &stream, int level=0, int spacesPerLevel=4) const
@ NUM_ATTRIBUTES
Definition s_baltst_mysimplecontent.h:91
friend bool operator==(const MySimpleContent &lhs, const MySimpleContent &rhs)
Definition s_baltst_mysimplecontent.h:275
@ ATTRIBUTE_ID_ATTRIBUTE2
Definition s_baltst_mysimplecontent.h:86
@ ATTRIBUTE_ID_THE_CONTENT
Definition s_baltst_mysimplecontent.h:87
@ ATTRIBUTE_ID_ATTRIBUTE1
Definition s_baltst_mysimplecontent.h:85
MySimpleContent & operator=(const MySimpleContent &rhs)
Assign to this object the value of the specified rhs object.
int accessAttribute(t_ACCESSOR &accessor, int id) const
Definition s_baltst_mysimplecontent.h:422
bdlb::NullableValue< bsl::string > & attribute2()
Definition s_baltst_mysimplecontent.h:386
@ ATTRIBUTE_INDEX_ATTRIBUTE1
Definition s_baltst_mysimplecontent.h:95
@ ATTRIBUTE_INDEX_THE_CONTENT
Definition s_baltst_mysimplecontent.h:97
@ ATTRIBUTE_INDEX_ATTRIBUTE2
Definition s_baltst_mysimplecontent.h:96
MySimpleContent(bslma::Allocator *basicAllocator=0)
static const bdlat_AttributeInfo ATTRIBUTE_INFO_ARRAY[]
Definition s_baltst_mysimplecontent.h:103
int manipulateAttribute(t_MANIPULATOR &manipulator, int id)
Definition s_baltst_mysimplecontent.h:343
MySimpleContent(const MySimpleContent &original, 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