ui: sorting search results
* search results are sorted by: score > length > name * fixed crash that occurred when trying to get a node by id with id == 0
This commit is contained in:
@@ -133,6 +133,22 @@ namespace utility
|
||||
return text.size() >= postfix.size() && text.rfind(postfix) == (text.size() - postfix.size());
|
||||
}
|
||||
|
||||
std::string switchCases(std::string s)
|
||||
{
|
||||
for (char& c: s)
|
||||
{
|
||||
if (islower(c))
|
||||
{
|
||||
c = toupper(c);
|
||||
}
|
||||
else if (isupper(c))
|
||||
{
|
||||
c = tolower(c);
|
||||
}
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
std::string toUpperCase(const std::string& in)
|
||||
{
|
||||
std::string out;
|
||||
|
||||
@@ -37,6 +37,7 @@ namespace utility
|
||||
bool isPrefix(const std::string& prefix, const std::string& text);
|
||||
bool isPostfix(const std::string& postfix, const std::string& text);
|
||||
|
||||
std::string switchCases(std::string s);
|
||||
std::string toUpperCase(const std::string& in);
|
||||
std::string toLowerCase(const std::string& in);
|
||||
bool equalsCaseInsensitive(const std::string& a, const std::string& b);
|
||||
|
||||
Reference in New Issue
Block a user