i->second->dump(i->first);
}
}
+
+IniFile::Section::EntryTable::const_iterator
+IniFile::Section::begin() const
+{
+ return table.begin();
+}
+
+IniFile::Section::EntryTable::const_iterator
+IniFile::Section::end() const
+{
+ return table.end();
+}
+
+void
+IniFile::visitSection(const std::string §ionName,
+ IniFile::VisitSectionCallback cb)
+{
+ const auto& section = *table.at(sectionName);
+ for (const auto& pair : section) {
+ cb(pair.first, pair.second->getValue());
+ }
+}
#define __INIFILE_HH__
#include <fstream>
+#include <functional>
#include <list>
#include <string>
#include <unordered_map>
/// Print the contents of this section to cout (for debugging).
void dump(const std::string §ionName);
+
+ EntryTable::const_iterator begin() const;
+ EntryTable::const_iterator end() const;
};
/// SectionTable type. Map of strings to Section object pointers.
/// Dump contents to cout. For debugging.
void dump();
+
+ /// Visitor callback that receives key/value pairs.
+ using VisitSectionCallback = std::function<void(
+ const std::string&, const std::string&)>;
+
+ /// Iterate over key/value pairs of the given section.
+ void visitSection(const std::string §ionName, VisitSectionCallback cb);
};
#endif // __INIFILE_HH__
/*
- * Copyright (c) 2015 ARM Limited
+ * Copyright (c) 2015, 2020 ARM Limited
* All rights reserved
*
* The license below extends only to copyright in the software and shall
return db->sectionExists(section);
}
+void
+CheckpointIn::visitSection(const std::string §ion,
+ IniFile::VisitSectionCallback cb)
+{
+ db->visitSection(section, cb);
+}
+
void
objParamIn(CheckpointIn &cp, const string &name, SimObject * ¶m)
{
#include <unordered_map>
#include <vector>
+#include "base/inifile.hh"
#include "base/logging.hh"
#include "sim/serialize_handlers.hh"
bool entryExists(const std::string §ion, const std::string &entry);
bool sectionExists(const std::string §ion);
+ void visitSection(const std::string §ion,
+ IniFile::VisitSectionCallback cb);
/** @}*/ //end of api_checkout group
// The following static functions have to do with checkpoint
param[name_to_index[key]] = value;
}
}
+ cp.visitSection(
+ Serializable::currentSection(),
+ [name_to_index](const std::string& key, const std::string& val)
+ {
+ if (!name_to_index.count(key)) {
+ warn("unknown entry found in checkpoint: %s %s %s\n",
+ Serializable::currentSection(), key, val);
+ }
+ }
+ );
}
//