mirror of
https://github.com/wiiu-env/launchiine.git
synced 2024-11-22 01:39:18 +01:00
Implemeting filterting of the game list
This commit is contained in:
parent
6e041490d6
commit
25a0aa54e7
@ -177,12 +177,11 @@ void GameList::updateTitleInfo() {
|
||||
void GameList::internalFilterList(std::vector<gameInfo*> &fullList) {
|
||||
for (uint32_t i = 0; i < fullList.size(); ++i) {
|
||||
gameInfo *header = fullList[i];
|
||||
|
||||
//! TODO: do filtering as needed
|
||||
|
||||
if (StringTools::findStringIC(header->name,gameFilter)) {
|
||||
filteredList.push_back(header);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int32_t GameList::filterList(const char * filter) {
|
||||
if(filter) {
|
||||
|
@ -209,3 +209,13 @@ std::vector<std::string> StringTools::stringSplit(const std::string & inValue, c
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool StringTools::findStringIC(const std::string & strHaystack, const std::string & strNeedle)
|
||||
{
|
||||
auto it = std::search(
|
||||
strHaystack.begin(), strHaystack.end(),
|
||||
strNeedle.begin(), strNeedle.end(),
|
||||
[](char ch1, char ch2) { return std::toupper(ch1) == std::toupper(ch2); }
|
||||
);
|
||||
return (it != strHaystack.end() );
|
||||
}
|
||||
|
@ -29,6 +29,8 @@
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <wut_types.h>
|
||||
#include <algorithm>
|
||||
#include <cctype>
|
||||
|
||||
class StringTools {
|
||||
public:
|
||||
@ -74,6 +76,9 @@ public:
|
||||
}
|
||||
|
||||
static std::vector<std::string> stringSplit(const std::string & value, const std::string & splitter);
|
||||
|
||||
// https://stackoverflow.com/a/19839371
|
||||
static bool findStringIC(const std::string & strHaystack, const std::string & strNeedle);
|
||||
};
|
||||
|
||||
#endif /* __STRING_TOOLS_H */
|
||||
|
Loading…
Reference in New Issue
Block a user