Skip to content

Commit 6f1e462

Browse files
author
David Chu
committed
feat: add .Keys()
Add a new method to retrieve all keys in a given section.
1 parent 44ec495 commit 6f1e462

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

ini/INIReader.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,9 @@ class INIReader
249249
// Return the list of sections found in ini file
250250
const std::set<std::string> Sections() const;
251251

252+
// Return the list of keys in the given section
253+
const std::set<std::string> Keys(std::string section) const;
254+
252255
const std::unordered_map<std::string, std::string> Get(std::string section) const;
253256

254257
template<typename T = std::string>
@@ -319,6 +322,16 @@ inline const std::set<std::string> INIReader::Sections() const
319322
return retval;
320323
}
321324

325+
inline const std::set<std::string> INIReader::Keys(std::string section) const
326+
{
327+
auto const _section = Get(section);
328+
std::set<std::string> retval;
329+
for (auto const& element : _section) {
330+
retval.insert(element.first);
331+
}
332+
return retval;
333+
}
334+
322335
inline const std::unordered_map<std::string, std::string> INIReader::Get(std::string section) const {
323336
auto const _section = _values.find(section);
324337
if (_section == _values.end()) {

0 commit comments

Comments
 (0)