summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2011-02-14 18:57:18 (GMT)
committerRemko Tronçon <git@el-tramo.be>2011-02-14 21:36:32 (GMT)
commitcb05f5a908e20006c954ce38755c2e422ecc2388 (patch)
treea793551a5fe279a57d4330119560e8542f745484 /Swiften/Base/String.h
parentcad974b45c0fb9355e68d9728e42c9ae3dbcebc7 (diff)
downloadswift-cb05f5a908e20006c954ce38755c2e422ecc2388.zip
swift-cb05f5a908e20006c954ce38755c2e422ecc2388.tar.bz2
Removed Swift::String.
Diffstat (limited to 'Swiften/Base/String.h')
-rw-r--r--Swiften/Base/String.h139
1 files changed, 11 insertions, 128 deletions
diff --git a/Swiften/Base/String.h b/Swiften/Base/String.h
index 7d2f928..192d53b 100644
--- a/Swiften/Base/String.h
+++ b/Swiften/Base/String.h
@@ -6,141 +6,24 @@
#pragma once
-#include <boost/algorithm/string.hpp>
-
-#include <ostream>
+#include <map>
#include <string>
-#include <utility>
#include <vector>
-#include <cassert>
-#include <algorithm>
#define SWIFTEN_STRING_TO_CFSTRING(a) \
- CFStringCreateWithBytes(NULL, reinterpret_cast<const UInt8*>(a.getUTF8Data()), a.getUTF8Size(), kCFStringEncodingUTF8, false)
+ CFStringCreateWithBytes(NULL, reinterpret_cast<const UInt8*>(a.c_str()), a.size(), kCFStringEncodingUTF8, false)
namespace Swift {
- class ByteArray;
-
- class String {
- friend class ByteArray;
-
- public:
- String() {}
- String(const char* data) : data_(data) {}
- String(const char* data, size_t len) : data_(data, len) {}
- String(const std::string& data) : data_(data) {}
-
- bool isEmpty() const { return data_.empty(); }
-
- const char* getUTF8Data() const { return data_.c_str(); }
- const std::string& getUTF8String() const { return data_; }
- std::string& getUTF8String() { return data_; }
- size_t getUTF8Size() const { return data_.size(); }
- std::vector<unsigned int> getUnicodeCodePoints() const;
-
- void clear() { data_.clear(); }
-
- /**
- * Returns the part before and after 'c'.
- * If the given splitter does not occur in the string, the second
- * component is the empty string.
- */
- std::pair<String,String> getSplittedAtFirst(char c) const;
-
- std::vector<String> split(char c) const;
-
- String getLowerCase() const {
- return boost::to_lower_copy(data_);
- }
-
- void removeAll(char c) {
- data_.erase(std::remove(data_.begin(), data_.end(), c), data_.end());
- }
-
- void replaceAll(char c, const String& s);
-
- bool beginsWith(char c) const {
- return data_.size() > 0 && data_[0] == c;
- }
-
- bool beginsWith(const String& s) const {
- return boost::starts_with(data_, s.data_);
- }
-
- bool endsWith(char c) const {
- return data_.size() > 0 && data_[data_.size()-1] == c;
- }
-
- bool endsWith(const String& s) const {
- return boost::ends_with(data_, s.data_);
- }
-
- String getSubstring(size_t begin, size_t end) const {
- return String(data_.substr(begin, end));
- }
-
- size_t find(char c) const {
- assert((c & 0x80) == 0);
- return data_.find(c);
- }
-
- size_t npos() const {
- return data_.npos;
- }
-
- friend String operator+(const String& a, const String& b) {
- return String(a.data_ + b.data_);
+ namespace String {
+ std::vector<unsigned int> getUnicodeCodePoints(const std::string&);
+ std::pair<std::string, std::string> getSplittedAtFirst(const std::string&, char c);
+ std::vector<std::string> split(const std::string&, char c);
+ void replaceAll(std::string&, char c, const std::string& s);
+ inline bool beginsWith(const std::string& s, char c) {
+ return s.size() > 0 && s[0] == c;
}
-
- friend String operator+(const String& a, char b) {
- return String(a.data_ + b);
+ inline bool endsWith(const std::string& s, char c) {
+ return s.size() > 0 && s[s.size()-1] == c;
}
-
- String& operator+=(const String& o) {
- data_ += o.data_;
- return *this;
- }
-
- String& operator+=(char c) {
- data_ += c;
- return *this;
- }
-
- String& operator=(const String& o) {
- data_ = o.data_;
- return *this;
- }
-
- bool contains(const String& o) {
- return data_.find(o.data_) != std::string::npos;
- }
-
- char operator[](size_t i) const {
- return data_[i];
- }
-
- friend bool operator>(const String& a, const String& b) {
- return a.data_ > b.data_;
- }
-
- friend bool operator<(const String& a, const String& b) {
- return a.data_ < b.data_;
- }
-
- friend bool operator!=(const String& a, const String& b) {
- return a.data_ != b.data_;
- }
-
- friend bool operator==(const String& a, const String& b) {
- return a.data_ == b.data_;
- }
-
- friend std::ostream& operator<<(std::ostream& os, const String& s) {
- os << s.data_;
- return os;
- }
-
- private:
- std::string data_;
};
}