Add an append= keyword that works in a somewhat similar way to

default=.  In the append= case, when looking up an entry, it also
looks in the section named by the append= for something to append
to the entry

--HG--
extra : convert_revision : b51915094ad3ca151d7f241c29e19b6b29d3a3c0
This commit is contained in:
Nathan Binkert 2003-10-26 22:42:45 -05:00
parent 91293e02d2
commit 13bcf233f1
2 changed files with 31 additions and 2 deletions

View file

@ -367,14 +367,40 @@ IniFile::findDefault(const string &_section, const string &entry,
string &value) const string &value) const
{ {
string section = _section; string section = _section;
while (!find(section, entry, value)) { while (!findAppend(section, entry, value)) {
if (!find(section, "default", section)) if (!find(section, "default", section)) {
return false; return false;
} }
}
return true; return true;
} }
bool
IniFile::findAppend(const string &_section, const string &entry,
string &value) const
{
string section = _section;
bool ret = false;
bool first = true;
do {
string val;
if (find(section, entry, val)) {
ret = true;
if (first) {
value = val;
first = false;
} else {
value += " ";
value += val;
}
}
} while (find(section, "append", section));
return ret;
}
bool bool
IniFile::Section::printUnreferenced(const string &sectionName) IniFile::Section::printUnreferenced(const string &sectionName)

View file

@ -196,6 +196,9 @@ class IniFile
bool findDefault(const std::string &section, const std::string &entry, bool findDefault(const std::string &section, const std::string &entry,
std::string &value) const; std::string &value) const;
bool findAppend(const std::string &section, const std::string &entry,
std::string &value) const;
/// Print unreferenced entries in object. Iteratively calls /// Print unreferenced entries in object. Iteratively calls
/// printUnreferend() on all the constituent sections. /// printUnreferend() on all the constituent sections.
bool printUnreferenced(); bool printUnreferenced();