summaryrefslogtreecommitdiff
path: root/protocols/Twitter/src/StringUtil.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2015-03-31 16:42:07 +0000
committerGeorge Hazan <george.hazan@gmail.com>2015-03-31 16:42:07 +0000
commitd3a10049eee36dc0c451cbed542314a94f62ab3c (patch)
tree546ce7b3a217740e352cb74882ffee4afa0f1f93 /protocols/Twitter/src/StringUtil.cpp
parentbebfb51465b364d5673a3f555655213dbff0b2c6 (diff)
Twitter:
- unused module removed; - copyright update; - code cleaning git-svn-id: http://svn.miranda-ng.org/main/trunk@12575 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Twitter/src/StringUtil.cpp')
-rw-r--r--protocols/Twitter/src/StringUtil.cpp65
1 files changed, 21 insertions, 44 deletions
diff --git a/protocols/Twitter/src/StringUtil.cpp b/protocols/Twitter/src/StringUtil.cpp
index a395b67fa7..61cb9adbd2 100644
--- a/protocols/Twitter/src/StringUtil.cpp
+++ b/protocols/Twitter/src/StringUtil.cpp
@@ -29,27 +29,18 @@ void Split(const tstring& str, std::vector<tstring>& out, TCHAR sep, bool includ
unsigned start = 0;
unsigned end = 0;
- while(true)
- {
- if(end == str.size() || str[end] == sep)
- {
- if(end > start || includeEmpty)
- {
+ while (true) {
+ if (end == str.size() || str[end] == sep) {
+ if (end > start || includeEmpty)
out.push_back(str.substr(start, end - start));
- }
- if(end == str.size())
- {
+ if (end == str.size())
break;
- }
++end;
start = end;
}
- else
- {
- ++end;
- }
+ else ++end;
}
}
@@ -60,38 +51,25 @@ tstring GetWord(const tstring& str, unsigned index, bool getRest)
unsigned count = 0;
- while(true)
- {
- if(end == str.size() || str[end] == _T(' '))
- {
- if(end > start)
- {
- if(count == index)
- {
- if(getRest)
- {
+ while (true) {
+ if (end == str.size() || str[end] == _T(' ')) {
+ if (end > start) {
+ if (count == index) {
+ if (getRest)
return str.substr(start);
- }
- else
- {
- return str.substr(start, end - start);
- }
+
+ return str.substr(start, end - start);
}
++count;
}
- if(end == str.size())
- {
+ if (end == str.size())
break;
- }
++end;
start = end;
}
- else
- {
- ++end;
- }
+ else ++end;
}
return _T("");
}
@@ -100,12 +78,11 @@ tstring GetWord(const tstring& str, unsigned index, bool getRest)
// within the string with "to". returns the pointer to the string which is kinda silly IMO
std::string& replaceAll(std::string& context, const std::string& from, const std::string& to)
{
- size_t lookHere = 0;
- size_t foundHere;
- while((foundHere = context.find(from, lookHere)) != std::string::npos)
- {
- context.replace(foundHere, from.size(), to);
- lookHere = foundHere + to.size();
- }
- return context;
+ size_t lookHere = 0;
+ size_t foundHere;
+ while ((foundHere = context.find(from, lookHere)) != std::string::npos) {
+ context.replace(foundHere, from.size(), to);
+ lookHere = foundHere + to.size();
+ }
+ return context;
}