5#include "warpxm/warpxm_config.h"
36 typedef std::map<std::string, WxAny, std::less<std::string>>
AnyMap_t;
63 template<
typename VALUETYPE>
bool add(
const std::string& name,
const VALUETYPE& value)
65 return _values.insert(
AnyPair_t(name, value)).second;
73 bool has(
const std::string& name)
const;
80 template<
typename VALUETYPE> VALUETYPE
get(
const std::string& name)
const
82 AnyMap_t::const_iterator i = _values.find(name);
83 if (i != _values.end())
84 return ((*i).second).to_value<VALUETYPE>();
87 wxe <<
"Value " << name <<
" not found";
97 template<
typename VALUETYPE>
98 VALUETYPE
getWithDefault(
const std::string& name,
const VALUETYPE defaultValue)
const
102 return get<VALUETYPE>(name);
116 AnyMap_t::const_iterator i = _values.find(name);
117 if (i != _values.end())
118 return ((*i).second);
121 wxe <<
"Value " << name <<
" not found";
130 return const_cast<WxAny&
>(
const_cast<const WxCrypt&
>(*this).
get(name));
137 void set(
const std::string& name,
const WxAny& val)
148 _values[name] = std::move(val);
151 template<
class T>
void set(
const std::string& name, T val)
153 _values[name] = std::move(val);
161 template<
typename VALUETYPE>
162 std::vector<VALUETYPE>
getVec(
const std::string& name)
const
164 return get(name).to_value<std::vector<VALUETYPE>>();
Class WxAny is based on the "any" class described in "Valued Conversion", Kevlin Henney,...
Definition: wxany.h:139
WxCrypt provides a container to store/retrive name-value pairs.
Definition: wxcrypt.h:33
const WxAny & get(const std::string &name) const
Gets the raw WxAny value associated with name.
Definition: wxcrypt.h:114
std::pair< std::string, WxAny > AnyPair_t
Definition: wxcrypt.h:37
void set(const std::string &name, const WxAny &val)
Ensures a value with name is this wxcrypt, either by adding it or changing the existing map.
Definition: wxcrypt.h:137
bool has(const std::string &name) const
Returns true if the 'name' exists in the crypt.
VALUETYPE getWithDefault(const std::string &name, const VALUETYPE defaultValue) const
Retrieve the value associated with name, or the given default value if no such key is in the cryptset...
Definition: wxcrypt.h:98
int crypt_signed_int_t
Definition: wxcrypt.h:41
WxAny & get(const std::string &name)
Gets the raw WxAny value associated with name.
Definition: wxcrypt.h:128
WxCrypt(const WxCrypt &crypt)
Copy ctor: make a deep copy of 'crypt'.
bool add(const std::string &name, const VALUETYPE &value)
Insert a name, value pair.
Definition: wxcrypt.h:63
void set(const std::string &name, T val)
Definition: wxcrypt.h:151
std::vector< VALUETYPE > getVec(const std::string &name) const
Retrieve list of values associated with name.
Definition: wxcrypt.h:162
WxCrypt & operator=(const WxCrypt &rhs)
Assignment operator: LHS is a deep copy of 'rhs'.
std::map< std::string, WxAny, std::less< std::string > > AnyMap_t
Definition: wxcrypt.h:36
VALUETYPE get(const std::string &name) const
Retrieve the value associated with name.
Definition: wxcrypt.h:80
void set(const std::string &name, WxAny &&val)
Ensures a value with name is this wxcrypt, either by adding it or changing the existing map.
Definition: wxcrypt.h:146
wxm::lib::Except is the class to use for creating and throwing exceptions.
Definition: wxexcept.h:31