summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/resources/itemdb.cpp10
-rw-r--r--src/utils/stringutils.cpp8
-rw-r--r--src/utils/stringutils.h12
3 files changed, 19 insertions, 11 deletions
diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp
index 49ba7bd9e..3f17c22ad 100644
--- a/src/resources/itemdb.cpp
+++ b/src/resources/itemdb.cpp
@@ -140,12 +140,6 @@ static ItemType itemTypeFromString(const std::string &name)
}
}
-static std::string normalized(const std::string &name)
-{
- std::string normalized = name;
- return toLower(trim(normalized));
-}
-
void ItemDB::load()
{
if (mLoaded)
@@ -315,7 +309,7 @@ void ItemDB::load()
mItemInfos[id] = itemInfo;
if (!name.empty())
{
- std::string temp = normalized(name);
+ std::string temp = normalize(name);
NamedItemInfos::const_iterator itr = mNamedItemInfos.find(temp);
if (itr == mNamedItemInfos.end())
@@ -413,7 +407,7 @@ const ItemInfo &ItemDB::get(const std::string &name)
{
assert(mLoaded);
- NamedItemInfos::const_iterator i = mNamedItemInfos.find(normalized(name));
+ NamedItemInfos::const_iterator i = mNamedItemInfos.find(normalize(name));
if (i == mNamedItemInfos.end())
{
diff --git a/src/utils/stringutils.cpp b/src/utils/stringutils.cpp
index e69b03937..f2cbea050 100644
--- a/src/utils/stringutils.cpp
+++ b/src/utils/stringutils.cpp
@@ -357,4 +357,10 @@ void replaceSpecialChars(std::string &text)
pos1 = text.find("&", pos1);
}
-} \ No newline at end of file
+}
+
+std::string normalize(const std::string &name)
+{
+ std::string normalized = name;
+ return toLower(trim(normalized));;
+}
diff --git a/src/utils/stringutils.h b/src/utils/stringutils.h
index 4532a5b00..15d41380f 100644
--- a/src/utils/stringutils.h
+++ b/src/utils/stringutils.h
@@ -110,8 +110,6 @@ std::string &removeBadChars(std::string &str);
*/
std::string removeColors(std::string msg);
-bool isWordSeparator(char chr);
-
const std::string findSameSubstring(const std::string &str1,
const std::string &str2);
@@ -125,6 +123,11 @@ const std::string findSameSubstring(const std::string &str1,
*/
int compareStrI(const std::string &a, const std::string &b);
+/**
+ * Tells wether the character is a word separator.
+ */
+bool isWordSeparator(char chr);
+
unsigned long findI(std::string str, std::string subStr);
unsigned long findI(std::string str, std::list<std::string> &list);
@@ -156,4 +159,9 @@ bool getBoolFromString(const std::string &text);
void replaceSpecialChars(std::string &text);
+/**
+ * Normalize a string, which means lowercase and trim it.
+ */
+std::string normalize(const std::string &name);
+
#endif // UTILS_STRINGUTILS_H