45 #include <drain/Log.h>
46 #include <drain/String.h>
47 #include <drain/Type.h>
49 #include "Dictionary.h"
81 typedef typename dict_t::key_t key_t;
105 SingleFlagger(
const dict_t & dict,
const storage_t &v) : dict(dict) {
115 SingleFlagger(
const dict_t & dict, storage_t & v,
char sep=
',') : flagger_t(v, sep), dict(dict){
125 bool isSet(
const storage_t & x)
const override {
126 return (this->value == x);
138 const key_t &
str()
const override {
151 void assign(
const std::string & key)
override {
155 if ((key.find(
',')!= std::string::npos)||(key.find(
'|')!= std::string::npos)){
156 Logger mout(__FILE__, __FUNCTION__);
160 if (this->
getDict().hasKey(key)){
164 Logger mout(__FILE__, __FUNCTION__);
165 value_t v =
static_cast<value_t
>(atoi(key.c_str()));
167 mout.
suspicious(
"value: ", v,
" corresponds to no value in dict:", this->
getDict());
182 template <
typename E>
185 ostr << flagger.
str();
198 template <
typename E,
typename T=
size_t>
208 typedef typename dict_t::key_t key_t;
231 template <
typename ... V>
258 bool isSet(
const storage_t & x)
const override {
259 return ((this->value & x) == x);
264 this->value = (this->value & ~x);
275 template <
typename ... V>
277 void set(
const V &... args) {
284 template <
typename V,
typename ...VV>
286 void add(
const V & arg,
const VV &... args) {
294 const key_t &
str()
const override {
330 void assign(
const std::string & s)
override {
350 void addOne(
const key_t & key){
375 template <
typename T2>
377 void addOne(
const T2 & value){
380 this->value |=
static_cast<value_t
>(value);
385 std::string currentStr;
393 template <
typename E,
typename T>
457 typedef typename F::value_t value_t;
458 typedef typename F::dict_t dict_t;
462 const dict_t & getDict()
const {
488 Flags2(
const std::initializer_list<typename dict_t::entry_t> & list) : dict(list){
497 Flags2<F> & operator=(
const T & v){
Two-way mapping between strings and objects of template class T.
Definition: Dictionary.h:63
const K & getKey(const V &value, bool lenient=true) const
Identity mapping useful for type deduction of template arguments in functions.
Definition: Dictionary.h:172
bool hasValue(const V &value) const
Given a key, return the first value associated with it.
Definition: Dictionary.h:143
const V & getValue(const K &key, bool lenient=true) const
Given a key, return the first value associated with it.
Definition: Dictionary.h:149
static ivalue_t getIntValue(const drain::Dictionary< key_t, T > &dict, const std::string &keys, char separator=',')
Computes bitwise OR function on the numeric or alphabetic value(s) presented by a string.
Definition: FlagBase.h:199
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.
Definition: FlagBase.h:278
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.
Definition: FlagBase.h:266
Definition: FlagBase.h:361
virtual void set(const key_t &key)
Sets one or several flags.
Definition: FlagBase.h:423
Flagger with referenced/external dictionary accepting values of (integer) type T.
Definition: Flags.h:452
Flags2()
Definition: Flags.h:478
Flags2(const std::initializer_list< typename dict_t::entry_t > &list)
Constructor for relatively short dictionaries.
Definition: Flags.h:488
LogSourc e is the means for a function or any program segment to "connect" to a Log.
Definition: Log.h:310
Logger & error(const TT &... args)
Echoes.
Definition: Log.h:414
Logger & unimplemented(const TT &... args)
Feature to be done. Special type of Logger::note().
Definition: Log.h:509
Logger & suspicious(const TT &... args)
A weak warning about something going possibly wrong.
Definition: Log.h:498
void unset(const storage_t &x)
Unset some bit(s).
Definition: Flags.h:263
MultiFlagger(const dict_t &dict, storage_t &target, char sep=',')
Definition: Flags.h:241
void add(const V &arg, const VV &... args)
Add bit values.
Definition: Flags.h:286
virtual void assign(const std::string &s) override
Split a string to separate keys and/or values and set them.
Definition: Flags.h:330
virtual bool isSet(const storage_t &x) const override
Return true, all the bits of argument x are set.
Definition: Flags.h:258
const dict_t & dict
Given only a numeric/enum value,.
Definition: Flags.h:325
void set(const V &... args)
Set bits, accepting numeric values or keys.
Definition: Flags.h:277
virtual const key_t & str() const override
For exporting values.
Definition: Flags.h:294
virtual std::string & str()
For importing values. After assignment, update() should be called. Experimental.
Definition: Flags.h:303
virtual const dict_t & getDict() const override
Returns the static dictionary created for this value_t .
Definition: Flags.h:252
virtual bool isSet(const storage_t &x) const override
Return true, if value is exactly x .
Definition: Flags.h:125
virtual const key_t & str() const override
String corresponding the current value. Returns empty, if not found.
Definition: Flags.h:138
virtual void assign(const std::string &key) override
Assign key. Expects a single key, not a combination of keys.
Definition: Flags.h:151
virtual const dict_t & getDict() const override
Returns the static dictionary created for this value_t .
Definition: Flags.h:91
Definition: DataSelector.cpp:1277