44 struct ParamList :
public std::map<std::string, Any>{
47 typedef std::string
Key;
58 inline ParamList(
const std::string &commaSepKeyValueString) {
59 init(commaSepKeyValueString);
63 inline ParamList(
const char *commaSepKeyValueString) {
64 init(commaSepKeyValueString);
67 inline void init(
const std::string commaSepKeyValueString) {
68 std::vector<std::string> ts =
tok(commaSepKeyValueString,
",",
true,
'\\');
69 for(
size_t i=0;i<ts.size();++i){
70 std::vector<std::string> kv =
tok(ts[i],
"=",
true,
'\\');
73 const_cast<ParamList*>(
this)->operator[](kv[0]) = kv[1];
81 const Key &key1=
"",
const Value &value1=
"",
82 const Key &key2=
"",
const Value &value2=
"",
83 const Key &key3=
"",
const Value &value3=
"",
84 const Key &key4=
"",
const Value &value4=
"",
85 const Key &key5=
"",
const Value &value5=
"",
86 const Key &key6=
"",
const Value &value6=
"",
87 const Key &key7=
"",
const Value &value7=
"",
88 const Key &key8=
"",
const Value &value8=
"",
89 const Key &key9=
"",
const Value &value9=
"" ){
90 if(key0.length())
operator[](key0) = value0;
91 if(key1.length())
operator[](key1) = value1;
92 if(key2.length())
operator[](key2) = value2;
93 if(key3.length())
operator[](key3) = value3;
94 if(key4.length())
operator[](key4) = value4;
95 if(key5.length())
operator[](key5) = value5;
96 if(key6.length())
operator[](key6) = value6;
97 if(key7.length())
operator[](key7) = value7;
98 if(key8.length())
operator[](key8) = value8;
99 if(key9.length())
operator[](key9) = value9;
104 inline bool hasKey(
const Key &key)
const {
return find(key) != end(); }
109 iterator it = find(key);
110 if(it != end()) erase(it);
115 const_iterator it = find(key);
116 if(it == end())
throw ICLException(
"error in ParamList::operator[](key) with key=" + key +
": key not found!");
121 using std::map<std::string,Any>::operator[];
void removeKey(const Key &key)
removes the given key from the map
Definition: ParamList.h:108
Any Value
The Value type (icl::Any)
Definition: ParamList.h:50
undocument this line if you encounter any issues!
Definition: Any.h:37
ParamList()
creates an empty param list instance
Definition: ParamList.h:53
bool hasKey(const Key &key) const
returns whether the map contains the given key
Definition: ParamList.h:104
Utility structure that utilizes an std::map as parameter list.
Definition: ParamList.h:44
void init(const std::string commaSepKeyValueString)
Definition: ParamList.h:67
const Any & operator[](const Key &key) const
extension for the unconst operator that is provided by the std::map class
Definition: ParamList.h:114
ParamList(const std::string &commaSepKeyValueString)
creates a param list from a single given string
Definition: ParamList.h:58
Base class for Exception handling in the ICL.
Definition: Exception.h:42
ParamList(const Key &key0, const Value &value0, const Key &key1="", const Value &value1="", const Key &key2="", const Value &value2="", const Key &key3="", const Value &value3="", const Key &key4="", const Value &value4="", const Key &key5="", const Value &value5="", const Key &key6="", const Value &value6="", const Key &key7="", const Value &value7="", const Key &key8="", const Value &value8="", const Key &key9="", const Value &value9="")
Constructor, that can get up to 10 key-value pairs.
Definition: ParamList.h:80
std::string Key
The Key type (std::string)
Definition: ParamList.h:47
ParamList(const char *commaSepKeyValueString)
this allows for implicit creation of a ParamList instance from a given const char *
Definition: ParamList.h:63
Simple generic data type implementation that uses a string based data representation.
Definition: Any.h:109
ICLUtils_API std::vector< std::string > tok(const std::string &s, const std::string &delims=" ", bool singleCharDelims=true, char escapeChar='\0')
tokenizes a string with given delimiters (internally using a temporary StrTok instance)
#define ICLASSERT_THROW(X, OBJ)
Definition: Macros.h:155