Merge pull request #966 from RachelBryk/template-set
Change IniFile::Section::Set() with default value to use a template.
This commit is contained in:
commit
7d39936b49
|
@ -60,30 +60,6 @@ void IniFile::Section::Set(const std::string& key, const std::string& newValue,
|
||||||
Delete(key);
|
Delete(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IniFile::Section::Set(const std::string& key, const float newValue, const float defaultValue)
|
|
||||||
{
|
|
||||||
if (newValue != defaultValue)
|
|
||||||
Set(key, newValue);
|
|
||||||
else
|
|
||||||
Delete(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
void IniFile::Section::Set(const std::string& key, int newValue, int defaultValue)
|
|
||||||
{
|
|
||||||
if (newValue != defaultValue)
|
|
||||||
Set(key, newValue);
|
|
||||||
else
|
|
||||||
Delete(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
void IniFile::Section::Set(const std::string& key, bool newValue, bool defaultValue)
|
|
||||||
{
|
|
||||||
if (newValue != defaultValue)
|
|
||||||
Set(key, newValue);
|
|
||||||
else
|
|
||||||
Delete(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
void IniFile::Section::Set(const std::string& key, const std::vector<std::string>& newValues)
|
void IniFile::Section::Set(const std::string& key, const std::vector<std::string>& newValues)
|
||||||
{
|
{
|
||||||
std::string temp;
|
std::string temp;
|
||||||
|
|
|
@ -50,23 +50,31 @@ public:
|
||||||
Set(key, StringFromFormat("%f", newValue));
|
Set(key, StringFromFormat("%f", newValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Set(const std::string& key, const float newValue, const float defaultValue);
|
|
||||||
void Set(const std::string& key, double newValue)
|
void Set(const std::string& key, double newValue)
|
||||||
{
|
{
|
||||||
Set(key, StringFromFormat("%f", newValue));
|
Set(key, StringFromFormat("%f", newValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Set(const std::string& key, int newValue, int defaultValue);
|
|
||||||
void Set(const std::string& key, int newValue)
|
void Set(const std::string& key, int newValue)
|
||||||
{
|
{
|
||||||
Set(key, StringFromInt(newValue));
|
Set(key, StringFromInt(newValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Set(const std::string& key, bool newValue, bool defaultValue);
|
|
||||||
void Set(const std::string& key, bool newValue)
|
void Set(const std::string& key, bool newValue)
|
||||||
{
|
{
|
||||||
Set(key, StringFromBool(newValue));
|
Set(key, StringFromBool(newValue));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
void Set(const std::string& key, T newValue, const T defaultValue)
|
||||||
|
{
|
||||||
|
if (newValue != defaultValue)
|
||||||
|
Set(key, newValue);
|
||||||
|
else
|
||||||
|
Delete(key);
|
||||||
|
}
|
||||||
|
|
||||||
void Set(const std::string& key, const std::vector<std::string>& newValues);
|
void Set(const std::string& key, const std::vector<std::string>& newValues);
|
||||||
|
|
||||||
bool Get(const std::string& key, int* value, int defaultValue = 0);
|
bool Get(const std::string& key, int* value, int defaultValue = 0);
|
||||||
|
|
Loading…
Reference in New Issue