|
|
@ -2,7 +2,7 @@
|
|
|
|
#define GAME_MWDIALOGUE_KEYWORDSEARCH_H
|
|
|
|
#define GAME_MWDIALOGUE_KEYWORDSEARCH_H
|
|
|
|
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
#include <map>
|
|
|
|
#include <locale>
|
|
|
|
#include <cctype>
|
|
|
|
#include <stdexcept>
|
|
|
|
#include <stdexcept>
|
|
|
|
#include <vector>
|
|
|
|
#include <vector>
|
|
|
|
#include <algorithm> // std::reverse
|
|
|
|
#include <algorithm> // std::reverse
|
|
|
@ -44,7 +44,7 @@ public:
|
|
|
|
typename Entry::childen_t::iterator current;
|
|
|
|
typename Entry::childen_t::iterator current;
|
|
|
|
typename Entry::childen_t::iterator next;
|
|
|
|
typename Entry::childen_t::iterator next;
|
|
|
|
|
|
|
|
|
|
|
|
current = mRoot.mChildren.find (std::tolower (*keyword.begin(), mLocale));
|
|
|
|
current = mRoot.mChildren.find (tolower (*keyword.begin()));
|
|
|
|
if (current == mRoot.mChildren.end())
|
|
|
|
if (current == mRoot.mChildren.end())
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
else if (current->second.mKeyword.size() && Misc::StringUtils::ciEqual(current->second.mKeyword, keyword))
|
|
|
|
else if (current->second.mKeyword.size() && Misc::StringUtils::ciEqual(current->second.mKeyword, keyword))
|
|
|
@ -55,7 +55,7 @@ public:
|
|
|
|
|
|
|
|
|
|
|
|
for (Point i = ++keyword.begin(); i != keyword.end(); ++i)
|
|
|
|
for (Point i = ++keyword.begin(); i != keyword.end(); ++i)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
next = current->second.mChildren.find(std::tolower (*i, mLocale));
|
|
|
|
next = current->second.mChildren.find(tolower (*i));
|
|
|
|
if (next == current->second.mChildren.end())
|
|
|
|
if (next == current->second.mChildren.end())
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
if (Misc::StringUtils::ciEqual(next->second.mKeyword, keyword))
|
|
|
|
if (Misc::StringUtils::ciEqual(next->second.mKeyword, keyword))
|
|
|
@ -89,7 +89,7 @@ public:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// check first character
|
|
|
|
// check first character
|
|
|
|
typename Entry::childen_t::iterator candidate = mRoot.mChildren.find (std::tolower (*i, mLocale));
|
|
|
|
typename Entry::childen_t::iterator candidate = mRoot.mChildren.find (tolower (*i));
|
|
|
|
|
|
|
|
|
|
|
|
// no match, on to next character
|
|
|
|
// no match, on to next character
|
|
|
|
if (candidate == mRoot.mChildren.end ())
|
|
|
|
if (candidate == mRoot.mChildren.end ())
|
|
|
@ -104,7 +104,7 @@ public:
|
|
|
|
|
|
|
|
|
|
|
|
while ((j + 1) != end)
|
|
|
|
while ((j + 1) != end)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
typename Entry::childen_t::iterator next = candidate->second.mChildren.find (std::tolower (*++j, mLocale));
|
|
|
|
typename Entry::childen_t::iterator next = candidate->second.mChildren.find (tolower (*++j));
|
|
|
|
|
|
|
|
|
|
|
|
if (next == candidate->second.mChildren.end ())
|
|
|
|
if (next == candidate->second.mChildren.end ())
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -136,7 +136,7 @@ public:
|
|
|
|
|
|
|
|
|
|
|
|
while (k != end && t != candidate->second.mKeyword.end ())
|
|
|
|
while (k != end && t != candidate->second.mKeyword.end ())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (std::tolower (*k, mLocale) != std::tolower (*t, mLocale))
|
|
|
|
if (tolower (*k) != tolower (*t))
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
++k, ++t;
|
|
|
|
++k, ++t;
|
|
|
@ -212,7 +212,7 @@ private:
|
|
|
|
|
|
|
|
|
|
|
|
void seed_impl (string_t keyword, value_t value, size_t depth, Entry & entry)
|
|
|
|
void seed_impl (string_t keyword, value_t value, size_t depth, Entry & entry)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int ch = tolower (keyword.at (depth), mLocale);
|
|
|
|
int ch = tolower (keyword.at (depth));
|
|
|
|
|
|
|
|
|
|
|
|
typename Entry::childen_t::iterator j = entry.mChildren.find (ch);
|
|
|
|
typename Entry::childen_t::iterator j = entry.mChildren.find (ch);
|
|
|
|
|
|
|
|
|
|
|
@ -249,7 +249,6 @@ private:
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Entry mRoot;
|
|
|
|
Entry mRoot;
|
|
|
|
std::locale mLocale;
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|