diff options
| author | Gordon Sim <gsim@apache.org> | 2008-04-01 17:13:43 +0000 |
|---|---|---|
| committer | Gordon Sim <gsim@apache.org> | 2008-04-01 17:13:43 +0000 |
| commit | 1cf652659d44237437d2afd805afd53cbab36665 (patch) | |
| tree | d18dd525f03012c5a0aed9722f9b31e286210f3d /qpid/cpp/src | |
| parent | aa6c292b43a5aaffc431688bec19617a8f385229 (diff) | |
| download | qpid-python-1cf652659d44237437d2afd805afd53cbab36665.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@643478 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp/src')
| -rw-r--r-- | qpid/cpp/src/qpid/framing/Buffer.cpp | 16 | ||||
| -rw-r--r-- | qpid/cpp/src/qpid/framing/Buffer.h | 4 |
2 files changed, 20 insertions, 0 deletions
diff --git a/qpid/cpp/src/qpid/framing/Buffer.cpp b/qpid/cpp/src/qpid/framing/Buffer.cpp index 81f3456ce1..69168d462a 100644 --- a/qpid/cpp/src/qpid/framing/Buffer.cpp +++ b/qpid/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/qpid/cpp/src/qpid/framing/Buffer.h b/qpid/cpp/src/qpid/framing/Buffer.h index 585379b09a..94cc2d320f 100644 --- a/qpid/cpp/src/qpid/framing/Buffer.h +++ b/qpid/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 |
