summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp')
-rw-r--r--cpp/src/qpid/framing/Buffer.cpp16
-rw-r--r--cpp/src/qpid/framing/Buffer.h4
2 files changed, 20 insertions, 0 deletions
diff --git a/cpp/src/qpid/framing/Buffer.cpp b/cpp/src/qpid/framing/Buffer.cpp
index 81f3456ce1..69168d462a 100644
--- a/cpp/src/qpid/framing/Buffer.cpp
+++ b/cpp/src/qpid/framing/Buffer.cpp
@@ -22,6 +22,7 @@
#include "FramingContent.h"
#include "FieldTable.h"
#include <string.h>
+#include <boost/format.hpp>
namespace qpid {
namespace framing {
@@ -257,4 +258,19 @@ void Buffer::getRawData(uint8_t* s, size_t len){
position += len;
}
+void Buffer::dump(std::ostream& out) const {
+ for (uint32_t i = position; i < size; i++)
+ {
+ if (i != position)
+ out << " ";
+ out << boost::format("%02x") % ((unsigned) (uint8_t) data[i]);
+ }
+}
+
+std::ostream& operator<<(std::ostream& out, const Buffer& b){
+ out << "Buffer[";
+ b.dump(out);
+ return out << "]";
+}
+
}}
diff --git a/cpp/src/qpid/framing/Buffer.h b/cpp/src/qpid/framing/Buffer.h
index 585379b09a..94cc2d320f 100644
--- a/cpp/src/qpid/framing/Buffer.h
+++ b/cpp/src/qpid/framing/Buffer.h
@@ -112,8 +112,12 @@ class Buffer
template <class T> void put(const T& data) { data.encode(*this); }
template <class T> void get(T& data) { data.decode(*this); }
+
+ void dump(std::ostream&) const;
};
+std::ostream& operator<<(std::ostream&, const Buffer&);
+
}} // namespace qpid::framing