diff options
author | Remko Tronçon <git@el-tramo.be> | 2011-06-03 12:25:57 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2011-06-03 12:46:12 (GMT) |
commit | 21fda3308975201eeebeacd98e2b587ef4448862 (patch) | |
tree | e8aebe473a636cf5a312814d4054d8af0d9ad6a6 /Swiften/Base/SafeString.h | |
parent | 10334c139670861d4860da59ad837fc3fe6fd41e (diff) | |
download | swift-contrib-21fda3308975201eeebeacd98e2b587ef4448862.zip swift-contrib-21fda3308975201eeebeacd98e2b587ef4448862.tar.bz2 |
Limit the use of the SafeString type.
Diffstat (limited to 'Swiften/Base/SafeString.h')
-rw-r--r-- | Swiften/Base/SafeString.h | 75 |
1 files changed, 0 insertions, 75 deletions
diff --git a/Swiften/Base/SafeString.h b/Swiften/Base/SafeString.h deleted file mode 100644 index d549bd1..0000000 --- a/Swiften/Base/SafeString.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2011 Remko Tronçon - * Licensed under the GNU General Public License v3. - * See Documentation/Licenses/GPLv3.txt for more information. - */ - -#pragma once - -#include <vector> -#include <string> - -#include <Swiften/Base/SafeAllocator.h> - -namespace Swift { - class SafeString { - public: - typedef std::vector<char, SafeAllocator<char> > Data; - typedef Data::iterator Iterator; - typedef Data::const_iterator ConstIterator; - - SafeString() { - } - - SafeString(const std::string& s) : data(s.begin(), s.end()) { - } - - SafeString(const char*); - - SafeString(const char* begin, const char* end) : data(begin, end) { - } - - std::string toString() const { - return data.empty() ? std::string() : std::string(&data[0], data.size()); - } - - void resize(size_t n) { - data.resize(n); - } - - char& operator[](size_t n) { - return data[n]; - } - - Iterator begin() { - return data.begin(); - } - - Iterator end() { - return data.end(); - } - - ConstIterator begin() const { - return data.begin(); - } - - ConstIterator end() const { - return data.end(); - } - - size_t size() const { - return data.size(); - } - - void clear() { - data.clear(); - } - - bool operator==(const SafeString& o) const { - return data == o.data; - } - - private: - std::vector<char, SafeAllocator<char> > data; - }; -}; |