zynq_7010/zynq_7010_code/Properties.cpp

53 lines
1.4 KiB
C++
Raw Blame History

#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);
}
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/ <20><>properties<65><73> ) = %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;
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4>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 */