BDE 4.39.x Production Release
Loading...
Searching...
No Matches
s_baltst_myintenumeration.h
Go to the documentation of this file.
1/// @file s_baltst_myintenumeration.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// s_baltst_myintenumeration.h *DO NOT EDIT* @generated -*-C++-*-
8#ifndef INCLUDED_S_BALTST_MYINTENUMERATION
9#define INCLUDED_S_BALTST_MYINTENUMERATION
10
11#include <bsls_ident.h>
12BSLS_IDENT_RCSID(s_baltst_myintenumeration_h, "$Id$ $CSID$")
14
15/// @defgroup s_baltst_myintenumeration s_baltst_myintenumeration
16/// @brief Provide value-semantic attribute classes
17/// @addtogroup Standalones
18/// @{
19/// @addtogroup s_baltst
20/// @{
21/// @addtogroup s_baltst_myintenumeration
22/// @{
23///
24/// <h1> Outline </h1>
25/// * <a href="#s_baltst_myintenumeration-purpose"> Purpose</a>
26///
27/// # Purpose {#s_baltst_myintenumeration-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_myintenumeration
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
52
53#include <bsls_objectbuffer.h>
54
55#include <bsls_assert.h>
56
57#include <bsl_iosfwd.h>
58#include <bsl_limits.h>
59
60
61
62namespace s_baltst { class MyIntEnumeration; }
63namespace s_baltst { class MyIntEnumerationRecord; }
64namespace s_baltst {
65
66 // ======================
67 // class MyIntEnumeration
68 // ======================
69
71
72 // INSTANCE DATA
73 int d_value;
74
75 // FRIENDS
76 friend bool operator==(const MyIntEnumeration& lhs, const MyIntEnumeration& rhs);
77 friend bool operator!=(const MyIntEnumeration& lhs, const MyIntEnumeration& rhs);
78
79 public:
80 // TYPES
81 typedef int BaseType;
82
83 // CONSTANTS
84 static const char CLASS_NAME[];
85
86 static const int VALUE1;
87
88 static const int VALUE2;
89
90 // CREATORS
91
92 /// Create an object of type `MyIntEnumeration` having the default
93 /// value.
95
96 /// Create an object of type `MyIntEnumeration` having the value of the
97 /// specified `original` object.
98 MyIntEnumeration(const MyIntEnumeration& original);
99
100#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) \
101 && defined(BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT)
102 /// Create an object of type `MyIntEnumeration` having the value of the
103 /// specified `original` object. After performing this action, the
104 /// `original` object will be left in a valid, but unspecified state.
105 MyIntEnumeration(MyIntEnumeration&& original) = default;
106#endif
107
108 /// Create an object of type `MyIntEnumeration` having the specified
109 /// `value`.
110 explicit MyIntEnumeration(const int& value);
111
112 /// Destroy this object.
114
115 // MANIPULATORS
116
117 /// Assign to this object the value of the specified `rhs` object.
119
120#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) \
121 && defined(BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT)
122 /// Assign to this object the value of the specified `rhs` object.
123 /// After performing this action, the `rhs` object will be left in a
124 /// valid, but unspecified state.
126#endif
127
128 /// Reset this object to the default value (i.e., its value upon
129 /// default construction).
130 void reset();
131
132 /// Convert from the specified `value` to this type. Return 0 if
133 /// successful and non-zero otherwise.
134 int fromInt(const int& value);
135
136 // ACCESSORS
137
138 /// Format this object to the specified output `stream` at the
139 /// optionally specified indentation `level` and return a reference to
140 /// the modifiable `stream`. If `level` is specified, optionally
141 /// specify `spacesPerLevel`, the number of spaces per indentation level
142 /// for this and all of its nested objects. Each line is indented by
143 /// the absolute value of `level * spacesPerLevel`. If `level` is
144 /// negative, suppress indentation of the first line. If
145 /// `spacesPerLevel` is negative, suppress line breaks and format the
146 /// entire output on one line. If `stream` is initially invalid, this operation has no effect.
147 ///
148 /// \note Note that a trailing newline is provided
149 /// in multiline mode only.
150 bsl::ostream& print(bsl::ostream& stream,
151 int level = 0,
152 int spacesPerLevel = 4) const;
153
154 /// Convert this value to `int`.
155 const int& toInt() const;
156
157 // PUBLIC CLASS METHODS
158
159 /// Check if the specified `value` satisfies the restrictions of this
160 /// class (i.e., "MyIntEnumeration"). Return 0 if successful (i.e., the
161 /// restrictions are satisfied) and non-zero otherwise.
162 static int checkRestrictions(const int& value);
163};
164
165// FREE OPERATORS
166
167/// Return `true` if the specified `lhs` and `rhs` attribute objects have
168/// the same value, and `false` otherwise. Two attribute objects have the
169/// same value if each respective attribute has the same value.
170inline
171bool operator==(const MyIntEnumeration& lhs, const MyIntEnumeration& rhs);
172
173/// Return `true` if the specified `lhs` and `rhs` attribute objects do not
174/// have the same value, and `false` otherwise. Two attribute objects do
175/// not have the same value if one or more respective attributes differ in
176/// values.
177inline
178bool operator!=(const MyIntEnumeration& lhs, const MyIntEnumeration& rhs);
179
180/// Format the specified `rhs` to the specified output `stream` and
181/// return a reference to the modifiable `stream`.
182inline
183bsl::ostream& operator<<(bsl::ostream& stream, const MyIntEnumeration& rhs);
184
185} // close package namespace
186
187// TRAITS
188
190
191namespace s_baltst {
192
193 // ============================
194 // class MyIntEnumerationRecord
195 // ============================
196
198
199 // INSTANCE DATA
200 MyIntEnumeration d_value;
201
202 public:
203 // TYPES
204 enum {
206 };
207
208 enum {
210 };
211
212 enum {
214 };
215
216 // CONSTANTS
217 static const char CLASS_NAME[];
218
220
221 public:
222 // CLASS METHODS
223
224 /// Return attribute information for the attribute indicated by the
225 /// specified `id` if the attribute exists, and 0 otherwise.
227
228 /// Return attribute information for the attribute indicated by the
229 /// specified `name` of the specified `nameLength` if the attribute
230 /// exists, and 0 otherwise.
232 const char *name,
233 int nameLength);
234
235 // CREATORS
236
237 /// Create an object of type `MyIntEnumerationRecord` having the default
238 /// value.
240
241 /// Create an object of type `MyIntEnumerationRecord` having the value
242 /// of the specified `original` object.
244
245#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) \
246 && defined(BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT)
247 /// Create an object of type `MyIntEnumerationRecord` having the value
248 /// of the specified `original` object. After performing this action,
249 /// the `original` object will be left in a valid, but unspecified
250 /// state.
252#endif
253
254 /// Destroy this object.
256
257 // MANIPULATORS
258
259 /// Assign to this object the value of the specified `rhs` object.
261
262#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) \
263 && defined(BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT)
264 /// Assign to this object the value of the specified `rhs` object.
265 /// After performing this action, the `rhs` object will be left in a
266 /// valid, but unspecified state.
268#endif
269
270 /// Reset this object to the default value (i.e., its value upon
271 /// default construction).
272 void reset();
273
274 /// Invoke the specified `manipulator` sequentially on the address of
275 /// each (modifiable) attribute of this object, supplying `manipulator`
276 /// with the corresponding attribute information structure until such
277 /// invocation returns a non-zero value. Return the value from the
278 /// last invocation of `manipulator` (i.e., the invocation that
279 /// terminated the sequence).
280 template <typename t_MANIPULATOR>
281 int manipulateAttributes(t_MANIPULATOR& manipulator);
282
283 /// Invoke the specified `manipulator` on the address of
284 /// the (modifiable) attribute indicated by the specified `id`,
285 /// supplying `manipulator` with the corresponding attribute
286 /// information structure. Return the value returned from the
287 /// invocation of `manipulator` if `id` identifies an attribute of this
288 /// class, and -1 otherwise.
289 template <typename t_MANIPULATOR>
290 int manipulateAttribute(t_MANIPULATOR& manipulator, int id);
291
292 /// Invoke the specified `manipulator` on the address of
293 /// the (modifiable) attribute indicated by the specified `name` of the
294 /// specified `nameLength`, supplying `manipulator` with the
295 /// corresponding attribute information structure. Return the value
296 /// returned from the invocation of `manipulator` if `name` identifies
297 /// an attribute of this class, and -1 otherwise.
298 template <typename t_MANIPULATOR>
299 int manipulateAttribute(t_MANIPULATOR& manipulator,
300 const char *name,
301 int nameLength);
302
303 /// Return a reference to the modifiable "Value" attribute of this
304 /// object.
306
307 // ACCESSORS
308
309 /// Format this object to the specified output `stream` at the
310 /// optionally specified indentation `level` and return a reference to
311 /// the modifiable `stream`. If `level` is specified, optionally
312 /// specify `spacesPerLevel`, the number of spaces per indentation level
313 /// for this and all of its nested objects. Each line is indented by
314 /// the absolute value of `level * spacesPerLevel`. If `level` is
315 /// negative, suppress indentation of the first line. If
316 /// `spacesPerLevel` is negative, suppress line breaks and format the
317 /// entire output on one line. If `stream` is initially invalid, this operation has no effect.
318 ///
319 /// \note Note that a trailing newline is provided
320 /// in multiline mode only.
321 bsl::ostream& print(bsl::ostream& stream,
322 int level = 0,
323 int spacesPerLevel = 4) const;
324
325 /// Invoke the specified `accessor` sequentially on each
326 /// (non-modifiable) attribute of this object, supplying `accessor`
327 /// with the corresponding attribute information structure until such
328 /// invocation returns a non-zero value. Return the value from the
329 /// last invocation of `accessor` (i.e., the invocation that terminated
330 /// the sequence).
331 template <typename t_ACCESSOR>
332 int accessAttributes(t_ACCESSOR& accessor) const;
333
334 /// Invoke the specified `accessor` on the (non-modifiable) attribute
335 /// of this object indicated by the specified `id`, supplying `accessor`
336 /// with the corresponding attribute information structure. Return the
337 /// value returned from the invocation of `accessor` if `id` identifies
338 /// an attribute of this class, and -1 otherwise.
339 template <typename t_ACCESSOR>
340 int accessAttribute(t_ACCESSOR& accessor, int id) const;
341
342 /// Invoke the specified `accessor` on the (non-modifiable) attribute
343 /// of this object indicated by the specified `name` of the specified
344 /// `nameLength`, supplying `accessor` with the corresponding attribute
345 /// information structure. Return the value returned from the
346 /// invocation of `accessor` if `name` identifies an attribute of this
347 /// class, and -1 otherwise.
348 template <typename t_ACCESSOR>
349 int accessAttribute(t_ACCESSOR& accessor,
350 const char *name,
351 int nameLength) const;
352
353 /// Return a reference offering non-modifiable access to the "Value"
354 /// attribute of this object.
355 const MyIntEnumeration& value() const;
356};
357
358// FREE OPERATORS
359
360/// Return `true` if the specified `lhs` and `rhs` attribute objects have
361/// the same value, and `false` otherwise. Two attribute objects have the
362/// same value if each respective attribute has the same value.
363inline
364bool operator==(const MyIntEnumerationRecord& lhs, const MyIntEnumerationRecord& rhs);
365
366/// Return `true` if the specified `lhs` and `rhs` attribute objects do not
367/// have the same value, and `false` otherwise. Two attribute objects do
368/// not have the same value if one or more respective attributes differ in
369/// values.
370inline
371bool operator!=(const MyIntEnumerationRecord& lhs, const MyIntEnumerationRecord& rhs);
372
373/// Format the specified `rhs` to the specified output `stream` and
374/// return a reference to the modifiable `stream`.
375inline
376bsl::ostream& operator<<(bsl::ostream& stream, const MyIntEnumerationRecord& rhs);
377
378} // close package namespace
379
380// TRAITS
381
383
384// ============================================================================
385// INLINE FUNCTION DEFINITIONS
386// ============================================================================
387
388namespace s_baltst {
389
390 // ----------------------
391 // class MyIntEnumeration
392 // ----------------------
393
394// CREATORS
395inline
397: d_value()
398{
399}
400
401inline
403: d_value(original.d_value)
404{
405}
406
407inline
409: d_value(value)
410{
411 BSLS_ASSERT(checkRestrictions(value) == 0);
412}
413
414inline
418
419// MANIPULATORS
420inline
422{
423 d_value = rhs.d_value;
424 return *this;
425}
426
427inline
432
433inline
434int MyIntEnumeration::fromInt(const int& value)
435{
436 int ret = checkRestrictions(value);
437 if (0 == ret) {
438 d_value = value;
439 }
440
441 return ret;
442}
443
444// ACCESSORS
445inline
446bsl::ostream& MyIntEnumeration::print(bsl::ostream& stream,
447 int level,
448 int spacesPerLevel) const
449{
450 return bdlb::PrintMethods::print(stream, d_value, level, spacesPerLevel);
451}
452
453inline
454const int& MyIntEnumeration::toInt() const
455{
456 return d_value;
457}
458
459
460
461 // ----------------------------
462 // class MyIntEnumerationRecord
463 // ----------------------------
464
465// CLASS METHODS
466// MANIPULATORS
467template <typename t_MANIPULATOR>
468int MyIntEnumerationRecord::manipulateAttributes(t_MANIPULATOR& manipulator)
469{
470 int ret;
471
472 ret = manipulator(&d_value, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_VALUE]);
473 if (ret) {
474 return ret;
475 }
476
477 return 0;
478}
479
480template <typename t_MANIPULATOR>
481int MyIntEnumerationRecord::manipulateAttribute(t_MANIPULATOR& manipulator, int id)
482{
483 enum { NOT_FOUND = -1 };
484
485 switch (id) {
486 case ATTRIBUTE_ID_VALUE: {
487 return manipulator(&d_value, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_VALUE]);
488 }
489 default:
490 return NOT_FOUND;
491 }
492}
493
494template <typename t_MANIPULATOR>
496 t_MANIPULATOR& manipulator,
497 const char *name,
498 int nameLength)
499{
500 enum { NOT_FOUND = -1 };
501
502 const bdlat_AttributeInfo *attributeInfo =
503 lookupAttributeInfo(name, nameLength);
504 if (0 == attributeInfo) {
505 return NOT_FOUND;
506 }
507
508 return manipulateAttribute(manipulator, attributeInfo->d_id);
509}
510
511inline
513{
514 return d_value;
515}
516
517// ACCESSORS
518template <typename t_ACCESSOR>
519int MyIntEnumerationRecord::accessAttributes(t_ACCESSOR& accessor) const
520{
521 int ret;
522
523 ret = accessor(d_value, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_VALUE]);
524 if (ret) {
525 return ret;
526 }
527
528 return 0;
529}
530
531template <typename t_ACCESSOR>
532int MyIntEnumerationRecord::accessAttribute(t_ACCESSOR& accessor, int id) const
533{
534 enum { NOT_FOUND = -1 };
535
536 switch (id) {
537 case ATTRIBUTE_ID_VALUE: {
538 return accessor(d_value, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_VALUE]);
539 }
540 default:
541 return NOT_FOUND;
542 }
543}
544
545template <typename t_ACCESSOR>
547 t_ACCESSOR& accessor,
548 const char *name,
549 int nameLength) const
550{
551 enum { NOT_FOUND = -1 };
552
553 const bdlat_AttributeInfo *attributeInfo =
554 lookupAttributeInfo(name, nameLength);
555 if (0 == attributeInfo) {
556 return NOT_FOUND;
557 }
558
559 return accessAttribute(accessor, attributeInfo->d_id);
560}
561
562inline
564{
565 return d_value;
566}
567
568} // close package namespace
569
570// FREE FUNCTIONS
571
572inline
576{
577 return lhs.d_value == rhs.d_value;
578}
579
580inline
584{
585 return lhs.d_value != rhs.d_value;
586}
587
588inline
589bsl::ostream& s_baltst::operator<<(
590 bsl::ostream& stream,
592{
593 return rhs.print(stream, 0, -1);
594}
595
596inline
600{
601 return lhs.value() == rhs.value();
602}
603
604inline
608{
609 return !(lhs == rhs);
610}
611
612inline
613bsl::ostream& s_baltst::operator<<(
614 bsl::ostream& stream,
616{
617 return rhs.print(stream, 0, -1);
618}
619
620
621#endif
622
623// GENERATED BY BLP_BAS_CODEGEN_2023.10.25
624// USING bas_codegen.pl s_baltst_myintenumeration.xsd --mode msg --includedir . --msgComponent myintenumeration --noRecurse --noExternalization --noHashSupport --noAggregateConversion
625// ----------------------------------------------------------------------------
626// NOTICE:
627// Copyright 2023 Bloomberg Finance L.P. All rights reserved.
628// Property of Bloomberg Finance L.P. (BFLP)
629// This software is made available solely pursuant to the
630// terms of a BFLP license agreement which governs its use.
631// ------------------------------- END-OF-FILE --------------------------------
632
633/** @} */
634/** @} */
635/** @} */
Definition s_baltst_myintenumeration.h:197
static const bdlat_AttributeInfo * lookupAttributeInfo(int id)
@ NUM_ATTRIBUTES
Definition s_baltst_myintenumeration.h:209
static const char CLASS_NAME[]
Definition s_baltst_myintenumeration.h:217
int manipulateAttributes(t_MANIPULATOR &manipulator)
Definition s_baltst_myintenumeration.h:468
bsl::ostream & print(bsl::ostream &stream, int level=0, int spacesPerLevel=4) const
static const bdlat_AttributeInfo ATTRIBUTE_INFO_ARRAY[]
Definition s_baltst_myintenumeration.h:219
MyIntEnumeration & value()
Definition s_baltst_myintenumeration.h:512
int manipulateAttribute(t_MANIPULATOR &manipulator, int id)
Definition s_baltst_myintenumeration.h:481
MyIntEnumerationRecord & operator=(const MyIntEnumerationRecord &rhs)
Assign to this object the value of the specified rhs object.
~MyIntEnumerationRecord()
Destroy this object.
@ ATTRIBUTE_ID_VALUE
Definition s_baltst_myintenumeration.h:205
int accessAttributes(t_ACCESSOR &accessor) const
Definition s_baltst_myintenumeration.h:519
@ ATTRIBUTE_INDEX_VALUE
Definition s_baltst_myintenumeration.h:213
MyIntEnumerationRecord(const MyIntEnumerationRecord &original)
int accessAttribute(t_ACCESSOR &accessor, int id) const
Definition s_baltst_myintenumeration.h:532
static const bdlat_AttributeInfo * lookupAttributeInfo(const char *name, int nameLength)
Definition s_baltst_myintenumeration.h:70
bsl::ostream & print(bsl::ostream &stream, int level=0, int spacesPerLevel=4) const
Definition s_baltst_myintenumeration.h:446
friend bool operator==(const MyIntEnumeration &lhs, const MyIntEnumeration &rhs)
static const char CLASS_NAME[]
Definition s_baltst_myintenumeration.h:84
const int & toInt() const
Convert this value to int.
Definition s_baltst_myintenumeration.h:454
static int checkRestrictions(const int &value)
friend bool operator!=(const MyIntEnumeration &lhs, const MyIntEnumeration &rhs)
~MyIntEnumeration()
Destroy this object.
Definition s_baltst_myintenumeration.h:415
int fromInt(const int &value)
Definition s_baltst_myintenumeration.h:434
MyIntEnumeration & operator=(const MyIntEnumeration &rhs)
Assign to this object the value of the specified rhs object.
Definition s_baltst_myintenumeration.h:421
void reset()
Definition s_baltst_myintenumeration.h:428
int BaseType
Definition s_baltst_myintenumeration.h:81
MyIntEnumeration()
Definition s_baltst_myintenumeration.h:396
static const int VALUE1
Definition s_baltst_myintenumeration.h:86
static const int VALUE2
Definition s_baltst_myintenumeration.h:88
#define BDLAT_DECL_CUSTOMIZEDTYPE_WITH_BITWISEMOVEABLE_TRAITS(ClassName)
Definition bdlat_typetraits.h:344
#define BDLAT_DECL_SEQUENCE_WITH_BITWISEMOVEABLE_TRAITS(ClassName)
Definition bdlat_typetraits.h:294
#define BSLS_ASSERT(X)
Definition bsls_assert.h:1976
#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
void reset(TYPE *object)
Reset the value of the specified object to its default value.
bsl::ostream & print(bsl::ostream &stream, const TYPE &object, int level=0, int spacesPerLevel=4)
Definition bdlb_printmethods.h:725
ALLOCATOR const STRING_VIEW_LIKE_TYPE & rhs
Definition bslstl_string.h:3918
ALLOCATOR & lhs
Definition bslstl_string.h:3917
Definition s_baltst_address.h:66
bsl::ostream & operator<<(bsl::ostream &stream, const BasicSchemaAnnotationElement &rhs)
bool operator==(const BasicSchemaAnnotationElement &lhs, const BasicSchemaAnnotationElement &rhs)
bool operator!=(const BasicSchemaAnnotationElement &lhs, const BasicSchemaAnnotationElement &rhs)
Definition bdlat_attributeinfo.h:139
int d_id
Definition bdlat_attributeinfo.h:142