diff options
Diffstat (limited to 'cpp/src/qpid/framing')
| -rw-r--r-- | cpp/src/qpid/framing/AMQMethodBody.cpp | 5 | ||||
| -rw-r--r-- | cpp/src/qpid/framing/AMQMethodBody.h | 6 | ||||
| -rw-r--r-- | cpp/src/qpid/framing/SequenceNumberSet.cpp | 61 | ||||
| -rw-r--r-- | cpp/src/qpid/framing/SequenceNumberSet.h | 49 | ||||
| -rw-r--r-- | cpp/src/qpid/framing/amqp_types.h | 1 |
5 files changed, 121 insertions, 1 deletions
diff --git a/cpp/src/qpid/framing/AMQMethodBody.cpp b/cpp/src/qpid/framing/AMQMethodBody.cpp index 04941eaa58..eb34d48c5f 100644 --- a/cpp/src/qpid/framing/AMQMethodBody.cpp +++ b/cpp/src/qpid/framing/AMQMethodBody.cpp @@ -60,4 +60,9 @@ void AMQMethodBody::decode(Buffer& buffer, uint32_t /*size*/) { decodeContent(buffer); } +void AMQMethodBody::encode(Buffer& buffer) const { + encodeId(buffer); + encodeContent(buffer); +} + }} // namespace qpid::framing diff --git a/cpp/src/qpid/framing/AMQMethodBody.h b/cpp/src/qpid/framing/AMQMethodBody.h index 55cf5cb864..2b46c6ea00 100644 --- a/cpp/src/qpid/framing/AMQMethodBody.h +++ b/cpp/src/qpid/framing/AMQMethodBody.h @@ -47,6 +47,7 @@ class AMQMethodBody : public AMQBody AMQMethodBody(ProtocolVersion ver) : version(ver) {} virtual ~AMQMethodBody() {} void decode(Buffer&, uint32_t); + virtual void encode(Buffer& buffer) const; virtual MethodId amqpMethodId() const = 0; virtual ClassId amqpClassId() const = 0; @@ -64,8 +65,8 @@ class AMQMethodBody : public AMQBody virtual bool isRequest() const { return false; } virtual bool isResponse() const { return false; } - protected: static uint32_t baseSize() { return 4; } + protected: struct ClassMethodId { uint16_t classId; @@ -76,6 +77,9 @@ class AMQMethodBody : public AMQBody void encodeId(Buffer& buffer) const; virtual void encodeContent(Buffer& buffer) const = 0; virtual void decodeContent(Buffer& buffer) = 0; + + virtual void printPrefix(std::ostream&) const {} + }; diff --git a/cpp/src/qpid/framing/SequenceNumberSet.cpp b/cpp/src/qpid/framing/SequenceNumberSet.cpp new file mode 100644 index 0000000000..357b5dabd7 --- /dev/null +++ b/cpp/src/qpid/framing/SequenceNumberSet.cpp @@ -0,0 +1,61 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +#include "SequenceNumberSet.h" + +using namespace qpid::framing; + +void SequenceNumberSet::encode(Buffer& buffer) const +{ + buffer.putShort(size()); + for (const_iterator i = begin(); i != end(); i++) { + buffer.putLong(i->getValue()); + } +} + +void SequenceNumberSet::decode(Buffer& buffer) +{ + uint16_t count = buffer.getShort(); + for (uint16_t i = 0; i < count; i++) { + push_back(SequenceNumber(buffer.getLong())); + } +} + +uint32_t SequenceNumberSet::encodedSize() const +{ + return 2 /*count*/ + (size() * 4); +} + +namespace qpid{ +namespace framing{ + +std::ostream& operator<<(std::ostream& out, const SequenceNumberSet& set) { + out << "{"; + for (SequenceNumberSet::const_iterator i = set.begin(); i != set.end(); i++) { + if (i != set.begin()) out << ", "; + out << (i->getValue()); + } + out << "}"; + return out; +} + +} +} diff --git a/cpp/src/qpid/framing/SequenceNumberSet.h b/cpp/src/qpid/framing/SequenceNumberSet.h new file mode 100644 index 0000000000..bcf78d4f22 --- /dev/null +++ b/cpp/src/qpid/framing/SequenceNumberSet.h @@ -0,0 +1,49 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +#ifndef _framing_SequenceNumberSet_h +#define _framing_SequenceNumberSet_h + +#include <ostream> +#include <vector> +#include "amqp_types.h" +#include "Buffer.h" +#include "SequenceNumber.h" + +namespace qpid { +namespace framing { + +class SequenceNumberSet : public std::vector<SequenceNumber> +{ +public: + typedef std::vector<SequenceNumber>::const_iterator const_iterator; + typedef std::vector<SequenceNumber>::iterator iterator; + + void encode(Buffer& buffer) const; + void decode(Buffer& buffer); + uint32_t encodedSize() const; + + friend std::ostream& operator<<(std::ostream&, const SequenceNumberSet&); +}; + +}} // namespace qpid::framing + + +#endif diff --git a/cpp/src/qpid/framing/amqp_types.h b/cpp/src/qpid/framing/amqp_types.h index efb720f047..ff75b28468 100644 --- a/cpp/src/qpid/framing/amqp_types.h +++ b/cpp/src/qpid/framing/amqp_types.h @@ -53,6 +53,7 @@ typedef uint16_t ReplyCode; // Types represented by classes. class Content; class FieldTable; +class SequenceNumberSet; // Useful constants |
