BDE 4.14.0 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<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.
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 a reference offering non-modifiable access to the
266 /// "TheContent" attribute of this object.
267 const bsl::string& theContent() const;
268};
269
270// FREE OPERATORS
271
272/// Return `true` if the specified `lhs` and `rhs` attribute objects have
273/// the same value, and `false` otherwise. Two attribute objects have the
274/// same value if each respective attribute has the same value.
275inline
276bool operator==(const MySimpleContent& lhs, const MySimpleContent& rhs);
277
278/// Return `true` if the specified `lhs` and `rhs` attribute objects do not
279/// have the same value, and `false` otherwise. Two attribute objects do
280/// not have the same value if one or more respective attributes differ in
281/// values.
282inline
283bool operator!=(const MySimpleContent& lhs, const MySimpleContent& rhs);
284
285/// Format the specified `rhs` to the specified output `stream` and
286/// return a reference to the modifiable `stream`.
287inline
288bsl::ostream& operator<<(bsl::ostream& stream, const MySimpleContent& rhs);
289
290} // close package namespace
291
292// TRAITS
293
295
296// ============================================================================
297// INLINE FUNCTION DEFINITIONS
298// ============================================================================
299
300namespace s_baltst {
301
302 // ---------------------
303 // class MySimpleContent
304 // ---------------------
305
306// CLASS METHODS
307// MANIPULATORS
308template <class MANIPULATOR>
309int MySimpleContent::manipulateAttributes(MANIPULATOR& manipulator)
310{
311 int ret;
312
313 ret = manipulator(&d_attribute1, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE1]);
314 if (ret) {
315 return ret;
316 }
317
318 ret = manipulator(&d_attribute2, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE2]);
319 if (ret) {
320 return ret;
321 }
322
323 ret = manipulator(&d_theContent, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_THE_CONTENT]);
324 if (ret) {
325 return ret;
326 }
327
328 return 0;
329}
330
331template <class MANIPULATOR>
332int MySimpleContent::manipulateAttribute(MANIPULATOR& manipulator, int id)
333{
334 enum { NOT_FOUND = -1 };
335
336 switch (id) {
338 return manipulator(&d_attribute1, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE1]);
339 }
341 return manipulator(&d_attribute2, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE2]);
342 }
344 return manipulator(&d_theContent, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_THE_CONTENT]);
345 }
346 default:
347 return NOT_FOUND;
348 }
349}
350
351template <class MANIPULATOR>
353 MANIPULATOR& manipulator,
354 const char *name,
355 int nameLength)
356{
357 enum { NOT_FOUND = -1 };
358
359 const bdlat_AttributeInfo *attributeInfo =
360 lookupAttributeInfo(name, nameLength);
361 if (0 == attributeInfo) {
362 return NOT_FOUND;
363 }
364
365 return manipulateAttribute(manipulator, attributeInfo->d_id);
366}
367
368inline
370{
371 return d_attribute1;
372}
373
374inline
379
380inline
382{
383 return d_theContent;
384}
385
386// ACCESSORS
387template <class ACCESSOR>
388int MySimpleContent::accessAttributes(ACCESSOR& accessor) const
389{
390 int ret;
391
392 ret = accessor(d_attribute1, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE1]);
393 if (ret) {
394 return ret;
395 }
396
397 ret = accessor(d_attribute2, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE2]);
398 if (ret) {
399 return ret;
400 }
401
402 ret = accessor(d_theContent, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_THE_CONTENT]);
403 if (ret) {
404 return ret;
405 }
406
407 return 0;
408}
409
410template <class ACCESSOR>
411int MySimpleContent::accessAttribute(ACCESSOR& accessor, int id) const
412{
413 enum { NOT_FOUND = -1 };
414
415 switch (id) {
417 return accessor(d_attribute1, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE1]);
418 }
420 return accessor(d_attribute2, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_ATTRIBUTE2]);
421 }
423 return accessor(d_theContent, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_THE_CONTENT]);
424 }
425 default:
426 return NOT_FOUND;
427 }
428}
429
430template <class ACCESSOR>
432 ACCESSOR& accessor,
433 const char *name,
434 int nameLength) const
435{
436 enum { NOT_FOUND = -1 };
437
438 const bdlat_AttributeInfo *attributeInfo =
439 lookupAttributeInfo(name, nameLength);
440 if (0 == attributeInfo) {
441 return NOT_FOUND;
442 }
443
444 return accessAttribute(accessor, attributeInfo->d_id);
445}
446
447inline
449{
450 return d_attribute1;
451}
452
453inline
455{
456 return d_attribute2;
457}
458
459inline
461{
462 return d_theContent;
463}
464
465} // close package namespace
466
467// FREE FUNCTIONS
468
469inline
471 const s_baltst::MySimpleContent& lhs,
472 const s_baltst::MySimpleContent& rhs)
473{
474 return lhs.attribute1() == rhs.attribute1()
475 && lhs.attribute2() == rhs.attribute2()
476 && lhs.theContent() == rhs.theContent();
477}
478
479inline
481 const s_baltst::MySimpleContent& lhs,
482 const s_baltst::MySimpleContent& rhs)
483{
484 return !(lhs == rhs);
485}
486
487inline
488bsl::ostream& s_baltst::operator<<(
489 bsl::ostream& stream,
490 const s_baltst::MySimpleContent& rhs)
491{
492 return rhs.print(stream, 0, -1);
493}
494
495
496#endif
497
498// GENERATED BY @BLP_BAS_CODEGEN_VERSION@
499// USING bas_codegen.pl s_baltst_mysimplecontent.xsd --mode msg --includedir . --msgComponent mysimplecontent --noRecurse --noExternalization --noHashSupport --noAggregateConversion
500// ----------------------------------------------------------------------------
501// NOTICE:
502// Copyright 2022 Bloomberg Finance L.P. All rights reserved.
503// Property of Bloomberg Finance L.P. (BFLP)
504// This software is made available solely pursuant to the
505// terms of a BFLP license agreement which governs its use.
506// ------------------------------- END-OF-FILE --------------------------------
507
508/** @} */
509/** @} */
510/** @} */
Definition bdlb_nullablevalue.h:257
Definition bslstl_string.h:1281
Definition bslma_allocator.h:457
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:369
@ 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()
Destroy this object.
static const bdlat_AttributeInfo * lookupAttributeInfo(int id)
static const bdlat_AttributeInfo * lookupAttributeInfo(const char *name, int nameLength)
bsl::string & theContent()
Definition s_baltst_mysimplecontent.h:381
int accessAttribute(ACCESSOR &accessor, int id) const
Definition s_baltst_mysimplecontent.h:411
@ 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
bsl::ostream & print(bsl::ostream &stream, int level=0, int spacesPerLevel=4) const
int manipulateAttribute(MANIPULATOR &manipulator, int id)
Definition s_baltst_mysimplecontent.h:332
int manipulateAttributes(MANIPULATOR &manipulator)
Definition s_baltst_mysimplecontent.h:309
@ NUM_ATTRIBUTES
Definition s_baltst_mysimplecontent.h:91
MySimpleContent & operator=(const MySimpleContent &rhs)
Assign to this object the value of the specified rhs object.
bdlb::NullableValue< bsl::string > & attribute2()
Definition s_baltst_mysimplecontent.h:375
MySimpleContent(bslma::Allocator *basicAllocator=0)
static const bdlat_AttributeInfo ATTRIBUTE_INFO_ARRAY[]
Definition s_baltst_mysimplecontent.h:103
MySimpleContent(const MySimpleContent &original, bslma::Allocator *basicAllocator=0)
int accessAttributes(ACCESSOR &accessor) const
Definition s_baltst_mysimplecontent.h:388
#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