diff options
author | Andrei Karas <akaras@inbox.ru> | 2009-10-31 15:42:28 +0200 |
---|---|---|
committer | Blue <bluesansdouze@gmail.com> | 2010-01-07 23:12:10 +0100 |
commit | be5460f2a294bb8e50b40f498f29a556b31bedd7 (patch) | |
tree | 5256167e0b8487fdb2c49090986cc883614fb9b1 /src/utils | |
parent | 84da747711ed1713984ca514a8bb786219a85d9b (diff) | |
download | mana-be5460f2a294bb8e50b40f498f29a556b31bedd7.tar.gz mana-be5460f2a294bb8e50b40f498f29a556b31bedd7.tar.bz2 mana-be5460f2a294bb8e50b40f498f29a556b31bedd7.tar.xz mana-be5460f2a294bb8e50b40f498f29a556b31bedd7.zip |
Chat auto completing
Diffstat (limited to 'src/utils')
-rw-r--r-- | src/utils/stringutils.cpp | 18 | ||||
-rw-r--r-- | src/utils/stringutils.h | 4 |
2 files changed, 22 insertions, 0 deletions
diff --git a/src/utils/stringutils.cpp b/src/utils/stringutils.cpp index 67a0d831..6727dcdf 100644 --- a/src/utils/stringutils.cpp +++ b/src/utils/stringutils.cpp @@ -140,3 +140,21 @@ int compareStrI(const std::string &a, const std::string &b) return 0; } + +bool isWordSeparator(char chr) +{ + return (chr == ' ' || chr == ',' || chr == '.'); +} + +const std::string findSameSubstring(std::string &str1, std::string &str2) +{ + int minLength = str1.length() > str2.length() ? str2.length() : str1.length(); + for (int f = 0; f < minLength; f ++) + { + if (str1.at(f) != str2.at(f)) + { + return str1.substr(0, f); + } + } + return str1.substr(0, minLength); +} diff --git a/src/utils/stringutils.h b/src/utils/stringutils.h index 3624268f..4f0138de 100644 --- a/src/utils/stringutils.h +++ b/src/utils/stringutils.h @@ -119,4 +119,8 @@ std::string removeColors(std::string msg); */ int compareStrI(const std::string &a, const std::string &b); +bool isWordSeparator(char chr); + +const std::string findSameSubstring(std::string &str1, std::string &str2); + #endif // UTILS_STRINGUTILS_H |