Keep a list of section config values that are not key/value pairs:

This change to BasicConfig stores all appended lines which are not key/value
pairs in a separate values vector which can be retrieved later. This is to
support sections containing both key/value pairs and a list of values.
This commit is contained in:
Vinnie Falco
2014-10-09 18:39:58 -07:00
parent dfeb9967b8
commit db5d52b4b2
2 changed files with 91 additions and 76 deletions

View File

@@ -32,7 +32,7 @@ Section::set (std::string const& key, std::string const& value)
}
void
Section::append (std::string const& line)
Section::append (std::vector <std::string> const& lines)
{
// <key> '=' <value>
static boost::regex const re1 (
@@ -47,18 +47,16 @@ Section::append (std::string const& line)
, boost::regex_constants::optimize
);
boost::smatch match;
lines_.push_back (line);
if (boost::regex_match (line, match, re1))
set (match[1], match[2]);
}
void
Section::append (std::vector <std::string> const& lines)
{
lines_.reserve (lines_.size() + lines.size());
std::for_each (lines.begin(), lines.end(),
[&](std::string const& line) { this->append (line); });
for (auto const& line : lines)
{
boost::smatch match;
lines_.push_back (line);
if (boost::regex_match (line, match, re1))
set (match[1], match[2]);
else
values_.push_back (line);
}
}
bool