From 18135ce6abc0ee02e36aef424be183cd7238a558 Mon Sep 17 00:00:00 2001 From: Andreas Sandberg Date: Tue, 4 Oct 2016 11:22:16 +0100 Subject: 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 Reviewed-by: Nikos Nikoleris --- src/base/inifile.cc | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/base/inifile.cc') diff --git a/src/base/inifile.cc b/src/base/inifile.cc index 402c6469f..80ed3eb06 100644 --- a/src/base/inifile.cc +++ b/src/base/inifile.cc @@ -229,6 +229,17 @@ IniFile::find(const string §ionName, const string &entryName, 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 IniFile::sectionExists(const string §ionName) const { -- cgit v1.2.3