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:
parent
a9f2a5e657
commit
e0a31533b5
@ -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;
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user