return ret;
}
-KeyRing *KeyRing::create_empty()
-{
- return new KeyRing();
-}
-
int KeyRing::set_modifier(const char *type,
const char *val,
EntityName& name,
bufferlist bl;
bli.copy_all(bl);
ConfFile cf;
- std::deque<std::string> parse_errors;
- if (cf.parse_bufferlist(&bl, &parse_errors, NULL) != 0) {
+ if (cf.parse_bufferlist(&bl, nullptr) != 0) {
throw buffer::malformed_input("cannot parse buffer");
}
- for (ConfFile::const_section_iter_t s = cf.sections_begin();
- s != cf.sections_end(); ++s) {
- string name = s->first;
+ for (auto& [name, section] : cf) {
if (name == "global")
continue;
throw buffer::malformed_input(oss.str().c_str());
}
- for (ConfSection::const_line_iter_t l = s->second.lines.begin();
- l != s->second.lines.end(); ++l) {
- if (l->key.empty())
+ for (auto& [k, val] : section) {
+ if (k.empty())
continue;
- string k(l->key);
- std::replace(k.begin(), k.end(), '_', ' ');
- ret = set_modifier(k.c_str(), l->val.c_str(), ename, caps);
+ string key;
+ std::replace_copy(k.begin(), k.end(), back_inserter(key), '_', ' ');
+ ret = set_modifier(key.c_str(), val.c_str(), ename, caps);
if (ret < 0) {
ostringstream oss;
- oss << "error setting modifier for [" << name << "] type=" << k
- << " val=" << l->val;
+ oss << "error setting modifier for [" << name << "] type=" << key
+ << " val=" << val;
throw buffer::malformed_input(oss.str().c_str());
}
}