summaryrefslogtreecommitdiff
path: root/src/utils/stringutils.cpp
diff options
context:
space:
mode:
authorTametomo <irarice@gmail.com>2009-04-20 07:44:26 -0600
committerBjørn Lindeijer <bjorn@lindeijer.nl>2009-04-29 19:56:01 +0200
commit377880eca6d9d0cace2c43a12a131b67661192d3 (patch)
tree842689993d011295f6efbfa36be7cfe28a8317b4 /src/utils/stringutils.cpp
parent461cf5d1ce4cecfaaa6cef45cb5ba0955c16ca41 (diff)
downloadmana-client-377880eca6d9d0cace2c43a12a131b67661192d3.tar.gz
mana-client-377880eca6d9d0cace2c43a12a131b67661192d3.tar.bz2
mana-client-377880eca6d9d0cace2c43a12a131b67661192d3.tar.xz
mana-client-377880eca6d9d0cace2c43a12a131b67661192d3.zip
Changed palette colors to be once again stored in a human readable
format once again. This was originally reverted because it caused a regression on Windows, but not Linux, which was later found out to be because there's a Linux kernel function which will convert hex strings into an integer format, while Windows doesn't share the same luxury. So, to avoid any issues, this commit adds an atox (ascii to hex) string utility, and uses it when parsing hex strings for colors from the configuration file. Also ensured that people who have colors saved in the old, raw integer format can get their colors converted to hex values. Signed-off-by: Tametomo <irarice@gmail.com> Signed-off-by: Bjørn Lindeijer <bjorn@lindeijer.nl>
Diffstat (limited to 'src/utils/stringutils.cpp')
-rw-r--r--src/utils/stringutils.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/utils/stringutils.cpp b/src/utils/stringutils.cpp
index 2f9bc9a8..57a0131e 100644
--- a/src/utils/stringutils.cpp
+++ b/src/utils/stringutils.cpp
@@ -30,10 +30,9 @@ std::string &trim(std::string &str)
{
str.erase(pos + 1);
pos = str.find_first_not_of(' ');
+
if (pos != std::string::npos)
- {
str.erase(0, pos);
- }
}
else
{
@@ -49,6 +48,14 @@ std::string &toLower(std::string &str)
return str;
}
+unsigned int atox(const std::string &str)
+{
+ unsigned int value;
+ sscanf(str.c_str(), "0x%06x", &value);
+
+ return value;
+}
+
const char *ipToString(int address)
{
static char asciiIP[16];