base: Add getSectionNames to IniFile
authorAndrew Bardsley <Andrew.Bardsley@arm.com>
Sat, 20 Sep 2014 21:17:47 +0000 (17:17 -0400)
committerAndrew Bardsley <Andrew.Bardsley@arm.com>
Sat, 20 Sep 2014 21:17:47 +0000 (17:17 -0400)
Add an accessor to IniFile to list all the sections in the file.

src/base/inifile.cc
src/base/inifile.hh

index 011887635ef4fe03a944245a6e4bffc80b7c880c..402c6469ff817abef8555430350014329b05847a 100644 (file)
@@ -280,6 +280,16 @@ IniFile::Section::printUnreferenced(const string &sectionName)
 }
 
 
+void
+IniFile::getSectionNames(vector<string> &list) const
+{
+    for (SectionTable::const_iterator i = table.begin();
+         i != table.end(); ++i)
+    {
+        list.push_back((*i).first);
+    }
+}
+
 bool
 IniFile::printUnreferenced()
 {
index 83cf80cf014b4d009413673de06f16471cf35ed5..c2d263619535caf1101b92f73caf4bf79530f659 100644 (file)
@@ -192,6 +192,9 @@ class IniFile
     /// @return True if the section exists.
     bool sectionExists(const std::string &section) 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();