CONZEPT 16 C++ API
C16::Flags< Enumeration > Class Template Reference

Set of enumerators. More...

#include "C16/Flags.hpp"

Detailed Description

template<typename Enumeration>
class C16::Flags< Enumeration >

Set of enumerators.

Template Parameters
EnumerationType of the enumeration of the flags

Static Public Attributes

static const Flags< Enumeration > EMPTY = Flags<Enumeration>()
 Empty flags. More...
 
static constexpr Enumeration NOTHING = static_cast<Enumeration>(0)
 Valueless enumerator. More...
 

Public Member Functions

constexpr Flags ()
 Constructs empty flags. More...
 
constexpr Flags (const std::initializer_list< Enumeration > &enumerators)
 Constructs flags by means of enumerators. More...
 
constexpr bool contains (Enumeration enumerator) const
 Gets if the flags contain an enumerator. More...
 
constexpr value_type value () const
 Gets the value of the flags. More...
 
void add (Enumeration enumerator)
 Adds a single enumerator to the flags. More...
 
void add (const std::initializer_list< Enumeration > &enumerators)
 Adds multiple enumerators to the flags. More...
 
void remove (Enumeration enumerator)
 Removes a single enumerator from the flags. More...
 
void remove (const std::initializer_list< Enumeration > &enumerators)
 Removes multiple enumerators from the flags. More...
 
void clear ()
 Empties the flags. More...
 
void set (Enumeration enumerator, bool set)
 Sets a single enumerator of the flags. More...
 
void set (const std::initializer_list< Enumeration > &enumerators, bool set)
 Sets multiple enumerators of the flags. More...
 
void toggle (Enumeration enumerator)
 Toggles a single enumerator of the flags. More...
 
void toggle (const std::initializer_list< Enumeration > &enumerators)
 Toggles multiple enumerators of the flags. More...
 

Member Data Documentation

◆ EMPTY

template<typename Enumeration >
const Flags< Enumeration > C16::Flags< Enumeration >::EMPTY = Flags<Enumeration>()
static

Empty flags.

◆ NOTHING

template<typename Enumeration >
constexpr Enumeration C16::Flags< Enumeration >::NOTHING = static_cast<Enumeration>(0)
staticconstexpr

Valueless enumerator.

Constructor & Destructor Documentation

◆ Flags() [1/2]

template<typename Enumeration >
constexpr C16::Flags< Enumeration >::Flags ( )
inlineconstexpr

Constructs empty flags.

◆ Flags() [2/2]

template<typename Enumeration >
constexpr C16::Flags< Enumeration >::Flags ( const std::initializer_list< Enumeration > &  enumerators)
inlineconstexpr

Constructs flags by means of enumerators.

Parameters
enumeratorsEnumerators

Member Function Documentation

◆ contains()

template<typename Enumeration >
constexpr bool C16::Flags< Enumeration >::contains ( Enumeration  enumerator) const
inlineconstexpr

Gets if the flags contain an enumerator.

Parameters
enumeratorEnumerator

References C16::Flags< Enumeration >::value().

◆ value()

template<typename Enumeration >
constexpr value_type C16::Flags< Enumeration >::value ( ) const
inlineconstexpr

◆ add() [1/2]

template<typename Enumeration >
void C16::Flags< Enumeration >::add ( Enumeration  enumerator)
inline

Adds a single enumerator to the flags.

Parameters
enumeratorEnumerator

References C16::Flags< Enumeration >::value().

Referenced by C16::Flags< Enumeration >::set().

◆ add() [2/2]

template<typename Enumeration >
void C16::Flags< Enumeration >::add ( const std::initializer_list< Enumeration > &  enumerators)
inline

Adds multiple enumerators to the flags.

Parameters
enumeratorsEnumerators

References C16::Flags< Enumeration >::value().

◆ remove() [1/2]

template<typename Enumeration >
void C16::Flags< Enumeration >::remove ( Enumeration  enumerator)
inline

Removes a single enumerator from the flags.

Parameters
enumeratorEnumerator

References C16::Flags< Enumeration >::value().

Referenced by C16::Flags< Enumeration >::set().

◆ remove() [2/2]

template<typename Enumeration >
void C16::Flags< Enumeration >::remove ( const std::initializer_list< Enumeration > &  enumerators)
inline

Removes multiple enumerators from the flags.

Parameters
enumeratorsEnumerators

References C16::Flags< Enumeration >::value().

◆ clear()

template<typename Enumeration >
void C16::Flags< Enumeration >::clear ( )
inline

Empties the flags.

◆ set() [1/2]

template<typename Enumeration >
void C16::Flags< Enumeration >::set ( Enumeration  enumerator,
bool  set 
)
inline

Sets a single enumerator of the flags.

Parameters
enumeratorEnumerator
setAdd or remove
trueAdds the enumerator to the flags.
falseRemoves the enumerator from the flags.

References C16::Flags< Enumeration >::add(), and C16::Flags< Enumeration >::remove().

Referenced by C16::Flags< Enumeration >::set().

◆ set() [2/2]

template<typename Enumeration >
void C16::Flags< Enumeration >::set ( const std::initializer_list< Enumeration > &  enumerators,
bool  set 
)
inline

Sets multiple enumerators of the flags.

Parameters
enumeratorsEnumerators
setAdd or remove
trueAdds the enumerators to the flags.
falseRemoves the enumerators from the flags.

References C16::Flags< Enumeration >::add(), C16::Flags< Enumeration >::remove(), and C16::Flags< Enumeration >::set().

◆ toggle() [1/2]

template<typename Enumeration >
void C16::Flags< Enumeration >::toggle ( Enumeration  enumerator)
inline

Toggles a single enumerator of the flags.

Parameters
enumeratorEnumerator

References C16::Flags< Enumeration >::value().

◆ toggle() [2/2]

template<typename Enumeration >
void C16::Flags< Enumeration >::toggle ( const std::initializer_list< Enumeration > &  enumerators)
inline

Toggles multiple enumerators of the flags.

Parameters
enumeratorsEnumerators

References C16::Flags< Enumeration >::value().