summaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/stringutils.cpp6
-rw-r--r--src/utils/stringutils.h11
2 files changed, 17 insertions, 0 deletions
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