diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-12-01 22:58:51 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-12-01 23:00:32 +0300 |
commit | edab962f4183b599c4c7c5beb75947589443ccca (patch) | |
tree | b57644fb6da0a03ade25247624538e6b0b59d327 /src/utils/stringutils.cpp | |
parent | 1a21baa93fd555e25b95732590282ba9a63dea86 (diff) | |
download | plus-edab962f4183b599c4c7c5beb75947589443ccca.tar.gz plus-edab962f4183b599c4c7c5beb75947589443ccca.tar.bz2 plus-edab962f4183b599c4c7c5beb75947589443ccca.tar.xz plus-edab962f4183b599c4c7c5beb75947589443ccca.zip |
Add string cut functions.
Diffstat (limited to 'src/utils/stringutils.cpp')
-rw-r--r-- | src/utils/stringutils.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/utils/stringutils.cpp b/src/utils/stringutils.cpp index 864f509fc..ee6b6fb07 100644 --- a/src/utils/stringutils.cpp +++ b/src/utils/stringutils.cpp @@ -638,6 +638,16 @@ bool findCutLast(std::string &restrict str1, const std::string &restrict str2) return false; } +void cutLast(std::string &restrict str1, const std::string &restrict str2) +{ + const size_t s1 = str1.size(); + const size_t s2 = str2.size(); + if (s1 < s2) + return; + if (str1.substr(s1 - s2) == str2) + str1 = str1.substr(0, s1 - s2); +} + bool findCutFirst(std::string &restrict str1, const std::string &restrict str2) { const size_t s1 = str1.size(); @@ -652,6 +662,16 @@ bool findCutFirst(std::string &restrict str1, const std::string &restrict str2) return false; } +void cutFirst(std::string &restrict str1, const std::string &restrict str2) +{ + const size_t s1 = str1.size(); + const size_t s2 = str2.size(); + if (s1 < s2) + return; + if (str1.substr(0, s2) == str2) + str1 = str1.substr(s2); +} + std::string &removeProtocol(std::string &url) { const size_t i = url.find("://"); |