System::Enum< E, Guard > Struct Template Reference

Provides methods that perform some operations on values of enum type. This is a static type with no instance services. You should never create instances of it by any means. More...

#include "format_builder.h"

Public Types

using UnderlyingType = typename std::underlying_type< E >::type
 Alias for the enum's underlying type. More...
 

Static Public Member Functions

static const System::TypeInfoGetUnderlyingType ()
 Returns the underlying type of the enumeration. More...
 
static bool HasFlag (E value, E mask)
 Determines if the specified bits are set in a bitary representation of the specified enum value. More...
 
static bool IsDefined (E value)
 Determines whether the specified value is a member of enumeration type E. More...
 
template<class T >
static std::enable_if< std::is_convertible< T, UnderlyingType >::value, bool >::type IsDefined (T value)
 Determines whether the specified value is a member of enumeration type T. More...
 
static bool IsDefined (const String &name)
 Determines if the value with the specified name is among members of enum E. More...
 
template<class T >
static std::enable_if< std::is_same< T, E >::value||std::is_convertible< T, UnderlyingType >::value, String >::type GetName (T value)
 Returns the name of the enumeration constant that has the specified value. More...
 
template<class T >
static std::enable_if< std::is_same< T, E >::value||std::is_convertible< T, UnderlyingType >::value, String >::type GetDescription (T value)
 Returns the name of the enumeration constant that has the specified value. More...
 
static E Parse (const String &str, bool ignoreCase=false)
 Converts the specfied string into equivalent enum constant. More...
 
static bool TryParse (const String &str, E &result)
 Tries to convert the specified string into equivalent enum constant. More...
 
static bool TryParse (const String &str, bool ignoreCase, E &result)
 Tries to convert the specified string into equivalent enum constant. More...
 
static ArrayPtr< E > GetValues ()
 Returns an array containing all members of enumeration E. More...
 
static ArrayPtr< StringGetNames ()
 Returns an array containing names of all members of enumeration E. More...
 
template<typename T , typename _ = typename std::enable_if<std::is_arithmetic<T>::value || std::is_enum<T>::value>::type>
static int Compare (E a, T b)
 Performs the arithmetic comparison of the values of the specified enumeration constants. More...
 

Detailed Description

template<class E, class Guard = typename std::enable_if<std::is_enum<E>::value>::type>
struct System::Enum< E, Guard >

Provides methods that perform some operations on values of enum type. This is a static type with no instance services. You should never create instances of it by any means.

Template Parameters
EThe type of enum on values of which the class handles
GuardService type argument whose purpose is to ensure that E is enumerable type

Member Typedef Documentation

◆ UnderlyingType

template<class E , class Guard = typename std::enable_if<std::is_enum<E>::value>::type>
using System::Enum< E, Guard >::UnderlyingType = typename std::underlying_type<E>::type

Alias for the enum's underlying type.

Member Function Documentation

◆ Compare()

template<class E , class Guard = typename std::enable_if<std::is_enum<E>::value>::type>
template<typename T , typename _ = typename std::enable_if<std::is_arithmetic<T>::value || std::is_enum<T>::value>::type>
static int System::Enum< E, Guard >::Compare ( a,
b 
)
inlinestatic

Performs the arithmetic comparison of the values of the specified enumeration constants.

Parameters
aThe first comparand
bThe second comparand
Returns
-1 if a is less than b; 0 if the values are equal; 1 if a is greater than b

◆ GetDescription()

template<class E , class Guard = typename std::enable_if<std::is_enum<E>::value>::type>
template<class T >
static std::enable_if<std::is_same<T, E>::value || std::is_convertible<T, UnderlyingType>::value, String>::type System::Enum< E, Guard >::GetDescription ( value)
inlinestatic

Returns the name of the enumeration constant that has the specified value.

Parameters
valueThe value of enum constant whose name is to be returned
Returns
The name of the specified enum constant

◆ GetName()

template<class E , class Guard = typename std::enable_if<std::is_enum<E>::value>::type>
template<class T >
static std::enable_if< std::is_same<T,E>::value || std::is_convertible<T, UnderlyingType>::value, String>::type System::Enum< E, Guard >::GetName ( value)
inlinestatic

