BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bdlat_enumfunctions.h
Go to the documentation of this file.
1/// @file bdlat_enumfunctions.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// bdlat_enumfunctions.h -*-C++-*-
8#ifndef INCLUDED_BDLAT_ENUMFUNCTIONS
9#define INCLUDED_BDLAT_ENUMFUNCTIONS
10
11#include <bsls_ident.h>
12BSLS_IDENT("$Id: $")
13
14/// @defgroup bdlat_enumfunctions bdlat_enumfunctions
15/// @brief Provide a namespace defining enumeration functions.
16/// @addtogroup bdl
17/// @{
18/// @addtogroup bdlat
19/// @{
20/// @addtogroup bdlat_enumfunctions
21/// @{
22///
23/// <h1> Outline </h1>
24/// * <a href="#bdlat_enumfunctions-purpose"> Purpose</a>
25/// * <a href="#bdlat_enumfunctions-classes"> Classes </a>
26/// * <a href="#bdlat_enumfunctions-description"> Description </a>
27/// * <a href="#bdlat_enumfunctions-usage"> Usage </a>
28/// * <a href="#bdlat_enumfunctions-example-1-basic-usage"> Example 1: Basic Usage </a>
29///
30/// # Purpose {#bdlat_enumfunctions-purpose}
31/// Provide a namespace defining enumeration functions.
32///
33/// # Classes {#bdlat_enumfunctions-classes}
34///
35/// - bdlat_EnumFunctions: namespace for calling enumeration functions
36///
37/// @see
38///
39/// # Description {#bdlat_enumfunctions-description}
40/// The `bdlat_EnumFunctions` `namespace` provided in this
41/// component defines parameterized functions that expose "enumeration" behavior
42/// for "enumeration" types. See the package-level documentation for a full
43/// description of "enumeration" types. The functions in this namespace allow
44/// users to:
45/// @code
46/// o load an enumeration value from an integer value ('fromInt').
47/// o load an enumeration value from a string value ('fromString').
48/// o load an integer value from an enumeration value ('toInt').
49/// o load a string value from an enumeration value ('toString').
50/// o set an enumeration to its fallback value ('makeFallback').
51/// o check whether an enumeration supports a fallback value
52/// ('hasFallback').
53/// o test whether an enumeration is equal to the fallback value
54/// ('isFallback').
55/// @endcode
56/// The meta-functions `IsEnumeration` and `HasFallbackEnumerator` indicate
57/// whether a type supports the above functions. If the compile-time constant
58/// `IsEnumeration<TYPE>::value` is declared to be nonzero, the type must
59/// support the first four functions listed above. If the compile-time constant
60/// `HasFallbackEnumerator<TYPE>::value` is declared to be nonzero, the type
61/// must also support the last three functions listed above.
62///
63/// This component provides default implementations of the above listed
64/// functions and meta-functions for types that have the
65/// `bdlat_TypeTraitBasicEnumeration` trait. For other types, one may
66/// specialize the meta-functions and provide implementations for the functions
67/// by declaring overloads of the corresponding customization points. An
68/// example of this is provided in the `Usage` section of this document.
69///
70/// ## Usage {#bdlat_enumfunctions-usage}
71///
72///
73/// This section illustrates intended use of this component.
74///
75/// ### Example 1: Basic Usage {#bdlat_enumfunctions-example-1-basic-usage}
76///
77///
78/// Suppose you have a C++ `enum` type called `ImageType` whose enumerators
79/// represent supported formats for image files:
80/// @code
81/// #include <bdlat_enumfunctions.h>
82/// #include <bdlb_string.h>
83/// #include <bsl_iostream.h>
84/// #include <bsl_sstream.h>
85/// #include <bsl_string.h>
86///
87/// namespace BloombergLP {
88///
89/// namespace mine {
90///
91/// enum ImageType {
92/// JPG = 0,
93/// PNG = 1,
94/// GIF = 2,
95/// UNKNOWN = 100
96/// };
97/// @endcode
98/// We can now make `ImageType` expose "enumeration" behavior by implementing
99/// all the necessary `bdlat_enum*` functions for `ImageType` inside the `mine`
100/// namespace (*not* by attempting to declare specializations or overloads in
101/// the `bdlat_EnumFunctions` namespace). First we should forward declare all
102/// the functions that we will implement inside the `mine` namespace:
103/// @code
104/// // MANIPULATORS
105///
106/// int bdlat_enumFromInt(ImageType* result, int number);
107/// // Load into the specified 'result' the enumerator matching the
108/// // specified 'number'. Return 0 on success, and a non-zero value
109/// // with no effect on 'result' if 'number' does not match any
110/// // enumerator.
111///
112/// int bdlat_enumFromString(ImageType *result,
113/// const char *string,
114/// int stringLength);
115/// // Load into the specified 'result' the enumerator matching the
116/// // specified 'string' of the specified 'stringLength'. Return 0 on
117/// // success, and a non-zero value with no effect on 'result' if
118/// // 'string' and 'stringLength' do not match any enumerator.
119///
120/// int bdlat_enumMakeFallback(ImageType *result);
121/// // Load into the specified 'result' the fallback enumerator value and
122/// // return 0 to indicate success.
123///
124/// // ACCESSORS
125///
126/// void bdlat_enumToInt(int *result, const ImageType& value);
127/// // Load into the specified 'result' the integer representation of the
128/// // enumerator value held by the specified 'value'.
129///
130/// void bdlat_enumToString(bsl::string *result, const ImageType& value);
131/// // Load into the specified 'result' the string representation of the
132/// // enumerator value held by the specified 'value'.
133///
134/// bool bdlat_enumHasFallback(const ImageType&);
135/// // Return 'true' to indicate that this type supports a fallback
136/// // enumerator.
137///
138/// bool bdlat_enumIsFallback(const ImageType& value);
139/// // Return 'true' if the specified 'value' equals the fallback
140/// // enumerator, and 'false' otherwise.
141///
142/// } // close namespace mine
143/// @endcode
144/// Next, we provide the definitions for each of these functions:
145/// @code
146/// // MANIPULATORS
147///
148/// inline
149/// int mine::bdlat_enumFromInt(ImageType *result, int number)
150/// {
151/// enum { SUCCESS = 0, NOT_FOUND = -1 };
152///
153/// switch (number) {
154/// case JPG: {
155/// *result = JPG;
156/// return SUCCESS;
157/// }
158/// case PNG: {
159/// *result = PNG;
160/// return SUCCESS;
161/// }
162/// case GIF: {
163/// *result = GIF;
164/// return SUCCESS;
165/// }
166/// case UNKNOWN: {
167/// *result = UNKNOWN;
168/// return SUCCESS;
169/// }
170/// default: {
171/// return NOT_FOUND;
172/// }
173/// }
174/// }
175///
176/// inline
177/// int mine::bdlat_enumFromString(ImageType *result,
178/// const char *string,
179/// int stringLength)
180/// {
181/// enum { SUCCESS = 0, NOT_FOUND = -1 };
182///
183/// if (bdlb::String::areEqualCaseless("jpg",
184/// string,
185/// stringLength)) {
186/// *result = JPG;
187/// return SUCCESS;
188/// }
189///
190/// if (bdlb::String::areEqualCaseless("png",
191/// string,
192/// stringLength)) {
193/// *result = PNG;
194/// return SUCCESS;
195/// }
196///
197/// if (bdlb::String::areEqualCaseless("gif",
198/// string,
199/// stringLength)) {
200/// *result = GIF;
201/// return SUCCESS;
202/// }
203///
204/// if (bdlb::String::areEqualCaseless("unknown",
205/// string,
206/// stringLength)) {
207/// *result = UNKNOWN;
208/// return SUCCESS;
209/// }
210///
211/// return NOT_FOUND;
212/// }
213///
214/// inline
215/// int mine::bdlat_enumMakeFallback(ImageType *result)
216/// {
217/// *result = UNKNOWN;
218/// return 0;
219/// }
220///
221/// // ACCESSORS
222///
223/// inline
224/// void mine::bdlat_enumToInt(int *result, const ImageType& value)
225/// {
226/// *result = static_cast<int>(value);
227/// }
228///
229/// inline
230/// void mine::bdlat_enumToString(bsl::string *result, const ImageType& value)
231/// {
232/// switch (value) {
233/// case JPG: {
234/// *result = "JPG";
235/// } break;
236/// case PNG: {
237/// *result = "PNG";
238/// } break;
239/// case GIF: {
240/// *result = "GIF";
241/// } break;
242/// case UNKNOWN: {
243/// *result = "UNKNOWN";
244/// } break;
245/// default: {
246/// *result = "INVALID";
247/// } break;
248/// }
249/// }
250///
251/// inline
252/// bool mine::bdlat_enumHasFallback(const ImageType&)
253/// {
254/// return true;
255/// }
256///
257/// inline
258/// bool mine::bdlat_enumIsFallback(const ImageType& value)
259/// {
260/// return value == UNKNOWN;
261/// }
262/// @endcode
263/// Finally, we need to specialize the `IsEnumeration` and
264/// `HasFallbackEnumerator` meta-functions in the `bdlat_EnumFunctions`
265/// namespace for the `mine::ImageType` type. This makes the `bdlat`
266/// infrastructure recognize `ImageType` as an enumeration abstraction with a
267/// fallback enumerator:
268/// @code
269/// namespace bdlat_EnumFunctions {
270/// template <>
271/// struct IsEnumeration<mine::ImageType> : public bsl::true_type {
272/// };
273/// template <>
274/// struct HasFallbackEnumerator<mine::ImageType> : public bsl::true_type {
275/// };
276/// } // close namespace 'bdlat_EnumFunctions'
277/// } // close namespace 'BloombergLP'
278/// @endcode
279/// The `bdlat` infrastructure (and any component that uses this infrastructure)
280/// will now recognize `ImageType` as an "enumeration" type with a fallback
281/// enumerator. For example, suppose we have the following XML data:
282/// @code
283/// <?xml version='1.0' encoding='UTF-8' ?>
284/// <ImageType>PNG</ImageType>
285/// @endcode
286/// Using the @ref balxml_decoder component, we can load this XML data into a
287/// `ImageType` object:
288/// @code
289/// #include <balxml_decoder.h>
290///
291/// void decodeImageTypeFromXML(bsl::istream& inputData)
292/// {
293/// using namespace BloombergLP;
294///
295/// ImageType object = 0;
296///
297/// balxml::DecoderOptions options;
298/// balxml::MiniReader reader;
299/// balxml::ErrorInfo errInfo;
300///
301/// balxml::Decoder decoder(&options, &reader, &errInfo);
302/// int result = decoder.decode(inputData, &object);
303///
304/// assert(0 == result);
305/// assert(PNG == object);
306/// }
307/// @endcode
308/// Note that the `bdlat` framework can be used for functionality other than
309/// encoding/decoding into XML. When `mine::ImageType` is plugged into the
310/// framework, then it will be automatically usable within the framework. For
311/// example, consider the following generic functions that read a string from a
312/// stream and decode its value into a `bdlat` "enumeration" object:
313/// @code
314/// template <class TYPE>
315/// int readEnum(bsl::istream& stream, TYPE *object)
316/// {
317/// bsl::string value;
318/// stream >> value;
319///
320/// return bdlat_EnumFunctions::fromString(object,
321/// value.c_str(),
322/// value.length())) {
323/// }
324///
325/// template <class TYPE>
326/// int readEnumOrFallback(bsl::istream& stream, TYPE *object)
327/// {
328/// const int rc = readEnum(stream, object);
329/// return (0 == rc) ? rc : bdlat_EnumFunctions::makeFallback(object);
330/// }
331/// @endcode
332/// We can use these generic functions with `mine::ImageType` as follows:
333/// @code
334/// void usageExample()
335/// {
336/// using namespace BloombergLP;
337///
338/// bsl::stringstream ss;
339/// mine::ImageType object;
340///
341/// ss << "JPG\nWEBP\nWEBP\n";
342///
343/// assert(0 == readEnum(ss, &object));
344/// assert(mine::JPG == object);
345///
346/// assert(0 != readEnum(ss, &object));
347/// assert(mine::JPG == object);
348///
349/// assert(0 == readEnumOrFallback(ss, &object));
350/// assert(mine::UNKNOWN == object);
351/// }
352/// @endcode
353/// @}
354/** @} */
355/** @} */
356
357/** @addtogroup bdl
358 * @{
359 */
360/** @addtogroup bdlat
361 * @{
362 */
363/** @addtogroup bdlat_enumfunctions
364 * @{
365 */
366
367#include <bdlscm_version.h>
368
369#include <bdlat_bdeatoverrides.h>
370#include <bdlat_typetraits.h>
371
372#include <bslalg_hastrait.h>
373
374#include <bslmf_assert.h>
376#include <bslmf_matchanytype.h>
377
378#include <bsls_assert.h>
379#include <bsls_platform.h>
380
381#include <bsl_string.h>
382
383
384
385 // =============================
386 // namespace bdlat_EnumFunctions
387 // =============================
388
390 // This 'namespace' provides functions that expose "enumeration" behavior
391 // for "enumeration" types. See the component-level documentation for more
392 // information.
393
394 // META-FUNCTIONS
395
396 /// This `struct` should be specialized for third-party types that need
397 /// to expose "enumeration" behavior. See the component-level
398 /// documentation for further information.
399 template <class TYPE>
401 : public bsl::integral_constant<
402 bool,
403 bslalg::HasTrait<TYPE, bdlat_TypeTraitBasicEnumeration>::value> {
404 };
405
406 /// This `struct` should be specialized for third-party types that need
407 /// to declare the fact that they have a fallback enumerator value.
408 /// Clients that specialize this struct must ensure that if
409 /// `HasFallbackEnumerator<TYPE>::value` is true, then
410 /// `IsEnumeration<TYPE>::value` is also true; otherwise, the behavior
411 /// is undefined.
412 template <class TYPE>
414 : public bsl::integral_constant<
415 bool,
416 bslalg::HasTrait<TYPE, bdlat_TypeTraitHasFallbackEnumerator>::value> {
417 };
418
419 // MANIPULATORS
420
421 /// Load into the specified `result` the enumerator matching the
422 /// specified `number`. Return 0 on success, and a non-zero value with
423 /// no effect on `result` if `number` does not match any enumerator.
424 template <class TYPE>
425 int fromInt(TYPE *result, int number);
426
427 /// Load into the specified `result` the enumerator matching the
428 /// specified `string` of the specified `stringLength`. Return 0 on
429 /// success, and a non-zero value with no effect on `result` if `string`
430 /// and `stringLength` do not match any enumerator.
431 template <class TYPE>
432 int fromString(TYPE *result, const char *string, int stringLength);
433
434 /// Load into the specified `result` the fallback enumerator value.
435 /// Return 0 on success, and a non-zero value with no effect on `result`
436 /// if it does not have a fallback enumerator.
437 template <class TYPE>
438 int makeFallback(TYPE *result);
439
440 // ACCESSORS
441
442 /// Return `true` if the specified `value` supports a fallback
443 /// enumerator, and `false` otherwise.
444 template <class TYPE>
445 bool hasFallback(const TYPE& value);
446
447 /// Return `true` if the specified `value` is equal to a fallback
448 /// enumerator, and `false` otherwise.
449 template <class TYPE>
450 bool isFallback(const TYPE& value);
451
452 /// Load into the specified `result` the integer representation of the
453 /// enumerator value held by the specified `value`.
454 template <class TYPE>
455 void toInt(int *result, const TYPE& value);
456
457 /// Load into the specified `result` the string representation of the
458 /// enumerator value held by the specified `value`.
459 template <class TYPE>
460 void toString(bsl::string *result, const TYPE& value);
461
462} // close namespace bdlat_EnumFunctions
463
464 // ===================================
465 // struct bdlat_EnumFunctions_ImplUtil
466 // ===================================
467
468/// # Implementation Notes
469/// The below functions use tag dispatch to provide an implementation of the
470/// fallback-related operations that either delegate to the associated
471/// customization points or immediately return a non-zero value to indicate
472/// failure, depending on whether the type does or does not satisfy the
473/// `HasFallbackEnumerator` trait, respectively. The purpose of doing this
474/// is so that the fallback-related operations can be used on any type, even
475/// enumeration types that do not have fallback enumerators.
477
478 // CLASS METHODS
479 template <class TYPE>
480 static int makeFallback(TYPE *result, bsl::true_type);
481 template <class TYPE>
482 static int makeFallback(TYPE *result, bsl::false_type);
483
484 template <class TYPE>
485 static bool hasFallback(const TYPE& value, bsl::true_type);
486 template <class TYPE>
487 static bool hasFallback(const TYPE& value, bsl::false_type);
488
489 template <class TYPE>
490 static bool isFallback(const TYPE& value, bsl::true_type);
491 template <class TYPE>
492 static bool isFallback(const TYPE& value, bsl::false_type);
493};
494
495 // ====================
496 // default declarations
497 // ====================
498
499namespace bdlat_EnumFunctions {
500 // This namespace declaration adds the default implementations of the
501 // "enumeration" customization-point functions to 'bdlat_EnumFunctions'.
502 // These default implementations assume the type of the acted-upon object
503 // is a basic-enumeration type. For more information about
504 // basic-enumeration types, see @ref bdlat_typetraits .
505 //
506 // In order to use a type as a 'bdlat' enumeration type that is *not* a
507 // basic-enumeration type, you must implement the below customization
508 // points for that type as overloads in the namespace that the type belongs
509 // to. Overloading the 'bdlat_enumMakeFallback', 'bdlat_enumHasFallback',
510 // and 'bdlat_enumIsFallback' functions is required only if
511 // 'HasFallbackEnumerator' is 'true' for your type or class of types. In
512 // that case, the three functions' behaviors must be consistent with each
513 // other, which means that the following axioms must hold for a non-const
514 // lvalue 'x':
515 //: 1 Whenever 'bdlat_enumHasFallback(x)' is 'false',
516 //: 'bdlat_enumMakeFallback(&x)' would fail by leaving 'x' unchanged and
517 //: returning a nonzero value, and 'bdlat_enumIsFallback(x)' is 'false';
518 //: 2 Whenever 'bdlat_enumHasFallback(x)' is 'true',
519 //: 'bdlat_enumMakeFallback(&x)' would succeed by returning 0 and a
520 //: call to 'bdlat_enumIsFallback(x)' immediately afterward would return
521 //: 'true'.
522
523 // MANIPULATORS
524 template <class TYPE>
525 int bdlat_enumFromInt(TYPE *result, int number);
526
527 template <class TYPE>
528 int bdlat_enumFromString(TYPE *result,
529 const char *string,
530 int stringLength);
531
532 /// Load into the specified `result` the fallback enumerator value.
533 /// Return 0 on success, and a non-zero value with no effect on `result`
534 /// if it does not have a fallback enumerator. The behavior is
535 /// undefined if this default implementation of `bdlat_enumMakeFallback`
536 /// is instantiated with a template parameter `TYPE` such that
537 /// `bdlat_HasFallbackEnumerator<TYPE>` is `false`. Note that this is a
538 /// customization point function and should not be called directly by
539 /// user code. Use `bdlat_EnumFunctions::makeFallback` instead.
540 template <class TYPE>
541 int bdlat_enumMakeFallback(TYPE *result);
542
543 // ACCESSORS
544 template <class TYPE>
545 void bdlat_enumToInt(int *result, const TYPE& value);
546
547 template <class TYPE>
548 void bdlat_enumToString(bsl::string *result, const TYPE& value);
549
550 /// Return `true` if the specified `value` supports a fallback
551 /// enumerator, and `false` otherwise. The behavior is undefined if
552 /// this default implementation of `bdlat_enumHasFallback` is
553 /// instantiated with a template parameter `TYPE` such that
554 /// `bdlat_HasFallbackEnumerator<TYPE>` is `false`. Note that this is a
555 /// customization point function and should not be called directly by
556 /// user code. Use `bdlat_EnumFunctions::hasFallback` instead.
557 template <class TYPE>
558 bool bdlat_enumHasFallback(const TYPE& value);
559
560 /// Return `true` if the specified `value` is equal to a fallback
561 /// enumerator, and `false` otherwise. The behavior is undefined if
562 /// this default implementation of `bdlat_enumIsFallback` is
563 /// instantiated with a template parameter `TYPE` such that
564 /// `bdlat_HasFallbackEnumerator<TYPE>` is `false`. Note that this is a
565 /// customization point function and should not be called directly by
566 /// user code. Use `bdlat_EnumFunctions::isFallback` instead.
567 template <class TYPE>
568 bool bdlat_enumIsFallback(const TYPE& value);
569
570} // close namespace bdlat_EnumFunctions
571
572// ============================================================================
573// INLINE FUNCTION DEFINITIONS
574// ============================================================================
575
576 // -----------------------------
577 // namespace bdlat_EnumFunctions
578 // -----------------------------
579
580// MANIPULATORS
581template <class TYPE>
582inline
583int bdlat_EnumFunctions::fromInt(TYPE *result, int number)
584{
585 return bdlat_enumFromInt(result, number);
586}
587
588template <class TYPE>
589inline
590int bdlat_EnumFunctions::fromString(TYPE *result,
591 const char *string,
592 int stringLength)
593{
594 return bdlat_enumFromString(result, string, stringLength);
595}
596
597template <class TYPE>
598inline
599int bdlat_EnumFunctions::makeFallback(TYPE *result)
600{
603}
604
605// ACCESSORS
606template <class TYPE>
607inline
608bool bdlat_EnumFunctions::hasFallback(const TYPE& value)
609{
612}
613
614template <class TYPE>
615inline
616bool bdlat_EnumFunctions::isFallback(const TYPE& value)
617{
620}
621
622template <class TYPE>
623inline
624void bdlat_EnumFunctions::toInt(int *result, const TYPE& value)
625{
626 bdlat_enumToInt(result, value);
627}
628
629
630template <class TYPE>
631inline
632void bdlat_EnumFunctions::toString(bsl::string *result, const TYPE& value)
633{
634 bdlat_enumToString(result, value);
635}
636
637 // -----------------------------------
638 // struct bdlat_EnumFunctions_ImplUtil
639 // -----------------------------------
640
641// CLASS METHODS
642template <class TYPE>
644{
645#if !defined(BSLS_PLATFORM_CMP_SUN)
647#endif
649 return bdlat_enumMakeFallback(result);
650}
651
652template <class TYPE>
654{
655 static_cast<void>(result);
656 return -1;
657}
658
659template <class TYPE>
662{
663#if !defined(BSLS_PLATFORM_CMP_SUN)
665#endif
667 return bdlat_enumHasFallback(value);
668}
669
670template <class TYPE>
673{
674 static_cast<void>(value);
675 return false;
676}
677
678template <class TYPE>
681{
682#if !defined(BSLS_PLATFORM_CMP_SUN)
684#endif
686 return bdlat_enumIsFallback(value);
687}
688
689template <class TYPE>
692{
693 static_cast<void>(value);
694 return false;
695}
696 // -------------------
697 // default definitions
698 // -------------------
699
700// MANIPULATORS
701template <class TYPE>
702inline
703int bdlat_EnumFunctions::bdlat_enumFromInt(TYPE *result, int number)
704{
706
707 typedef typename bdlat_BasicEnumerationWrapper<TYPE>::Wrapper Wrapper;
708 return Wrapper::fromInt(result, number);
709}
710
711template <class TYPE>
712inline
714 const char *string,
715 int stringLength)
716{
719
720 typedef typename bdlat_BasicEnumerationWrapper<TYPE>::Wrapper Wrapper;
721 return Wrapper::fromString(result, string, stringLength);
722}
723
724template <class TYPE>
725inline
727{
728#if !defined(BSLS_PLATFORM_CMP_SUN)
733#endif
734
735 typedef typename bdlat_BasicEnumerationWrapper<TYPE>::Wrapper Wrapper;
736 return Wrapper::makeFallback(result);
737}
738
739// ACCESSORS
740template <class TYPE>
741inline
742void bdlat_EnumFunctions::bdlat_enumToInt(int *result, const TYPE& value)
743{
746
747 *result = static_cast<int>(value);
748}
749
750template <class TYPE>
751inline
753 const TYPE& value)
754{
757
758 typedef typename bdlat_BasicEnumerationWrapper<TYPE>::Wrapper Wrapper;
759 *result = Wrapper::toString(value);
760}
761
762template <class TYPE>
763inline
764bool bdlat_EnumFunctions::bdlat_enumHasFallback(const TYPE& value)
765{
766#if !defined(BSLS_PLATFORM_CMP_SUN)
771#endif
772
773 typedef typename bdlat_BasicEnumerationWrapper<TYPE>::Wrapper Wrapper;
774 return Wrapper::hasFallback(value);
775}
776
777template <class TYPE>
778inline
779bool bdlat_EnumFunctions::bdlat_enumIsFallback(const TYPE& value)
780{
781#if !defined(BSLS_PLATFORM_CMP_SUN)
786#endif
787
788 typedef typename bdlat_BasicEnumerationWrapper<TYPE>::Wrapper Wrapper;
789 return Wrapper::isFallback(value);
790}
791
792
793
794#endif
795
796// ----------------------------------------------------------------------------
797// Copyright 2015 Bloomberg Finance L.P.
798//
799// Licensed under the Apache License, Version 2.0 (the "License");
800// you may not use this file except in compliance with the License.
801// You may obtain a copy of the License at
802//
803// http://www.apache.org/licenses/LICENSE-2.0
804//
805// Unless required by applicable law or agreed to in writing, software
806// distributed under the License is distributed on an "AS IS" BASIS,
807// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
808// See the License for the specific language governing permissions and
809// limitations under the License.
810// ----------------------------- END-OF-FILE ----------------------------------
811
812/** @} */
813/** @} */
814/** @} */
Definition bslstl_string.h:1281
static bool hasFallback(const TYPE &value, bsl::true_type)
Definition bdlat_enumfunctions.h:660
static int makeFallback(TYPE *result, bsl::true_type)
Definition bdlat_enumfunctions.h:643
static bool isFallback(const TYPE &value, bsl::true_type)
Definition bdlat_enumfunctions.h:679
#define BSLMF_ASSERT(expr)
Definition bslmf_assert.h:229
#define BSLS_IDENT(str)
Definition bsls_ident.h:195
Definition bdlat_enumfunctions.h:389
void bdlat_enumToString(bsl::string *result, const TYPE &value)
void toInt(int *result, const TYPE &value)
int fromString(TYPE *result, const char *string, int stringLength)
int bdlat_enumFromInt(TYPE *result, int number)
bool bdlat_enumHasFallback(const TYPE &value)
bool bdlat_enumIsFallback(const TYPE &value)
int fromInt(TYPE *result, int number)
void toString(bsl::string *result, const TYPE &value)
int bdlat_enumFromString(TYPE *result, const char *string, int stringLength)
void bdlat_enumToInt(int *result, const TYPE &value)
int bdlat_enumMakeFallback(TYPE *result)
int makeFallback(TYPE *result)
bool hasFallback(const TYPE &value)
bool isFallback(const TYPE &value)
Definition bdlat_typetraits.h:146
Definition bdlat_enumfunctions.h:416
Definition bdlat_enumfunctions.h:403
Definition bdlat_enumfunctions.h:476
This trait may be declared for "enumeration" types.
Definition bdlat_typetraits.h:121
Definition bslmf_integralconstant.h:244
Definition bslalg_hastrait.h:117