summaryrefslogtreecommitdiff
path: root/cpp/src/qpid/framing/Buffer.h
diff options
context:
space:
mode:
authorAlan Conway <aconway@apache.org>2008-02-29 23:18:51 +0000
committerAlan Conway <aconway@apache.org>2008-02-29 23:18:51 +0000
commita80f66c2f220b037c50021497aac0fb09788b7aa (patch)
tree5183794e7f2b4067ce5b2e49f36e849c7f73074b /cpp/src/qpid/framing/Buffer.h
parent6dd59f62185ab8547cc1eec0a57731e0ab5a8645 (diff)
downloadqpid-python-a80f66c2f220b037c50021497aac0fb09788b7aa.tar.gz
- Added Buffer::Iterator so amqp_0_10::Codec can use a Buffer
- AMQBody wrappers for amqp_0_10::Command and Control - Extended AMQBody for CommandBody and ControlBody. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@632490 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/framing/Buffer.h')
-rw-r--r--cpp/src/qpid/framing/Buffer.h26
1 files changed, 24 insertions, 2 deletions
diff --git a/cpp/src/qpid/framing/Buffer.h b/cpp/src/qpid/framing/Buffer.h
index d0ca41f82b..9c0d403462 100644
--- a/cpp/src/qpid/framing/Buffer.h
+++ b/cpp/src/qpid/framing/Buffer.h
@@ -20,6 +20,7 @@
*/
#include "amqp_types.h"
#include "qpid/Exception.h"
+#include <boost/iterator/iterator_facade.hpp>
#ifndef _Buffer_
#define _Buffer_
@@ -41,8 +42,28 @@ class Buffer
void checkAvailable(uint32_t count) { if (position + count > size) throw OutOfBounds(); }
-public:
-
+ public:
+
+ /** Buffer input/output iterator.
+ * Supports using an amqp_0_10::Codec with a framing::Buffer.
+ */
+ class Iterator : public boost::iterator_facade<
+ Iterator, char, boost::random_access_traversal_tag>
+ {
+ public:
+ Iterator(Buffer& b) : buffer(&b) {}
+
+ private:
+ friend class boost::iterator_core_access;
+ char& dereference() const { return buffer->data[buffer->position]; }
+ void increment() { ++buffer->position; }
+ bool equal(const Iterator& x) const { return buffer == x.buffer; }
+
+ Buffer* buffer;
+ };
+
+ friend class Iterator;
+
Buffer(char* data=0, uint32_t size=0);
void record();
@@ -52,6 +73,7 @@ public:
uint32_t available() { return size - position; }
uint32_t getSize() { return size; }
uint32_t getPosition() { return position; }
+ Iterator getIterator() { return Iterator(*this); }
void putOctet(uint8_t i);
void putShort(uint16_t i);