* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * Authors: Nathan Binkert
- * Steve Reinhardt
*/
#ifndef __INIFILE_HH__
#include <fstream>
#include <list>
#include <string>
+#include <unordered_map>
#include <vector>
-#include "base/hashmap.hh"
-
/**
* @file
* Declaration of IniFile object.
///
class Entry
{
- std::string value; ///< The entry value.
- mutable bool referenced; ///< Has this entry been used?
+ std::string value; ///< The entry value.
+ mutable bool referenced; ///< Has this entry been used?
public:
/// Constructor.
class Section
{
/// EntryTable type. Map of strings to Entry object pointers.
- typedef m5::hash_map<std::string, Entry *> EntryTable;
+ typedef std::unordered_map<std::string, Entry *> EntryTable;
- EntryTable table; ///< Table of entries.
- mutable bool referenced; ///< Has this section been used?
+ EntryTable table; ///< Table of entries.
+ mutable bool referenced; ///< Has this section been used?
public:
/// Constructor.
};
/// SectionTable type. Map of strings to Section object pointers.
- typedef m5::hash_map<std::string, Section *> SectionTable;
+ typedef std::unordered_map<std::string, Section *> SectionTable;
protected:
/// Hash of section names to Section object pointers.
/// @retval True if successful, false if errors were encountered.
bool load(std::istream &f);
- /// Load the specified file, passing it through the C preprocessor.
- /// Parameter settings found in the file will be merged with any
- /// already defined in this object.
- /// @param file The path of the file to load.
- /// @param cppFlags Vector of extra flags to pass to cpp.
- /// @retval True if successful, false if errors were encountered.
- bool loadCPP(const std::string &file, std::vector<char *> &cppFlags);
-
/// Load the specified file.
/// Parameter settings found in the file will be merged with any
/// already defined in this object.
bool find(const std::string §ion, const std::string &entry,
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.
/// Note that the 'Section' class is (intentionally) not public,
/// so all clients can do is get a bool that says whether there
/// @return True if the section exists.
bool sectionExists(const std::string §ion) const;
+ /// Push all section names into the given vector
+ void getSectionNames(std::vector<std::string> &list) const;
+
/// Print unreferenced entries in object. Iteratively calls
/// printUnreferend() on all the constituent sections.
bool printUnreferenced();