Public Member Functions | Private Attributes | Friends | List of all members
ecl::Flags< Enum > Class Template Reference

Convenience class for organising boolean flags. More...

#include <flags.hpp>

Public Member Functions

 Flags ()
 
 Flags (const Flags< Enum > &other)
 
 Flags (Enum flag)
 
 operator int () const
 
Flags< Enum > operator& (Enum flag) const
 
Flags< Enum > operator& (int mask) const
 
Flags< Enum > & operator&= (int mask)
 
Flags< Enum > & operator= (const Enum &flag)
 
Flags< Enum > & operator= (const Flags< Enum > &other)
 
Flags< Enum > operator^ (Enum flag) const
 
Flags< Enum > operator^ (Flags< Enum > other) const
 
Flags< Enum > & operator^= (Enum flag)
 
Flags< Enum > & operator^= (Flags< Enum > other)
 
Flags< Enum > operator| (Enum flag) const
 
Flags< Enum > operator| (Flags< Enum > other) const
 
Flags< Enum > & operator|= (Enum flag)
 
Flags< Enum > & operator|= (Flags< Enum > other)
 
Flags< Enum > operator~ () const
 
bool testFlag (Enum flag) const
 
 ~Flags ()
 

Private Attributes

int value
 

Friends

Flags< Enum > operator| (Enum flag, Flags< Enum > flags)
 

Detailed Description

template<typename Enum>
class ecl::Flags< Enum >

Convenience class for organising boolean flags.

This class organises a group of flags (via enums) in a convenient and typesafe manner. It is essentially a container for flags (in the form of enums) with a convenient interface on top.

Usage:

enum Settings {
Fast 0x0001,
Medium 0x0002,
Slow 0x0004,
Red 0x0010,
Blue 0x0020
}
settings = settings|Fast|Slow;

Definition at line 71 of file flags.hpp.

Constructor & Destructor Documentation

◆ Flags() [1/3]

template<typename Enum >
ecl::Flags< Enum >::Flags ( )
inline

Definition at line 77 of file flags.hpp.

◆ Flags() [2/3]

template<typename Enum >
ecl::Flags< Enum >::Flags ( const Flags< Enum > &  other)
inline

Default constructor.

Definition at line 78 of file flags.hpp.

◆ Flags() [3/3]

template<typename Enum >
ecl::Flags< Enum >::Flags ( Enum  flag)
inline

Copy constructor.

Definition at line 79 of file flags.hpp.

◆ ~Flags()

template<typename Enum >
ecl::Flags< Enum >::~Flags ( )
inline

Raw constructor.

Definition at line 80 of file flags.hpp.

Member Function Documentation

◆ operator int()

template<typename Enum >
ecl::Flags< Enum >::operator int ( ) const
inline

Definition at line 110 of file flags.hpp.

◆ operator&() [1/2]

template<typename Enum >
Flags<Enum> ecl::Flags< Enum >::operator& ( Enum  flag) const
inline

Single flag masking operator.

Returns
Flags<Enum> : new instance of the flag set.

Definition at line 134 of file flags.hpp.

◆ operator&() [2/2]

template<typename Enum >
Flags<Enum> ecl::Flags< Enum >::operator& ( int  mask) const
inline

Type compatibility with ints. Mask operator.

Returns
Flags<Enum> : new instance of the flag set.

Definition at line 123 of file flags.hpp.

◆ operator&=()

template<typename Enum >
Flags<Enum>& ecl::Flags< Enum >::operator&= ( int  mask)
inline

Self operating mask.

Returns
Flags<Enum> : updated instance of the masked flag set.

Definition at line 224 of file flags.hpp.

◆ operator=() [1/2]

template<typename Enum >
Flags<Enum>& ecl::Flags< Enum >::operator= ( const Enum &  flag)
inline

Assignment operator.

Returns
Flags<Enum> : updated instance of the flag set.

Definition at line 214 of file flags.hpp.

◆ operator=() [2/2]

template<typename Enum >
Flags<Enum>& ecl::Flags< Enum >::operator= ( const Flags< Enum > &  other)
inline

Assignment operator.

Returns
Flags<Enum> : updated instance of the flag set.

Definition at line 204 of file flags.hpp.

◆ operator^() [1/2]

template<typename Enum >
Flags<Enum> ecl::Flags< Enum >::operator^ ( Enum  flag) const
inline

Single flag XOR operator.

Returns
Flags<Enum> : new instance of the flag set.

Definition at line 178 of file flags.hpp.

◆ operator^() [2/2]

template<typename Enum >
Flags<Enum> ecl::Flags< Enum >::operator^ ( Flags< Enum >  other) const
inline

XOR operator.

Returns
Flags<Enum> : new instance of the flag set.

Definition at line 167 of file flags.hpp.

◆ operator^=() [1/2]

template<typename Enum >
Flags<Enum>& ecl::Flags< Enum >::operator^= ( Enum  flag)
inline

Self operating XOR operation with a single flag.

Returns
Flags<Enum> : updated instance of the masked flag set.

Definition at line 264 of file flags.hpp.

◆ operator^=() [2/2]

template<typename Enum >
Flags<Enum>& ecl::Flags< Enum >::operator^= ( Flags< Enum >  other)
inline

Self operating XOR operation.

Returns
Flags<Enum> : updated instance of the masked flag set.

Definition at line 254 of file flags.hpp.

◆ operator|() [1/2]

template<typename Enum >
Flags<Enum> ecl::Flags< Enum >::operator| ( Enum  flag) const
inline

Single flag OR operator.

Returns
Flags<Enum> : new instance of the flag set.

Definition at line 156 of file flags.hpp.

◆ operator|() [2/2]

template<typename Enum >
Flags<Enum> ecl::Flags< Enum >::operator| ( Flags< Enum >  other) const
inline

OR operator.

Returns
Flags<Enum> : new instance of the flag set.

Definition at line 145 of file flags.hpp.

◆ operator|=() [1/2]

template<typename Enum >
Flags<Enum>& ecl::Flags< Enum >::operator|= ( Enum  flag)
inline

Self operating OR operation with a single flag.

Returns
Flags<Enum> : updated instance of the masked flag set.

Definition at line 244 of file flags.hpp.

◆ operator|=() [2/2]

template<typename Enum >
Flags<Enum>& ecl::Flags< Enum >::operator|= ( Flags< Enum >  other)
inline

Self operating OR operation.

Returns
Flags<Enum> : updated instance of the masked flag set.

Definition at line 234 of file flags.hpp.

◆ operator~()

template<typename Enum >
Flags<Enum> ecl::Flags< Enum >::operator~ ( ) const
inline

Complement operator.

Returns
Flags<Enum> : new instance of the flag set.

Definition at line 189 of file flags.hpp.

◆ testFlag()

template<typename Enum >
bool ecl::Flags< Enum >::testFlag ( Enum  flag) const
inline

Test current status of a flag.

Definition at line 90 of file flags.hpp.

Friends And Related Function Documentation

◆ operator|

template<typename Enum >
Flags<Enum> operator| ( Enum  flag,
Flags< Enum >  flags 
)
friend

Adding a flag (OR operation) to an existing flag set.

Returns
Flags<Enum> : resulting instance of the flag combination.

Definition at line 278 of file flags.hpp.

Member Data Documentation

◆ value

template<typename Enum >
int ecl::Flags< Enum >::value
private

Definition at line 283 of file flags.hpp.


The documentation for this class was generated from the following file:


ecl_utilities
Author(s): Daniel Stonier
autogenerated on Wed Mar 2 2022 00:16:32