// s_baltst_sequencewithanonymitychoice.h         *DO NOT EDIT*          @generated -*-C++-*-
#ifndef INCLUDED_S_BALTST_SEQUENCEWITHANONYMITYCHOICE
#define INCLUDED_S_BALTST_SEQUENCEWITHANONYMITYCHOICE

#include <bsls_ident.h>
BSLS_IDENT_RCSID(s_baltst_sequencewithanonymitychoice_h,"$Id$ $CSID$")
BSLS_IDENT_PRAGMA_ONCE

//@PURPOSE: Provide value-semantic attribute classes

#include <bslalg_typetraits.h>

#include <bdlat_attributeinfo.h>

#include <bdlat_selectioninfo.h>

#include <bdlat_typetraits.h>

#include <bsls_objectbuffer.h>

#include <bslma_default.h>

#include <bsls_assert.h>

#include <s_baltst_address.h>

#include <s_baltst_basicrecord.h>

#include <s_baltst_customint.h>

#include <s_baltst_customstring.h>

#include <s_baltst_customizedstring.h>

#include <s_baltst_enumerated.h>

#include <s_baltst_mychoice.h>

#include <s_baltst_myenumeration.h>

#include <s_baltst_mysequence.h>

#include <s_baltst_mysequencewithanonymouschoicechoice.h>

#include <s_baltst_mysequencewitharray.h>

#include <s_baltst_mysequencewithattributes.h>

#include <s_baltst_mysequencewithnillable.h>

#include <s_baltst_mysequencewithnullable.h>

#include <s_baltst_mysimplecontent.h>

#include <s_baltst_mysimpleintcontent.h>

#include <s_baltst_rawdata.h>

#include <s_baltst_rawdataswitched.h>

#include <s_baltst_rawdataunformatted.h>

#include <s_baltst_sequencewithanonymitychoice1.h>

#include <s_baltst_simplerequest.h>

#include <s_baltst_sqrt.h>

#include <s_baltst_unsignedsequence.h>

#include <s_baltst_voidsequence.h>

#include <s_baltst_bigrecord.h>

#include <s_baltst_employee.h>

#include <s_baltst_mysequencewithanonymouschoice.h>

#include <s_baltst_mysequencewithnillables.h>

#include <s_baltst_mysequencewithnullables.h>

#include <s_baltst_ratsnest.h>

#include <s_baltst_ratsnest.h>

#include <s_baltst_ratsnest.h>

#include <s_baltst_ratsnest.h>

#include <bsl_iosfwd.h>
#include <bsl_limits.h>

namespace BloombergLP {

namespace bslma { class Allocator; }

namespace s_baltst { class SequenceWithAnonymityChoice; }
namespace s_baltst {

                     // =================================
                     // class SequenceWithAnonymityChoice
                     // =================================

class SequenceWithAnonymityChoice {

    // INSTANCE DATA
    union {
        bsls::ObjectBuffer< Sequence6 >     d_selection1;
        bsls::ObjectBuffer< unsigned char > d_selection2;
        bsls::ObjectBuffer< CustomString >  d_selection3;
        bsls::ObjectBuffer< CustomInt >     d_selection4;
    };

    int                                     d_selectionId;
    bslma::Allocator                       *d_allocator_p;

  public:
    // TYPES

    enum {
        SELECTION_ID_UNDEFINED  = -1
      , SELECTION_ID_SELECTION1 = 0
      , SELECTION_ID_SELECTION2 = 1
      , SELECTION_ID_SELECTION3 = 2
      , SELECTION_ID_SELECTION4 = 3
    };

    enum {
        NUM_SELECTIONS = 4
    };

    enum {
        SELECTION_INDEX_SELECTION1 = 0
      , SELECTION_INDEX_SELECTION2 = 1
      , SELECTION_INDEX_SELECTION3 = 2
      , SELECTION_INDEX_SELECTION4 = 3
    };

    // CONSTANTS
    static const char CLASS_NAME[];

    static const bdlat_SelectionInfo SELECTION_INFO_ARRAY[];

    // CLASS METHODS
    static const bdlat_SelectionInfo *lookupSelectionInfo(int id);
        // Return selection information for the selection indicated by the
        // specified 'id' if the selection exists, and 0 otherwise. 

