diff --git a/apps/openmw/mwgui/settingswindow.cpp b/apps/openmw/mwgui/settingswindow.cpp index ed0bf72771..c8c97d1796 100644 --- a/apps/openmw/mwgui/settingswindow.cpp +++ b/apps/openmw/mwgui/settingswindow.cpp @@ -1,5 +1,4 @@ #include "settingswindow.hpp" -#include "weightedsearch.hpp" #include #include @@ -43,6 +42,7 @@ #include "../mwlua/luamanagerimp.hpp" #include "confirmationdialog.hpp" +#include "weightedsearch.hpp" namespace { @@ -942,28 +942,6 @@ namespace MWGui mControlsBox->setVisibleVScroll(true); } - std::vector generatePatternArray(const MyGUI::UString& inputString) - { - if (inputString.empty() || inputString.find_first_not_of(" ") == std::string::npos) - return std::vector(); - std::string inputStringLowerCase = Misc::StringUtils::lowerCase(inputString); - std::istringstream stringStream(inputStringLowerCase); - return { std::istream_iterator(stringStream), std::istream_iterator() }; - } - size_t weightedSearch(const std::string& corpus, const std::vector& patternArray) - { - if (patternArray.empty()) - return 1; - - std::string corpusLowerCase = Misc::StringUtils::lowerCase(corpus); - - size_t numberOfMatches = 0; - for (const std::string& word : patternArray) - numberOfMatches += corpusLowerCase.find(word) != std::string::npos ? 1 : 0; - - return numberOfMatches; - } - void SettingsWindow::renderScriptSettings() { mScriptAdapter->detach(); diff --git a/apps/openmw/mwgui/weightedsearch.hpp b/apps/openmw/mwgui/weightedsearch.hpp index 5db23f1e0b..2f88f474d7 100644 --- a/apps/openmw/mwgui/weightedsearch.hpp +++ b/apps/openmw/mwgui/weightedsearch.hpp @@ -1,15 +1,39 @@ #ifndef MWGUI_WEIGHTEDSEARCH_H #define MWGUI_WEIGHTEDSEARCH_H +#include +#include +#include #include #include #include +#include + namespace MWGui { - std::vector generatePatternArray(const MyGUI::UString& inputString); - std::size_t weightedSearch(const std::string& corpus, const std::vector& patternArray); + std::vector generatePatternArray(const MyGUI::UString& inputString) + { + if (inputString.empty() || inputString.find_first_not_of(" ") == std::string::npos) + return std::vector(); + std::string inputStringLowerCase = Misc::StringUtils::lowerCase(inputString); + std::istringstream stringStream(inputStringLowerCase); + return { std::istream_iterator(stringStream), std::istream_iterator() }; + } + std::size_t weightedSearch(const std::string& corpus, const std::vector& patternArray) + { + if (patternArray.empty()) + return 1; + + std::string corpusLowerCase = Misc::StringUtils::lowerCase(corpus); + + std::size_t numberOfMatches = 0; + for (const std::string& word : patternArray) + numberOfMatches += corpusLowerCase.find(word) != std::string::npos ? 1 : 0; + + return numberOfMatches; + } } #endif