8#ifndef INCLUDED_S_BALTST_TESTENUMERATION
9#define INCLUDED_S_BALTST_TESTENUMERATION
55#include <bsl_ostream.h>
56#include <bsl_string.h>
57#include <bsl_string_view.h>
70template <
class E0,
class E1 = TestNilEnumerator,
class E2 = TestNilEnumerator>
109 int fromString(
const char *
string,
int stringLength);
114 void toInt(
int *result)
const;
120template <
class E0,
class E1,
class E2>
122 const TestEnumeration<E0, E1, E2>&
object);
124template <
class E0,
class E1,
class E2>
125bool operator==(
const TestEnumeration<E0, E1, E2>& lhs,
126 const TestEnumeration<E0, E1, E2>& rhs);
128template <
class E0,
class E1,
class E2>
129bool operator!=(
const TestEnumeration<E0, E1, E2>& lhs,
130 const TestEnumeration<E0, E1, E2>& rhs);
133template <
class E0,
class E1,
class E2>
135 const TestEnumeration<E0, E1, E2>&
object);
137template <
class E0,
class E1,
class E2>
140template <
class E0,
class E1,
class E2>
145template <
class E0,
class E1,
class E2>
146void bdlat_enumToInt(
int *result,
const TestEnumeration<E0, E1, E2>& value);
148template <
class E0,
class E1,
class E2>
150 const TestEnumeration<E0, E1, E2>& value);
156template <
class E0,
class E1,
class E2>
174template <
class E0,
class E1,
class E2>
178 return lhs.d_value == rhs.d_value;
182template <
class E0,
class E1,
class E2>
188template <
class E0,
class E1,
class E2>
194template <
class E0,
class E1,
class E2>
196: d_value(original.d_value)
201template <
class E0,
class E1,
class E2>
205 d_value = original.d_value;
209template <
class E0,
class E1,
class E2>
212 if (Enumerator0::intValue() == number) {
213 d_value = Enumerator0::intValue();
217 if (k_HAS_ENUMERATOR_1 && Enumerator1::intValue() == number) {
218 d_value = Enumerator1::intValue();
222 if (k_HAS_ENUMERATOR_2 && Enumerator2::intValue() == number) {
223 d_value = Enumerator2::intValue();
230template <
class E0,
class E1,
class E2>
236 if (Enumerator0::stringValue() == stringRef) {
237 d_value = Enumerator0::intValue();
241 if (k_HAS_ENUMERATOR_1 && Enumerator1::stringValue() == stringRef) {
242 d_value = Enumerator1::intValue();
246 if (k_HAS_ENUMERATOR_2 && Enumerator2::stringValue() == stringRef) {
247 d_value = Enumerator2::intValue();
255template <
class E0,
class E1,
class E2>
258 return "MyEnumeration";
261template <
class E0,
class E1,
class E2>
265 (k_HAS_ENUMERATOR_1 && d_value == Enumerator1::intValue()) ||
266 (k_HAS_ENUMERATOR_2 && d_value == Enumerator2::intValue()));
271template <
class E0,
class E1,
class E2>
275 (k_HAS_ENUMERATOR_1 && d_value == Enumerator1::intValue()) ||
276 (k_HAS_ENUMERATOR_2 && d_value == Enumerator2::intValue()));
278 if (Enumerator0::intValue() == d_value) {
279 *result = Enumerator0::stringValue();
282 if (k_HAS_ENUMERATOR_1 && Enumerator1::intValue() == d_value) {
283 *result = Enumerator1::stringValue();
286 if (k_HAS_ENUMERATOR_2 && Enumerator2::intValue() == d_value) {
287 *result = Enumerator2::stringValue();
292template <
class E0,
class E1,
class E2>
297 object.toString(&value);
299 return stream <<
"[" <<
object.className() <<
" value " << value <<
"]";
302template <
class E0,
class E1,
class E2>
309template <
class E0,
class E1,
class E2>
317template <
class E0,
class E1,
class E2>
320 return object.className();
323template <
class E0,
class E1,
class E2>
326 return result->
fromInt(number);
329template <
class E0,
class E1,
class E2>
334 return result->
fromString(
string, stringLength);
337template <
class E0,
class E1,
class E2>
343template <
class E0,
class E1,
class E2>
Definition bslstl_stringview.h:441
Definition bslstl_string.h:1281
Definition s_baltst_testenumeration.h:71
E0 Enumerator0
Definition s_baltst_testenumeration.h:78
const char * className() const
Definition s_baltst_testenumeration.h:256
BSLMF_ASSERT((!bslmf::IsSame< TestNilEnumerator, E0 >::value))
E1 Enumerator1
Definition s_baltst_testenumeration.h:79
TestEnumeration & operator=(const TestEnumeration &original)
Definition s_baltst_testenumeration.h:202
int fromString(const char *string, int stringLength)
Definition s_baltst_testenumeration.h:231
static bool areEqual(const TestEnumeration &lhs, const TestEnumeration &rhs)
Definition s_baltst_testenumeration.h:175
int fromInt(int number)
Definition s_baltst_testenumeration.h:210
@ k_HAS_ENUMERATOR_1
Definition s_baltst_testenumeration.h:84
@ k_HAS_ENUMERATOR_2
Definition s_baltst_testenumeration.h:85
void toInt(int *result) const
Definition s_baltst_testenumeration.h:262
TestEnumeration()
Definition s_baltst_testenumeration.h:183
E2 Enumerator2
Definition s_baltst_testenumeration.h:80
void toString(bsl::string *result) const
Definition s_baltst_testenumeration.h:272
#define BSLS_ASSERT(X)
Definition bsls_assert.h:1804
#define BSLS_IDENT(str)
Definition bsls_ident.h:195
Definition bdlat_enumfunctions.h:389
Definition s_baltst_address.h:66
int bdlat_enumFromInt(TestDynamicType< VALUE_TYPE > *object, int number)
Definition s_baltst_testdynamictype.h:1972
int bdlat_enumFromString(TestDynamicType< VALUE_TYPE > *object, const char *string, int stringLength)
Definition s_baltst_testdynamictype.h:1978
void bdlat_enumToInt(int *result, const TestDynamicType< VALUE_TYPE > &object)
Definition s_baltst_testdynamictype.h:1986
void bdlat_enumToString(bsl::string *result, const TestDynamicType< VALUE_TYPE > &object)
Definition s_baltst_testdynamictype.h:1992
const char * bdlat_TypeName_className(const TestChoice< C0, C1, C2 > &object)
Definition s_baltst_testchoice.h:718
bsl::ostream & operator<<(bsl::ostream &stream, const Address &rhs)
Definition bdlat_enumfunctions.h:403
Definition bslmf_issame.h:181