    static const bdlat_SelectionInfo *lookupSelectionInfo(
                                                       const char *name,
                                                       int         nameLength);
        // Return selection information for the selection indicated by the
        // specified 'name' of the specified 'nameLength' if the selection
        // exists, and 0 otherwise. 

    // CREATORS
    explicit SequenceWithAnonymityChoice(bslma::Allocator *basicAllocator = 0);
        // Create an object of type 'SequenceWithAnonymityChoice' having the
        // default value.   Use the optionally specified 'basicAllocator' to
        // supply memory.   If 'basicAllocator' is 0, the currently installed
        // default allocator is used. 

    SequenceWithAnonymityChoice(const SequenceWithAnonymityChoice& original,
                               bslma::Allocator *basicAllocator = 0);
        // Create an object of type 'SequenceWithAnonymityChoice' having the
        // value of the specified 'original' object.   Use the optionally
        // specified 'basicAllocator' to supply memory.   If 'basicAllocator' is
        // 0, the currently installed default allocator is used. 

#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) \
 && defined(BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT)
    SequenceWithAnonymityChoice(SequenceWithAnonymityChoice&& original) noexcept;
        // Create an object of type 'SequenceWithAnonymityChoice' having the
        // value of the specified 'original' object.   After performing this
        // action, the 'original' object will be left in a valid, but
        // unspecified state. 

    SequenceWithAnonymityChoice(SequenceWithAnonymityChoice&& original,
                               bslma::Allocator *basicAllocator);
        // Create an object of type 'SequenceWithAnonymityChoice' having the
        // value of the specified 'original' object.   After performing this
        // action, the 'original' object will be left in a valid, but
        // unspecified state.   Use the optionally specified 'basicAllocator' to
        // supply memory.   If 'basicAllocator' is 0, the currently installed
        // default allocator is used. 
#endif

    ~SequenceWithAnonymityChoice();
        // Destroy this object. 

    // MANIPULATORS
    SequenceWithAnonymityChoice& operator=(const SequenceWithAnonymityChoice& rhs);
        // Assign to this object the value of the specified 'rhs' object. 

#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) \
 && defined(BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT)
    SequenceWithAnonymityChoice& operator=(SequenceWithAnonymityChoice&& rhs);
        // Assign to this object the value of the specified 'rhs' object. 
        // After performing this action, the 'rhs' object will be left in a
        // valid, but unspecified state. 
#endif

    void reset();
        // Reset this object to the default value (i.e., its value upon default
        // construction). 

    int makeSelection(int selectionId);
        // Set the value of this object to be the default for the selection
        // indicated by the specified 'selectionId'.   Return 0 on success, and
        // non-zero value otherwise (i.e., the selection is not found). 

    int makeSelection(const char *name, int nameLength);
        // Set the value of this object to be the default for the selection
        // indicated by the specified 'name' of the specified 'nameLength'. 
        // Return 0 on success, and non-zero value otherwise (i.e., the
        // selection is not found). 

    Sequence6& makeSelection1();
    Sequence6& makeSelection1(const Sequence6& value);
#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) \
 && defined(BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT)
    Sequence6& makeSelection1(Sequence6&& value);
#endif
        // Set the value of this object to be a "Selection1" value.   Optionally
        // specify the 'value' of the "Selection1".   If 'value' is not
        // specified, the default "Selection1" value is used. 

    unsigned char& makeSelection2();
    unsigned char& makeSelection2(unsigned char value);
        // Set the value of this object to be a "Selection2" value.   Optionally
        // specify the 'value' of the "Selection2".   If 'value' is not
        // specified, the default "Selection2" value is used. 

    CustomString& makeSelection3();
    CustomString& makeSelection3(const CustomString& value);
#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) \
 && defined(BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT)
    CustomString& makeSelection3(CustomString&& value);
#endif
        // Set the value of this object to be a "Selection3" value.   Optionally
        // specify the 'value' of the "Selection3".   If 'value' is not
        // specified, the default "Selection3" value is used. 

    CustomInt& makeSelection4();
    CustomInt& makeSelection4(const CustomInt& value);
#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) \
 && defined(BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT)
    CustomInt& makeSelection4(CustomInt&& value);
#endif
        // Set the value of this object to be a "Selection4" value.   Optionally
        // specify the 'value' of the "Selection4".   If 'value' is not
        // specified, the default "Selection4" value is used. 

