std::ifstream ifs{fname};
const std::string buffer{std::istreambuf_iterator<char>(ifs),
std::istreambuf_iterator<char>()};
- if (load_from_buffer(buffer, warnings)) {
+ if (parse_buffer(buffer, warnings)) {
return 0;
} else {
return -EINVAL;
};
}
-bool ConfFile::load_from_buffer(std::string_view buf, std::ostream* err)
+bool ConfFile::parse_buffer(std::string_view buf, std::ostream* err)
{
+ assert(err);
if (int err_pos = check_utf8(buf.data(), buf.size()); err_pos > 0) {
*err << "parse error: invalid UTF-8 found at line "
<< std::count(buf.begin(), std::next(buf.begin(), err_pos), '\n') + 1;
if (!warnings) {
warnings = &oss;
}
- return load_from_buffer({bl->c_str(), bl->length()}, warnings) ? 0 : -EINVAL;
+ return parse_buffer({bl->c_str(), bl->length()}, warnings) ? 0 : -EINVAL;
}
int ConfFile::read(const std::string& section_name,
ConfFile(const std::vector<conf_section_t>& sections);
int parse_file(const std::string &fname, std::ostream *warnings);
int parse_bufferlist(ceph::bufferlist *bl, std::ostream *warnings);
+ bool parse_buffer(std::string_view buf, std::ostream* warning);
int read(const std::string& section, std::string_view key,
std::string &val) const;
static std::string normalize_key_name(std::string_view key);
void check_old_style_section_names(const std::vector<std::string>& prefixes,
std::ostream& os);
-private:
- bool load_from_buffer(std::string_view buf, std::ostream* warning);
};
std::ostream &operator<<(std::ostream& oss, const ConfFile& cf);