mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-26 15:55:31 +01:00
IniFile: Mark getter functions as const
This commit is contained in:
parent
4fb48fd209
commit
822cf2bcbf
@ -72,7 +72,7 @@ void IniFile::Section::Set(const std::string& key, const std::vector<std::string
|
|||||||
Set(key, temp);
|
Set(key, temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IniFile::Section::Get(const std::string& key, std::string* value, const std::string& defaultValue)
|
bool IniFile::Section::Get(const std::string& key, std::string* value, const std::string& defaultValue) const
|
||||||
{
|
{
|
||||||
auto it = values.find(key);
|
auto it = values.find(key);
|
||||||
if (it != values.end())
|
if (it != values.end())
|
||||||
@ -85,11 +85,11 @@ bool IniFile::Section::Get(const std::string& key, std::string* value, const std
|
|||||||
*value = defaultValue;
|
*value = defaultValue;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IniFile::Section::Get(const std::string& key, std::vector<std::string>* out)
|
bool IniFile::Section::Get(const std::string& key, std::vector<std::string>* out) const
|
||||||
{
|
{
|
||||||
std::string temp;
|
std::string temp;
|
||||||
bool retval = Get(key, &temp);
|
bool retval = Get(key, &temp);
|
||||||
@ -97,69 +97,84 @@ bool IniFile::Section::Get(const std::string& key, std::vector<std::string>* out
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// ignore starting , if any
|
|
||||||
|
// ignore starting comma, if any
|
||||||
size_t subStart = temp.find_first_not_of(",");
|
size_t subStart = temp.find_first_not_of(",");
|
||||||
|
|
||||||
// split by ,
|
// split by comma
|
||||||
while (subStart != std::string::npos)
|
while (subStart != std::string::npos)
|
||||||
{
|
{
|
||||||
// Find next ,
|
// Find next comma
|
||||||
size_t subEnd = temp.find(',', subStart);
|
size_t subEnd = temp.find(',', subStart);
|
||||||
if (subStart != subEnd)
|
if (subStart != subEnd)
|
||||||
// take from first char until next ,
|
{
|
||||||
|
// take from first char until next comma
|
||||||
out->push_back(StripSpaces(temp.substr(subStart, subEnd - subStart)));
|
out->push_back(StripSpaces(temp.substr(subStart, subEnd - subStart)));
|
||||||
// Find the next non , char
|
}
|
||||||
|
|
||||||
|
// Find the next non-comma char
|
||||||
subStart = temp.find_first_not_of(",", subEnd);
|
subStart = temp.find_first_not_of(",", subEnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IniFile::Section::Get(const std::string& key, int* value, int defaultValue)
|
bool IniFile::Section::Get(const std::string& key, int* value, int defaultValue) const
|
||||||
{
|
{
|
||||||
std::string temp;
|
std::string temp;
|
||||||
bool retval = Get(key, &temp);
|
bool retval = Get(key, &temp);
|
||||||
|
|
||||||
if (retval && TryParse(temp, value))
|
if (retval && TryParse(temp, value))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
*value = defaultValue;
|
*value = defaultValue;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IniFile::Section::Get(const std::string& key, u32* value, u32 defaultValue)
|
bool IniFile::Section::Get(const std::string& key, u32* value, u32 defaultValue) const
|
||||||
{
|
{
|
||||||
std::string temp;
|
std::string temp;
|
||||||
bool retval = Get(key, &temp);
|
bool retval = Get(key, &temp);
|
||||||
|
|
||||||
if (retval && TryParse(temp, value))
|
if (retval && TryParse(temp, value))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
*value = defaultValue;
|
*value = defaultValue;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IniFile::Section::Get(const std::string& key, bool* value, bool defaultValue)
|
bool IniFile::Section::Get(const std::string& key, bool* value, bool defaultValue) const
|
||||||
{
|
{
|
||||||
std::string temp;
|
std::string temp;
|
||||||
bool retval = Get(key, &temp);
|
bool retval = Get(key, &temp);
|
||||||
|
|
||||||
if (retval && TryParse(temp, value))
|
if (retval && TryParse(temp, value))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
*value = defaultValue;
|
*value = defaultValue;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IniFile::Section::Get(const std::string& key, float* value, float defaultValue)
|
bool IniFile::Section::Get(const std::string& key, float* value, float defaultValue) const
|
||||||
{
|
{
|
||||||
std::string temp;
|
std::string temp;
|
||||||
bool retval = Get(key, &temp);
|
bool retval = Get(key, &temp);
|
||||||
|
|
||||||
if (retval && TryParse(temp, value))
|
if (retval && TryParse(temp, value))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
*value = defaultValue;
|
*value = defaultValue;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IniFile::Section::Get(const std::string& key, double* value, double defaultValue)
|
bool IniFile::Section::Get(const std::string& key, double* value, double defaultValue) const
|
||||||
{
|
{
|
||||||
std::string temp;
|
std::string temp;
|
||||||
bool retval = Get(key, &temp);
|
bool retval = Get(key, &temp);
|
||||||
|
|
||||||
if (retval && TryParse(temp, value))
|
if (retval && TryParse(temp, value))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
*value = defaultValue;
|
*value = defaultValue;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -38,8 +38,6 @@ public:
|
|||||||
void Set(const std::string& key, const std::string& newValue);
|
void Set(const std::string& key, const std::string& newValue);
|
||||||
void Set(const std::string& key, const std::string& newValue, const std::string& defaultValue);
|
void Set(const std::string& key, const std::string& newValue, const std::string& defaultValue);
|
||||||
|
|
||||||
bool Get(const std::string& key, std::string* value, const std::string& defaultValue = NULL_STRING);
|
|
||||||
|
|
||||||
void Set(const std::string& key, u32 newValue)
|
void Set(const std::string& key, u32 newValue)
|
||||||
{
|
{
|
||||||
Set(key, StringFromFormat("0x%08x", newValue));
|
Set(key, StringFromFormat("0x%08x", newValue));
|
||||||
@ -76,12 +74,13 @@ public:
|
|||||||
|
|
||||||
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, std::string* value, const std::string& defaultValue = NULL_STRING) const;
|
||||||
bool Get(const std::string& key, u32* value, u32 defaultValue = 0);
|
bool Get(const std::string& key, int* value, int defaultValue = 0) const;
|
||||||
bool Get(const std::string& key, bool* value, bool defaultValue = false);
|
bool Get(const std::string& key, u32* value, u32 defaultValue = 0) const;
|
||||||
bool Get(const std::string& key, float* value, float defaultValue = false);
|
bool Get(const std::string& key, bool* value, bool defaultValue = false) const;
|
||||||
bool Get(const std::string& key, double* value, double defaultValue = false);
|
bool Get(const std::string& key, float* value, float defaultValue = 0.0f) const;
|
||||||
bool Get(const std::string& key, std::vector<std::string>* values);
|
bool Get(const std::string& key, double* value, double defaultValue = 0.0) const;
|
||||||
|
bool Get(const std::string& key, std::vector<std::string>* values) const;
|
||||||
|
|
||||||
bool operator < (const Section& other) const
|
bool operator < (const Section& other) const
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user