summaryrefslogtreecommitdiff
path: root/src/client/Client.cpp
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2012-08-05 17:35:12 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2012-08-05 17:35:12 (GMT)
commit4ce22e4e7705224a9b4c1b9bfa8886de0029a3e3 (patch)
treed9c02db57d9a20709758d7b771ee60ea9cbe4e88 /src/client/Client.cpp
parent30f8049efc6efc086509d235df413e4932dab83e (diff)
downloadpowder-4ce22e4e7705224a9b4c1b9bfa8886de0029a3e3.zip
powder-4ce22e4e7705224a9b4c1b9bfa8886de0029a3e3.tar.gz
Wall Edge option, fixes #70
Diffstat (limited to 'src/client/Client.cpp')
-rw-r--r--src/client/Client.cpp84
1 files changed, 84 insertions, 0 deletions
diff --git a/src/client/Client.cpp b/src/client/Client.cpp
index 5d1e439..64abe0e 100644
--- a/src/client/Client.cpp
+++ b/src/client/Client.cpp
@@ -1692,6 +1692,34 @@ int Client::GetPrefInteger(std::string property, int defaultValue)
return defaultValue;
}
+unsigned int Client::GetPrefUInteger(std::string property, unsigned int defaultValue)
+{
+ try
+ {
+ std::stringstream defHexInt;
+ defHexInt << std::hex << defaultValue;
+
+ std::string hexString = GetPrefString(property, defHexInt.str());
+ unsigned int finalValue = defaultValue;
+
+ std::stringstream hexInt;
+ hexInt << hexString;
+
+ hexInt >> std::hex >> finalValue;
+
+ return finalValue;
+ }
+ catch (json::Exception & e)
+ {
+
+ }
+ catch(exception & e)
+ {
+
+ }
+ return defaultValue;
+}
+
vector<string> Client::GetPrefStringArray(std::string property)
{
try
@@ -1780,6 +1808,40 @@ vector<int> Client::GetPrefIntegerArray(std::string property)
return vector<int>();
}
+vector<unsigned int> Client::GetPrefUIntegerArray(std::string property)
+{
+ try
+ {
+ json::Array value = GetPref(property);
+ vector<unsigned int> intArray;
+ for(json::Array::iterator iter = value.Begin(); iter != value.End(); ++iter)
+ {
+ try
+ {
+ json::String cValue = *iter;
+ unsigned int finalValue = 0;
+
+ std::string hexString = cValue.Value();
+ std::stringstream hexInt;
+ hexInt << std::hex << hexString;
+ hexInt >> finalValue;
+
+ intArray.push_back(finalValue);
+ }
+ catch (json::Exception & e)
+ {
+
+ }
+ }
+ return intArray;
+ }
+ catch (json::Exception & e)
+ {
+
+ }
+ return vector<unsigned int>();
+}
+
vector<bool> Client::GetPrefBoolArray(std::string property)
{
try
@@ -1841,6 +1903,14 @@ void Client::SetPref(std::string property, int value)
SetPref(property, intValue);
}
+void Client::SetPref(std::string property, unsigned int value)
+{
+ std::stringstream hexInt;
+ hexInt << std::hex << value;
+ json::UnknownElement intValue = json::String(hexInt.str());
+ SetPref(property, intValue);
+}
+
void Client::SetPref(std::string property, vector<string> value)
{
json::Array newArray;
@@ -1888,6 +1958,20 @@ void Client::SetPref(std::string property, vector<int> value)
SetPref(property, newArrayValue);
}
+void Client::SetPref(std::string property, vector<unsigned int> value)
+{
+ json::Array newArray;
+ for(vector<unsigned int>::iterator iter = value.begin(); iter != value.end(); ++iter)
+ {
+ std::stringstream hexInt;
+ hexInt << std::hex << *iter;
+
+ newArray.Insert(json::String(hexInt.str()));
+ }
+ json::UnknownElement newArrayValue = newArray;
+ SetPref(property, newArrayValue);
+}
+
void Client::SetPref(std::string property, bool value)
{
json::UnknownElement boolValue = json::Boolean(value);