BDE 4.39.x Production Release
Loading...
Searching...
No Matches
s_baltst_myenumerationunpreservedwithfallback.h
Go to the documentation of this file.
1/// @file s_baltst_myenumerationunpreservedwithfallback.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// s_baltst_myenumerationunpreservedwithfallback.h *DO NOT EDIT* @generated -*-C++-*-
8#ifndef INCLUDED_S_BALTST_MYENUMERATIONUNPRESERVEDWITHFALLBACK
9#define INCLUDED_S_BALTST_MYENUMERATIONUNPRESERVEDWITHFALLBACK
10
11#include <bsls_ident.h>
12BSLS_IDENT_RCSID(s_baltst_myenumerationunpreservedwithfallback_h, "$Id$ $CSID$")
14
15/// @defgroup s_baltst_myenumerationunpreservedwithfallback s_baltst_myenumerationunpreservedwithfallback
16/// @brief Provide value-semantic attribute classes
17/// @addtogroup Standalones
18/// @{
19/// @addtogroup s_baltst
20/// @{
21/// @addtogroup s_baltst_myenumerationunpreservedwithfallback
22/// @{
23///
24/// <h1> Outline </h1>
25/// * <a href="#s_baltst_myenumerationunpreservedwithfallback-purpose"> Purpose</a>
26///
27/// # Purpose {#s_baltst_myenumerationunpreservedwithfallback-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_myenumerationunpreservedwithfallback
40 * @{
41 */
42
43#include <bslalg_typetraits.h>
44
45#include <bdlat_attributeinfo.h>
46
48
49#include <bdlat_selectioninfo.h>
50
51#include <bdlat_typetraits.h>
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#include <bsl_ostream.h>
61#include <bsl_string.h>
62
63
64
65namespace s_baltst { class MyEnumerationUnpreservedWithFallbackRecord; }
66namespace s_baltst {
67
68 // ==========================================
69 // class MyEnumerationUnpreservedWithFallback
70 // ==========================================
71
73
74 public:
75 // TYPES
76 enum Value {
77 UNKNOWN = 0
78 , VALUE1 = 1
79 , VALUE2 = 2
80 };
81
82 enum {
84 };
85
86 // CONSTANTS
87 static const char CLASS_NAME[];
88
90
91 // CLASS METHODS
92
93 /// Return the string representation exactly matching the enumerator
94 /// name corresponding to the specified enumeration `value`.
95 static const char *toString(Value value);
96
97 /// Load into the specified `result` the enumerator matching the
98 /// specified `string` of the specified `stringLength`. Return 0 on
99 /// success, and a non-zero value with no effect on `result` otherwise
100 /// (i.e., `string` does not match any enumerator).
101 static int fromString(Value *result,
102 const char *string,
103 int stringLength);
104
105 /// Load into the specified `result` the enumerator matching the
106 /// specified `string`. Return 0 on success, and a non-zero value with
107 /// no effect on `result` otherwise (i.e., `string` does not match any
108 /// enumerator).
109 static int fromString(Value *result,
110 const bsl::string& string);
111
112 /// Load into the specified `result` the enumerator matching the
113 /// specified `number`. Return 0 on success, and a non-zero value with
114 /// no effect on `result` otherwise (i.e., `number` does not match any
115 /// enumerator).
116 static int fromInt(Value *result, int number);
117
118 /// Load into the specified `result` the fallback enumerator value and
119 /// return 0 to indicate success.
120 static int makeFallback(Value *result);
121
122 /// Return `true` to indicate that this type supports a fallback
123 /// enumerator.
124 static bool hasFallback(Value);
125
126 /// Return `true` if the specified `value` equals the fallback
127 /// enumerator, and `false` otherwise.
128 static bool isFallback(Value value);
129
130 /// Write to the specified `stream` the string representation of
131 /// the specified enumeration `value`. Return a reference to
132 /// the modifiable `stream`.
133 static bsl::ostream& print(bsl::ostream& stream, Value value);
134};
135
136// FREE OPERATORS
137
138/// Format the specified `rhs` to the specified output `stream` and
139/// return a reference to the modifiable `stream`.
140inline
141bsl::ostream& operator<<(bsl::ostream& stream, MyEnumerationUnpreservedWithFallback::Value rhs);
142
143} // close package namespace
144
145// TRAITS
146
148
149
150namespace s_baltst {
151
152 // ================================================
153 // class MyEnumerationUnpreservedWithFallbackRecord
154 // ================================================
155
157
158 // INSTANCE DATA
160
161 public:
162 // TYPES
163 enum {
165 };
166
167 enum {
169 };
170
171 enum {
173 };
174
175 // CONSTANTS
176 static const char CLASS_NAME[];
177
179
180 public:
181 // CLASS METHODS
182
183 /// Return attribute information for the attribute indicated by the
184 /// specified `id` if the attribute exists, and 0 otherwise.
186
187 /// Return attribute information for the attribute indicated by the
188 /// specified `name` of the specified `nameLength` if the attribute
189 /// exists, and 0 otherwise.
191 const char *name,
192 int nameLength);
193
194 // CREATORS
195
196 /// Create an object of type
197 /// `MyEnumerationUnpreservedWithFallbackRecord` having the default
198 /// value.
200
201 /// Create an object of type
202 /// `MyEnumerationUnpreservedWithFallbackRecord` having the value of the
203 /// specified `original` object.
205
206#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) \
207 && defined(BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT)
208 /// Create an object of type
209 /// `MyEnumerationUnpreservedWithFallbackRecord` having the value of the
210 /// specified `original` object. After performing this action, the
211 /// `original` object will be left in a valid, but unspecified state.
213#endif
214
215 /// Destroy this object.
217
218 // MANIPULATORS
219
220 /// Assign to this object the value of the specified `rhs` object.
222
223#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) \
224 && defined(BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT)
225 /// Assign to this object the value of the specified `rhs` object.
226 /// After performing this action, the `rhs` object will be left in a
227 /// valid, but unspecified state.
229#endif
230
231 /// Reset this object to the default value (i.e., its value upon
232 /// default construction).
233 void reset();
234
235 /// Invoke the specified `manipulator` sequentially on the address of
236 /// each (modifiable) attribute of this object, supplying `manipulator`
237 /// with the corresponding attribute information structure until such
238 /// invocation returns a non-zero value. Return the value from the
239 /// last invocation of `manipulator` (i.e., the invocation that
240 /// terminated the sequence).
241 template <typename t_MANIPULATOR>
242 int manipulateAttributes(t_MANIPULATOR& manipulator);
243
244 /// Invoke the specified `manipulator` on the address of
245 /// the (modifiable) attribute indicated by the specified `id`,
246 /// supplying `manipulator` with the corresponding attribute
247 /// information structure. Return the value returned from the
248 /// invocation of `manipulator` if `id` identifies an attribute of this
249 /// class, and -1 otherwise.
250 template <typename t_MANIPULATOR>
251 int manipulateAttribute(t_MANIPULATOR& manipulator, int id);
252
253 /// Invoke the specified `manipulator` on the address of
254 /// the (modifiable) attribute indicated by the specified `name` of the
255 /// specified `nameLength`, supplying `manipulator` with the
256 /// corresponding attribute information structure. Return the value
257 /// returned from the invocation of `manipulator` if `name` identifies
258 /// an attribute of this class, and -1 otherwise.
259 template <typename t_MANIPULATOR>
260 int manipulateAttribute(t_MANIPULATOR& manipulator,
261 const char *name,
262 int nameLength);
263
264 /// Return a reference to the modifiable "Value" attribute of this
265 /// object.
267
268 // ACCESSORS
269
270 /// Format this object to the specified output `stream` at the
271 /// optionally specified indentation `level` and return a reference to
272 /// the modifiable `stream`. If `level` is specified, optionally
273 /// specify `spacesPerLevel`, the number of spaces per indentation level
274 /// for this and all of its nested objects. Each line is indented by
275 /// the absolute value of `level * spacesPerLevel`. If `level` is
276 /// negative, suppress indentation of the first line. If
277 /// `spacesPerLevel` is negative, suppress line breaks and format the
278 /// entire output on one line. If `stream` is initially invalid, this operation has no effect.
279 ///
280 /// \note Note that a trailing newline is provided
281 /// in multiline mode only.
282 bsl::ostream& print(bsl::ostream& stream,
283 int level = 0,
284 int spacesPerLevel = 4) const;
285
286 /// Invoke the specified `accessor` sequentially on each
287 /// (non-modifiable) attribute of this object, supplying `accessor`
288 /// with the corresponding attribute information structure until such
289 /// invocation returns a non-zero value. Return the value from the
290 /// last invocation of `accessor` (i.e., the invocation that terminated
291 /// the sequence).
292 template <typename t_ACCESSOR>
293 int accessAttributes(t_ACCESSOR& accessor) const;
294
295 /// Invoke the specified `accessor` on the (non-modifiable) attribute
296 /// of this object indicated by the specified `id`, supplying `accessor`
297 /// with the corresponding attribute information structure. Return the
298 /// value returned from the invocation of `accessor` if `id` identifies
299 /// an attribute of this class, and -1 otherwise.
300 template <typename t_ACCESSOR>
301 int accessAttribute(t_ACCESSOR& accessor, int id) const;
302
303 /// Invoke the specified `accessor` on the (non-modifiable) attribute
304 /// of this object indicated by the specified `name` of the specified
305 /// `nameLength`, supplying `accessor` with the corresponding attribute
306 /// information structure. Return the value returned from the
307 /// invocation of `accessor` if `name` identifies an attribute of this
308 /// class, and -1 otherwise.
309 template <typename t_ACCESSOR>
310 int accessAttribute(t_ACCESSOR& accessor,
311 const char *name,
312 int nameLength) const;
313
314 /// Return the value of the "Value" attribute of this object.
316};
317
318// FREE OPERATORS
319
320/// Return `true` if the specified `lhs` and `rhs` attribute objects have
321/// the same value, and `false` otherwise. Two attribute objects have the
322/// same value if each respective attribute has the same value.
323inline
325
326/// Return `true` if the specified `lhs` and `rhs` attribute objects do not
327/// have the same value, and `false` otherwise. Two attribute objects do
328/// not have the same value if one or more respective attributes differ in
329/// values.
330inline
332
333/// Format the specified `rhs` to the specified output `stream` and
334/// return a reference to the modifiable `stream`.
335inline
336bsl::ostream& operator<<(bsl::ostream& stream, const MyEnumerationUnpreservedWithFallbackRecord& rhs);
337
338} // close package namespace
339
340// TRAITS
341
343
344// ============================================================================
345// INLINE FUNCTION DEFINITIONS
346// ============================================================================
347
348namespace s_baltst {
349
350 // ------------------------------------------
351 // class MyEnumerationUnpreservedWithFallback
352 // ------------------------------------------
353
354// CLASS METHODS
355inline
357{
358 return fromString(result, string.c_str(), static_cast<int>(string.length()));
359}
360
361inline
362bsl::ostream& MyEnumerationUnpreservedWithFallback::print(bsl::ostream& stream,
364{
365 return stream << toString(value);
366}
367
368inline
374
375inline
380
381inline
386
387
388
389 // ------------------------------------------------
390 // class MyEnumerationUnpreservedWithFallbackRecord
391 // ------------------------------------------------
392
393// CLASS METHODS
394// MANIPULATORS
395template <typename t_MANIPULATOR>
397{
398 int ret;
399
400 ret = manipulator(&d_value, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_VALUE]);
401 if (ret) {
402 return ret;
403 }
404
405 return 0;
406}
407
408template <typename t_MANIPULATOR>
410{
411 enum { NOT_FOUND = -1 };
412
413 switch (id) {
414 case ATTRIBUTE_ID_VALUE: {
415 return manipulator(&d_value, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_VALUE]);
416 }
417 default:
418 return NOT_FOUND;
419 }
420}
421
422template <typename t_MANIPULATOR>
424 t_MANIPULATOR& manipulator,
425 const char *name,
426 int nameLength)
427{
428 enum { NOT_FOUND = -1 };
429
430 const bdlat_AttributeInfo *attributeInfo =
431 lookupAttributeInfo(name, nameLength);
432 if (0 == attributeInfo) {
433 return NOT_FOUND;
434 }
435
436 return manipulateAttribute(manipulator, attributeInfo->d_id);
437}
438
439inline
444
445// ACCESSORS
446template <typename t_ACCESSOR>
448{
449 int ret;
450
451 ret = accessor(d_value, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_VALUE]);
452 if (ret) {
453 return ret;
454 }
455
456 return 0;
457}
458
459template <typename t_ACCESSOR>
461{
462 enum { NOT_FOUND = -1 };
463
464 switch (id) {
465 case ATTRIBUTE_ID_VALUE: {
466 return accessor(d_value, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_VALUE]);
467 }
468 default:
469 return NOT_FOUND;
470 }
471}
472
473template <typename t_ACCESSOR>
475 t_ACCESSOR& accessor,
476 const char *name,
477 int nameLength) const
478{
479 enum { NOT_FOUND = -1 };
480
481 const bdlat_AttributeInfo *attributeInfo =
482 lookupAttributeInfo(name, nameLength);
483 if (0 == attributeInfo) {
484 return NOT_FOUND;
485 }
486
487 return accessAttribute(accessor, attributeInfo->d_id);
488}
489
490inline
495
496} // close package namespace
497
498// FREE FUNCTIONS
499
500inline
501bsl::ostream& s_baltst::operator<<(
502 bsl::ostream& stream,
504{
506}
507
508inline
512{
513 return lhs.value() == rhs.value();
514}
515
516inline
520{
521 return !(lhs == rhs);
522}
523
524inline
525bsl::ostream& s_baltst::operator<<(
526 bsl::ostream& stream,
528{
529 return rhs.print(stream, 0, -1);
530}
531
532
533#endif
534
535// GENERATED BY BLP_BAS_CODEGEN_2023.09.30
536// USING bas_codegen.pl s_baltst_myenumerationunpreservedwithfallback.xsd --mode msg --includedir . --msgComponent myenumerationunpreservedwithfallback --noRecurse --noExternalization --noHashSupport --noAggregateConversion
537// ----------------------------------------------------------------------------
538// NOTICE:
539// Copyright 2023 Bloomberg Finance L.P. All rights reserved.
540// Property of Bloomberg Finance L.P. (BFLP)
541// This software is made available solely pursuant to the
542// terms of a BFLP license agreement which governs its use.
543// ------------------------------- END-OF-FILE --------------------------------
544
545/** @} */
546/** @} */
547/** @} */
Definition bslstl_string.h:1252
Definition s_baltst_myenumerationunpreservedwithfallback.h:156
int accessAttribute(t_ACCESSOR &accessor, int id) const
Definition s_baltst_myenumerationunpreservedwithfallback.h:460
~MyEnumerationUnpreservedWithFallbackRecord()
Destroy this object.
MyEnumerationUnpreservedWithFallbackRecord & operator=(const MyEnumerationUnpreservedWithFallbackRecord &rhs)
Assign to this object the value of the specified rhs object.
static const bdlat_AttributeInfo ATTRIBUTE_INFO_ARRAY[]
Definition s_baltst_myenumerationunpreservedwithfallback.h:178
static const bdlat_AttributeInfo * lookupAttributeInfo(int id)
int accessAttributes(t_ACCESSOR &accessor) const
Definition s_baltst_myenumerationunpreservedwithfallback.h:447
static const bdlat_AttributeInfo * lookupAttributeInfo(const char *name, int nameLength)
MyEnumerationUnpreservedWithFallback::Value & value()
Definition s_baltst_myenumerationunpreservedwithfallback.h:440
int manipulateAttribute(t_MANIPULATOR &manipulator, int id)
Definition s_baltst_myenumerationunpreservedwithfallback.h:409
@ ATTRIBUTE_INDEX_VALUE
Definition s_baltst_myenumerationunpreservedwithfallback.h:172
@ ATTRIBUTE_ID_VALUE
Definition s_baltst_myenumerationunpreservedwithfallback.h:164
static const char CLASS_NAME[]
Definition s_baltst_myenumerationunpreservedwithfallback.h:176
MyEnumerationUnpreservedWithFallbackRecord(const MyEnumerationUnpreservedWithFallbackRecord &original)
int manipulateAttributes(t_MANIPULATOR &manipulator)
Definition s_baltst_myenumerationunpreservedwithfallback.h:396
bsl::ostream & print(bsl::ostream &stream, int level=0, int spacesPerLevel=4) const
@ NUM_ATTRIBUTES
Definition s_baltst_myenumerationunpreservedwithfallback.h:168
#define BDLAT_DECL_ENUMERATION_WITH_FALLBACK_TRAITS(ClassName)
Definition bdlat_typetraits.h:324
#define BDLAT_DECL_SEQUENCE_WITH_BITWISEMOVEABLE_TRAITS(ClassName)
Definition bdlat_typetraits.h:294
#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
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
Definition bdlat_enumeratorinfo.h:99
Definition s_baltst_myenumerationunpreservedwithfallback.h:72
static int fromInt(Value *result, int number)
@ NUM_ENUMERATORS
Definition s_baltst_myenumerationunpreservedwithfallback.h:83
static bool isFallback(Value value)
Definition s_baltst_myenumerationunpreservedwithfallback.h:382
Value
Definition s_baltst_myenumerationunpreservedwithfallback.h:76
@ UNKNOWN
Definition s_baltst_myenumerationunpreservedwithfallback.h:77
@ VALUE2
Definition s_baltst_myenumerationunpreservedwithfallback.h:79
@ VALUE1
Definition s_baltst_myenumerationunpreservedwithfallback.h:78
static const char * toString(Value value)
static int makeFallback(Value *result)
Definition s_baltst_myenumerationunpreservedwithfallback.h:369
static bsl::ostream & print(bsl::ostream &stream, Value value)
Definition s_baltst_myenumerationunpreservedwithfallback.h:362
static bool hasFallback(Value)
Definition s_baltst_myenumerationunpreservedwithfallback.h:376
static const bdlat_EnumeratorInfo ENUMERATOR_INFO_ARRAY[]
Definition s_baltst_myenumerationunpreservedwithfallback.h:89
static const char CLASS_NAME[]
Definition s_baltst_myenumerationunpreservedwithfallback.h:87
static int fromString(Value *result, const char *string, int stringLength)