56 lines
1.2 KiB
C++
Executable File
56 lines
1.2 KiB
C++
Executable File
|
|
#pragma once
|
|
|
|
#include <wfr/common/types/WfsTypes.h>
|
|
#include <wfr/common/exceptions/exceptions.h>
|
|
#include <wfr/common/resource/ResourceCapabilities.h>
|
|
#include <boost/format.hpp>
|
|
#include <initializer_list>
|
|
#include <atomic>
|
|
#include <string>
|
|
#include <map>
|
|
|
|
|
|
namespace wfr {
|
|
namespace utils {
|
|
|
|
typedef std::initializer_list<std::pair<std::string, std::string>> PropertyList;
|
|
|
|
|
|
class Properties {
|
|
private:
|
|
std::map<std::string, std::string> properties;
|
|
|
|
public:
|
|
Properties() {}
|
|
Properties(PropertyList props) {
|
|
for (auto i : props) {
|
|
properties.insert(i);
|
|
}
|
|
}
|
|
|
|
bool hasProperty(const std::string& key) const noexcept {
|
|
return properties.find(key) != properties.end();
|
|
}
|
|
|
|
const std::string& getProperty(const std::string& key) const {
|
|
auto i = properties.find(key);
|
|
if (i != properties.end()) {
|
|
return i->second;
|
|
} else {
|
|
throw exception::wfr_not_found((boost::format("Property \"%1%\" not found.") % key).str());
|
|
}
|
|
}
|
|
|
|
const std::map<std::string, std::string>& getProperties() const {
|
|
return properties;
|
|
}
|
|
|
|
void addProperty(const std::string& key, const std::string& value) noexcept {
|
|
properties[key] = value;
|
|
}
|
|
};
|
|
|
|
} /* namespace utils */
|
|
} /* namespace wfr */
|