summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2011-05-23 19:09:49 (GMT)
committerRemko Tronçon <git@el-tramo.be>2011-05-23 19:09:49 (GMT)
commit4e05484ab2475cd50572a81e831235f916e8b7ba (patch)
tree7414fdb091254a826d0e4054fa2a5fe66e995e49 /Swiften/Base
parent4681af4be3dd8722b2b23515c315e5bad9193c58 (diff)
downloadswift-4e05484ab2475cd50572a81e831235f916e8b7ba.zip
swift-4e05484ab2475cd50572a81e831235f916e8b7ba.tar.bz2
Added makeString().
Diffstat (limited to 'Swiften/Base')
-rw-r--r--Swiften/Base/String.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/Swiften/Base/String.h b/Swiften/Base/String.h
index 0de6cac..db6c28b 100644
--- a/Swiften/Base/String.h
+++ b/Swiften/Base/String.h
@@ -8,6 +8,7 @@
#include <string>
#include <vector>
+#include <sstream>
#define SWIFTEN_STRING_TO_CFSTRING(a) \
CFStringCreateWithBytes(NULL, reinterpret_cast<const UInt8*>(a.c_str()), a.size(), kCFStringEncodingUTF8, false)
@@ -18,11 +19,28 @@ namespace Swift {
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;
}
+
inline bool endsWith(const std::string& s, char c) {
return s.size() > 0 && s[s.size()-1] == c;
}
};
+
+ class makeString {
+ public:
+ template <typename T> makeString& operator<<(T const& v) {
+ stream << v;
+ return *this;
+ }
+
+ operator std::string() const {
+ return stream.str();
+ }
+
+ private:
+ std::ostringstream stream;
+ };
}