gem5 v24.0.0.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 |
Visitor callback that receives key/value pairs. | |
Public Member Functions | |
IniFile () | |
Constructor. | |
bool | load (std::istream &f) |
Load parameter settings from given istream. | |
bool | load (const std::string &file) |
Load the specified file. | |
bool | add (const std::string &s) |
Take string of the form "<section>:<parameter>=<value>" or "<section>:<parameter>+=<value>" and add to database. | |
bool | find (const std::string §ion, const std::string &entry, std::string &value) const |
Find value corresponding to given section and entry names. | |
bool | entryExists (const std::string §ion, const std::string &entry) const |
Determine whether the entry exists within named section exists in the .ini file. | |
bool | sectionExists (const std::string §ion) const |
Determine whether the named section exists in the .ini file. | |
void | getSectionNames (std::vector< std::string > &list) const |
Push all section names into the given vector. | |
bool | printUnreferenced () const |
Print unreferenced entries in object. | |
void | dump () |
Dump contents to cout. For debugging. | |
void | visitSection (const std::string §ionName, VisitSectionCallback cb) |
Iterate over key/value pairs of the given section. | |
Protected Types | |
typedef std::unordered_map< std::string, Section > | SectionTable |
SectionTable type. Map of strings to Section object pointers. | |
Protected Member Functions | |
Section * | addSection (const std::string §ionName) |
Look up section with the given name, creating a new section if not found. | |
Section * | findSection (const std::string §ionName) |
Look up section with the given name. | |
const Section * | findSection (const std::string §ionName) const |
Protected Attributes | |
SectionTable | table |
Hash of section names to Section object pointers. | |
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 55 of file inifile.hh.
|
protected |
SectionTable type. Map of strings to Section object pointers.
Definition at line 146 of file inifile.hh.
Visitor callback that receives key/value pairs.
Definition at line 214 of file inifile.hh.
gem5::IniFile::IniFile | ( | ) |
Constructor.
Definition at line 42 of file inifile.cc.
bool gem5::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 154 of file inifile.cc.
References addSection(), gem5::eat_white(), gem5::ArmISA::offset, and gem5::ArmISA::s.
|
protected |
Look up section with the given name, creating a new section if not found.
Pointer | to section object. |
Definition at line 130 of file inifile.cc.
References table.
void gem5::IniFile::dump | ( | ) |
Dump contents to cout. For debugging.
Definition at line 330 of file inifile.cc.
References gem5::ArmISA::i, and table.
bool gem5::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 224 of file inifile.cc.
References findSection().
Referenced by gem5::CheckpointIn::entryExists().
bool gem5::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 207 of file inifile.cc.
References findSection().
Referenced by gem5::CheckpointIn::find(), gem5::CxxIniFile::getParam(), gem5::CxxIniFile::getParamVector(), TEST(), and TEST().
|
protected |
Look up section with the given name.
Pointer | to section object, or NULL if not found. |
Definition at line 136 of file inifile.cc.
Referenced by entryExists(), find(), and sectionExists().
|
protected |
Definition at line 143 of file inifile.cc.
References gem5::ArmISA::i, and table.
void gem5::IniFile::getSectionNames | ( | std::vector< std::string > & | list | ) | const |
Push all section names into the given vector.
Definition at line 286 of file inifile.cc.
References table.
Referenced by gem5::CxxIniFile::getAllObjectNames().
bool gem5::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 46 of file inifile.cc.
References gem5::ArmISA::f, and load().
bool gem5::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 171 of file inifile.cc.
References gem5::IniFile::Section::add(), addSection(), gem5::eat_end_white(), gem5::eat_white(), and gem5::ArmISA::f.
Referenced by gem5::CheckpointIn::CheckpointIn(), gem5::CxxIniFile::load(), load(), TEST(), and TEST().
bool gem5::IniFile::printUnreferenced | ( | ) | const |
Print unreferenced entries in object.
Iteratively calls printUnreferend() on all the constituent sections.
Definition at line 295 of file inifile.cc.
References table.
bool gem5::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 236 of file inifile.cc.
References findSection().
Referenced by gem5::CxxIniFile::objectExists(), and gem5::CheckpointIn::sectionExists().
void gem5::IniFile::visitSection | ( | const std::string & | sectionName, |
IniFile::VisitSectionCallback | cb ) |
Iterate over key/value pairs of the given section.
Definition at line 351 of file inifile.cc.
References table.
Referenced by gem5::CheckpointIn::visitSection().
|
protected |
Hash of section names to Section object pointers.
Definition at line 150 of file inifile.hh.
Referenced by gem5::IniFile::Section::addEntry(), addSection(), gem5::IniFile::Section::begin(), dump(), gem5::IniFile::Section::dump(), gem5::IniFile::Section::end(), gem5::IniFile::Section::findEntry(), findSection(), getSectionNames(), printUnreferenced(), gem5::IniFile::Section::printUnreferenced(), and visitSection().