summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Base/String.h')
-rw-r--r--Swiften/Base/String.h19
1 files changed, 18 insertions, 1 deletions
diff --git a/Swiften/Base/String.h b/Swiften/Base/String.h
index 192d53b..db6c28b 100644
--- a/Swiften/Base/String.h
+++ b/Swiften/Base/String.h
@@ -6,9 +6,9 @@
#pragma once
-#include <map>
#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)
@@ -19,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;
+ };
}