summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Base/ByteArray.cpp')
-rw-r--r--Swiften/Base/ByteArray.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/Swiften/Base/ByteArray.cpp b/Swiften/Base/ByteArray.cpp
index c3869fc..323c866 100644
--- a/Swiften/Base/ByteArray.cpp
+++ b/Swiften/Base/ByteArray.cpp
@@ -72,4 +72,14 @@ std::vector<unsigned char> ByteArray::create(const unsigned char* c, size_t n) {
return data;
}
+std::string ByteArray::toString() const {
+ size_t i;
+ for (i = data_.size(); i > 0; --i) {
+ if (data_[i - 1] != 0) {
+ break;
+ }
+ }
+ return i > 0 ? std::string(reinterpret_cast<const char*>(getData()), i) : "";
+}
+
}