Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
Flagger Class Reference

A bit vector with external Dictionary mapping from strings to bits and vice versa. More...

#include <FlagsOld.h>

Inheritance diagram for Flagger:
Inheritance graph
[legend]
Collaboration diagram for Flagger:
Collaboration graph
[legend]

Public Member Functions

 Flagger (const dict_t &dict, char separator=0)
 
 Flagger (ivalue_t &value, const dict_t &dict, char separator=0)
 
 Flagger (const Flagger &flags)
 
template<typename T , typename ... TT>
Flaggerset (const T &arg, const TT &... args)
 Set desired flags. Does not reset any flag (zero value has no effect). More...
 
Flaggerunset (ivalue_t x)
 Unset desired flags. Does not set any flag.
 
Flaggerunset (const key_t &key)
 Unset desired flags. Does not set any flag.
 
Flaggerreset ()
 Reset all the flags.
 
bool isSet (ivalue_t x) const
 Checks if a given bit, or any of given bits, is set.
 
bool isSet (const key_t &key) const
 
Flaggeroperator= (const Flagger &x)
 
template<class T >
Flaggeroperator= (const T &x)
 Sets value, ie. set or unsets all the flags. More...
 
void assign (ivalue_t x)
 Sets value, ie. set or unsets all the flags. More...
 
void assign (const Flagger &flags)
 Copies flags as an integer value. Same dictionary not checked. More...
 
void assign (const std::string &params)
 Set flags, like 'FILEOK=1,WARN=0'. More...
 
 operator ivalue_t () const
 
 operator bool () const
 
 operator std::string () const
 
ivalue_t getValue (const std::string &key, char separator=0) const
 Computes bitwise OR function on the numeric or alphabetic value(s) presented by a string. More...
 
std::string getKeys (ivalue_t value, char separator=0) const
 Given an integer, retrieves dictionary keys corresponding to each index of set bits.
 
std::string getKeys (char separator=0) const
 Given an integer, retrieves dictionary keys corresponding to each index of set bits.
 
const dict_t::keylist_t & keys () const
 
std::ostream & keysToStream (std::ostream &ostr=std::cout, char separator=0) const
 Display current value as key values of which the value is composed with OR function. More...
 
template<class T >
void exportStatus (std::map< std::string, T > &statusMap) const
 
- Public Member Functions inherited from FlagResolver
template<typename T >
FlagResolver::ivalue_t addEntry (drain::Dictionary< key_t, T > &dict, const typename dict_t::key_t &key, ivalue_t i)
 

Public Attributes

ivalue_t ownValue
 
ivalue_t & value
 
const dict_tdictionary
 
char separator
 

Static Public Attributes

static const drain::SprinterLayout flagDictLayout
 
- Static Public Attributes inherited from FlagResolver
static const ivalue_t ALL = ~FlagResolver::ivalue_t(0)
 

Protected Member Functions

Flaggerset ()
 
FlaggerdeepSet (ivalue_t x)
 
FlaggerdeepSet (const key_t &key)
 Set desired flags. Does not reset any flag. More...
 

Protected Attributes

dict_t::keylist_t keyList
 

Additional Inherited Members

- Public Types inherited from FlagResolver
typedef std::string key_t
 
typedef unsigned long int ivalue_t
 
typedef drain::Dictionary< key_t, ivalue_t > dict_t
 "Recommended" dictionary type. All the methods are templates, however.
 
- Static Public Member Functions inherited from FlagResolver
template<typename T >
static ivalue_t getValue (const drain::Dictionary< key_t, T > &dict, const std::string &key, char separator=',')
 Computes bitwise OR function on the numeric or alphabetic value(s) presented by a string. More...
 
template<typename T >
static std::string getKeys (const drain::Dictionary< key_t, T > &dict, ivalue_t, char separator=',')
 Given an integer, retrieves dictionary keys corresponding to each index of set bits. More...
 
template<typename T >
static std::ostream & keysToStream (const drain::Dictionary< key_t, T > &dict, ivalue_t value, std::ostream &ostr, char separator=',')
 Write keys in a stream, in numeric order. More...
 
template<typename T , typename V >
static void valuesToList (ivalue_t value, const drain::Dictionary< key_t, T > &dict, std::list< V > &container)
 Given a bit vector (integer value), extracts separate flag values to a list. More...
 
template<typename T >
static ivalue_t addEntry (drain::Dictionary< key_t, T > &dict, const key_t &key, ivalue_t i=0)
 Add a new entry in the dictionary. More...
 
template<typename T >
static ivalue_t getFreeBit (const drain::Dictionary< key_t, T > &dict)
 Return an interger (bit vector) with a new, previously unused value. More...
 

Detailed Description

A bit vector with external Dictionary mapping from strings to bits and vice versa.

Member Function Documentation

◆ assign() [1/3]

void assign ( const Flagger flags)
inline

Copies flags as an integer value. Same dictionary not checked.

See also
set().
Parameters
flags-

◆ assign() [2/3]

void assign ( const std::string &  params)

Set flags, like 'FILEOK=1,WARN=0'.

Set flags.

Parameters
x- comma separated keys or bit values 1, 2, 4, 8

◆ assign() [3/3]

void assign ( ivalue_t  x)
inline

Sets value, ie. set or unsets all the flags.

See also
set().
Parameters
x- bit values 1, 2, 4, 8 ... etc combined with OR function.

◆ deepSet()

Flagger& deepSet ( const key_t &  key)
inlineprotected

Set desired flags. Does not reset any flag.

See also
assign().

◆ getValue()

ivalue_t getValue ( const std::string &  key,
char  separator = 0 
) const
inline

Computes bitwise OR function on the numeric or alphabetic value(s) presented by a string.

Parameters
key- String containing keys ("note,error") or values ("4,8,32") or a mixture of them.
lenient- If true, bypassed unknown keys silently, otherwise throws exception

◆ keysToStream()

std::ostream& keysToStream ( std::ostream &  ostr = std::cout,
char  separator = 0 
) const
inline

Display current value as key values of which the value is composed with OR function.

Parameters
ostr
separator- character appended between keys, if not own separator risky: ivalue_t ~char !

◆ operator=()

Flagger& operator= ( const T &  x)
inline

Sets value, ie. set or unsets all the flags.

Parameters
x- bit values 1, 2, 4, 8 ... etc combined with OR function.

◆ set()

Flagger& set ( const T &  arg,
const TT &...  args 
)
inline

Set desired flags. Does not reset any flag (zero value has no effect).

See also
assign().

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