zynq_7010/Properties.cpp

53 lines
1.4 KiB
C++
Raw Normal View History

2023-07-17 03:29:37 +00:00
#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)
2023-09-19 02:40:47 +00:00
printf("Get Config File Size (path: /usr/local/huago/ <20><>properties<65><73> ) = %d \r\n",properties.size());
2023-07-17 03:29:37 +00:00
if (properties.find(key) == properties.end()) {
return defaultValue;
}
return properties.at(key);
}
std::vector<std::string> Properties::GetPropertyNames() const {
return keys;
}
2023-09-19 02:40:47 +00:00
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4>map
2023-07-17 03:29:37 +00:00
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 */