BDE 4.14.0 Production release
Loading...
Searching...
No Matches
s_baltst_mysequencewithchoices.h
Go to the documentation of this file.
1/// @file s_baltst_mysequencewithchoices.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// s_baltst_mysequencewithchoices.h *DO NOT EDIT* @generated -*-C++-*-
8#ifndef INCLUDED_S_BALTST_MYSEQUENCEWITHCHOICES
9#define INCLUDED_S_BALTST_MYSEQUENCEWITHCHOICES
10
11#include <bsls_ident.h>
12BSLS_IDENT_RCSID(s_baltst_mysequencewithchoices_h, "$Id$ $CSID$")
14
15/// @defgroup s_baltst_mysequencewithchoices s_baltst_mysequencewithchoices
16/// @brief Provide value-semantic attribute classes
17/// @addtogroup Standalones
18/// @{
19/// @addtogroup s_baltst
20/// @{
21/// @addtogroup s_baltst_mysequencewithchoices
22/// @{
23///
24/// <h1> Outline </h1>
25/// * <a href="#s_baltst_mysequencewithchoices-purpose"> Purpose</a>
26///
27/// # Purpose {#s_baltst_mysequencewithchoices-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_mysequencewithchoices
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 <bsls_assert.h>
54
55#include <bsl_iosfwd.h>
56#include <bsl_limits.h>
57
58
59
60namespace s_baltst { class MySequenceWithChoicesChoice1; }
61namespace s_baltst { class MySequenceWithChoicesChoice2; }
62namespace s_baltst { class MySequenceWithChoices; }
63namespace s_baltst {
64
65 // ==================================
66 // class MySequenceWithChoicesChoice1
67 // ==================================
68
70
71 // INSTANCE DATA
72 union {
75 };
76
77 int d_selectionId;
78
79 public:
80 // TYPES
81
82 enum {
86 };
87
88 enum {
90 };
91
92 enum {
95 };
96
97 // CONSTANTS
98 static const char CLASS_NAME[];
99
101
102 // CLASS METHODS
103
104 /// Return selection information for the selection indicated by the
105 /// specified `id` if the selection exists, and 0 otherwise.
107
108 /// Return selection information for the selection indicated by the
109 /// specified `name` of the specified `nameLength` if the selection
110 /// exists, and 0 otherwise.
112 const char *name,
113 int nameLength);
114
115 // CREATORS
116
117 /// Create an object of type `MySequenceWithChoicesChoice1` having the
118 /// default value.
120
121 /// Create an object of type `MySequenceWithChoicesChoice1` having the
122 /// value of the specified `original` object.
124
125#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) \
126 && defined(BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT)
127 /// Create an object of type `MySequenceWithChoicesChoice1` having the
128 /// value of the specified `original` object. After performing this
129 /// action, the `original` object will be left in a valid, but
130 /// unspecified state.
132#endif
133
134 /// Destroy this object.
136
137 // MANIPULATORS
138
139 /// Assign to this object the value of the specified `rhs` object.
141
142#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) \
143 && defined(BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT)
144 /// Assign to this object the value of the specified `rhs` object.
145 /// After performing this action, the `rhs` object will be left in a
146 /// valid, but unspecified state.
148#endif
149
150 /// Reset this object to the default value (i.e., its value upon default
151 /// construction).
152 void reset();
153
154 /// Set the value of this object to be the default for the selection
155 /// indicated by the specified `selectionId`. Return 0 on success, and
156 /// non-zero value otherwise (i.e., the selection is not found).
158
159 /// Set the value of this object to be the default for the selection
160 /// indicated by the specified `name` of the specified `nameLength`.
161 /// Return 0 on success, and non-zero value otherwise (i.e., the
162 /// selection is not found).
163 int makeSelection(const char *name, int nameLength);
164
165 /// Set the value of this object to be a "ChoiceA" value. Optionally
166 /// specify the `value` of the "ChoiceA". If `value` is not specified,
167 /// the default "ChoiceA" value is used.
169 int& makeChoiceA(int value);
170
171 /// Set the value of this object to be a "ChoiceB" value. Optionally
172 /// specify the `value` of the "ChoiceB". If `value` is not specified,
173 /// the default "ChoiceB" value is used.
175 int& makeChoiceB(int value);
176
177 /// Invoke the specified `manipulator` on the address of the modifiable
178 /// selection, supplying `manipulator` with the corresponding selection
179 /// information structure. Return the value returned from the
180 /// invocation of `manipulator` if this object has a defined selection,
181 /// and -1 otherwise.
182 template<class MANIPULATOR>
183 int manipulateSelection(MANIPULATOR& manipulator);
184
185 /// Return a reference to the modifiable "ChoiceA" selection of this
186 /// object if "ChoiceA" is the current selection. The behavior is
187 /// undefined unless "ChoiceA" is the selection of this object.
188 int& choiceA();
189
190 /// Return a reference to the modifiable "ChoiceB" selection of this
191 /// object if "ChoiceB" is the current selection. The behavior is
192 /// undefined unless "ChoiceB" is the selection of this object.
193 int& choiceB();
194
195 // ACCESSORS
196
197 /// Format this object to the specified output `stream` at the
198 /// optionally specified indentation `level` and return a reference to
199 /// the modifiable `stream`. If `level` is specified, optionally
200 /// specify `spacesPerLevel`, the number of spaces per indentation level
201 /// for this and all of its nested objects. Each line is indented by
202 /// the absolute value of `level * spacesPerLevel`. If `level` is
203 /// negative, suppress indentation of the first line. If
204 /// `spacesPerLevel` is negative, suppress line breaks and format the
205 /// entire output on one line. If `stream` is initially invalid, this
206 /// operation has no effect. Note that a trailing newline is provided
207 /// in multiline mode only.
208 bsl::ostream& print(bsl::ostream& stream,
209 int level = 0,
210 int spacesPerLevel = 4) const;
211
212 /// Return the id of the current selection if the selection is defined,
213 /// and -1 otherwise.
214 int selectionId() const;
215
216 /// Invoke the specified `accessor` on the non-modifiable selection,
217 /// supplying `accessor` with the corresponding selection information
218 /// structure. Return the value returned from the invocation of
219 /// `accessor` if this object has a defined selection, and -1 otherwise.
220 template<class ACCESSOR>
221 int accessSelection(ACCESSOR& accessor) const;
222
223 /// Return a reference to the non-modifiable "ChoiceA" selection of this
224 /// object if "ChoiceA" is the current selection. The behavior is
225 /// undefined unless "ChoiceA" is the selection of this object.
226 const int& choiceA() const;
227
228 /// Return a reference to the non-modifiable "ChoiceB" selection of this
229 /// object if "ChoiceB" is the current selection. The behavior is
230 /// undefined unless "ChoiceB" is the selection of this object.
231 const int& choiceB() const;
232
233 /// Return `true` if the value of this object is a "ChoiceA" value, and
234 /// return `false` otherwise.
235 bool isChoiceAValue() const;
236
237 /// Return `true` if the value of this object is a "ChoiceB" value, and
238 /// return `false` otherwise.
239 bool isChoiceBValue() const;
240
241 /// Return `true` if the value of this object is undefined, and `false`
242 /// otherwise.
243 bool isUndefinedValue() const;
244
245 /// Return the symbolic name of the current selection of this object.
246 const char *selectionName() const;
247};
248
249// FREE OPERATORS
250
251/// Return `true` if the specified `lhs` and `rhs` objects have the same
252/// value, and `false` otherwise. Two `MySequenceWithChoicesChoice1` objects have the same
253/// value if either the selections in both objects have the same ids and
254/// the same values, or both selections are undefined.
255inline
256bool operator==(const MySequenceWithChoicesChoice1& lhs, const MySequenceWithChoicesChoice1& rhs);
257
258/// Return `true` if the specified `lhs` and `rhs` objects do not have the
259/// same values, as determined by `operator==`, and `false` otherwise.
260inline
261bool operator!=(const MySequenceWithChoicesChoice1& lhs, const MySequenceWithChoicesChoice1& rhs);
262
263/// Format the specified `rhs` to the specified output `stream` and
264/// return a reference to the modifiable `stream`.
265inline
266bsl::ostream& operator<<(bsl::ostream& stream, const MySequenceWithChoicesChoice1& rhs);
267
268} // close package namespace
269
270// TRAITS
271
273
274namespace s_baltst {
275
276 // ==================================
277 // class MySequenceWithChoicesChoice2
278 // ==================================
279
281
282 // INSTANCE DATA
283 union {
286 };
287
288 int d_selectionId;
289
290 public:
291 // TYPES
292
293 enum {
297 };
298
299 enum {
301 };
302
303 enum {
306 };
307
308 // CONSTANTS
309 static const char CLASS_NAME[];
310
312
313 // CLASS METHODS
314
315 /// Return selection information for the selection indicated by the
316 /// specified `id` if the selection exists, and 0 otherwise.
318
319 /// Return selection information for the selection indicated by the
320 /// specified `name` of the specified `nameLength` if the selection
321 /// exists, and 0 otherwise.
323 const char *name,
324 int nameLength);
325
326 // CREATORS
327
328 /// Create an object of type `MySequenceWithChoicesChoice2` having the
329 /// default value.
331
332 /// Create an object of type `MySequenceWithChoicesChoice2` having the
333 /// value of the specified `original` object.
335
336#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) \
337 && defined(BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT)
338 /// Create an object of type `MySequenceWithChoicesChoice2` having the
339 /// value of the specified `original` object. After performing this
340 /// action, the `original` object will be left in a valid, but
341 /// unspecified state.
343#endif
344
345 /// Destroy this object.
347
348 // MANIPULATORS
349
350 /// Assign to this object the value of the specified `rhs` object.
352
353#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) \
354 && defined(BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT)
355 /// Assign to this object the value of the specified `rhs` object.
356 /// After performing this action, the `rhs` object will be left in a
357 /// valid, but unspecified state.
359#endif
360
361 /// Reset this object to the default value (i.e., its value upon default
362 /// construction).
363 void reset();
364
365 /// Set the value of this object to be the default for the selection
366 /// indicated by the specified `selectionId`. Return 0 on success, and
367 /// non-zero value otherwise (i.e., the selection is not found).
369
370 /// Set the value of this object to be the default for the selection
371 /// indicated by the specified `name` of the specified `nameLength`.
372 /// Return 0 on success, and non-zero value otherwise (i.e., the
373 /// selection is not found).
374 int makeSelection(const char *name, int nameLength);
375
376 /// Set the value of this object to be a "ChoiceC" value. Optionally
377 /// specify the `value` of the "ChoiceC". If `value` is not specified,
378 /// the default "ChoiceC" value is used.
380 int& makeChoiceC(int value);
381
382 /// Set the value of this object to be a "ChoiceD" value. Optionally
383 /// specify the `value` of the "ChoiceD". If `value` is not specified,
384 /// the default "ChoiceD" value is used.
386 int& makeChoiceD(int value);
387
388 /// Invoke the specified `manipulator` on the address of the modifiable
389 /// selection, supplying `manipulator` with the corresponding selection
390 /// information structure. Return the value returned from the
391 /// invocation of `manipulator` if this object has a defined selection,
392 /// and -1 otherwise.
393 template<class MANIPULATOR>
394 int manipulateSelection(MANIPULATOR& manipulator);
395
396 /// Return a reference to the modifiable "ChoiceC" selection of this
397 /// object if "ChoiceC" is the current selection. The behavior is
398 /// undefined unless "ChoiceC" is the selection of this object.
399 int& choiceC();
400
401 /// Return a reference to the modifiable "ChoiceD" selection of this
402 /// object if "ChoiceD" is the current selection. The behavior is
403 /// undefined unless "ChoiceD" is the selection of this object.
404 int& choiceD();
405
406 // ACCESSORS
407
408 /// Format this object to the specified output `stream` at the
409 /// optionally specified indentation `level` and return a reference to
410 /// the modifiable `stream`. If `level` is specified, optionally
411 /// specify `spacesPerLevel`, the number of spaces per indentation level
412 /// for this and all of its nested objects. Each line is indented by
413 /// the absolute value of `level * spacesPerLevel`. If `level` is
414 /// negative, suppress indentation of the first line. If
415 /// `spacesPerLevel` is negative, suppress line breaks and format the
416 /// entire output on one line. If `stream` is initially invalid, this
417 /// operation has no effect. Note that a trailing newline is provided
418 /// in multiline mode only.
419 bsl::ostream& print(bsl::ostream& stream,
420 int level = 0,
421 int spacesPerLevel = 4) const;
422
423 /// Return the id of the current selection if the selection is defined,
424 /// and -1 otherwise.
425 int selectionId() const;
426
427 /// Invoke the specified `accessor` on the non-modifiable selection,
428 /// supplying `accessor` with the corresponding selection information
429 /// structure. Return the value returned from the invocation of
430 /// `accessor` if this object has a defined selection, and -1 otherwise.
431 template<class ACCESSOR>
432 int accessSelection(ACCESSOR& accessor) const;
433
434 /// Return a reference to the non-modifiable "ChoiceC" selection of this
435 /// object if "ChoiceC" is the current selection. The behavior is
436 /// undefined unless "ChoiceC" is the selection of this object.
437 const int& choiceC() const;
438
439 /// Return a reference to the non-modifiable "ChoiceD" selection of this
440 /// object if "ChoiceD" is the current selection. The behavior is
441 /// undefined unless "ChoiceD" is the selection of this object.
442 const int& choiceD() const;
443
444 /// Return `true` if the value of this object is a "ChoiceC" value, and
445 /// return `false` otherwise.
446 bool isChoiceCValue() const;
447
448 /// Return `true` if the value of this object is a "ChoiceD" value, and
449 /// return `false` otherwise.
450 bool isChoiceDValue() const;
451
452 /// Return `true` if the value of this object is undefined, and `false`
453 /// otherwise.
454 bool isUndefinedValue() const;
455
456 /// Return the symbolic name of the current selection of this object.
457 const char *selectionName() const;
458};
459
460// FREE OPERATORS
461
462/// Return `true` if the specified `lhs` and `rhs` objects have the same
463/// value, and `false` otherwise. Two `MySequenceWithChoicesChoice2` objects have the same
464/// value if either the selections in both objects have the same ids and
465/// the same values, or both selections are undefined.
466inline
467bool operator==(const MySequenceWithChoicesChoice2& lhs, const MySequenceWithChoicesChoice2& rhs);
468
469/// Return `true` if the specified `lhs` and `rhs` objects do not have the
470/// same values, as determined by `operator==`, and `false` otherwise.
471inline
472bool operator!=(const MySequenceWithChoicesChoice2& lhs, const MySequenceWithChoicesChoice2& rhs);
473
474/// Format the specified `rhs` to the specified output `stream` and
475/// return a reference to the modifiable `stream`.
476inline
477bsl::ostream& operator<<(bsl::ostream& stream, const MySequenceWithChoicesChoice2& rhs);
478
479} // close package namespace
480
481// TRAITS
482
484
485namespace s_baltst {
486
487 // ===========================
488 // class MySequenceWithChoices
489 // ===========================
490
492
493 // INSTANCE DATA
496
497 public:
498 // TYPES
499 enum {
502 };
503
504 enum {
506 };
507
508 enum {
511 };
512
513 // CONSTANTS
514 static const char CLASS_NAME[];
515
517
518 public:
519 // CLASS METHODS
520
521 /// Return attribute information for the attribute indicated by the
522 /// specified `id` if the attribute exists, and 0 otherwise.
524
525 /// Return attribute information for the attribute indicated by the
526 /// specified `name` of the specified `nameLength` if the attribute
527 /// exists, and 0 otherwise.
529 const char *name,
530 int nameLength);
531
532 // CREATORS
533
534 /// Create an object of type `MySequenceWithChoices` having the default
535 /// value.
537
538 /// Create an object of type `MySequenceWithChoices` having the value of
539 /// the specified `original` object.
541
542#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) \
543 && defined(BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT)
544 /// Create an object of type `MySequenceWithChoices` having the value of
545 /// the specified `original` object. After performing this action, the
546 /// `original` object will be left in a valid, but unspecified state.
547 MySequenceWithChoices(MySequenceWithChoices&& original) = default;
548#endif
549
550 /// Destroy this object.
552
553 // MANIPULATORS
554
555 /// Assign to this object the value of the specified `rhs` object.
557
558#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) \
559 && defined(BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT)
560 /// Assign to this object the value of the specified `rhs` object.
561 /// After performing this action, the `rhs` object will be left in a
562 /// valid, but unspecified state.
564#endif
565
566 /// Reset this object to the default value (i.e., its value upon
567 /// default construction).
568 void reset();
569
570 /// Invoke the specified `manipulator` sequentially on the address of
571 /// each (modifiable) attribute of this object, supplying `manipulator`
572 /// with the corresponding attribute information structure until such
573 /// invocation returns a non-zero value. Return the value from the
574 /// last invocation of `manipulator` (i.e., the invocation that
575 /// terminated the sequence).
576 template<class MANIPULATOR>
577 int manipulateAttributes(MANIPULATOR& manipulator);
578
579 /// Invoke the specified `manipulator` on the address of
580 /// the (modifiable) attribute indicated by the specified `id`,
581 /// supplying `manipulator` with the corresponding attribute
582 /// information structure. Return the value returned from the
583 /// invocation of `manipulator` if `id` identifies an attribute of this
584 /// class, and -1 otherwise.
585 template<class MANIPULATOR>
586 int manipulateAttribute(MANIPULATOR& manipulator, int id);
587
588 /// Invoke the specified `manipulator` on the address of
589 /// the (modifiable) attribute indicated by the specified `name` of the
590 /// specified `nameLength`, supplying `manipulator` with the
591 /// corresponding attribute information structure. Return the value
592 /// returned from the invocation of `manipulator` if `name` identifies
593 /// an attribute of this class, and -1 otherwise.
594 template<class MANIPULATOR>
595 int manipulateAttribute(MANIPULATOR& manipulator,
596 const char *name,
597 int nameLength);
598
599 /// Return a reference to the modifiable "First" attribute of this
600 /// object.
602
603 /// Return a reference to the modifiable "Second" attribute of this
604 /// object.
606
607 // ACCESSORS
608
609 /// Format this object to the specified output `stream` at the
610 /// optionally specified indentation `level` and return a reference to
611 /// the modifiable `stream`. If `level` is specified, optionally
612 /// specify `spacesPerLevel`, the number of spaces per indentation level
613 /// for this and all of its nested objects. Each line is indented by
614 /// the absolute value of `level * spacesPerLevel`. If `level` is
615 /// negative, suppress indentation of the first line. If
616 /// `spacesPerLevel` is negative, suppress line breaks and format the
617 /// entire output on one line. If `stream` is initially invalid, this
618 /// operation has no effect. Note that a trailing newline is provided
619 /// in multiline mode only.
620 bsl::ostream& print(bsl::ostream& stream,
621 int level = 0,
622 int spacesPerLevel = 4) const;
623
624 /// Invoke the specified `accessor` sequentially on each
625 /// (non-modifiable) attribute of this object, supplying `accessor`
626 /// with the corresponding attribute information structure until such
627 /// invocation returns a non-zero value. Return the value from the
628 /// last invocation of `accessor` (i.e., the invocation that terminated
629 /// the sequence).
630 template<class ACCESSOR>
631 int accessAttributes(ACCESSOR& accessor) const;
632
633 /// Invoke the specified `accessor` on the (non-modifiable) attribute
634 /// of this object indicated by the specified `id`, supplying `accessor`
635 /// with the corresponding attribute information structure. Return the
636 /// value returned from the invocation of `accessor` if `id` identifies
637 /// an attribute of this class, and -1 otherwise.
638 template<class ACCESSOR>
639 int accessAttribute(ACCESSOR& accessor, int id) const;
640
641 /// Invoke the specified `accessor` on the (non-modifiable) attribute
642 /// of this object indicated by the specified `name` of the specified
643 /// `nameLength`, supplying `accessor` with the corresponding attribute
644 /// information structure. Return the value returned from the
645 /// invocation of `accessor` if `name` identifies an attribute of this
646 /// class, and -1 otherwise.
647 template<class ACCESSOR>
648 int accessAttribute(ACCESSOR& accessor,
649 const char *name,
650 int nameLength) const;
651
652 /// Return a reference offering non-modifiable access to the "First"
653 /// attribute of this object.
654 const MySequenceWithChoicesChoice1& first() const;
655
656 /// Return a reference offering non-modifiable access to the "Second"
657 /// attribute of this object.
659};
660
661// FREE OPERATORS
662
663/// Return `true` if the specified `lhs` and `rhs` attribute objects have
664/// the same value, and `false` otherwise. Two attribute objects have the
665/// same value if each respective attribute has the same value.
666inline
667bool operator==(const MySequenceWithChoices& lhs, const MySequenceWithChoices& rhs);
668
669/// Return `true` if the specified `lhs` and `rhs` attribute objects do not
670/// have the same value, and `false` otherwise. Two attribute objects do
671/// not have the same value if one or more respective attributes differ in
672/// values.
673inline
674bool operator!=(const MySequenceWithChoices& lhs, const MySequenceWithChoices& rhs);
675
676/// Format the specified `rhs` to the specified output `stream` and
677/// return a reference to the modifiable `stream`.
678inline
679bsl::ostream& operator<<(bsl::ostream& stream, const MySequenceWithChoices& rhs);
680
681} // close package namespace
682
683// TRAITS
684
686
687// ============================================================================
688// INLINE FUNCTION DEFINITIONS
689// ============================================================================
690
691namespace s_baltst {
692
693 // ----------------------------------
694 // class MySequenceWithChoicesChoice1
695 // ----------------------------------
696
697// CLASS METHODS
698// CREATORS
699inline
701: d_selectionId(SELECTION_ID_UNDEFINED)
702{
703}
704
705inline
710
711// MANIPULATORS
712template <class MANIPULATOR>
714{
715 switch (d_selectionId) {
717 return manipulator(&d_choiceA.object(),
720 return manipulator(&d_choiceB.object(),
722 default:
724 return -1;
725 }
726}
727
728inline
730{
731 BSLS_ASSERT(SELECTION_ID_CHOICE_A == d_selectionId);
732 return d_choiceA.object();
733}
734
735inline
737{
738 BSLS_ASSERT(SELECTION_ID_CHOICE_B == d_selectionId);
739 return d_choiceB.object();
740}
741
742// ACCESSORS
743inline
745{
746 return d_selectionId;
747}
748
749template <class ACCESSOR>
751{
752 switch (d_selectionId) {
754 return accessor(d_choiceA.object(),
757 return accessor(d_choiceB.object(),
759 default:
760 BSLS_ASSERT(SELECTION_ID_UNDEFINED == d_selectionId);
761 return -1;
762 }
763}
764
765inline
767{
768 BSLS_ASSERT(SELECTION_ID_CHOICE_A == d_selectionId);
769 return d_choiceA.object();
770}
771
772inline
774{
775 BSLS_ASSERT(SELECTION_ID_CHOICE_B == d_selectionId);
776 return d_choiceB.object();
777}
778
779inline
781{
782 return SELECTION_ID_CHOICE_A == d_selectionId;
783}
784
785inline
787{
788 return SELECTION_ID_CHOICE_B == d_selectionId;
789}
790
791inline
793{
794 return SELECTION_ID_UNDEFINED == d_selectionId;
795}
796
797
798 // ----------------------------------
799 // class MySequenceWithChoicesChoice2
800 // ----------------------------------
801
802// CLASS METHODS
803// CREATORS
804inline
806: d_selectionId(SELECTION_ID_UNDEFINED)
807{
808}
809
810inline
815
816// MANIPULATORS
817template <class MANIPULATOR>
819{
820 switch (d_selectionId) {
822 return manipulator(&d_choiceC.object(),
825 return manipulator(&d_choiceD.object(),
827 default:
829 return -1;
830 }
831}
832
833inline
835{
836 BSLS_ASSERT(SELECTION_ID_CHOICE_C == d_selectionId);
837 return d_choiceC.object();
838}
839
840inline
842{
843 BSLS_ASSERT(SELECTION_ID_CHOICE_D == d_selectionId);
844 return d_choiceD.object();
845}
846
847// ACCESSORS
848inline
850{
851 return d_selectionId;
852}
853
854template <class ACCESSOR>
856{
857 switch (d_selectionId) {
859 return accessor(d_choiceC.object(),
862 return accessor(d_choiceD.object(),
864 default:
865 BSLS_ASSERT(SELECTION_ID_UNDEFINED == d_selectionId);
866 return -1;
867 }
868}
869
870inline
872{
873 BSLS_ASSERT(SELECTION_ID_CHOICE_C == d_selectionId);
874 return d_choiceC.object();
875}
876
877inline
879{
880 BSLS_ASSERT(SELECTION_ID_CHOICE_D == d_selectionId);
881 return d_choiceD.object();
882}
883
884inline
886{
887 return SELECTION_ID_CHOICE_C == d_selectionId;
888}
889
890inline
892{
893 return SELECTION_ID_CHOICE_D == d_selectionId;
894}
895
896inline
898{
899 return SELECTION_ID_UNDEFINED == d_selectionId;
900}
901
902
903 // ---------------------------
904 // class MySequenceWithChoices
905 // ---------------------------
906
907// CLASS METHODS
908// MANIPULATORS
909template <class MANIPULATOR>
911{
912 int ret;
913
914 ret = manipulator(&d_first, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_FIRST]);
915 if (ret) {
916 return ret;
917 }
918
919 ret = manipulator(&d_second, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_SECOND]);
920 if (ret) {
921 return ret;
922 }
923
924 return 0;
925}
926
927template <class MANIPULATOR>
928int MySequenceWithChoices::manipulateAttribute(MANIPULATOR& manipulator, int id)
929{
930 enum { NOT_FOUND = -1 };
931
932 switch (id) {
933 case ATTRIBUTE_ID_FIRST: {
934 return manipulator(&d_first, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_FIRST]);
935 }
936 case ATTRIBUTE_ID_SECOND: {
937 return manipulator(&d_second, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_SECOND]);
938 }
939 default:
940 return NOT_FOUND;
941 }
942}
943
944template <class MANIPULATOR>
946 MANIPULATOR& manipulator,
947 const char *name,
948 int nameLength)
949{
950 enum { NOT_FOUND = -1 };
951
952 const bdlat_AttributeInfo *attributeInfo =
953 lookupAttributeInfo(name, nameLength);
954 if (0 == attributeInfo) {
955 return NOT_FOUND;
956 }
957
958 return manipulateAttribute(manipulator, attributeInfo->d_id);
959}
960
961inline
966
967inline
972
973// ACCESSORS
974template <class ACCESSOR>
975int MySequenceWithChoices::accessAttributes(ACCESSOR& accessor) const
976{
977 int ret;
978
979 ret = accessor(d_first, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_FIRST]);
980 if (ret) {
981 return ret;
982 }
983
984 ret = accessor(d_second, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_SECOND]);
985 if (ret) {
986 return ret;
987 }
988
989 return 0;
990}
991
992template <class ACCESSOR>
993int MySequenceWithChoices::accessAttribute(ACCESSOR& accessor, int id) const
994{
995 enum { NOT_FOUND = -1 };
996
997 switch (id) {
998 case ATTRIBUTE_ID_FIRST: {
999 return accessor(d_first, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_FIRST]);
1000 }
1001 case ATTRIBUTE_ID_SECOND: {
1002 return accessor(d_second, ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_SECOND]);
1003 }
1004 default:
1005 return NOT_FOUND;
1006 }
1007}
1008
1009template <class ACCESSOR>
1011 ACCESSOR& accessor,
1012 const char *name,
1013 int nameLength) const
1014{
1015 enum { NOT_FOUND = -1 };
1016
1017 const bdlat_AttributeInfo *attributeInfo =
1018 lookupAttributeInfo(name, nameLength);
1019 if (0 == attributeInfo) {
1020 return NOT_FOUND;
1021 }
1022
1023 return accessAttribute(accessor, attributeInfo->d_id);
1024}
1025
1026inline
1028{
1029 return d_first;
1030}
1031
1032inline
1034{
1035 return d_second;
1036}
1037
1038} // close package namespace
1039
1040// FREE FUNCTIONS
1041
1042inline
1046{
1048 if (lhs.selectionId() == rhs.selectionId()) {
1049 switch (rhs.selectionId()) {
1050 case Class::SELECTION_ID_CHOICE_A:
1051 return lhs.choiceA() == rhs.choiceA();
1052 case Class::SELECTION_ID_CHOICE_B:
1053 return lhs.choiceB() == rhs.choiceB();
1054 default:
1055 BSLS_ASSERT(Class::SELECTION_ID_UNDEFINED == rhs.selectionId());
1056 return true;
1057 }
1058 }
1059 else {
1060 return false;
1061 }
1062}
1063
1064inline
1068{
1069 return !(lhs == rhs);
1070}
1071
1072inline
1073bsl::ostream& s_baltst::operator<<(
1074 bsl::ostream& stream,
1076{
1077 return rhs.print(stream, 0, -1);
1078}
1079
1080
1081inline
1085{
1087 if (lhs.selectionId() == rhs.selectionId()) {
1088 switch (rhs.selectionId()) {
1089 case Class::SELECTION_ID_CHOICE_C:
1090 return lhs.choiceC() == rhs.choiceC();
1091 case Class::SELECTION_ID_CHOICE_D:
1092 return lhs.choiceD() == rhs.choiceD();
1093 default:
1094 BSLS_ASSERT(Class::SELECTION_ID_UNDEFINED == rhs.selectionId());
1095 return true;
1096 }
1097 }
1098 else {
1099 return false;
1100 }
1101}
1102
1103inline
1107{
1108 return !(lhs == rhs);
1109}
1110
1111inline
1112bsl::ostream& s_baltst::operator<<(
1113 bsl::ostream& stream,
1115{
1116 return rhs.print(stream, 0, -1);
1117}
1118
1119
1120inline
1124{
1125 return lhs.first() == rhs.first()
1126 && lhs.second() == rhs.second();
1127}
1128
1129inline
1133{
1134 return !(lhs == rhs);
1135}
1136
1137inline
1138bsl::ostream& s_baltst::operator<<(
1139 bsl::ostream& stream,
1141{
1142 return rhs.print(stream, 0, -1);
1143}
1144
1145
1146#endif
1147
1148// GENERATED BY @BLP_BAS_CODEGEN_VERSION@
1149// USING bas_codegen.pl s_baltst_mysequencewithchoices.xsd --mode msg --includedir . --msgComponent mysequencewithchoices --noRecurse --noExternalization --noHashSupport --noAggregateConversion
1150// ----------------------------------------------------------------------------
1151// NOTICE:
1152// Copyright 2022 Bloomberg Finance L.P. All rights reserved.
1153// Property of Bloomberg Finance L.P. (BFLP)
1154// This software is made available solely pursuant to the
1155// terms of a BFLP license agreement which governs its use.
1156// ------------------------------- END-OF-FILE --------------------------------
1157
1158/** @} */
1159/** @} */
1160/** @} */
Definition s_baltst_mysequencewithchoices.h:69
static const bdlat_SelectionInfo SELECTION_INFO_ARRAY[]
Definition s_baltst_mysequencewithchoices.h:100
bool isChoiceBValue() const
Definition s_baltst_mysequencewithchoices.h:786
const char * selectionName() const
Return the symbolic name of the current selection of this object.
bsls::ObjectBuffer< int > d_choiceB
Definition s_baltst_mysequencewithchoices.h:74
static const char CLASS_NAME[]
Definition s_baltst_mysequencewithchoices.h:98
int accessSelection(ACCESSOR &accessor) const
Definition s_baltst_mysequencewithchoices.h:750
int makeSelection(const char *name, int nameLength)
bsl::ostream & print(bsl::ostream &stream, int level=0, int spacesPerLevel=4) const
static const bdlat_SelectionInfo * lookupSelectionInfo(int id)
bool isUndefinedValue() const
Definition s_baltst_mysequencewithchoices.h:792
int & choiceA()
Definition s_baltst_mysequencewithchoices.h:729
bsls::ObjectBuffer< int > d_choiceA
Definition s_baltst_mysequencewithchoices.h:73
~MySequenceWithChoicesChoice1()
Destroy this object.
Definition s_baltst_mysequencewithchoices.h:706
MySequenceWithChoicesChoice1 & operator=(const MySequenceWithChoicesChoice1 &rhs)
Assign to this object the value of the specified rhs object.
static const bdlat_SelectionInfo * lookupSelectionInfo(const char *name, int nameLength)
MySequenceWithChoicesChoice1()
Definition s_baltst_mysequencewithchoices.h:700
@ SELECTION_INDEX_CHOICE_A
Definition s_baltst_mysequencewithchoices.h:93
@ SELECTION_INDEX_CHOICE_B
Definition s_baltst_mysequencewithchoices.h:94
bool isChoiceAValue() const
Definition s_baltst_mysequencewithchoices.h:780
@ SELECTION_ID_CHOICE_B
Definition s_baltst_mysequencewithchoices.h:85
@ SELECTION_ID_CHOICE_A
Definition s_baltst_mysequencewithchoices.h:84
@ SELECTION_ID_UNDEFINED
Definition s_baltst_mysequencewithchoices.h:83
int manipulateSelection(MANIPULATOR &manipulator)
Definition s_baltst_mysequencewithchoices.h:713
MySequenceWithChoicesChoice1(const MySequenceWithChoicesChoice1 &original)
int & choiceB()
Definition s_baltst_mysequencewithchoices.h:736
int selectionId() const
Definition s_baltst_mysequencewithchoices.h:744
@ NUM_SELECTIONS
Definition s_baltst_mysequencewithchoices.h:89
Definition s_baltst_mysequencewithchoices.h:280
static const char CLASS_NAME[]
Definition s_baltst_mysequencewithchoices.h:309
int makeSelection(const char *name, int nameLength)
bool isUndefinedValue() const
Definition s_baltst_mysequencewithchoices.h:897
static const bdlat_SelectionInfo SELECTION_INFO_ARRAY[]
Definition s_baltst_mysequencewithchoices.h:311
int accessSelection(ACCESSOR &accessor) const
Definition s_baltst_mysequencewithchoices.h:855
static const bdlat_SelectionInfo * lookupSelectionInfo(int id)
int manipulateSelection(MANIPULATOR &manipulator)
Definition s_baltst_mysequencewithchoices.h:818
~MySequenceWithChoicesChoice2()
Destroy this object.
Definition s_baltst_mysequencewithchoices.h:811
int selectionId() const
Definition s_baltst_mysequencewithchoices.h:849
static const bdlat_SelectionInfo * lookupSelectionInfo(const char *name, int nameLength)
@ SELECTION_ID_UNDEFINED
Definition s_baltst_mysequencewithchoices.h:294
@ SELECTION_ID_CHOICE_C
Definition s_baltst_mysequencewithchoices.h:295
@ SELECTION_ID_CHOICE_D
Definition s_baltst_mysequencewithchoices.h:296
@ SELECTION_INDEX_CHOICE_D
Definition s_baltst_mysequencewithchoices.h:305
@ SELECTION_INDEX_CHOICE_C
Definition s_baltst_mysequencewithchoices.h:304
MySequenceWithChoicesChoice2 & operator=(const MySequenceWithChoicesChoice2 &rhs)
Assign to this object the value of the specified rhs object.
int & choiceC()
Definition s_baltst_mysequencewithchoices.h:834
bsl::ostream & print(bsl::ostream &stream, int level=0, int spacesPerLevel=4) const
const char * selectionName() const
Return the symbolic name of the current selection of this object.
MySequenceWithChoicesChoice2(const MySequenceWithChoicesChoice2 &original)
bsls::ObjectBuffer< int > d_choiceD
Definition s_baltst_mysequencewithchoices.h:285
MySequenceWithChoicesChoice2()
Definition s_baltst_mysequencewithchoices.h:805
bool isChoiceCValue() const
Definition s_baltst_mysequencewithchoices.h:885
@ NUM_SELECTIONS
Definition s_baltst_mysequencewithchoices.h:300
bsls::ObjectBuffer< int > d_choiceC
Definition s_baltst_mysequencewithchoices.h:284
int & choiceD()
Definition s_baltst_mysequencewithchoices.h:841
bool isChoiceDValue() const
Definition s_baltst_mysequencewithchoices.h:891
Definition s_baltst_mysequencewithchoices.h:491
static const char CLASS_NAME[]
Definition s_baltst_mysequencewithchoices.h:514
int accessAttributes(ACCESSOR &accessor) const
Definition s_baltst_mysequencewithchoices.h:975
int manipulateAttributes(MANIPULATOR &manipulator)
Definition s_baltst_mysequencewithchoices.h:910
MySequenceWithChoices(const MySequenceWithChoices &original)
MySequenceWithChoices & operator=(const MySequenceWithChoices &rhs)
Assign to this object the value of the specified rhs object.
@ ATTRIBUTE_ID_FIRST
Definition s_baltst_mysequencewithchoices.h:500
@ ATTRIBUTE_ID_SECOND
Definition s_baltst_mysequencewithchoices.h:501
int manipulateAttribute(MANIPULATOR &manipulator, int id)
Definition s_baltst_mysequencewithchoices.h:928
@ ATTRIBUTE_INDEX_SECOND
Definition s_baltst_mysequencewithchoices.h:510
@ ATTRIBUTE_INDEX_FIRST
Definition s_baltst_mysequencewithchoices.h:509
MySequenceWithChoicesChoice2 & second()
Definition s_baltst_mysequencewithchoices.h:968
int accessAttribute(ACCESSOR &accessor, int id) const
Definition s_baltst_mysequencewithchoices.h:993
static const bdlat_AttributeInfo * lookupAttributeInfo(int id)
~MySequenceWithChoices()
Destroy this object.
bsl::ostream & print(bsl::ostream &stream, int level=0, int spacesPerLevel=4) const
@ NUM_ATTRIBUTES
Definition s_baltst_mysequencewithchoices.h:505
static const bdlat_AttributeInfo * lookupAttributeInfo(const char *name, int nameLength)
static const bdlat_AttributeInfo ATTRIBUTE_INFO_ARRAY[]
Definition s_baltst_mysequencewithchoices.h:516
MySequenceWithChoicesChoice1 & first()
Definition s_baltst_mysequencewithchoices.h:962
#define BDLAT_DECL_CHOICE_WITH_BITWISEMOVEABLE_TRAITS(ClassName)
Definition bdlat_typetraits.h:242
#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
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_selectioninfo.h:136
TYPE & object()
Definition bsls_objectbuffer.h:351