8#ifndef INCLUDED_S_BALTST_TESTCHOICE
9#define INCLUDED_S_BALTST_TESTCHOICE
74 template <
class ACCESSOR>
75 static int access(ACCESSOR& accessor,
78 template <
class ACCESSOR,
class SELECTION>
79 static int access(ACCESSOR& accessor,
80 const SELECTION& selection,
83 template <
class MANIPULATOR>
84 static int manipulate(MANIPULATOR& manipulator,
87 template <
class MANIPULATOR,
class SELECTION>
88 static int manipulate(MANIPULATOR& manipulator,
124template <
class TYPED_SELECTION_0 =
126 class TYPED_SELECTION_1 =
128 class TYPED_SELECTION_2 =
167 template <
class VALUE>
179 int makeSelection(
const char *selectionName,
int selectionNameLength);
181 template <
class MANIPULATOR>
187 template <
class ACCESSOR>
193 int selectionNameLength)
const;
207template <
class V0,
class V1,
class V2>
209 const TestChoice<V0, V1, V2>& choice);
211template <
class C0,
class C1,
class C2>
213bool operator==(
const TestChoice<C0, C1, C2>& lhs,
214 const TestChoice<C0, C1, C2>& rhs);
216template <
class C0,
class C1,
class C2>
218bool operator!=(
const TestChoice<C0, C1, C2>& lhs,
219 const TestChoice<C0, C1, C2>& rhs);
225template <
class C0,
class C1,
class C2>
231template <
class C0,
class C1,
class C2>
239template <
class C0,
class C1,
class C2>
241 const char *selectionName,
242 int selectionNameLength);
249template <
class C0,
class C1,
class C2,
class MANIPULATOR>
251 MANIPULATOR& manipulator);
258template <
class C0,
class C1,
class C2,
class ACCESSOR>
262template <
class C0,
class C1,
class C2>
264 const TestChoice<C0, C1, C2>&
object,
265 const char *selectionName,
266 int selectionNameLength);
268template <
class C0,
class C1,
class C2>
274template <
class C0,
class C1,
class C2>
277template <
class C0,
class C1,
class C2>
279 const TestChoice<C0, C1, C2>& rhs);
281template <
class C0,
class C1,
class C2>
288template <
class C0,
class C1,
class C2>
305template <
class ACCESSOR>
313template <
class ACCESSOR,
class SELECTION>
315 const SELECTION& selection,
318 return accessor(selection, selectionInfo);
321template <
class MANIPULATOR>
329template <
class MANIPULATOR,
class SELECTION>
331 SELECTION *selection,
334 return manipulator(selection, selectionInfo);
342template <
class TYPED_SELECTION_0,
343 class TYPED_SELECTION_1,
344 class TYPED_SELECTION_2>
352template <
class TYPED_SELECTION_0,
353 class TYPED_SELECTION_1,
354 class TYPED_SELECTION_2>
358, d_allocator_p(
bslma::Default::allocator())
362template <
class TYPED_SELECTION_0,
363 class TYPED_SELECTION_1,
364 class TYPED_SELECTION_2>
368, d_allocator_p(
bslma::Default::allocator(basicAllocator))
372template <
class TYPED_SELECTION_0,
373 class TYPED_SELECTION_1,
374 class TYPED_SELECTION_2>
375template <
class VALUE>
378: d_value(value,
bslma::Default::allocator(basicAllocator))
379, d_allocator_p(basicAllocator)
386template <
class TYPED_SELECTION_0,
387 class TYPED_SELECTION_1,
388 class TYPED_SELECTION_2>
391: d_value(original.d_value.object(), basicAllocator)
392, d_allocator_p(
bslma::Default::allocator(basicAllocator))
397template <
class TYPED_SELECTION_0,
398 class TYPED_SELECTION_1,
399 class TYPED_SELECTION_2>
404 d_value.object() = original.d_value.
object();
411template <
class TYPED_SELECTION_0,
412 class TYPED_SELECTION_1,
413 class TYPED_SELECTION_2>
417 switch (selectionId) {
419 if (!k_HAS_CHOICE_0) {
423 d_value.object().template createInPlace<Selection0Type>();
427 if (!k_HAS_CHOICE_1) {
431 d_value.object().template createInPlace<Selection1Type>();
435 if (!k_HAS_CHOICE_2) {
439 d_value.object().template createInPlace<Selection2Type>();
450template <
class TYPED_SELECTION_0,
451 class TYPED_SELECTION_1,
452 class TYPED_SELECTION_2>
454 makeSelection(
const char *selectionName,
int selectionNameLength)
458 if (k_HAS_CHOICE_0 && Selection0::name() == selection) {
459 d_value.object().template createInPlace<Selection0Type>();
463 if (k_HAS_CHOICE_1 && Selection1::name() == selection) {
464 d_value.object().template createInPlace<Selection1Type>();
468 if (k_HAS_CHOICE_2 && Selection2::name() == selection) {
469 d_value.object().template createInPlace<Selection2Type>();
481template <
class TYPED_SELECTION_0,
482 class TYPED_SELECTION_1,
483 class TYPED_SELECTION_2>
484template <
class MANIPULATOR>
488 switch (d_value.object().typeIndex()) {
494 BSLS_ASSERT(d_value.object().template is<Selection0Type>());
495 return ImplUtil::manipulate(
497 &d_value.object().template the<Selection0Type>(),
498 Selection0::selectionInfo());
502 BSLS_ASSERT(d_value.object().template is<Selection1Type>());
503 return ImplUtil::manipulate(
505 &d_value.object().template the<Selection1Type>(),
506 Selection1::selectionInfo());
510 BSLS_ASSERT(d_value.object().template is<Selection2Type>());
511 return ImplUtil::manipulate(
513 &d_value.object().template the<Selection2Type>(),
514 Selection2::selectionInfo());
521template <
class TYPED_SELECTION_0,
522 class TYPED_SELECTION_1,
523 class TYPED_SELECTION_2>
527 d_value.object().template createInPlace<Selection0Type>();
536template <
class TYPED_SELECTION_0,
537 class TYPED_SELECTION_1,
538 class TYPED_SELECTION_2>
539template <
class ACCESSOR>
543 switch (d_value.object().typeIndex()) {
549 BSLS_ASSERT(d_value.object().template is<Selection0Type>());
550 return ImplUtil::access(
552 d_value.object().template the<Selection0Type>(),
553 Selection0::selectionInfo());
557 BSLS_ASSERT(d_value.object().template is<Selection1Type>());
558 return ImplUtil::access(
560 d_value.object().template the<Selection1Type>(),
561 Selection1::selectionInfo());
565 BSLS_ASSERT(d_value.object().template is<Selection2Type>());
566 return ImplUtil::access(
568 d_value.object().template the<Selection2Type>(),
569 Selection2::selectionInfo());
576template <
class TYPED_SELECTION_0,
577 class TYPED_SELECTION_1,
578 class TYPED_SELECTION_2>
582 if (k_HAS_CHOICE_0 && Selection0::id() == selectionId) {
586 if (k_HAS_CHOICE_1 && Selection1::id() == selectionId) {
590 if (k_HAS_CHOICE_2 && Selection2::id() == selectionId) {
597template <
class TYPED_SELECTION_0,
598 class TYPED_SELECTION_1,
599 class TYPED_SELECTION_2>
601 hasSelection(
const char *selectionName,
int selectionNameLength)
const
605 if (k_HAS_CHOICE_0 && Selection0::name() == selection) {
609 if (k_HAS_CHOICE_1 && Selection1::name() == selection) {
613 if (k_HAS_CHOICE_2 && Selection2::name() == selection) {
622template <
class TYPED_SELECTION_0,
623 class TYPED_SELECTION_1,
624 class TYPED_SELECTION_2>
627 TYPED_SELECTION_2>::className()
const
632template <
class TYPED_SELECTION_0,
633 class TYPED_SELECTION_1,
634 class TYPED_SELECTION_2>
638 return d_value.object().typeIndex() - 1;
641template <
class TYPED_SELECTION_0,
642 class TYPED_SELECTION_1,
643 class TYPED_SELECTION_2>
644const typename TYPED_SELECTION_0::Type&
649 return d_value.object().template the<Selection0Type>();
652template <
class TYPED_SELECTION_0,
653 class TYPED_SELECTION_1,
654 class TYPED_SELECTION_2>
655const typename TYPED_SELECTION_1::Type&
660 return d_value.object().template the<Selection1Type>();
663template <
class TYPED_SELECTION_0,
664 class TYPED_SELECTION_1,
665 class TYPED_SELECTION_2>
666const typename TYPED_SELECTION_2::Type&
671 return d_value.object().template the<Selection2Type>();
675template <
class V0,
class V1,
class V2>
681 stream <<
"[" << choice.
className() <<
" ";
684 stream << Choice::Selection0::name() <<
" = "
688 stream << Choice::Selection1::name() <<
" = "
692 stream << Choice::Selection2::name() <<
" = "
697 return stream <<
"]";
700template <
class C0,
class C1,
class C2>
708template <
class C0,
class C1,
class C2>
717template <
class C0,
class C1,
class C2>
720 return object.className();
723template <
class C0,
class C1,
class C2>
726 return object->makeSelection(selectionId);
729template <
class C0,
class C1,
class C2>
731 const char *selectionName,
732 int selectionNameLength)
734 return object->makeSelection(selectionName, selectionNameLength);
737template <
class C0,
class C1,
class C2,
class MANIPULATOR>
739 MANIPULATOR& manipulator)
741 return object->manipulateSelection(manipulator);
744template <
class C0,
class C1,
class C2,
class ACCESSOR>
748 return object.accessSelection(accessor);
751template <
class C0,
class C1,
class C2>
754 const char *selectionName,
755 int selectionNameLength)
757 return object.hasSelection(selectionName, selectionNameLength);
760template <
class C0,
class C1,
class C2>
764 return object.hasSelection(selectionId);
767template <
class C0,
class C1,
class C2>
770 return object.selectionId();
773template <
class C0,
class C1,
class C2>
781template <
class C0,
class C1,
class C2>
Definition bdlb_variant.h:2312
Definition bslstl_stringview.h:441
Definition bslalg_constructorproxy.h:368
OBJECT_TYPE & object() BSLS_KEYWORD_NOEXCEPT
Return a reference to the modifiable object held by this proxy.
Definition bslalg_constructorproxy.h:1187
Definition bslma_allocator.h:457
Definition s_baltst_testchoice.h:130
int makeSelection(int selectionId)
Definition s_baltst_testchoice.h:415
TestChoice()
Definition s_baltst_testchoice.h:356
TYPED_SELECTION_0::Type Selection0Type
Definition s_baltst_testchoice.h:135
int accessSelection(ACCESSOR &accessor) const
Definition s_baltst_testchoice.h:541
void reset()
Definition s_baltst_testchoice.h:525
bool hasSelection(int selectionId) const
Definition s_baltst_testchoice.h:580
const Selection0Type & theSelection0() const
Definition s_baltst_testchoice.h:646
TYPED_SELECTION_0::Selection Selection0
Definition s_baltst_testchoice.h:134
TYPED_SELECTION_1::Type Selection1Type
Definition s_baltst_testchoice.h:137
TYPED_SELECTION_2::Type Selection2Type
Definition s_baltst_testchoice.h:139
const char * className() const
Definition s_baltst_testchoice.h:627
int manipulateSelection(MANIPULATOR &manipulator)
Definition s_baltst_testchoice.h:486
static bool areEqual(const TestChoice &lhs, const TestChoice &rhs)
Definition s_baltst_testchoice.h:346
TYPED_SELECTION_1::Selection Selection1
Definition s_baltst_testchoice.h:136
const Selection1Type & theSelection1() const
Definition s_baltst_testchoice.h:657
const Selection2Type & theSelection2() const
Definition s_baltst_testchoice.h:668
TestChoice & operator=(const TestChoice &original)
Definition s_baltst_testchoice.h:402
TYPED_SELECTION_2::Selection Selection2
Definition s_baltst_testchoice.h:138
int selectionId() const
Definition s_baltst_testchoice.h:636
Definition s_baltst_testnilvalue.h:60
Definition s_baltst_testselection.h:121
#define BSLMF_ASSERT(expr)
Definition bslmf_assert.h:229
#define BSLS_ASSERT(X)
Definition bsls_assert.h:1804
#define BSLS_IDENT(str)
Definition bsls_ident.h:195
Definition bdlat_choicefunctions.h:504
Definition balxml_encoderoptions.h:68
Definition s_baltst_address.h:66
bool bdlat_choiceHasSelection(const TestChoice< C0, C1, C2 > &object, const char *selectionName, int selectionNameLength)
Definition s_baltst_testchoice.h:752
int bdlat_valueTypeAssign(TestChoice< C0, C1, C2 > *lhs, const TestChoice< C0, C1, C2 > &rhs)
Definition s_baltst_testchoice.h:774
const char * bdlat_TypeName_className(const TestChoice< C0, C1, C2 > &object)
Definition s_baltst_testchoice.h:718
int bdlat_choiceManipulateSelection(TestChoice< C0, C1, C2 > *object, MANIPULATOR &manipulator)
Definition s_baltst_testchoice.h:738
int bdlat_choiceSelectionId(const TestChoice< C0, C1, C2 > &object)
Definition s_baltst_testchoice.h:768
int bdlat_choiceAccessSelection(const TestChoice< C0, C1, C2 > &object, ACCESSOR &accessor)
Definition s_baltst_testchoice.h:745
bsl::ostream & operator<<(bsl::ostream &stream, const Address &rhs)
int bdlat_choiceMakeSelection(TestChoice< C0, C1, C2 > *object, int selectionId)
Definition s_baltst_testchoice.h:724
void bdlat_valueTypeReset(TestChoice< C0, C1, C2 > *object)
Definition s_baltst_testchoice.h:782
Definition bdlat_selectioninfo.h:136
Definition bslmf_issame.h:181
Definition s_baltst_testchoice.h:71
static int access(ACCESSOR &accessor, const TestNilValue selection, const bdlat_SelectionInfo &selectionInfo)
Definition s_baltst_testchoice.h:306
static int manipulate(MANIPULATOR &manipulator, TestNilValue *selection, const bdlat_SelectionInfo &selectionInfo)
Definition s_baltst_testchoice.h:322