diff options
author | Remko Tronçon <git@el-tramo.be> | 2011-02-13 10:13:40 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2011-02-13 10:37:59 (GMT) |
commit | 6872dd34f88b08568a4784fe46373a0af0b69165 (patch) | |
tree | d14eddb94afbfedb045510ba2d455d110d19b71f /Swiften/Base/String.h | |
parent | b734b6a5986703b6b10ea548c93af11f9df771bf (diff) | |
download | swift-contrib-6872dd34f88b08568a4784fe46373a0af0b69165.zip swift-contrib-6872dd34f88b08568a4784fe46373a0af0b69165.tar.bz2 |
Use boost string algorithms.
Diffstat (limited to 'Swiften/Base/String.h')
-rw-r--r-- | Swiften/Base/String.h | 16 |
1 files changed, 9 insertions, 7 deletions
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 |