All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
Radiant::FlagsT< T, S > Class Template Reference

This class implements type-safe flags. More...

#include <Radiant/Flags.hpp>

Public Types

typedef S Int
 Internal type used to store the flags.
 

Public Member Functions

asInt () const
 Convert the flags to integer. More...
 
void clear ()
 Clear all flags to zero.
 
 FlagsT ()
 Construct empty flags object.
 
 FlagsT (T t)
 Construct flags. More...
 
 FlagsT (const FlagsT &f)
 Construct a copy. More...
 
bool operator! () const
 Check if no flags are raised. More...
 
bool operator!= (const FlagsT &b) const
 Compare if two flags are inequal. More...
 
FlagsT operator& (const FlagsT &b) const
 Do a bit-wise AND of flags. More...
 
FlagsToperator&= (const FlagsT &b)
 Do a bit-wise AND of flags and assign the result to this. More...
 
bool operator< (const FlagsT< T > &t) const
 
FlagsToperator= (const FlagsT &b)
 Copy flags. More...
 
bool operator== (const FlagsT &b) const
 Compare if two flags are equal. More...
 
FlagsT operator^ (const FlagsT &b) const
 Do a bit-wise XOR of flags. More...
 
FlagsToperator^= (const FlagsT &b)
 Do a bit-wise XOR of flags and assign the result to this. More...
 
FlagsT operator| (const FlagsT &b) const
 Do a bit-wise OR of flags. More...
 
FlagsToperator|= (const FlagsT &b)
 Do a bit-wise OR of flags and assign the result to this. More...
 
FlagsT operator~ () const
 Flip all the flags. More...
 

Static Public Member Functions

static FlagsT< T > fromInt (Int i)
 Converts int to Flags. More...
 

Detailed Description

template<typename T, typename S = typename IntOfSize<sizeof(T)>::Type>
class Radiant::FlagsT< T, S >

This class implements type-safe flags.

Template Parameters
TType of the flag type (enum)
SInternal type for storing the flags

Constructor & Destructor Documentation

template<typename T, typename S = typename IntOfSize<sizeof(T)>::Type>
Radiant::FlagsT< T, S >::FlagsT ( t)
inline

Construct flags.

Parameters
tinitial values
template<typename T, typename S = typename IntOfSize<sizeof(T)>::Type>
Radiant::FlagsT< T, S >::FlagsT ( const FlagsT< T, S > &  f)
inline

Construct a copy.

Parameters
fflags to copy

Member Function Documentation

template<typename T, typename S = typename IntOfSize<sizeof(T)>::Type>
S Radiant::FlagsT< T, S >::asInt ( ) const
inline

Convert the flags to integer.

Returns
flags as integer
template<typename T, typename S = typename IntOfSize<sizeof(T)>::Type>
static FlagsT<T> Radiant::FlagsT< T, S >::fromInt ( Int  i)
inlinestatic

Converts int to Flags.

If you end up using this function, you better have a real good reason to do so.

Parameters
iintegers to convert from
Returns
converted flags
template<typename T, typename S = typename IntOfSize<sizeof(T)>::Type>
bool Radiant::FlagsT< T, S >::operator! ( ) const
inline

Check if no flags are raised.

Returns
true if all flags are zero; otherwise false
template<typename T, typename S = typename IntOfSize<sizeof(T)>::Type>
bool Radiant::FlagsT< T, S >::operator!= ( const FlagsT< T, S > &  b) const
inline

Compare if two flags are inequal.

Parameters
bflags to compare
Returns
true if the flags are inequal; otherwise false
template<typename T, typename S = typename IntOfSize<sizeof(T)>::Type>
FlagsT Radiant::FlagsT< T, S >::operator& ( const FlagsT< T, S > &  b) const
inline

Do a bit-wise AND of flags.

Parameters
bflags to AND
Returns
combined flags
template<typename T, typename S = typename IntOfSize<sizeof(T)>::Type>
FlagsT& Radiant::FlagsT< T, S >::operator&= ( const FlagsT< T, S > &  b)
inline

Do a bit-wise AND of flags and assign the result to this.

Parameters
bflags to AND
Returns
reference to this
template<typename T, typename S = typename IntOfSize<sizeof(T)>::Type>
FlagsT& Radiant::FlagsT< T, S >::operator= ( const FlagsT< T, S > &  b)
inline

Copy flags.

Parameters
bflags to copy
Returns
reference to this flags object
template<typename T, typename S = typename IntOfSize<sizeof(T)>::Type>
bool Radiant::FlagsT< T, S >::operator== ( const FlagsT< T, S > &  b) const
inline

Compare if two flags are equal.

Parameters
bflags to compare
Returns
true if the flags are equal; otherwise false
template<typename T, typename S = typename IntOfSize<sizeof(T)>::Type>
FlagsT Radiant::FlagsT< T, S >::operator^ ( const FlagsT< T, S > &  b) const
inline

Do a bit-wise XOR of flags.

Parameters
bflags to XOR
Returns
combined flags
template<typename T, typename S = typename IntOfSize<sizeof(T)>::Type>
FlagsT& Radiant::FlagsT< T, S >::operator^= ( const FlagsT< T, S > &  b)
inline

Do a bit-wise XOR of flags and assign the result to this.

Parameters
bflags to XOR
Returns
reference to this
template<typename T, typename S = typename IntOfSize<sizeof(T)>::Type>
FlagsT Radiant::FlagsT< T, S >::operator| ( const FlagsT< T, S > &  b) const
inline

Do a bit-wise OR of flags.

Parameters
bflags to AND
Returns
combined flags
template<typename T, typename S = typename IntOfSize<sizeof(T)>::Type>
FlagsT& Radiant::FlagsT< T, S >::operator|= ( const FlagsT< T, S > &  b)
inline

Do a bit-wise OR of flags and assign the result to this.

Parameters
bflags to OR
Returns
reference to this
template<typename T, typename S = typename IntOfSize<sizeof(T)>::Type>
FlagsT Radiant::FlagsT< T, S >::operator~ ( ) const
inline

Flip all the flags.

Returns
flipped flags