summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Swiften/Base/SafeString.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/Swiften/Base/SafeString.h b/Swiften/Base/SafeString.h
new file mode 100644
index 0000000..ef9c7cc
--- /dev/null
+++ b/Swiften/Base/SafeString.h
@@ -0,0 +1,32 @@
+/*
+ * 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 <Swiften/Base/SafeByteArray.h>
+
+namespace Swift {
+ class SafeString {
+ public:
+ SafeString(const SafeByteArray& data) : data(data) {
+ }
+
+ SafeString(const std::string& s) {
+ data = createSafeByteArray(s);
+ }
+
+ SafeString(const char* s) {
+ data = createSafeByteArray(s);
+ }
+
+ operator SafeByteArray () const {
+ return data;
+ }
+
+ private:
+ SafeByteArray data;
+ };
+}