    template<class MANIPULATOR>
    int manipulateSelection(MANIPULATOR& manipulator);
        // Invoke the specified 'manipulator' on the address of the modifiable
        // selection, supplying 'manipulator' with the corresponding selection
        // information structure.   Return the value returned from the
        // invocation of 'manipulator' if this object has a defined selection,
        // and -1 otherwise. 

    Sequence6& selection1();
        // Return a reference to the modifiable "Selection1" selection of this
        // object if "Selection1" is the current selection.   The behavior is
        // undefined unless "Selection1" is the selection of this object. 

    unsigned char& selection2();
        // Return a reference to the modifiable "Selection2" selection of this
        // object if "Selection2" is the current selection.   The behavior is
        // undefined unless "Selection2" is the selection of this object. 

    CustomString& selection3();
        // Return a reference to the modifiable "Selection3" selection of this
        // object if "Selection3" is the current selection.   The behavior is
        // undefined unless "Selection3" is the selection of this object. 

    CustomInt& selection4();
        // Return a reference to the modifiable "Selection4" selection of this
        // object if "Selection4" is the current selection.   The behavior is
        // undefined unless "Selection4" is the selection of this object. 

    // ACCESSORS
    bsl::ostream& print(bsl::ostream& stream,
                        int           level = 0,
                        int           spacesPerLevel = 4) const;
        // Format this object to the specified output 'stream' at the
        // optionally specified indentation 'level' and return a reference to
        // the modifiable 'stream'.   If 'level' is specified, optionally
        // specify 'spacesPerLevel', the number of spaces per indentation level
        // for this and all of its nested objects.   Each line is indented by
        // the absolute value of 'level * spacesPerLevel'.   If 'level' is
        // negative, suppress indentation of the first line.   If
        // 'spacesPerLevel' is negative, suppress line breaks and format the
        // entire output on one line.   If 'stream' is initially invalid, this
        // operation has no effect.   Note that a trailing newline is provided
        // in multiline mode only. 

    int selectionId() const;
        // Return the id of the current selection if the selection is defined,
        // and -1 otherwise. 

    template<class ACCESSOR>
    int accessSelection(ACCESSOR& accessor) const;
        // Invoke the specified 'accessor' on the non-modifiable selection,
        // supplying 'accessor' with the corresponding selection information
        // structure.   Return the value returned from the invocation of
        // 'accessor' if this object has a defined selection, and -1 otherwise. 

    const Sequence6& selection1() const;
        // Return a reference to the non-modifiable "Selection1" selection of
        // this object if "Selection1" is the current selection.   The behavior
        // is undefined unless "Selection1" is the selection of this object. 

    const unsigned char& selection2() const;
        // Return a reference to the non-modifiable "Selection2" selection of
        // this object if "Selection2" is the current selection.   The behavior
        // is undefined unless "Selection2" is the selection of this object. 

    const CustomString& selection3() const;
        // Return a reference to the non-modifiable "Selection3" selection of
        // this object if "Selection3" is the current selection.   The behavior
        // is undefined unless "Selection3" is the selection of this object. 

    const CustomInt& selection4() const;
        // Return a reference to the non-modifiable "Selection4" selection of
        // this object if "Selection4" is the current selection.   The behavior
        // is undefined unless "Selection4" is the selection of this object. 

    bool isSelection1Value() const;
        // Return 'true' if the value of this object is a "Selection1" value,
        // and return 'false' otherwise. 

    bool isSelection2Value() const;
        // Return 'true' if the value of this object is a "Selection2" value,
        // and return 'false' otherwise. 

    bool isSelection3Value() const;
        // Return 'true' if the value of this object is a "Selection3" value,
        // and return 'false' otherwise. 

    bool isSelection4Value() const;
        // Return 'true' if the value of this object is a "Selection4" value,
        // and return 'false' otherwise. 

    bool isUndefinedValue() const;
        // Return 'true' if the value of this object is undefined, and 'false'
        // otherwise. 

