summaryrefslogtreecommitdiff
path: root/Source/Core/Common/IniFile.cpp
diff options
context:
space:
mode:
authorLioncash <mathew1800@gmail.com>2017-02-24 22:56:33 -0500
committerLioncash <mathew1800@gmail.com>2017-02-25 00:03:20 -0500
commitbeec40f178f3eb324d96378a5a9b18ebe407f171 (patch)
tree18ccad5fd2075ad1c948668cf87919b9453d53e7 /Source/Core/Common/IniFile.cpp
parent51136681dfa77c88f548d187c9c7954f0ad6ac32 (diff)
IniFile: Handle s64/u64 values
Diffstat (limited to 'Source/Core/Common/IniFile.cpp')
-rw-r--r--Source/Core/Common/IniFile.cpp63
1 files changed, 61 insertions, 2 deletions
diff --git a/Source/Core/Common/IniFile.cpp b/Source/Core/Common/IniFile.cpp
index e45ae15729..4285af64bc 100644
--- a/Source/Core/Common/IniFile.cpp
+++ b/Source/Core/Common/IniFile.cpp
@@ -2,9 +2,10 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.
-// see IniFile.h
+#include "Common/IniFile.h"
#include <algorithm>
+#include <cinttypes>
#include <cstddef>
#include <cstring>
#include <fstream>
@@ -15,7 +16,6 @@
#include "Common/CommonTypes.h"
#include "Common/FileUtil.h"
-#include "Common/IniFile.h"
#include "Common/StringUtil.h"
void IniFile::ParseLine(const std::string& line, std::string* keyOut, std::string* valueOut)
@@ -73,6 +73,41 @@ void IniFile::Section::Set(const std::string& key, const std::vector<std::string
Set(key, temp);
}
+void IniFile::Section::Set(const std::string& key, u32 newValue)
+{
+ Set(key, StringFromFormat("0x%08x", newValue));
+}
+
+void IniFile::Section::Set(const std::string& key, u64 new_value)
+{
+ Set(key, StringFromFormat("0x%016" PRIx64, new_value));
+}
+
+void IniFile::Section::Set(const std::string& key, float newValue)
+{
+ Set(key, StringFromFormat("%#.9g", newValue));
+}
+
+void IniFile::Section::Set(const std::string& key, double newValue)
+{
+ Set(key, StringFromFormat("%#.17g", newValue));
+}
+
+void IniFile::Section::Set(const std::string& key, int newValue)
+{
+ Set(key, StringFromInt(newValue));
+}
+
+void IniFile::Section::Set(const std::string& key, s64 newValue)
+{
+ Set(key, StringFromFormat("%" PRId64, newValue));
+}
+
+void IniFile::Section::Set(const std::string& key, bool newValue)
+{
+ Set(key, StringFromBool(newValue));
+}
+
bool IniFile::Section::Get(const std::string& key, std::string* value,
const std::string& defaultValue) const
{
@@ -133,6 +168,18 @@ bool IniFile::Section::Get(const std::string& key, int* value, int 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;
@@ -145,6 +192,18 @@ bool IniFile::Section::Get(const std::string& key, u32* value, u32 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;