summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2011-02-13 10:13:40 (GMT)
committerRemko Tronçon <git@el-tramo.be>2011-02-13 10:37:59 (GMT)
commit6872dd34f88b08568a4784fe46373a0af0b69165 (patch)
treed14eddb94afbfedb045510ba2d455d110d19b71f /Swiften
parentb734b6a5986703b6b10ea548c93af11f9df771bf (diff)
downloadswift-6872dd34f88b08568a4784fe46373a0af0b69165.zip
swift-6872dd34f88b08568a4784fe46373a0af0b69165.tar.bz2
Use boost string algorithms.
Diffstat (limited to 'Swiften')
-rw-r--r--Swiften/Base/String.cpp6
-rw-r--r--Swiften/Base/String.h16
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