26 #include <unordered_map> 28 #include "Poco/RWLock.h" 31 #include "kv_store_interface.h" 33 #ifndef AOSSL_CORE_INCLUDE_KV_STORE_H_ 34 #define AOSSL_CORE_INCLUDE_KV_STORE_H_ 43 std::unordered_map<std::string, std::string> opts;
44 Poco::RWLock rw_mutex;
50 Poco::ScopedReadRWLock lock(rw_mutex);
51 auto search = opts.find(key);
52 if (search != opts.end()) {
68 Poco::ScopedReadRWLock lock(rw_mutex);
69 val.
val.assign(opts[key]);
73 inline std::unordered_map<std::string, std::string> get_opts() {
74 Poco::ScopedReadRWLock lock(rw_mutex);
79 void add_opt(
const std::string& key, std::string value) \
80 {opts.emplace(key, value);}
83 inline void set_opt(std::string& key, std::string& value) {
84 Poco::ScopedWriteRWLock lock(rw_mutex);
91 #endif // AOSSL_CORE_INCLUDE_KV_STORE_H_ A Structure for holding a single value.
Definition: buffers.h:42
void add_opt(const std::string &key, std::string value)
Add an option.
Definition: kv_store.h:79
std::string val
Value stored.
Definition: buffers.h:44
Key Value Store.
Definition: kv_store.h:42
void get_opt(std::string key, StringBuffer &val)
Get an option by key.
Definition: kv_store.h:67
void set_opt(std::string &key, std::string &value)
Set an option.
Definition: kv_store.h:83
StringBuffer * get_opt(std::string key)
Get an option by key.
Definition: kv_store.h:60
Key Value Store.
Definition: kv_store_interface.h:38
bool success
Success flag.
Definition: buffers.h:35
bool opt_exist(std::string key)
Does a key exist?
Definition: kv_store.h:49