BDE 4.14.0 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
279 /// operation has no effect. Note that a trailing newline is provided
280 /// in multiline mode only.
281 bsl::ostream& print(bsl::ostream& stream,
282 int level = 0,
283 int spacesPerLevel = 4) const;
284
285 /// Invoke the specified `accessor` sequentially on each
286 /// (non-modifiable) attribute of this object, supplying `accessor`
287 /// with the corresponding attribute information structure until such
288 /// invocation returns a non-zero value. Return the value from the
289 /// last invocation of `accessor` (i.e., the invocation that terminated
290 /// the sequence).
291 template <typename t_ACCESSOR>
292 int accessAttributes(t_ACCESSOR& accessor) const;
293
294 /// Invoke the specified `accessor` on the (non-modifiable) attribute
295 /// of this object indicated by the specified `id`, supplying `accessor`
296 /// with the corresponding attribute information structure. Return the
297 /// value returned from the invocation of `accessor` if `id` identifies
298 /// an attribute of this class, and -1 otherwise.
299 template <typename t_ACCESSOR>
300 int accessAttribute(t_ACCESSOR& accessor, int id) const;
301
302 /// Invoke the specified `accessor` on the (non-modifiable) attribute
303 /// of this object indicated by the specified `name` of the specified
304 /// `nameLength`, supplying `accessor` with the corresponding attribute
305 /// information structure. Return the value returned from the
306 /// invocation of `accessor` if `name` identifies an attribute of this
307 /// class, and -1 otherwise.
308 template <typename t_ACCESSOR>
309 int accessAttribute(t_ACCESSOR& accessor,
310 const char *name,
311 int nameLength) const;
312
313 /// Return the value of the "Value" attribute of this object.
315};
316
317// FREE OPERATORS
318
319/// Return `true` if the specified `lhs` and `rhs` attribute objects have
320/// the same value, and `false` otherwise. Two attribute objects have the
321/// same value if each respective attribute has the same value.
322inline
324
325/// Return `true` if the specified `lhs` and `rhs` attribute objects do not
326/// have the same value, and `false` otherwise. Two attribute objects do
327/// not have the same value if one or more respective attributes differ in
328/// values.
329inline
331
332/// Format the specified `rhs` to the specified output `stream` and
333/// return a reference to the modifiable `stream`.
334inline
335bsl::ostream& operator<<(bsl::ostream& stream, const MyEnumerationUnpreservedWithFallbackRecord& rhs);
336
337} // close package namespace
338
339// TRAITS
340
342
343// ============================================================================
344// INLINE FUNCTION DEFINITIONS
345// ============================================================================
346
347namespace s_baltst {
348
349 // ------------------------------------------
350 // class MyEnumerationUnpreservedWithFallback
351 // ------------------------------------------
352
353// CLASS METHODS
354inline
356{
357 return fromString(result, string.c_str(), static_cast<int>(string.length()));
358}
359
360inline
361bsl::ostream& MyEnumerationUnpreservedWithFallback::print(bsl::ostream& stream,
363{
364 return stream << toString(value);
365}
366
367inline
373
374inline
379
380inline
385
386
387
388 // ------------------------------------------------
389 // class MyEnumerationUnpreservedWithFallbackRecord
390 // ------------------------------------------------
391
392// CLASS METHODS
393// MANIPULATORS
394template <typename t_MANIPULATOR>
396{
397 int ret;
398
399 ret = manipulator(&d_value, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_VALUE]);
400 if (ret) {
401 return ret;
402 }
403
404 return 0;
405}
406
407template <typename t_MANIPULATOR>
409{
410 enum { NOT_FOUND = -1 };
411
412 switch (id) {
413 case ATTRIBUTE_ID_VALUE: {
414 return manipulator(&d_value, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_VALUE]);
415 }
416 default:
417 return NOT_FOUND;
418 }
419}
420
421template <typename t_MANIPULATOR>
423 t_MANIPULATOR& manipulator,
424 const char *name,
425 int nameLength)
426{
427 enum { NOT_FOUND = -1 };
428
429 const bdlat_AttributeInfo *attributeInfo =
430 lookupAttributeInfo(name, nameLength);
431 if (0 == attributeInfo) {
432 return NOT_FOUND;
433 }
434
435 return manipulateAttribute(manipulator, attributeInfo->d_id);
436}
437
438inline
443
444// ACCESSORS
445template <typename t_ACCESSOR>
447{
448 int ret;
449
450 ret = accessor(d_value, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_VALUE]);
451 if (ret) {
452 return ret;
453 }
454
455 return 0;
456}
457
458template <typename t_ACCESSOR>
460{
461 enum { NOT_FOUND = -1 };
462
463 switch (id) {
464 case ATTRIBUTE_ID_VALUE: {
465 return accessor(d_value, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_VALUE]);
466 }
467 default:
468 return NOT_FOUND;
469 }
470}
471
472template <typename t_ACCESSOR>
474 t_ACCESSOR& accessor,
475 const char *name,
476 int nameLength) const
477{
478 enum { NOT_FOUND = -1 };
479
480 const bdlat_AttributeInfo *attributeInfo =
481 lookupAttributeInfo(name, nameLength);
482 if (0 == attributeInfo) {
483 return NOT_FOUND;
484 }
485
486 return accessAttribute(accessor, attributeInfo->d_id);
487}
488
489inline
494
495} // close package namespace
496
497// FREE FUNCTIONS
498
499inline
500bsl::ostream& s_baltst::operator<<(
501 bsl::ostream& stream,
503{
505}
506
507inline
511{
512 return lhs.value() == rhs.value();
513}
514
515inline
519{
520 return !(lhs == rhs);
521}
522
523inline
524bsl::ostream& s_baltst::operator<<(
525 bsl::ostream& stream,
527{
528 return rhs.print(stream, 0, -1);
529}
530
531
532#endif
533
534// GENERATED BY BLP_BAS_CODEGEN_2023.09.30
535// USING bas_codegen.pl s_baltst_myenumerationunpreservedwithfallback.xsd --mode msg --includedir . --msgComponent myenumerationunpreservedwithfallback --noRecurse --noExternalization --noHashSupport --noAggregateConversion
536// ----------------------------------------------------------------------------
537// NOTICE:
538// Copyright 2023 Bloomberg Finance L.P. All rights reserved.
539// Property of Bloomberg Finance L.P. (BFLP)
540// This software is made available solely pursuant to the
541// terms of a BFLP license agreement which governs its use.
542// ------------------------------- END-OF-FILE --------------------------------
543
544/** @} */
545/** @} */
546/** @} */
Definition bslstl_string.h:1281
Definition s_baltst_myenumerationunpreservedwithfallback.h:156
int accessAttribute(t_ACCESSOR &accessor, int id) const
Definition s_baltst_myenumerationunpreservedwithfallback.h:459
~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:446
static const bdlat_AttributeInfo * lookupAttributeInfo(const char *name, int nameLength)
@ NUM_ATTRIBUTES
Definition s_baltst_myenumerationunpreservedwithfallback.h:168
MyEnumerationUnpreservedWithFallback::Value & value()
Definition s_baltst_myenumerationunpreservedwithfallback.h:439
int manipulateAttribute(t_MANIPULATOR &manipulator, int id)
Definition s_baltst_myenumerationunpreservedwithfallback.h:408
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:395
bsl::ostream & print(bsl::ostream &stream, int level=0, int spacesPerLevel=4) const
@ ATTRIBUTE_INDEX_VALUE
Definition s_baltst_myenumerationunpreservedwithfallback.h:172
@ ATTRIBUTE_ID_VALUE
Definition s_baltst_myenumerationunpreservedwithfallback.h:164
#define BDLAT_DECL_ENUMERATION_WITH_FALLBACK_TRAITS(ClassName)
Definition bdlat_typetraits.h:305
#define BDLAT_DECL_SEQUENCE_WITH_BITWISEMOVEABLE_TRAITS(ClassName)
Definition bdlat_typetraits.h:275
#define BSLS_IDENT_RCSID(tag, str)
Definition bsls_ident.h:260
#define BSLS_IDENT_PRAGMA_ONCE
Definition bsls_ident.h:310
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
Definition bdlat_enumeratorinfo.h:97
Definition s_baltst_myenumerationunpreservedwithfallback.h:72
@ NUM_ENUMERATORS
Definition s_baltst_myenumerationunpreservedwithfallback.h:83
static int fromInt(Value *result, int number)
static bool isFallback(Value value)
Definition s_baltst_myenumerationunpreservedwithfallback.h:381
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:368
static bsl::ostream & print(bsl::ostream &stream, Value value)
Definition s_baltst_myenumerationunpreservedwithfallback.h:361
static bool hasFallback(Value)
Definition s_baltst_myenumerationunpreservedwithfallback.h:375
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)