Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
MultiFlagger< E, T > Class Template Reference

#include <Flags.h>

Inheritance diagram for MultiFlagger< E, T >:
Inheritance graph
[legend]
Collaboration diagram for MultiFlagger< E, T >:
Collaboration graph
[legend]

Public Types

typedef E value_t
 
typedef T storage_t
 
typedef FlaggerBase< E, T > flagger_t
 
typedef flagger_t::dict_t dict_t
 
typedef dict_t::key_t key_t
 
- Public Types inherited from FlaggerBase< E, size_t >
typedef E value_t
 
typedef size_t storage_t
 
typedef Dictionary< std::string, E > dict_t
 
typedef dict_t::key_t key_t
 

Public Member Functions

 MultiFlagger (const dict_t &dict)
 
template<typename ... V>
 MultiFlagger (const dict_t &dict, const V &... args)
 
 MultiFlagger (const dict_t &dict, storage_t &target, char sep=',')
 
virtual const dict_tgetDict () const override
 Returns the static dictionary created for this value_t . More...
 
virtual bool isSet (const storage_t &x) const override
 Return true, all the bits of argument x are set.
 
void unset (const storage_t &x)
 Unset some bit(s).
 
template<typename ... V>
void set (const V &... args)
 Set bits, accepting numeric values or keys. More...
 
template<typename V , typename ... VV>
void add (const V &arg, const VV &... args)
 Add bit values.
 
virtual const key_t & str () const override
 For exporting values.
 
virtual std::string & str ()
 For importing values. After assignment, update() should be called. Experimental.
 
- Public Member Functions inherited from FlaggerBase< E, size_t >
 FlaggerBase (char separator=',')
 
 FlaggerBase (storage_t &v, char separator=',')
 Value-referencing constructor. More...
 
virtual void reset ()
 
virtual void set (const key_t &key)
 Sets one or several flags.
 
virtual void set (const value_t &value)
 Set a single flag.
 
virtual void set (const FlaggerBase< E > &flagger)
 
virtual bool isSet (const storage_t &x) const=0
 Checks if a given bit, or any of given bits, is set. More...
 
bool isSet (const key_t &key) const
 
const storage_t & getValue () const
 
 operator const storage_t & () const
 Given an integer, retrieves dictionary keys corresponding to each index of set bits.
 
 operator storage_t & ()
 
 operator bool () const
 
 operator const key_t & () const
 
void debug (std::ostream &ostr) const
 

Protected Member Functions

virtual void assign (const std::string &s) override
 Split a string to separate keys and/or values and set them.
 
void add ()
 
void addOne (const key_t &key)
 
template<typename T2 >
void addOne (const T2 &value)
 

Protected Attributes

const dict_tdict
 Given only a numeric/enum value,. More...
 
std::string currentStr
 

Additional Inherited Members

- Public Attributes inherited from FlaggerBase< E, size_t >
storage_t & value
 
char separator
 

Detailed Description

template<typename E, typename T = size_t>
class drain::MultiFlagger< E, T >

Note that if enum definition contains overlapping (combined) values, SingleFlagger may be sufficient. If arbitrary bit combinations should be supported, MultiFlagger must be used. Example {USER=1, GROUP=2, OTHER=4, ALL=USER|GROUP|OTHER}.

Abstract class, because getDict() returning Dictionary<std::string,E> still undefined.

Constructor & Destructor Documentation

◆ MultiFlagger()

MultiFlagger ( const dict_t dict,
storage_t &  target,
char  sep = ',' 
)
inline
Parameters
v- linked variable

Member Function Documentation

◆ getDict()

virtual const dict_t& getDict ( ) const
inlineoverridevirtual

Returns the static dictionary created for this value_t .

Notice that this function is non-static but returns a reference to a static dictionary. In C++ virtual functions must be non-static. This is nevertheless handy in templated design, for example.

Implements FlaggerBase< E, size_t >.

◆ set()

void set ( const V &...  args)
inline

Set bits, accepting numeric values or keys.

Starts with resetting the flags.

Template Parameters
T– numeric values or strings

Member Data Documentation

◆ dict

const dict_t& dict
protected

Given only a numeric/enum value,.

This should be called after assigning a string to & str() .


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