summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2011-01-13 15:02:23 +0100
committerYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2011-01-13 15:02:23 +0100
commit5f54ef36e27e13dd37e232eca74fd196f31e7807 (patch)
treed1595e4e29f8b60781a88543dc83fe8084e37161 /src
parentf53a1cf0ff67b5bc11de5e28bb2d76070b019e0f (diff)
downloadmana-5f54ef36e27e13dd37e232eca74fd196f31e7807.tar.gz
mana-5f54ef36e27e13dd37e232eca74fd196f31e7807.tar.bz2
mana-5f54ef36e27e13dd37e232eca74fd196f31e7807.tar.xz
mana-5f54ef36e27e13dd37e232eca74fd196f31e7807.zip
Moved the normalize() function in strungUtils where it belongs.
(Preparation for bringing a smaller item loading refactoring patch.) Trivial.
Diffstat (limited to 'src')
-rw-r--r--src/resources/itemdb.cpp10
-rw-r--r--src/utils/stringutils.cpp6
-rw-r--r--src/utils/stringutils.h11
3 files changed, 19 insertions, 8 deletions
diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp
index b167e956..019c66e3 100644
--- a/src/resources/itemdb.cpp
+++ b/src/resources/itemdb.cpp
@@ -75,12 +75,6 @@ static ItemType itemTypeFromString(const std::string &name, int id = 0)
else return ITEM_UNUSABLE;
}
-static std::string normalized(const std::string &name)
-{
- std::string normalized = name;
- return toLower(trim(normalized));;
-}
-
void ItemDB::load()
{
if (mLoaded)
@@ -275,7 +269,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())
@@ -354,7 +348,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 ca03791f..96b67370 100644
--- a/src/utils/stringutils.cpp
+++ b/src/utils/stringutils.cpp
@@ -223,3 +223,9 @@ std::string autocomplete(std::vector<std::string> &candidates,
return newName;
}
+
+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 f032733d..2c6fad78 100644
--- a/src/utils/stringutils.h
+++ b/src/utils/stringutils.h
@@ -120,6 +120,9 @@ std::string removeColors(std::string msg);
*/
int compareStrI(const std::string &a, const std::string &b);
+/**
+ * Tells wether the character is a word separator.
+ */
bool isWordSeparator(char chr);
const std::string findSameSubstring(const std::string &str1,
@@ -135,7 +138,15 @@ const char* getSafeUtf8String(std::string text);
*/
bool getBoolFromString(const std::string &text, bool def = false);
+/**
+ * Returns the most approaching string of base from candidates.
+ */
std::string autocomplete(std::vector<std::string> &candidates,
std::string base);
+/**
+ * Normalize a string, which means lowercase and trim it.
+ */
+std::string normalize(const std::string &name);
+
#endif // UTILS_STRINGUTILS_H