BDE 4.14.0 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<class MANIPULATOR>
178 int manipulateAttributes(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<class MANIPULATOR>
187 int manipulateAttribute(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<class MANIPULATOR>
196 int manipulateAttribute(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
223 /// operation has no effect. Note that a trailing newline is provided
224 /// in multiline mode only.
225 bsl::ostream& print(bsl::ostream& stream,
226 int level = 0,
227 int spacesPerLevel = 4) const;
228
229 /// Invoke the specified `accessor` sequentially on each
230 /// (non-modifiable) attribute of this object, supplying `accessor`
231 /// with the corresponding attribute information structure until such
232 /// invocation returns a non-zero value. Return the value from the
233 /// last invocation of `accessor` (i.e., the invocation that terminated
234 /// the sequence).
235 template<class ACCESSOR>
236 int accessAttributes(ACCESSOR& accessor) const;
237
238 /// Invoke the specified `accessor` on the (non-modifiable) attribute
239 /// of this object indicated by the specified `id`, supplying `accessor`
240 /// with the corresponding attribute information structure. Return the
241 /// value returned from the invocation of `accessor` if `id` identifies
242 /// an attribute of this class, and -1 otherwise.
243 template<class ACCESSOR>
244 int accessAttribute(ACCESSOR& accessor, int id) const;
245
246 /// Invoke the specified `accessor` on the (non-modifiable) attribute
247 /// of this object indicated by the specified `name` of the specified
248 /// `nameLength`, supplying `accessor` with the corresponding attribute
249 /// information structure. Return the value returned from the
250 /// invocation of `accessor` if `name` identifies an attribute of this
251 /// class, and -1 otherwise.
252 template<class ACCESSOR>
253 int accessAttribute(ACCESSOR& accessor,
254 const char *name,
255 int nameLength) const;
256
257 /// Return a reference offering non-modifiable access to the
258 /// "Attribute1" attribute of this object.
260
261 /// Return a reference offering non-modifiable access to the
262 /// "Attribute2" attribute of this object.
264
265 /// Return the value of the "TheContent" attribute of this object.
266 int theContent() const;
267};
268
269// FREE OPERATORS
270
271/// Return `true` if the specified `lhs` and `rhs` attribute objects have
272/// the same value, and `false` otherwise. Two attribute objects have the
273/// same value if each respective attribute has the same value.
274inline
275bool operator==(const MySimpleIntContent& lhs, const MySimpleIntContent& rhs);
276
277/// Return `true` if the specified `lhs` and `rhs` attribute objects do not
278/// have the same value, and `false` otherwise. Two attribute objects do
279/// not have the same value if one or more respective attributes differ in
280/// values.
281inline
282bool operator!=(const MySimpleIntContent& lhs, const MySimpleIntContent& rhs);
283
284/// Format the specified `rhs` to the specified output `stream` and
285/// return a reference to the modifiable `stream`.
286inline
287bsl::ostream& operator<<(bsl::ostream& stream, const MySimpleIntContent& rhs);
288
289} // close package namespace
290
291// TRAITS
292
294
295// ============================================================================
296// INLINE FUNCTION DEFINITIONS
297// ============================================================================
298
299namespace s_baltst {
300
301 // ------------------------
302 // class MySimpleIntContent
303 // ------------------------
304
305// CLASS METHODS
306// MANIPULATORS
307template <class MANIPULATOR>
308int MySimpleIntContent::manipulateAttributes(MANIPULATOR& manipulator)
309{
310 int ret;
311
312 ret = manipulator(&d_attribute1, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE1]);
313 if (ret) {
314 return ret;
315 }
316
317 ret = manipulator(&d_attribute2, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE2]);
318 if (ret) {
319 return ret;
320 }
321
322 ret = manipulator(&d_theContent, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_THE_CONTENT]);
323 if (ret) {
324 return ret;
325 }
326
327 return 0;
328}
329
330template <class MANIPULATOR>
331int MySimpleIntContent::manipulateAttribute(MANIPULATOR& manipulator, int id)
332{
333 enum { NOT_FOUND = -1 };
334
335 switch (id) {
337 return manipulator(&d_attribute1, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE1]);
338 }
340 return manipulator(&d_attribute2, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE2]);
341 }
343 return manipulator(&d_theContent, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_THE_CONTENT]);
344 }
345 default:
346 return NOT_FOUND;
347 }
348}
349
350template <class MANIPULATOR>
352 MANIPULATOR& manipulator,
353 const char *name,
354 int nameLength)
355{
356 enum { NOT_FOUND = -1 };
357
358 const bdlat_AttributeInfo *attributeInfo =
359 lookupAttributeInfo(name, nameLength);
360 if (0 == attributeInfo) {
361 return NOT_FOUND;
362 }
363
364 return manipulateAttribute(manipulator, attributeInfo->d_id);
365}
366
367inline
369{
370 return d_attribute1;
371}
372
373inline
378
379inline
381{
382 return d_theContent;
383}
384
385// ACCESSORS
386template <class ACCESSOR>
387int MySimpleIntContent::accessAttributes(ACCESSOR& accessor) const
388{
389 int ret;
390
391 ret = accessor(d_attribute1, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE1]);
392 if (ret) {
393 return ret;
394 }
395
396 ret = accessor(d_attribute2, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE2]);
397 if (ret) {
398 return ret;
399 }
400
401 ret = accessor(d_theContent, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_THE_CONTENT]);
402 if (ret) {
403 return ret;
404 }
405
406 return 0;
407}
408
409template <class ACCESSOR>
410int MySimpleIntContent::accessAttribute(ACCESSOR& accessor, int id) const
411{
412 enum { NOT_FOUND = -1 };
413
414 switch (id) {
416 return accessor(d_attribute1, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE1]);
417 }
419 return accessor(d_attribute2, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE2]);
420 }
422 return accessor(d_theContent, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_THE_CONTENT]);
423 }
424 default:
425 return NOT_FOUND;
426 }
427}
428
429template <class ACCESSOR>
431 ACCESSOR& accessor,
432 const char *name,
433 int nameLength) const
434{
435 enum { NOT_FOUND = -1 };
436
437 const bdlat_AttributeInfo *attributeInfo =
438 lookupAttributeInfo(name, nameLength);
439 if (0 == attributeInfo) {
440 return NOT_FOUND;
441 }
442
443 return accessAttribute(accessor, attributeInfo->d_id);
444}
445
446inline
448{
449 return d_attribute1;
450}
451
452inline
454{
455 return d_attribute2;
456}
457
458inline
460{
461 return d_theContent;
462}
463
464} // close package namespace
465
466// FREE FUNCTIONS
467
468inline
472{
473 return lhs.attribute1() == rhs.attribute1()
474 && lhs.attribute2() == rhs.attribute2()
475 && lhs.theContent() == rhs.theContent();
476}
477
478inline
482{
483 return !(lhs == rhs);
484}
485
486inline
487bsl::ostream& s_baltst::operator<<(
488 bsl::ostream& stream,
490{
491 return rhs.print(stream, 0, -1);
492}
493
494
495#endif
496
497// GENERATED BY @BLP_BAS_CODEGEN_VERSION@
498// USING bas_codegen.pl s_baltst_mysimpleintcontent.xsd --mode msg --includedir . --msgComponent mysimpleintcontent --noRecurse --noExternalization --noHashSupport --noAggregateConversion
499// ----------------------------------------------------------------------------
500// NOTICE:
501// Copyright 2022 Bloomberg Finance L.P. All rights reserved.
502// Property of Bloomberg Finance L.P. (BFLP)
503// This software is made available solely pursuant to the
504// terms of a BFLP license agreement which governs its use.
505// ------------------------------- END-OF-FILE --------------------------------
506
507/** @} */
508/** @} */
509/** @} */
Definition bdlb_nullablevalue.h:257
Definition bslma_allocator.h:457
Definition s_baltst_mysimpleintcontent.h:75
bsl::ostream & print(bsl::ostream &stream, int level=0, int spacesPerLevel=4) const
static const char CLASS_NAME[]
Definition s_baltst_mysimpleintcontent.h:101
int manipulateAttribute(MANIPULATOR &manipulator, int id)
Definition s_baltst_mysimpleintcontent.h:331
MySimpleIntContent & operator=(const MySimpleIntContent &rhs)
Assign to this object the value of the specified rhs object.
~MySimpleIntContent()
Destroy this object.
@ NUM_ATTRIBUTES
Definition s_baltst_mysimpleintcontent.h:91
static const bdlat_AttributeInfo ATTRIBUTE_INFO_ARRAY[]
Definition s_baltst_mysimpleintcontent.h:103
bdlb::NullableValue< bsl::string > & attribute2()
Definition s_baltst_mysimpleintcontent.h:374
int & theContent()
Definition s_baltst_mysimpleintcontent.h:380
@ 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
int manipulateAttributes(MANIPULATOR &manipulator)
Definition s_baltst_mysimpleintcontent.h:308
int accessAttributes(ACCESSOR &accessor) const
Definition s_baltst_mysimpleintcontent.h:387
bdlb::NullableValue< bool > & attribute1()
Definition s_baltst_mysimpleintcontent.h:368
int accessAttribute(ACCESSOR &accessor, int id) const
Definition s_baltst_mysimpleintcontent.h:410
MySimpleIntContent(const MySimpleIntContent &original, bslma::Allocator *basicAllocator=0)
@ 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
static const bdlat_AttributeInfo * lookupAttributeInfo(int id)
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: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