    const char *selectionName() const;
        // Return the symbolic name of the current selection of this object. 
};

// FREE OPERATORS
inline
bool operator==(const SequenceWithAnonymityChoice& lhs, const SequenceWithAnonymityChoice& rhs);
    // Return 'true' if the specified 'lhs' and 'rhs' objects have the same
    // value, and 'false' otherwise.   Two 'SequenceWithAnonymityChoice' objects have the same
    // value if either the selections in both objects have the same ids and
    // the same values, or both selections are undefined. 

inline
bool operator!=(const SequenceWithAnonymityChoice& lhs, const SequenceWithAnonymityChoice& rhs);
    // Return 'true' if the specified 'lhs' and 'rhs' objects do not have the
    // same values, as determined by 'operator==', and 'false' otherwise. 

inline
bsl::ostream& operator<<(bsl::ostream& stream, const SequenceWithAnonymityChoice& rhs);
    // Format the specified 'rhs' to the specified output 'stream' and
    // return a reference to the modifiable 'stream'. 

}  // close package namespace

// TRAITS

BDLAT_DECL_CHOICE_WITH_ALLOCATOR_BITWISEMOVEABLE_TRAITS(s_baltst::SequenceWithAnonymityChoice)

// ============================================================================
//                         INLINE FUNCTION DEFINITIONS
// ============================================================================

namespace s_baltst {

