30 lines
650 B
C++
30 lines
650 B
C++
|
|
#include "datamanager.hpp"
|
||
|
|
|
||
|
|
std::shared_ptr<std::any> DataManager::load(const std::string& key) const {
|
||
|
|
auto it = data_.find(key);
|
||
|
|
if (it == data_.end()) {
|
||
|
|
return nullptr;
|
||
|
|
}
|
||
|
|
return std::make_shared<std::any>(it->second);
|
||
|
|
}
|
||
|
|
|
||
|
|
void DataManager::store(const std::string& key, const std::any& value) {
|
||
|
|
data_[key] = value;
|
||
|
|
}
|
||
|
|
|
||
|
|
bool DataManager::exists(const std::string& key) const {
|
||
|
|
return data_.find(key) != data_.end();
|
||
|
|
}
|
||
|
|
|
||
|
|
bool DataManager::remove(const std::string& key) {
|
||
|
|
return data_.erase(key) > 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
size_t DataManager::size() const {
|
||
|
|
return data_.size();
|
||
|
|
}
|
||
|
|
|
||
|
|
void DataManager::clear() {
|
||
|
|
data_.clear();
|
||
|
|
}
|