sim: Add a checkpoint function to test for entries
When loading a checkpoint, it's sometimes desirable to be able to test whether an entry within a secion exists. This is currently done automatically in the UNSERIALIZE_OPT_SCALAR macro, but it isn't possible to do for arrays, containers, or enums. Instead of adding even more macros, add a helper function (CheckpointIn::entryExists()) that tests for the presence of an entry. Change-Id: I4b4646b03276b889fd3916efefff3bd552317dbc Signed-off-by: Andreas Sandberg <andreas.sandberg@arm.com> Reviewed-by: Nikos Nikoleris <nikos.nikoleris@arm.com>
This commit is contained in:
parent
ee78758857
commit
18135ce6ab
4 changed files with 25 additions and 0 deletions
|
@ -229,6 +229,17 @@ IniFile::find(const string §ionName, const string &entryName,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
IniFile::entryExists(const string §ionName, const string &entryName) const
|
||||||
|
{
|
||||||
|
Section *section = findSection(sectionName);
|
||||||
|
|
||||||
|
if (!section)
|
||||||
|
return false;
|
||||||
|
else
|
||||||
|
return section->findEntry(entryName);
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
IniFile::sectionExists(const string §ionName) const
|
IniFile::sectionExists(const string §ionName) const
|
||||||
{
|
{
|
||||||
|
|
|
@ -184,6 +184,12 @@ class IniFile
|
||||||
bool find(const std::string §ion, const std::string &entry,
|
bool find(const std::string §ion, const std::string &entry,
|
||||||
std::string &value) const;
|
std::string &value) const;
|
||||||
|
|
||||||
|
/// Determine whether the entry exists within named section exists
|
||||||
|
/// in the .ini file.
|
||||||
|
/// @return True if the section exists.
|
||||||
|
bool entryExists(const std::string §ion,
|
||||||
|
const std::string &entry) const;
|
||||||
|
|
||||||
/// Determine whether the named section exists in the .ini file.
|
/// Determine whether the named section exists in the .ini file.
|
||||||
/// Note that the 'Section' class is (intentionally) not public,
|
/// Note that the 'Section' class is (intentionally) not public,
|
||||||
/// so all clients can do is get a bool that says whether there
|
/// so all clients can do is get a bool that says whether there
|
||||||
|
|
|
@ -692,6 +692,12 @@ CheckpointIn::~CheckpointIn()
|
||||||
delete db;
|
delete db;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
CheckpointIn::entryExists(const string §ion, const string &entry)
|
||||||
|
{
|
||||||
|
return db->entryExists(section, entry);
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
CheckpointIn::find(const string §ion, const string &entry, string &value)
|
CheckpointIn::find(const string §ion, const string &entry, string &value)
|
||||||
{
|
{
|
||||||
|
|
|
@ -359,6 +359,8 @@ class CheckpointIn
|
||||||
bool findObj(const std::string §ion, const std::string &entry,
|
bool findObj(const std::string §ion, const std::string &entry,
|
||||||
SimObject *&value);
|
SimObject *&value);
|
||||||
|
|
||||||
|
|
||||||
|
bool entryExists(const std::string §ion, const std::string &entry);
|
||||||
bool sectionExists(const std::string §ion);
|
bool sectionExists(const std::string §ion);
|
||||||
|
|
||||||
// The following static functions have to do with checkpoint
|
// The following static functions have to do with checkpoint
|
||||||
|
|
Loading…
Reference in a new issue