summaryrefslogtreecommitdiff
path: root/Source/Core/Common/Config
diff options
context:
space:
mode:
authorLeo Lam <leolino.lam@gmail.com>2017-08-04 10:07:05 +0800
committerGitHub <noreply@github.com>2017-08-04 10:07:05 +0800
commitf274bbcbe14a5424120f985d8ad6968e656aeb13 (patch)
tree9448e2a983affa8004031c5528a323071e9d279e /Source/Core/Common/Config
parent51af8d4aeba26e09aeaf90ab5ca02a7915252665 (diff)
parentdde3471b629900887041d7e24582110fa5877ece (diff)
Merge pull request #5872 from ligfx/wxnetplayonionconfig
WX: make Netplay use new-style config
Diffstat (limited to 'Source/Core/Common/Config')
-rw-r--r--Source/Core/Common/Config/Section.cpp17
-rw-r--r--Source/Core/Common/Config/Section.h2
2 files changed, 19 insertions, 0 deletions
diff --git a/Source/Core/Common/Config/Section.cpp b/Source/Core/Common/Config/Section.cpp
index 7db2c557ea..bb9fcef0e3 100644
--- a/Source/Core/Common/Config/Section.cpp
+++ b/Source/Core/Common/Config/Section.cpp
@@ -54,6 +54,11 @@ void Section::Set(const std::string& key, const std::string& value)
}
}
+void Section::Set(const std::string& key, u16 newValue)
+{
+ Section::Set(key, StringFromFormat("0x%04x", newValue));
+}
+
void Section::Set(const std::string& key, u32 newValue)
{
Section::Set(key, StringFromFormat("0x%08x", newValue));
@@ -124,6 +129,18 @@ bool Section::Get(const std::string& key, int* value, int defaultValue) const
return false;
}
+bool Section::Get(const std::string& key, u16* value, u16 defaultValue) const
+{
+ std::string temp;
+ bool retval = Get(key, &temp);
+
+ if (retval && TryParse(temp, value))
+ return true;
+
+ *value = defaultValue;
+ return false;
+}
+
bool Section::Get(const std::string& key, u32* value, u32 defaultValue) const
{
std::string temp;
diff --git a/Source/Core/Common/Config/Section.h b/Source/Core/Common/Config/Section.h
index 0a4662d156..948ebd67d4 100644
--- a/Source/Core/Common/Config/Section.h
+++ b/Source/Core/Common/Config/Section.h
@@ -35,6 +35,7 @@ public:
// Setters
virtual void Set(const std::string& key, const std::string& value);
+ void Set(const std::string& key, u16 newValue);
void Set(const std::string& key, u32 newValue);
void Set(const std::string& key, float newValue);
void Set(const std::string& key, double newValue);
@@ -57,6 +58,7 @@ public:
const std::string& default_value = NULL_STRING) const;
bool Get(const std::string& key, int* value, int defaultValue = 0) const;
+ bool Get(const std::string& key, u16* value, u16 defaultValue = 0) const;
bool Get(const std::string& key, u32* value, u32 defaultValue = 0) const;
bool Get(const std::string& key, bool* value, bool defaultValue = false) const;
bool Get(const std::string& key, float* value, float defaultValue = 0.0f) const;