BDE 4.14.0 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
147 /// operation has no effect. Note that a trailing newline is provided
148 /// in multiline mode only.
149 bsl::ostream& print(bsl::ostream& stream,
150 int level = 0,
151 int spacesPerLevel = 4) const;
152
153 /// Convert this value to `int`.
154 const int& toInt() const;
155
156 // PUBLIC CLASS METHODS
157
158 /// Check if the specified `value` satisfies the restrictions of this
159 /// class (i.e., "MyIntEnumeration"). Return 0 if successful (i.e., the
160 /// restrictions are satisfied) and non-zero otherwise.
161 static int checkRestrictions(const int& value);
162};
163
164// FREE OPERATORS
165
166/// Return `true` if the specified `lhs` and `rhs` attribute objects have
167/// the same value, and `false` otherwise. Two attribute objects have the
168/// same value if each respective attribute has the same value.
169inline
170bool operator==(const MyIntEnumeration& lhs, const MyIntEnumeration& rhs);
171
172/// Return `true` if the specified `lhs` and `rhs` attribute objects do not
173/// have the same value, and `false` otherwise. Two attribute objects do
174/// not have the same value if one or more respective attributes differ in
175/// values.
176inline
177bool operator!=(const MyIntEnumeration& lhs, const MyIntEnumeration& rhs);
178
179/// Format the specified `rhs` to the specified output `stream` and
180/// return a reference to the modifiable `stream`.
181inline
182bsl::ostream& operator<<(bsl::ostream& stream, const MyIntEnumeration& rhs);
183
184} // close package namespace
185
186// TRAITS
187
189
190namespace s_baltst {
191
192 // ============================
193 // class MyIntEnumerationRecord
194 // ============================
195
197
198 // INSTANCE DATA
199 MyIntEnumeration d_value;
200
201 public:
202 // TYPES
203 enum {
205 };
206
207 enum {
209 };
210
211 enum {
213 };
214
215 // CONSTANTS
216 static const char CLASS_NAME[];
217
219
220 public:
221 // CLASS METHODS
222
223 /// Return attribute information for the attribute indicated by the
224 /// specified `id` if the attribute exists, and 0 otherwise.
226
227 /// Return attribute information for the attribute indicated by the
228 /// specified `name` of the specified `nameLength` if the attribute
229 /// exists, and 0 otherwise.
231 const char *name,
232 int nameLength);
233
234 // CREATORS
235
236 /// Create an object of type `MyIntEnumerationRecord` having the default
237 /// value.
239
240 /// Create an object of type `MyIntEnumerationRecord` having the value
241 /// of the specified `original` object.
243
244#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) \
245 && defined(BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT)
246 /// Create an object of type `MyIntEnumerationRecord` having the value
247 /// of the specified `original` object. After performing this action,
248 /// the `original` object will be left in a valid, but unspecified
249 /// state.
251#endif
252
253 /// Destroy this object.
255
256 // MANIPULATORS
257
258 /// Assign to this object the value of the specified `rhs` object.
260
261#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) \
262 && defined(BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT)
263 /// Assign to this object the value of the specified `rhs` object.
264 /// After performing this action, the `rhs` object will be left in a
265 /// valid, but unspecified state.
267#endif
268
269 /// Reset this object to the default value (i.e., its value upon
270 /// default construction).
271 void reset();
272
273 /// Invoke the specified `manipulator` sequentially on the address of
274 /// each (modifiable) attribute of this object, supplying `manipulator`
275 /// with the corresponding attribute information structure until such
276 /// invocation returns a non-zero value. Return the value from the
277 /// last invocation of `manipulator` (i.e., the invocation that
278 /// terminated the sequence).
279 template <typename t_MANIPULATOR>
280 int manipulateAttributes(t_MANIPULATOR& manipulator);
281
282 /// Invoke the specified `manipulator` on the address of
283 /// the (modifiable) attribute indicated by the specified `id`,
284 /// supplying `manipulator` with the corresponding attribute
285 /// information structure. Return the value returned from the
286 /// invocation of `manipulator` if `id` identifies an attribute of this
287 /// class, and -1 otherwise.
288 template <typename t_MANIPULATOR>
289 int manipulateAttribute(t_MANIPULATOR& manipulator, int id);
290
291 /// Invoke the specified `manipulator` on the address of
292 /// the (modifiable) attribute indicated by the specified `name` of the
293 /// specified `nameLength`, supplying `manipulator` with the
294 /// corresponding attribute information structure. Return the value
295 /// returned from the invocation of `manipulator` if `name` identifies
296 /// an attribute of this class, and -1 otherwise.
297 template <typename t_MANIPULATOR>
298 int manipulateAttribute(t_MANIPULATOR& manipulator,
299 const char *name,
300 int nameLength);
301
302 /// Return a reference to the modifiable "Value" attribute of this
303 /// object.
305
306 // ACCESSORS
307
308 /// Format this object to the specified output `stream` at the
309 /// optionally specified indentation `level` and return a reference to
310 /// the modifiable `stream`. If `level` is specified, optionally
311 /// specify `spacesPerLevel`, the number of spaces per indentation level
312 /// for this and all of its nested objects. Each line is indented by
313 /// the absolute value of `level * spacesPerLevel`. If `level` is
314 /// negative, suppress indentation of the first line. If
315 /// `spacesPerLevel` is negative, suppress line breaks and format the
316 /// entire output on one line. If `stream` is initially invalid, this
317 /// operation has no effect. Note that a trailing newline is provided
318 /// in multiline mode only.
319 bsl::ostream& print(bsl::ostream& stream,
320 int level = 0,
321 int spacesPerLevel = 4) const;
322
323 /// Invoke the specified `accessor` sequentially on each
324 /// (non-modifiable) attribute of this object, supplying `accessor`
325 /// with the corresponding attribute information structure until such
326 /// invocation returns a non-zero value. Return the value from the
327 /// last invocation of `accessor` (i.e., the invocation that terminated
328 /// the sequence).
329 template <typename t_ACCESSOR>
330 int accessAttributes(t_ACCESSOR& accessor) const;
331
332 /// Invoke the specified `accessor` on the (non-modifiable) attribute
333 /// of this object indicated by the specified `id`, supplying `accessor`
334 /// with the corresponding attribute information structure. Return the
335 /// value returned from the invocation of `accessor` if `id` identifies
336 /// an attribute of this class, and -1 otherwise.
337 template <typename t_ACCESSOR>
338 int accessAttribute(t_ACCESSOR& accessor, int id) const;
339
340 /// Invoke the specified `accessor` on the (non-modifiable) attribute
341 /// of this object indicated by the specified `name` of the specified
342 /// `nameLength`, supplying `accessor` with the corresponding attribute
343 /// information structure. Return the value returned from the
344 /// invocation of `accessor` if `name` identifies an attribute of this
345 /// class, and -1 otherwise.
346 template <typename t_ACCESSOR>
347 int accessAttribute(t_ACCESSOR& accessor,
348 const char *name,
349 int nameLength) const;
350
351 /// Return a reference offering non-modifiable access to the "Value"
352 /// attribute of this object.
353 const MyIntEnumeration& value() const;
354};
355
356// FREE OPERATORS
357
358/// Return `true` if the specified `lhs` and `rhs` attribute objects have
359/// the same value, and `false` otherwise. Two attribute objects have the
360/// same value if each respective attribute has the same value.
361inline
362bool operator==(const MyIntEnumerationRecord& lhs, const MyIntEnumerationRecord& rhs);
363
364/// Return `true` if the specified `lhs` and `rhs` attribute objects do not
365/// have the same value, and `false` otherwise. Two attribute objects do
366/// not have the same value if one or more respective attributes differ in
367/// values.
368inline
369bool operator!=(const MyIntEnumerationRecord& lhs, const MyIntEnumerationRecord& rhs);
370
371/// Format the specified `rhs` to the specified output `stream` and
372/// return a reference to the modifiable `stream`.
373inline
374bsl::ostream& operator<<(bsl::ostream& stream, const MyIntEnumerationRecord& rhs);
375
376} // close package namespace
377
378// TRAITS
379
381
382// ============================================================================
383// INLINE FUNCTION DEFINITIONS
384// ============================================================================
385
386namespace s_baltst {
387
388 // ----------------------
389 // class MyIntEnumeration
390 // ----------------------
391
392// CREATORS
393inline
395: d_value()
396{
397}
398
399inline
401: d_value(original.d_value)
402{
403}
404
405inline
407: d_value(value)
408{
409 BSLS_ASSERT(checkRestrictions(value) == 0);
410}
411
412inline
416
417// MANIPULATORS
418inline
420{
421 d_value = rhs.d_value;
422 return *this;
423}
424
425inline
430
431inline
432int MyIntEnumeration::fromInt(const int& value)
433{
434 int ret = checkRestrictions(value);
435 if (0 == ret) {
436 d_value = value;
437 }
438
439 return ret;
440}
441
442// ACCESSORS
443inline
444bsl::ostream& MyIntEnumeration::print(bsl::ostream& stream,
445 int level,
446 int spacesPerLevel) const
447{
448 return bdlb::PrintMethods::print(stream, d_value, level, spacesPerLevel);
449}
450
451inline
452const int& MyIntEnumeration::toInt() const
453{
454 return d_value;
455}
456
457
458
459 // ----------------------------
460 // class MyIntEnumerationRecord
461 // ----------------------------
462
463// CLASS METHODS
464// MANIPULATORS
465template <typename t_MANIPULATOR>
466int MyIntEnumerationRecord::manipulateAttributes(t_MANIPULATOR& manipulator)
467{
468 int ret;
469
470 ret = manipulator(&d_value, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_VALUE]);
471 if (ret) {
472 return ret;
473 }
474
475 return 0;
476}
477
478template <typename t_MANIPULATOR>
479int MyIntEnumerationRecord::manipulateAttribute(t_MANIPULATOR& manipulator, int id)
480{
481 enum { NOT_FOUND = -1 };
482
483 switch (id) {
484 case ATTRIBUTE_ID_VALUE: {
485 return manipulator(&d_value, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_VALUE]);
486 }
487 default:
488 return NOT_FOUND;
489 }
490}
491
492template <typename t_MANIPULATOR>
494 t_MANIPULATOR& manipulator,
495 const char *name,
496 int nameLength)
497{
498 enum { NOT_FOUND = -1 };
499
500 const bdlat_AttributeInfo *attributeInfo =
501 lookupAttributeInfo(name, nameLength);
502 if (0 == attributeInfo) {
503 return NOT_FOUND;
504 }
505
506 return manipulateAttribute(manipulator, attributeInfo->d_id);
507}
508
509inline
511{
512 return d_value;
513}
514
515// ACCESSORS
516template <typename t_ACCESSOR>
517int MyIntEnumerationRecord::accessAttributes(t_ACCESSOR& accessor) const
518{
519 int ret;
520
521 ret = accessor(d_value, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_VALUE]);
522 if (ret) {
523 return ret;
524 }
525
526 return 0;
527}
528
529template <typename t_ACCESSOR>
530int MyIntEnumerationRecord::accessAttribute(t_ACCESSOR& accessor, int id) const
531{
532 enum { NOT_FOUND = -1 };
533
534 switch (id) {
535 case ATTRIBUTE_ID_VALUE: {
536 return accessor(d_value, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_VALUE]);
537 }
538 default:
539 return NOT_FOUND;
540 }
541}
542
543template <typename t_ACCESSOR>
545 t_ACCESSOR& accessor,
546 const char *name,
547 int nameLength) const
548{
549 enum { NOT_FOUND = -1 };
550
551 const bdlat_AttributeInfo *attributeInfo =
552 lookupAttributeInfo(name, nameLength);
553 if (0 == attributeInfo) {
554 return NOT_FOUND;
555 }
556
557 return accessAttribute(accessor, attributeInfo->d_id);
558}
559
560inline
562{
563 return d_value;
564}
565
566} // close package namespace
567
568// FREE FUNCTIONS
569
570inline
574{
575 return lhs.d_value == rhs.d_value;
576}
577
578inline
582{
583 return lhs.d_value != rhs.d_value;
584}
585
586inline
587bsl::ostream& s_baltst::operator<<(
588 bsl::ostream& stream,
590{
591 return rhs.print(stream, 0, -1);
592}
593
594inline
598{
599 return lhs.value() == rhs.value();
600}
601
602inline
606{
607 return !(lhs == rhs);
608}
609
610inline
611bsl::ostream& s_baltst::operator<<(
612 bsl::ostream& stream,
614{
615 return rhs.print(stream, 0, -1);
616}
617
618
619#endif
620
621// GENERATED BY BLP_BAS_CODEGEN_2023.10.25
622// USING bas_codegen.pl s_baltst_myintenumeration.xsd --mode msg --includedir . --msgComponent myintenumeration --noRecurse --noExternalization --noHashSupport --noAggregateConversion
623// ----------------------------------------------------------------------------
624// NOTICE:
625// Copyright 2023 Bloomberg Finance L.P. All rights reserved.
626// Property of Bloomberg Finance L.P. (BFLP)
627// This software is made available solely pursuant to the
628// terms of a BFLP license agreement which governs its use.
629// ------------------------------- END-OF-FILE --------------------------------
630
631/** @} */
632/** @} */
633/** @} */
Definition s_baltst_myintenumeration.h:196
@ ATTRIBUTE_ID_VALUE
Definition s_baltst_myintenumeration.h:204
static const bdlat_AttributeInfo * lookupAttributeInfo(int id)
static const char CLASS_NAME[]
Definition s_baltst_myintenumeration.h:216
@ ATTRIBUTE_INDEX_VALUE
Definition s_baltst_myintenumeration.h:212
int manipulateAttributes(t_MANIPULATOR &manipulator)
Definition s_baltst_myintenumeration.h:466
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:218
MyIntEnumeration & value()
Definition s_baltst_myintenumeration.h:510
int manipulateAttribute(t_MANIPULATOR &manipulator, int id)
Definition s_baltst_myintenumeration.h:479
MyIntEnumerationRecord & operator=(const MyIntEnumerationRecord &rhs)
Assign to this object the value of the specified rhs object.
~MyIntEnumerationRecord()
Destroy this object.
@ NUM_ATTRIBUTES
Definition s_baltst_myintenumeration.h:208
int accessAttributes(t_ACCESSOR &accessor) const
Definition s_baltst_myintenumeration.h:517
MyIntEnumerationRecord(const MyIntEnumerationRecord &original)
int accessAttribute(t_ACCESSOR &accessor, int id) const
Definition s_baltst_myintenumeration.h:530
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:444
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:452
static int checkRestrictions(const int &value)
friend bool operator!=(const MyIntEnumeration &lhs, const MyIntEnumeration &rhs)
~MyIntEnumeration()
Destroy this object.
Definition s_baltst_myintenumeration.h:413
int fromInt(const int &value)
Definition s_baltst_myintenumeration.h:432
MyIntEnumeration & operator=(const MyIntEnumeration &rhs)
Assign to this object the value of the specified rhs object.
Definition s_baltst_myintenumeration.h:419
void reset()
Definition s_baltst_myintenumeration.h:426
int BaseType
Definition s_baltst_myintenumeration.h:81
MyIntEnumeration()
Definition s_baltst_myintenumeration.h:394
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:325
#define BDLAT_DECL_SEQUENCE_WITH_BITWISEMOVEABLE_TRAITS(ClassName)
Definition bdlat_typetraits.h:275
#define BSLS_ASSERT(X)
Definition bsls_assert.h:1804
#define BSLS_IDENT_RCSID(tag, str)
Definition bsls_ident.h:260
#define BSLS_IDENT_PRAGMA_ONCE
Definition bsls_ident.h:310
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:719
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