Returns the name of the enumeration constant that has the specified value.

Parameters
valueThe value of enum constant whose name is to be returned
Returns
The name of the specified enum constant

◆ GetNames()

template<class E , class Guard = typename std::enable_if<std::is_enum<E>::value>::type>
static ArrayPtr<String> System::Enum< E, Guard >::GetNames ( )
inlinestatic

Returns an array containing names of all members of enumeration E.

◆ GetUnderlyingType()

template<class E , class Guard = typename std::enable_if<std::is_enum<E>::value>::type>
static const System::TypeInfo& System::Enum< E, Guard >::GetUnderlyingType ( )
inlinestatic

Returns the underlying type of the enumeration.

◆ GetValues()

template<class E , class Guard = typename std::enable_if<std::is_enum<E>::value>::type>
static ArrayPtr<E> System::Enum< E, Guard >::GetValues ( )
inlinestatic

Returns an array containing all members of enumeration E.

◆ HasFlag()

template<class E , class Guard = typename std::enable_if<std::is_enum<E>::value>::type>
static bool System::Enum< E, Guard >::HasFlag ( value,
mask 
)
inlinestatic

Determines if the specified bits are set in a bitary representation of the specified enum value.

Parameters
valueThe enum value to test
maskThe mask to check value's bits against
Returns
True if bits that are set in mask are also set in value, otherwise - false

◆ IsDefined() [1/3]

template<class E , class Guard = typename std::enable_if<std::is_enum<E>::value>::type>
static bool System::Enum< E, Guard >::IsDefined ( value)
inlinestatic

Determines whether the specified value is a member of enumeration type E.

Parameters
valueThe value to check
Returns
True if value is a member of enumeration E, otherwise - false

◆ IsDefined() [2/3]

template<class E , class Guard = typename std::enable_if<std::is_enum<E>::value>::type>
template<class T >
static std::enable_if< std::is_convertible<T, UnderlyingType>::value, bool>::type System::Enum< E, Guard >::IsDefined ( value)
inlinestatic

Determines whether the specified value is a member of enumeration type T.

Parameters
valueThe value to check
Returns
True if value is a member of enumeration T, otherwise - false

◆ IsDefined() [3/3]

template<class E , class Guard = typename std::enable_if<std::is_enum<E>::value>::type>
static bool System::Enum< E, Guard >::IsDefined ( const String name)
inlinestatic

Determines if the value with the specified name is among members of enum E.

Parameters
nameThe name to check
Returns
True if a member of enum E with the specified name exists.

◆ Parse()

template<class E , class Guard = typename std::enable_if<std::is_enum<E>::value>::type>
static E System::Enum< E, Guard >::Parse ( const String str,
bool  ignoreCase = false 
)
inlinestatic

Converts the specfied string into equivalent enum constant.

Parameters
strString that is interpreted as containing the name of enum constant
ignoreCaseSpecifies if the case should be ignored when interpreting the string
Returns
The enumeration constant whose name is specified in str
Exceptions
ArgumentExceptionIf the enum constant with name specifed in str was not found aboung the members of enum E.

◆ TryParse() [1/2]

template<class E , class Guard = typename std::enable_if<std::is_enum<E>::value>::type>
static bool System::Enum< E, Guard >::TryParse ( const String str,
E &  result 
)
inlinestatic

Tries to convert the specified string into equivalent enum constant.

Parameters
strString that is interpreted as containing the name of enum constant
resultThe output parameter that if conversion succeeds contains the result of conversion on function
Returns
True if conversion succeeded, otherwise - false

◆ TryParse() [2/2]

template<class E , class Guard = typename std::enable_if<std::is_enum<E>::value>::type>
static bool System::Enum< E, Guard >::TryParse ( const String str,
bool  ignoreCase,
E &  result 
)
inlinestatic

Tries to convert the specified string into equivalent enum constant.

Parameters
strString that is interpreted as containing the name of enum constant
ignoreCaseSpecifies if the case should be ignored when interpreting the string
resultThe output parameter that if conversion succeeds contains the result of conversion on function return
Returns
True if conversion succeeded, otherwise - false