|
gem5
v21.0.1.0
|
This class represents the contents of a ".ini" file. More...
#include <inifile.hh>
Classes | |
| class | Entry |
| A single key/value pair. More... | |
| class | Section |
| A section. More... | |
Public Types | |
| using | VisitSectionCallback = std::function< void(const std::string &, const std::string &)> |
| Visitor callback that receives key/value pairs. More... | |
Public Member Functions | |
| IniFile () | |
| Constructor. More... | |
| ~IniFile () | |
| Destructor. More... | |
| bool | load (std::istream &f) |
| Load parameter settings from given istream. More... | |
| bool | load (const std::string &file) |
| Load the specified file. More... | |
| bool | add (const std::string &s) |
| Take string of the form "<section>:<parameter>=<value>" or "<section>:<parameter>+=<value>" and add to database. More... | |
| bool | find (const std::string §ion, const std::string &entry, std::string &value) const |
| Find value corresponding to given section and entry names. More... | |
| bool | entryExists (const std::string §ion, const std::string &entry) const |
| Determine whether the entry exists within named section exists in the .ini file. More... | |
| bool | sectionExists (const std::string §ion) const |
| Determine whether the named section exists in the .ini file. More... | |
| void | getSectionNames (std::vector< std::string > &list) const |
| Push all section names into the given vector. More... | |
| bool | printUnreferenced () |
| Print unreferenced entries in object. More... | |
| void | dump () |
| Dump contents to cout. For debugging. More... | |
| void | visitSection (const std::string §ionName, VisitSectionCallback cb) |
| Iterate over key/value pairs of the given section. More... | |
Protected Types | |
| typedef std::unordered_map< std::string, Section * > | SectionTable |
| SectionTable type. Map of strings to Section object pointers. More... | |
Protected Member Functions | |
| Section * | addSection (const std::string §ionName) |
| Look up section with the given name, creating a new section if not found. More... | |
| Section * | findSection (const std::string §ionName) const |
| Look up section with the given name. More... | |
Protected Attributes | |
| SectionTable | table |
| Hash of section names to Section object pointers. More... | |
This class represents the contents of a ".ini" file.
It's basically a two level lookup table: a set of named sections, where each section is a set of key/value pairs. Section names, keys, and values are all uninterpreted strings.
Definition at line 52 of file inifile.hh.
|
protected |
SectionTable type. Map of strings to Section object pointers.
Definition at line 142 of file inifile.hh.
| using IniFile::VisitSectionCallback = std::function<void( const std::string&, const std::string&)> |
Visitor callback that receives key/value pairs.
Definition at line 213 of file inifile.hh.
| IniFile::IniFile | ( | ) |
Constructor.
Definition at line 39 of file inifile.cc.
| IniFile::~IniFile | ( | ) |
| bool IniFile::add | ( | const std::string & | s | ) |
Take string of the form "<section>:<parameter>=<value>" or "<section>:<parameter>+=<value>" and add to database.
| True | if successful, false if parse error. |
Definition at line 159 of file inifile.cc.
References addSection(), eat_white(), ArmISA::offset, and ArmISA::s.
|
protected |
| void IniFile::dump | ( | ) |
Dump contents to cout. For debugging.
Definition at line 340 of file inifile.cc.
| bool IniFile::entryExists | ( | const std::string & | section, |
| const std::string & | entry | ||
| ) | const |
Determine whether the entry exists within named section exists in the .ini file.
Definition at line 229 of file inifile.cc.
References IniFile::Section::findEntry(), and findSection().
Referenced by CheckpointIn::entryExists().
| bool IniFile::find | ( | const std::string & | section, |
| const std::string & | entry, | ||
| std::string & | value | ||
| ) | const |
Find value corresponding to given section and entry names.
Value is returned by reference in 'value' param.
| True | if found, false if not. |
Definition at line 212 of file inifile.cc.
References IniFile::Section::findEntry(), findSection(), and IniFile::Entry::getValue().
Referenced by CheckpointIn::find(), CheckpointIn::findObj(), CxxIniFile::getParam(), CxxIniFile::getParamVector(), and TEST().
|
protected |
Look up section with the given name.
| Pointer | to section object, or NULL if not found. |
Definition at line 148 of file inifile.cc.
References ArmISA::i, and table.
Referenced by entryExists(), find(), and sectionExists().
| void IniFile::getSectionNames | ( | std::vector< std::string > & | list | ) | const |
Push all section names into the given vector.
Definition at line 292 of file inifile.cc.
References ArmISA::i, sc_dt::list, and table.
Referenced by CxxIniFile::getAllObjectNames().
| bool IniFile::load | ( | const std::string & | file | ) |
Load the specified file.
Parameter settings found in the file will be merged with any already defined in this object.
| file | The path of the file to load. |
| True | if successful, false if errors were encountered. |
Definition at line 54 of file inifile.cc.
| bool IniFile::load | ( | std::istream & | f | ) |
Load parameter settings from given istream.
This is a helper function for load(string) and loadCPP(), which open a file and then pass it here.
| True | if successful, false if errors were encountered. |
Definition at line 176 of file inifile.cc.
References IniFile::Section::add(), addSection(), eat_end_white(), eat_white(), and ArmISA::f.
Referenced by CheckpointIn::CheckpointIn(), CxxIniFile::load(), load(), and TEST().
| bool IniFile::printUnreferenced | ( | ) |
Print unreferenced entries in object.
Iteratively calls printUnreferend() on all the constituent sections.
Definition at line 302 of file inifile.cc.
References IniFile::Section::findEntry(), ArmISA::i, IniFile::Section::isReferenced(), IniFile::Section::printUnreferenced(), and table.
| bool IniFile::sectionExists | ( | const std::string & | section | ) | const |
Determine whether the named section exists in the .ini file.
Note that the 'Section' class is (intentionally) not public, so all clients can do is get a bool that says whether there are any values in that section or not.
Definition at line 241 of file inifile.cc.
References findSection().
Referenced by CxxIniFile::objectExists(), and CheckpointIn::sectionExists().
| void IniFile::visitSection | ( | const std::string & | sectionName, |
| IniFile::VisitSectionCallback | cb | ||
| ) |
Iterate over key/value pairs of the given section.
Definition at line 361 of file inifile.cc.
References table.
Referenced by CheckpointIn::visitSection().
|
protected |
Hash of section names to Section object pointers.
Definition at line 146 of file inifile.hh.
Referenced by IniFile::Section::addEntry(), addSection(), IniFile::Section::begin(), IniFile::Section::dump(), dump(), IniFile::Section::end(), IniFile::Section::findEntry(), findSection(), getSectionNames(), IniFile::Section::printUnreferenced(), printUnreferenced(), visitSection(), and ~IniFile().