mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
BasicConfig support for legacy values:
* A legacy value is a config section with a single-line. * These values may be read from the BasicConfig interface so the deprecated Config class does not need to be exposed to clients. * Made Config class more testable.
This commit is contained in:
@@ -106,24 +106,6 @@ BasicConfig::section (std::string const& name) const
|
||||
return iter->second;
|
||||
}
|
||||
|
||||
void
|
||||
BasicConfig::remap (std::string const& legacy_section,
|
||||
std::string const& key, std::string const& new_section)
|
||||
{
|
||||
auto const iter = map_.find (legacy_section);
|
||||
if (iter == map_.end())
|
||||
return;
|
||||
if (iter->second.size() != 0)
|
||||
return;
|
||||
if (iter->second.lines().size() != 1)
|
||||
return;
|
||||
auto result = map_.emplace(std::piecewise_construct,
|
||||
std::make_tuple(new_section), std::make_tuple(new_section));
|
||||
auto& s = result.first->second;
|
||||
s.append (iter->second.lines().front());
|
||||
s.set (key, iter->second.lines().front());
|
||||
}
|
||||
|
||||
void
|
||||
BasicConfig::overwrite (std::string const& section, std::string const& key,
|
||||
std::string const& value)
|
||||
@@ -133,6 +115,18 @@ BasicConfig::overwrite (std::string const& section, std::string const& key,
|
||||
result.first->second.set (key, value);
|
||||
}
|
||||
|
||||
void
|
||||
BasicConfig::legacy(std::string const& section, std::string value)
|
||||
{
|
||||
map_[section].legacy(std::move(value));
|
||||
}
|
||||
|
||||
std::string
|
||||
BasicConfig::legacy(std::string const& sectionName) const
|
||||
{
|
||||
return section (sectionName).legacy ();
|
||||
}
|
||||
|
||||
void
|
||||
BasicConfig::build (IniFileSections const& ifs)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user