summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
authorGordon Sim <gsim@apache.org>2008-04-01 17:13:43 +0000
committerGordon Sim <gsim@apache.org>2008-04-01 17:13:43 +0000
commitfffcffa59b420aeac7931dc97eec18b76c9d1345 (patch)
tree0abfddfaa0cd189651c989bcc8b2a9463c61abf5 /cpp
parent0b8344c3212bf98feb4ecb869d1d9436d227ebfc (diff)
downloadqpid-python-fffcffa59b420aeac7931dc97eec18b76c9d1345.tar.gz
Added a dump method to buffer for debugging io (patch from rafaels@redhat.com)
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@643478 13f79535-47bb-0310-9956-ffa450edef68
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