remove deprecated Properties
This commit is contained in:
@@ -26,121 +26,6 @@ namespace pvAccess {
|
||||
using namespace epics::pvData;
|
||||
using namespace std;
|
||||
|
||||
Properties::Properties() {}
|
||||
|
||||
Properties::Properties(const string &fileName) : _fileName(fileName) {}
|
||||
|
||||
const std::string &Properties::getProperty(const string &key) const
|
||||
{
|
||||
_properties_t::const_iterator propertiesIterator = _properties.find(key);
|
||||
if(propertiesIterator != _properties.end()) {
|
||||
return propertiesIterator->second;
|
||||
} else {
|
||||
THROW_BASE_EXCEPTION(string("Property not found in the map: ") + key);
|
||||
}
|
||||
}
|
||||
|
||||
const std::string &Properties::getProperty(const string &key, const string &defaultValue) const
|
||||
{
|
||||
_properties_t::const_iterator propertiesIterator = _properties.find(key);
|
||||
if(propertiesIterator != _properties.end()) {
|
||||
return propertiesIterator->second;
|
||||
} else {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
void Properties::load()
|
||||
{
|
||||
load(_fileName);
|
||||
}
|
||||
|
||||
void Properties::load(const string &fileName)
|
||||
{
|
||||
ifstream strm(fileName.c_str());
|
||||
load(strm);
|
||||
}
|
||||
|
||||
namespace {
|
||||
string trim(const string& in)
|
||||
{
|
||||
size_t A = in.find_first_not_of(" \t\r"),
|
||||
B = in.find_last_not_of(" \t\r");
|
||||
if(A==B)
|
||||
return string();
|
||||
else
|
||||
return in.substr(A, B-A+1);
|
||||
}
|
||||
}
|
||||
|
||||
void Properties::load(std::istream& strm)
|
||||
{
|
||||
_properties_t newmap;
|
||||
|
||||
std::string line;
|
||||
unsigned lineno = 0;
|
||||
while(getline(strm, line).good()) {
|
||||
lineno++;
|
||||
size_t idx = line.find_first_not_of(" \t\r");
|
||||
if(idx==line.npos || line[idx]=='#')
|
||||
continue;
|
||||
|
||||
idx = line.find_first_of('=');
|
||||
if(idx==line.npos) {
|
||||
ostringstream msg;
|
||||
msg<<"Malformed line "<<lineno<<" expected '='";
|
||||
throw runtime_error(msg.str());
|
||||
}
|
||||
|
||||
string key(trim(line.substr(0, idx))),
|
||||
value(trim(line.substr(idx+1)));
|
||||
|
||||
if(key.empty()) {
|
||||
ostringstream msg;
|
||||
msg<<"Malformed line "<<lineno<<" expected name before '='";
|
||||
throw runtime_error(msg.str());
|
||||
}
|
||||
|
||||
newmap[key] = value;
|
||||
}
|
||||
if(strm.bad()) {
|
||||
ostringstream msg;
|
||||
msg<<"Malformed line "<<lineno<<" I/O error";
|
||||
throw runtime_error(msg.str());
|
||||
}
|
||||
_properties.swap(newmap);
|
||||
}
|
||||
|
||||
void Properties::store() const
|
||||
{
|
||||
store(_fileName);
|
||||
}
|
||||
|
||||
void Properties::store(const std::string& fname) const
|
||||
{
|
||||
ofstream strm(fname.c_str());
|
||||
store(strm);
|
||||
}
|
||||
|
||||
void Properties::store(std::ostream& strm) const
|
||||
{
|
||||
for(_properties_t::const_iterator it=_properties.begin(), end=_properties.end();
|
||||
it!=end && strm.good(); ++it)
|
||||
{
|
||||
strm << it->first << " = " << it->second << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
void Properties::list()
|
||||
{
|
||||
for (std::map<std::string,std::string>::iterator propertiesIterator = _properties.begin() ;
|
||||
propertiesIterator != _properties.end();
|
||||
propertiesIterator++ )
|
||||
{
|
||||
cout << "Key:" << propertiesIterator->first << ",Value: " << propertiesIterator->second << endl;
|
||||
}
|
||||
}
|
||||
|
||||
bool Configuration::getPropertyAsBoolean(const std::string &name, const bool defaultValue) const
|
||||
{
|
||||
string value = getPropertyAsString(name, defaultValue ? "1" : "0");
|
||||
|
||||
Reference in New Issue
Block a user