diff options
Diffstat (limited to 'Swiften')
-rw-r--r-- | Swiften/Base/String.cpp | 6 | ||||
-rw-r--r-- | Swiften/Base/String.h | 16 |
2 files changed, 9 insertions, 13 deletions
diff --git a/Swiften/Base/String.cpp b/Swiften/Base/String.cpp index f549e6e..17d49c2 100644 --- a/Swiften/Base/String.cpp +++ b/Swiften/Base/String.cpp @@ -96,12 +96,6 @@ void String::replaceAll(char c, const String& s) { } } -String String::getLowerCase() const { - std::string lower(data_); - std::transform(lower.begin(), lower.end(), lower.begin(), ::tolower); - return String(lower); -} - std::vector<String> String::split(char c) const { assert((c & 0x80) == 0); std::vector<String> result; diff --git a/Swiften/Base/String.h b/Swiften/Base/String.h index b05edba..c87d82b 100644 --- a/Swiften/Base/String.h +++ b/Swiften/Base/String.h @@ -4,8 +4,9 @@ * See Documentation/Licenses/GPLv3.txt for more information. */ -#ifndef SWIFTEN_STRING_H -#define SWIFTEN_STRING_H +#pragma once + +#include <boost/algorithm/string.hpp> #include <ostream> #include <string> @@ -48,7 +49,10 @@ namespace Swift { std::vector<String> split(char c) const; size_t getLength() const; - String getLowerCase() const; + + String getLowerCase() const { + return boost::to_lower_copy(data_); + } void removeAll(char c); @@ -59,7 +63,7 @@ namespace Swift { } bool beginsWith(const String& s) const { - return data_.substr(0, s.data_.size()) == s; + return boost::starts_with(data_, s.data_); } bool endsWith(char c) const { @@ -67,7 +71,7 @@ namespace Swift { } bool endsWith(const String& s) const { - return data_.substr(data_.size() - s.data_.size(), data_.npos) == s; + return boost::ends_with(data_, s.data_); } String getSubstring(size_t begin, size_t end) const { @@ -139,5 +143,3 @@ namespace Swift { std::string data_; }; } - -#endif |