                     // ---------------------------------
                     // class SequenceWithAnonymityChoice
                     // ---------------------------------

// CLASS METHODS
// CREATORS
inline
SequenceWithAnonymityChoice::SequenceWithAnonymityChoice(bslma::Allocator *basicAllocator)
: d_selectionId(SELECTION_ID_UNDEFINED)
, d_allocator_p(bslma::Default::allocator(basicAllocator))
{
}

inline
SequenceWithAnonymityChoice::~SequenceWithAnonymityChoice()
{
    reset();
}

// MANIPULATORS
template <class MANIPULATOR>
int SequenceWithAnonymityChoice::manipulateSelection(MANIPULATOR& manipulator)
{
    switch (d_selectionId) {
      case SequenceWithAnonymityChoice::SELECTION_ID_SELECTION1:
        return manipulator(&d_selection1.object(),
                SELECTION_INFO_ARRAY[SELECTION_INDEX_SELECTION1]);
      case SequenceWithAnonymityChoice::SELECTION_ID_SELECTION2:
        return manipulator(&d_selection2.object(),
                SELECTION_INFO_ARRAY[SELECTION_INDEX_SELECTION2]);
      case SequenceWithAnonymityChoice::SELECTION_ID_SELECTION3:
        return manipulator(&d_selection3.object(),
                SELECTION_INFO_ARRAY[SELECTION_INDEX_SELECTION3]);
      case SequenceWithAnonymityChoice::SELECTION_ID_SELECTION4:
        return manipulator(&d_selection4.object(),
                SELECTION_INFO_ARRAY[SELECTION_INDEX_SELECTION4]);
      default:
        BSLS_ASSERT(SequenceWithAnonymityChoice::SELECTION_ID_UNDEFINED == d_selectionId);
        return -1;
    }
}

inline
Sequence6& SequenceWithAnonymityChoice::selection1()
{
    BSLS_ASSERT(SELECTION_ID_SELECTION1 == d_selectionId);
    return d_selection1.object();
}

inline
unsigned char& SequenceWithAnonymityChoice::selection2()
{
    BSLS_ASSERT(SELECTION_ID_SELECTION2 == d_selectionId);
    return d_selection2.object();
}

inline
CustomString& SequenceWithAnonymityChoice::selection3()
{
    BSLS_ASSERT(SELECTION_ID_SELECTION3 == d_selectionId);
    return d_selection3.object();
}

inline
CustomInt& SequenceWithAnonymityChoice::selection4()
{
    BSLS_ASSERT(SELECTION_ID_SELECTION4 == d_selectionId);
    return d_selection4.object();
}

// ACCESSORS
inline
int SequenceWithAnonymityChoice::selectionId() const
{
    return d_selectionId;
}

template <class ACCESSOR>
int SequenceWithAnonymityChoice::accessSelection(ACCESSOR& accessor) const
{
    switch (d_selectionId) {
      case SELECTION_ID_SELECTION1:
        return accessor(d_selection1.object(),
                SELECTION_INFO_ARRAY[SELECTION_INDEX_SELECTION1]);
      case SELECTION_ID_SELECTION2:
        return accessor(d_selection2.object(),
                SELECTION_INFO_ARRAY[SELECTION_INDEX_SELECTION2]);
      case SELECTION_ID_SELECTION3:
        return accessor(d_selection3.object(),
                SELECTION_INFO_ARRAY[SELECTION_INDEX_SELECTION3]);
      case SELECTION_ID_SELECTION4:
        return accessor(d_selection4.object(),
                SELECTION_INFO_ARRAY[SELECTION_INDEX_SELECTION4]);
      default:
        BSLS_ASSERT(SELECTION_ID_UNDEFINED == d_selectionId);
        return -1;
    }
}

inline
const Sequence6& SequenceWithAnonymityChoice::selection1() const
{
    BSLS_ASSERT(SELECTION_ID_SELECTION1 == d_selectionId);
    return d_selection1.object();
}

inline
const unsigned char& SequenceWithAnonymityChoice::selection2() const
{
    BSLS_ASSERT(SELECTION_ID_SELECTION2 == d_selectionId);
    return d_selection2.object();
}

inline
const CustomString& SequenceWithAnonymityChoice::selection3() const
{
    BSLS_ASSERT(SELECTION_ID_SELECTION3 == d_selectionId);
    return d_selection3.object();
}

inline
const CustomInt& SequenceWithAnonymityChoice::selection4() const
{
    BSLS_ASSERT(SELECTION_ID_SELECTION4 == d_selectionId);
    return d_selection4.object();
}

inline
bool SequenceWithAnonymityChoice::isSelection1Value() const
{
    return SELECTION_ID_SELECTION1 == d_selectionId;
}

inline
bool SequenceWithAnonymityChoice::isSelection2Value() const
{
    return SELECTION_ID_SELECTION2 == d_selectionId;
}

inline
bool SequenceWithAnonymityChoice::isSelection3Value() const
{
    return SELECTION_ID_SELECTION3 == d_selectionId;
}

inline
bool SequenceWithAnonymityChoice::isSelection4Value() const
{
    return SELECTION_ID_SELECTION4 == d_selectionId;
}

inline
bool SequenceWithAnonymityChoice::isUndefinedValue() const
{
    return SELECTION_ID_UNDEFINED == d_selectionId;
}
}  // close package namespace

// FREE FUNCTIONS

inline
bool s_baltst::operator==(
        const s_baltst::SequenceWithAnonymityChoice& lhs,
        const s_baltst::SequenceWithAnonymityChoice& rhs)
{
    typedef s_baltst::SequenceWithAnonymityChoice Class;
    if (lhs.selectionId() == rhs.selectionId()) {
        switch (rhs.selectionId()) {
          case Class::SELECTION_ID_SELECTION1:
            return lhs.selection1() == rhs.selection1();
          case Class::SELECTION_ID_SELECTION2:
            return lhs.selection2() == rhs.selection2();
          case Class::SELECTION_ID_SELECTION3:
            return lhs.selection3() == rhs.selection3();
          case Class::SELECTION_ID_SELECTION4:
            return lhs.selection4() == rhs.selection4();
          default:
            BSLS_ASSERT(Class::SELECTION_ID_UNDEFINED == rhs.selectionId());
            return true;
        }
    }
    else {
        return false;
   }
}

inline
bool s_baltst::operator!=(
        const s_baltst::SequenceWithAnonymityChoice& lhs,
        const s_baltst::SequenceWithAnonymityChoice& rhs)
{
    return !( lhs == rhs);
}

inline
bsl::ostream& s_baltst::operator<<(
        bsl::ostream& stream,
        const s_baltst::SequenceWithAnonymityChoice& rhs)
{
    return rhs.print(stream, 0, -1);
}

}  // close enterprise namespace
#endif

// GENERATED BY BLP_BAS_CODEGEN_2020.03.30
// USING bas_codegen.pl s_baltst.xsd -m msg -p s_baltst -C tmp_singles --msgSplit 1 --noExternalization --noHashSupport --noAggregateConversion
// ----------------------------------------------------------------------------
// NOTICE:
//      Copyright 2020 Bloomberg Finance L.P. All rights reserved. 
//      Property of Bloomberg Finance L.P. (BFLP)
//      This software is made available solely pursuant to the
//      terms of a BFLP license agreement which governs its use. 
// ------------------------------- END-OF-FILE --------------------------------
