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