mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-06-19 19:00:09 +02:00
IniFile: Use templates for Get()
Gets rid of duplicated code.
This commit is contained in:
@ -110,90 +110,6 @@ bool IniFile::Section::Get(const std::string& key, std::vector<std::string>* out
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IniFile::Section::Get(const std::string& key, int* value, int defaultValue) const
|
||||
{
|
||||
std::string temp;
|
||||
bool retval = Get(key, &temp);
|
||||
|
||||
if (retval && TryParse(temp, value))
|
||||
return true;
|
||||
|
||||
*value = defaultValue;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IniFile::Section::Get(const std::string& key, s64* value, s64 default_value) const
|
||||
{
|
||||
std::string temp;
|
||||
bool retval = Get(key, &temp);
|
||||
|
||||
if (retval && TryParse(temp, value))
|
||||
return true;
|
||||
|
||||
*value = default_value;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IniFile::Section::Get(const std::string& key, u32* value, u32 defaultValue) const
|
||||
{
|
||||
std::string temp;
|
||||
bool retval = Get(key, &temp);
|
||||
|
||||
if (retval && TryParse(temp, value))
|
||||
return true;
|
||||
|
||||
*value = defaultValue;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IniFile::Section::Get(const std::string& key, u64* value, u64 default_value) const
|
||||
{
|
||||
std::string temp;
|
||||
bool retval = Get(key, &temp);
|
||||
|
||||
if (retval && TryParse(temp, value))
|
||||
return true;
|
||||
|
||||
*value = default_value;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IniFile::Section::Get(const std::string& key, bool* value, bool defaultValue) const
|
||||
{
|
||||
std::string temp;
|
||||
bool retval = Get(key, &temp);
|
||||
|
||||
if (retval && TryParse(temp, value))
|
||||
return true;
|
||||
|
||||
*value = defaultValue;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IniFile::Section::Get(const std::string& key, float* value, float defaultValue) const
|
||||
{
|
||||
std::string temp;
|
||||
bool retval = Get(key, &temp);
|
||||
|
||||
if (retval && TryParse(temp, value))
|
||||
return true;
|
||||
|
||||
*value = defaultValue;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IniFile::Section::Get(const std::string& key, double* value, double defaultValue) const
|
||||
{
|
||||
std::string temp;
|
||||
bool retval = Get(key, &temp);
|
||||
|
||||
if (retval && TryParse(temp, value))
|
||||
return true;
|
||||
|
||||
*value = defaultValue;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IniFile::Section::Exists(const std::string& key) const
|
||||
{
|
||||
return values.find(key) != values.end();
|
||||
|
Reference in New Issue
Block a user