summaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-08-26 16:57:05 +0300
committerAndrei Karas <akaras@inbox.ru>2011-08-27 05:37:27 +0300
commit12bf548533867a2eb3a1c354b778ef7f9157322a (patch)
tree3cb6f61396f00a5d3fa280ecd9d99f309f06f4ca /src/utils
parent2e7bfc350d38e16b3d340f8e4ea69e6ff6748f5c (diff)
downloadplus-12bf548533867a2eb3a1c354b778ef7f9157322a.tar.gz
plus-12bf548533867a2eb3a1c354b778ef7f9157322a.tar.bz2
plus-12bf548533867a2eb3a1c354b778ef7f9157322a.tar.xz
plus-12bf548533867a2eb3a1c354b778ef7f9157322a.zip
Basic support for guild bot integration.
Not working context menu actions, chat commands, auto complete.
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/stringutils.cpp54
-rw-r--r--src/utils/stringutils.h8
2 files changed, 62 insertions, 0 deletions
diff --git a/src/utils/stringutils.cpp b/src/utils/stringutils.cpp
index 0243c4315..317d88f2d 100644
--- a/src/utils/stringutils.cpp
+++ b/src/utils/stringutils.cpp
@@ -524,3 +524,57 @@ void deleteCharLeft(std::string &str, unsigned *pos)
break;
}
}
+
+bool findLast(std::string &str1, std::string str2)
+{
+ const unsigned s1 = str1.size();
+ const unsigned s2 = str2.size();
+ if (s1 < s2)
+ return false;
+ std::string tmp = str1.substr(s1 - s2);
+ if (tmp == str2)
+ return true;
+ return false;
+}
+
+bool findFirst(std::string &str1, std::string str2)
+{
+ const unsigned s1 = str1.size();
+ const unsigned s2 = str2.size();
+ if (s1 < s2)
+ return false;
+ std::string tmp = str1.substr(0, s2);
+ if (tmp == str2)
+ return true;
+ return false;
+}
+
+bool findCutLast(std::string &str1, std::string str2)
+{
+ const unsigned s1 = str1.size();
+ const unsigned s2 = str2.size();
+ if (s1 < s2)
+ return false;
+ std::string tmp = str1.substr(s1 - s2);
+ if (tmp == str2)
+ {
+ str1 = str1.substr(0, s1 - s2);
+ return true;
+ }
+ return false;
+}
+
+bool findCutFirst(std::string &str1, std::string str2)
+{
+ const unsigned s1 = str1.size();
+ const unsigned s2 = str2.size();
+ if (s1 < s2)
+ return false;
+ std::string tmp = str1.substr(0, s2);
+ if (tmp == str2)
+ {
+ str1 = str1.substr(s2);
+ return true;
+ }
+ return false;
+}
diff --git a/src/utils/stringutils.h b/src/utils/stringutils.h
index 4fe6369e9..25e038a89 100644
--- a/src/utils/stringutils.h
+++ b/src/utils/stringutils.h
@@ -193,4 +193,12 @@ std::string stringToHexPath(const std::string &str);
void deleteCharLeft(std::string &str, unsigned *pos);
+bool findLast(std::string &str1, std::string str2);
+
+bool findFirst(std::string &str1, std::string str2);
+
+bool findCutLast(std::string &str1, std::string str2);
+
+bool findCutFirst(std::string &str1, std::string str2);
+
#endif // UTILS_STRINGUTILS_H