summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Base/String.cpp')
-rw-r--r--Swiften/Base/String.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/Swiften/Base/String.cpp b/Swiften/Base/String.cpp
index 3495d9a..cc989f6 100644
--- a/Swiften/Base/String.cpp
+++ b/Swiften/Base/String.cpp
@@ -96,4 +96,21 @@ String String::getLowerCase() const {
return String(lower);
}
+std::vector<String> String::split(char c) const {
+ assert((c & 0x80) == 0);
+ std::vector<String> result;
+ String accumulator;
+ for (size_t i = 0; i < data_.size(); ++i) {
+ if (data_[i] == c) {
+ result.push_back(accumulator);
+ accumulator = "";
+ }
+ else {
+ accumulator += data_[i];
+ }
+ }
+ result.push_back(accumulator);
+ return result;
+}
+
}