diff options
author | Robert Pösel <robyer@seznam.cz> | 2015-10-19 20:11:55 +0000 |
---|---|---|
committer | Robert Pösel <robyer@seznam.cz> | 2015-10-19 20:11:55 +0000 |
commit | d16d69e7b86095c1493f4a7062751768c31a58fc (patch) | |
tree | f6396cd0a81bca933763ce4e90305be62128589b /protocols/Omegle/src/utils.cpp | |
parent | 3b8beab406e3e93c0c007a8291393bc491669b99 (diff) |
Omegle: Various improvements
* Remove typing weirdness
* Fix resetting "stranger is typing" on receiving message
* Make option "hi message" choose randomly from more messages
git-svn-id: http://svn.miranda-ng.org/main/trunk@15571 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Omegle/src/utils.cpp')
-rw-r--r-- | protocols/Omegle/src/utils.cpp | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/protocols/Omegle/src/utils.cpp b/protocols/Omegle/src/utils.cpp index 86db3feec1..0e5b4b2153 100644 --- a/protocols/Omegle/src/utils.cpp +++ b/protocols/Omegle/src/utils.cpp @@ -108,13 +108,29 @@ std::string utils::text::slashu_to_utf8(const std::string &data ) return new_string;
}
-std::string utils::text::trim(const std::string &data )
+std::string utils::text::trim(const std::string &data)
{
std::string spaces = " \t\r\n";
- std::string::size_type begin = data.find_first_not_of( spaces );
- std::string::size_type end = data.find_last_not_of( spaces ) + 1;
+ std::string::size_type begin = data.find_first_not_of(spaces);
+ std::string::size_type end = data.find_last_not_of(spaces);
- return (begin != std::string::npos) ? data.substr( begin, end - begin ) : "";
+ return (end != std::string::npos) ? data.substr(begin, end + 1 - begin) : "";
+}
+
+void utils::text::explode(std::string str, std::string separator, std::vector<std::string>* results)
+{
+ std::string::size_type pos;
+ pos = str.find_first_of(separator);
+ while (pos != std::string::npos) {
+ if (pos > 0) {
+ results->push_back(str.substr(0, pos));
+ }
+ str = str.substr(pos + 1);
+ pos = str.find_first_of(separator);
+ }
+ if (str.length() > 0) {
+ results->push_back(str);
+ }
}
int utils::debug::log(const std::string &file_name, const std::string &text)
|