1
0
mirror of https://github.com/benhoyt/inih.git synced 2025-01-28 22:52:54 +08:00

Add HasValue method to INIReader (#69)

* Add HasValue method to INIReader
This commit is contained in:
Jesse van Rhijn 2018-09-05 00:51:41 +02:00 committed by Ben Hoyt
parent a9f2a5e657
commit e0a31533b5
2 changed files with 9 additions and 0 deletions

View File

@ -62,6 +62,12 @@ bool INIReader::GetBoolean(const string& section, const string& name, bool defau
return default_value;
}
bool HasValue(const std::string& section, const std::string& name) const
{
string key = MakeKey(section, name);
return _values.count(key);
}
string INIReader::MakeKey(const string& section, const string& name)
{
string key = section + "=" + name;

View File

@ -42,6 +42,9 @@ public:
// and valid false values are "false", "no", "off", "0" (not case sensitive).
bool GetBoolean(const std::string& section, const std::string& name, bool default_value) const;
// Return true if a value exists with the given section and field names.
bool HasValue(const std::string& section, const std::string& name) const;
private:
int _error;
std::map<std::string, std::string> _values;