zynq_7010/Properties.cpp

54 lines
1.4 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <algorithm>
#include "Properties.h"
namespace cppproperties {
Properties::Properties() {
}
Properties::~Properties() {
}
std::string Properties::GetProperty(const std::string& key) const {
if (properties.find(key) == properties.end()) {
throw PropertyNotFoundException(key + " does not exist");
}
return properties.at(key);
}
//前面把配置文件参数读取 分成key和val放入map从map取出val
std::string Properties::GetProperty(const std::string& key, const std::string& defaultValue) const {
if (key.compare("fpga.correctColor.BOffset") == 0)
printf("Get Config File Size (path: /usr/local/huago/ “properties” ) = %d \r\n",properties.size());
if (properties.find(key) == properties.end()) {
return defaultValue;
}
return properties.at(key);
}
std::vector<std::string> Properties::GetPropertyNames() const {
return keys;
}
//把配置文件参数写入map
void Properties::AddProperty(const std::string& key, const std::string& value) {
if (properties.find(key) == properties.end()) {
keys.push_back(key);
}
properties[key] = value;
}
void Properties::RemoveProperty(const std::string& key) {
if (properties.find(key) == properties.end()) {
throw PropertyNotFoundException(key + " does not exist");
}
keys.erase(std::remove(keys.begin(), keys.end(), key), keys.end());
properties.erase(key);
}
} /* namespace cppproperties */