diff options
Diffstat (limited to 'cpp/src/qpid/framing')
-rw-r--r-- | cpp/src/qpid/framing/AMQFrame.cpp | 8 | ||||
-rw-r--r-- | cpp/src/qpid/framing/AMQHeaderBody.h | 7 | ||||
-rw-r--r-- | cpp/src/qpid/framing/Array.cpp | 6 | ||||
-rw-r--r-- | cpp/src/qpid/framing/BodyHandler.cpp | 2 | ||||
-rw-r--r-- | cpp/src/qpid/framing/BodyHolder.cpp | 2 | ||||
-rw-r--r-- | cpp/src/qpid/framing/Buffer.cpp | 1 | ||||
-rw-r--r-- | cpp/src/qpid/framing/FieldTable.cpp | 2 | ||||
-rw-r--r-- | cpp/src/qpid/framing/FieldValue.cpp | 2 | ||||
-rw-r--r-- | cpp/src/qpid/framing/FramingContent.cpp | 73 | ||||
-rw-r--r-- | cpp/src/qpid/framing/FramingContent.h | 63 | ||||
-rw-r--r-- | cpp/src/qpid/framing/ModelMethod.h | 8 | ||||
-rw-r--r-- | cpp/src/qpid/framing/SequenceNumber.cpp | 16 | ||||
-rw-r--r-- | cpp/src/qpid/framing/SequenceNumber.h | 6 | ||||
-rw-r--r-- | cpp/src/qpid/framing/SequenceSet.cpp | 2 | ||||
-rw-r--r-- | cpp/src/qpid/framing/Uuid.cpp | 2 | ||||
-rw-r--r-- | cpp/src/qpid/framing/amqp_types_full.h | 2 |
16 files changed, 40 insertions, 162 deletions
diff --git a/cpp/src/qpid/framing/AMQFrame.cpp b/cpp/src/qpid/framing/AMQFrame.cpp index eeb658600d..3ebb61feb5 100644 --- a/cpp/src/qpid/framing/AMQFrame.cpp +++ b/cpp/src/qpid/framing/AMQFrame.cpp @@ -73,7 +73,7 @@ bool AMQFrame::decode(Buffer& buffer) uint8_t flags = buffer.getOctet(); uint8_t framing_version = (flags & 0xc0) >> 6; if (framing_version != 0) - throw SyntaxErrorException(QPID_MSG("Framing version unsupported")); + throw FramingErrorException(QPID_MSG("Framing version unsupported")); bof = flags & 0x08; eof = flags & 0x04; bos = flags & 0x02; @@ -81,7 +81,7 @@ bool AMQFrame::decode(Buffer& buffer) uint8_t type = buffer.getOctet(); uint16_t frame_size = buffer.getShort(); if (frame_size < frameOverhead()-1) - throw SyntaxErrorException(QPID_MSG("Frame size too small")); + throw FramingErrorException(QPID_MSG("Frame size too small")); uint8_t reserved1 = buffer.getOctet(); uint8_t field1 = buffer.getOctet(); subchannel = field1 & 0x0f; @@ -92,7 +92,7 @@ bool AMQFrame::decode(Buffer& buffer) // TODO: should we check reserved2 against zero as well? - the // spec isn't clear if ((flags & 0x30) != 0 || reserved1 != 0 || (field1 & 0xf0) != 0) - throw SyntaxErrorException(QPID_MSG("Reserved bits not zero")); + throw FramingErrorException(QPID_MSG("Reserved bits not zero")); // TODO: should no longer care about body size and only pass up // B,E,b,e flags @@ -105,7 +105,7 @@ bool AMQFrame::decode(Buffer& buffer) body->decode(type,buffer, body_size); uint8_t end = buffer.getOctet(); if (end != 0xCE) - throw SyntaxErrorException(QPID_MSG("Frame end not found")); + throw FramingErrorException(QPID_MSG("Frame end not found")); return true; } diff --git a/cpp/src/qpid/framing/AMQHeaderBody.h b/cpp/src/qpid/framing/AMQHeaderBody.h index 2064468785..c69a768291 100644 --- a/cpp/src/qpid/framing/AMQHeaderBody.h +++ b/cpp/src/qpid/framing/AMQHeaderBody.h @@ -26,8 +26,6 @@ #include "Buffer.h" #include "qpid/framing/DeliveryProperties.h" #include "qpid/framing/MessageProperties.h" -#include "qpid/framing/PreviewDeliveryProperties.h" -#include "qpid/framing/PreviewMessageProperties.h" #include <iostream> #include <boost/optional.hpp> @@ -77,10 +75,7 @@ class AMQHeaderBody : public AMQBody }; // Could use boost::mpl::fold to construct a larger set. - typedef PropSet< PropSet< PropSet<PropSet<Empty, DeliveryProperties>, - MessageProperties>, - PreviewDeliveryProperties>, - PreviewMessageProperties> Properties; + typedef PropSet<PropSet<Empty, DeliveryProperties>, MessageProperties> Properties; Properties properties; diff --git a/cpp/src/qpid/framing/Array.cpp b/cpp/src/qpid/framing/Array.cpp index 71281c7a52..f0b6331ff3 100644 --- a/cpp/src/qpid/framing/Array.cpp +++ b/cpp/src/qpid/framing/Array.cpp @@ -77,7 +77,7 @@ void Array::decode(Buffer& buffer){ uint32_t size = buffer.getLong();//size added only when array is a top-level type uint32_t available = buffer.available(); if (available < size) { - throw SyntaxErrorException(QPID_MSG("Not enough data for array, expected " + throw IllegalArgumentException(QPID_MSG("Not enough data for array, expected " << size << " bytes but only " << available << " available")); } if (size) { @@ -88,7 +88,7 @@ void Array::decode(Buffer& buffer){ dummy.setType(typeOctet); available = buffer.available(); if (available < count * dummy.getData().size()) { - throw SyntaxErrorException(QPID_MSG("Not enough data for array, expected " + throw IllegalArgumentException(QPID_MSG("Not enough data for array, expected " << count << " items of " << dummy.getData().size() << " bytes each but only " << available << " bytes available")); } @@ -117,7 +117,7 @@ bool Array::operator==(const Array& x) const { void Array::add(ValuePtr value) { if (typeOctet != value->getType()) { - throw SyntaxErrorException(QPID_MSG("Wrong type of value, expected " << typeOctet)); + throw IllegalArgumentException(QPID_MSG("Wrong type of value, expected " << typeOctet)); } values.push_back(value); } diff --git a/cpp/src/qpid/framing/BodyHandler.cpp b/cpp/src/qpid/framing/BodyHandler.cpp index fb84be7cd6..ffbcf33a95 100644 --- a/cpp/src/qpid/framing/BodyHandler.cpp +++ b/cpp/src/qpid/framing/BodyHandler.cpp @@ -48,7 +48,7 @@ void BodyHandler::handleBody(AMQBody* body) { handleHeartbeat(polymorphic_downcast<AMQHeartbeatBody*>(body)); break; default: - throw SyntaxErrorException( + throw FramingErrorException( QPID_MSG("Invalid frame type " << body->type())); } } diff --git a/cpp/src/qpid/framing/BodyHolder.cpp b/cpp/src/qpid/framing/BodyHolder.cpp index de971b5b28..1b2f74de2c 100644 --- a/cpp/src/qpid/framing/BodyHolder.cpp +++ b/cpp/src/qpid/framing/BodyHolder.cpp @@ -59,7 +59,7 @@ void BodyHolder::decode(uint8_t type, Buffer& buffer, uint32_t size) { case CONTENT_BODY: *this=in_place<AMQContentBody>(); break; case HEARTBEAT_BODY: *this=in_place<AMQHeartbeatBody>(); break; default: - throw SyntaxErrorException(QPID_MSG("Invalid frame type " << type)); + throw IllegalArgumentException(QPID_MSG("Invalid frame type " << type)); } get()->decode(buffer, size); } diff --git a/cpp/src/qpid/framing/Buffer.cpp b/cpp/src/qpid/framing/Buffer.cpp index 69168d462a..19c94ffd58 100644 --- a/cpp/src/qpid/framing/Buffer.cpp +++ b/cpp/src/qpid/framing/Buffer.cpp @@ -19,7 +19,6 @@ * */ #include "Buffer.h" -#include "FramingContent.h" #include "FieldTable.h" #include <string.h> #include <boost/format.hpp> diff --git a/cpp/src/qpid/framing/FieldTable.cpp b/cpp/src/qpid/framing/FieldTable.cpp index ac2a0f286d..903c7ed100 100644 --- a/cpp/src/qpid/framing/FieldTable.cpp +++ b/cpp/src/qpid/framing/FieldTable.cpp @@ -133,7 +133,7 @@ void FieldTable::decode(Buffer& buffer){ uint32_t len = buffer.getLong(); uint32_t available = buffer.available(); if (available < len) - throw SyntaxErrorException(QPID_MSG("Not enough data for field table.")); + throw IllegalArgumentException(QPID_MSG("Not enough data for field table.")); uint32_t leftover = available - len; while(buffer.available() > leftover){ std::string name; diff --git a/cpp/src/qpid/framing/FieldValue.cpp b/cpp/src/qpid/framing/FieldValue.cpp index 8171a94ef2..681f20a793 100644 --- a/cpp/src/qpid/framing/FieldValue.cpp +++ b/cpp/src/qpid/framing/FieldValue.cpp @@ -79,7 +79,7 @@ void FieldValue::setType(uint8_t type) data.reset(new FixedWidthValue<0>()); break; default: - throw SyntaxErrorException(QPID_MSG("Unknown field table value type: " << (int)typeOctet)); + throw IllegalArgumentException(QPID_MSG("Unknown field table value type: " << (int)typeOctet)); } } diff --git a/cpp/src/qpid/framing/FramingContent.cpp b/cpp/src/qpid/framing/FramingContent.cpp deleted file mode 100644 index cd134b0e89..0000000000 --- a/cpp/src/qpid/framing/FramingContent.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/* - * - * 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 "Buffer.h" -#include "FramingContent.h" -#include "qpid/Exception.h" -#include "qpid/framing/reply_exceptions.h" - -namespace qpid { -namespace framing { - -Content::Content() : discriminator(0) {} - -Content::Content(uint8_t _discriminator, const string& _value): discriminator(_discriminator), value(_value) { - validate(); -} - -void Content::validate() { - if (discriminator == REFERENCE) { - if(value.empty()) { - throw InvalidArgumentException( - QPID_MSG("Reference cannot be empty")); - } - }else if (discriminator != INLINE) { - throw SyntaxErrorException( - QPID_MSG("Invalid discriminator: " << discriminator)); - } -} - -Content::~Content() {} - -void Content::encode(Buffer& buffer) const { - buffer.putOctet(discriminator); - buffer.putLongString(value); -} - -void Content::decode(Buffer& buffer) { - discriminator = buffer.getOctet(); - buffer.getLongString(value); - validate(); -} - -size_t Content::size() const { - return 1/*discriminator*/ + 4/*for recording size of long string*/ + value.size(); -} - -std::ostream& operator<<(std::ostream& out, const Content& content) { - if (content.discriminator == REFERENCE) { - out << "{REF:" << content.value << "}"; - } else if (content.discriminator == INLINE) { - out << "{INLINE:" << content.value.size() << " bytes}"; - } - return out; -} - -}} // namespace framing::qpid diff --git a/cpp/src/qpid/framing/FramingContent.h b/cpp/src/qpid/framing/FramingContent.h deleted file mode 100644 index 36f5d641b2..0000000000 --- a/cpp/src/qpid/framing/FramingContent.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * - * 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_FramingContent_h -#define _framing_FramingContent_h - -#include <ostream> - -namespace qpid { -namespace framing { - -class Buffer; - -enum discriminator_types { INLINE = 0, REFERENCE = 1 }; - -/** - * A representation of the AMQP Content data type (used for message - * bodies) which can hold inline data or a reference. - */ -class Content -{ - uint8_t discriminator; - string value; - - void validate(); - - public: - Content(); - Content(uint8_t _discriminator, const string& _value); - ~Content(); - - void encode(Buffer& buffer) const; - void decode(Buffer& buffer); - size_t size() const; - bool isInline() const { return discriminator == INLINE; } - bool isReference() const { return discriminator == REFERENCE; } - const string& getValue() const { return value; } - void setValue(const string& newValue) { value = newValue; } - - friend std::ostream& operator<<(std::ostream&, const Content&); -}; - -}} // namespace qpid::framing - - -#endif /*!_framing_FramingContent_h*/ diff --git a/cpp/src/qpid/framing/ModelMethod.h b/cpp/src/qpid/framing/ModelMethod.h index 07600aadca..8e4361e761 100644 --- a/cpp/src/qpid/framing/ModelMethod.h +++ b/cpp/src/qpid/framing/ModelMethod.h @@ -22,7 +22,7 @@ * */ #include "AMQMethodBody.h" -#include "qpid/framing/ExecutionHeader.h" +#include "qpid/framing/Header.h" namespace qpid { namespace framing { @@ -30,7 +30,7 @@ namespace framing { class ModelMethod : public AMQMethodBody { - mutable ExecutionHeader header; + mutable Header header; public: virtual ~ModelMethod() {} virtual void encodeHeader(Buffer& buffer) const { header.encode(buffer); } @@ -38,8 +38,8 @@ public: virtual uint32_t headerSize() const { return header.size(); } virtual bool isSync() const { return header.getSync(); } virtual void setSync(bool on) const { header.setSync(on); } - ExecutionHeader& getHeader() { return header; } - const ExecutionHeader& getHeader() const { return header; } + Header& getHeader() { return header; } + const Header& getHeader() const { return header; } }; diff --git a/cpp/src/qpid/framing/SequenceNumber.cpp b/cpp/src/qpid/framing/SequenceNumber.cpp index 1b62d296c6..cba00c860a 100644 --- a/cpp/src/qpid/framing/SequenceNumber.cpp +++ b/cpp/src/qpid/framing/SequenceNumber.cpp @@ -20,8 +20,10 @@ */ #include "SequenceNumber.h" +#include "Buffer.h" using qpid::framing::SequenceNumber; +using qpid::framing::Buffer; SequenceNumber::SequenceNumber() : value(0 - 1) {} @@ -77,6 +79,20 @@ bool SequenceNumber::operator>=(const SequenceNumber& other) const return *this == other || *this > other; } +void SequenceNumber::encode(Buffer& buffer) const +{ + buffer.putLong(value); +} + +void SequenceNumber::decode(Buffer& buffer) +{ + value = buffer.getLong(); +} + +uint32_t SequenceNumber::size() const { + return 4; +} + namespace qpid { namespace framing { diff --git a/cpp/src/qpid/framing/SequenceNumber.h b/cpp/src/qpid/framing/SequenceNumber.h index 0ed591b804..d659bec5c1 100644 --- a/cpp/src/qpid/framing/SequenceNumber.h +++ b/cpp/src/qpid/framing/SequenceNumber.h @@ -26,6 +26,8 @@ namespace qpid { namespace framing { +class Buffer; + /** * 4-byte sequence number that 'wraps around'. */ @@ -51,6 +53,10 @@ class SequenceNumber friend int32_t operator-(const SequenceNumber& a, const SequenceNumber& b); + void encode(Buffer& buffer) const; + void decode(Buffer& buffer); + uint32_t size() const; + template <class S> void serialize(S& s) { s(value); } }; diff --git a/cpp/src/qpid/framing/SequenceSet.cpp b/cpp/src/qpid/framing/SequenceSet.cpp index 2683b0025d..cdf890b7f8 100644 --- a/cpp/src/qpid/framing/SequenceSet.cpp +++ b/cpp/src/qpid/framing/SequenceSet.cpp @@ -49,7 +49,7 @@ void SequenceSet::decode(Buffer& buffer) uint16_t size = buffer.getShort(); uint16_t count = size / RANGE_SIZE;//number of ranges if (size % RANGE_SIZE) - throw FrameErrorException(QPID_MSG("Invalid size for sequence set: " << size)); + throw IllegalArgumentException(QPID_MSG("Invalid size for sequence set: " << size)); for (uint16_t i = 0; i < count; i++) { add(SequenceNumber(buffer.getLong()), SequenceNumber(buffer.getLong())); diff --git a/cpp/src/qpid/framing/Uuid.cpp b/cpp/src/qpid/framing/Uuid.cpp index 2918c48ce3..b58d9fce96 100644 --- a/cpp/src/qpid/framing/Uuid.cpp +++ b/cpp/src/qpid/framing/Uuid.cpp @@ -34,7 +34,7 @@ void Uuid::encode(Buffer& buf) const { void Uuid::decode(Buffer& buf) { if (buf.available() < size()) - throw SyntaxErrorException(QPID_MSG("Not enough data for UUID.")); + throw IllegalArgumentException(QPID_MSG("Not enough data for UUID.")); buf.getRawData(c_array(), size()); } diff --git a/cpp/src/qpid/framing/amqp_types_full.h b/cpp/src/qpid/framing/amqp_types_full.h index 1ab8777896..d0aaf28cb4 100644 --- a/cpp/src/qpid/framing/amqp_types_full.h +++ b/cpp/src/qpid/framing/amqp_types_full.h @@ -31,9 +31,7 @@ #include "amqp_types.h" #include "Array.h" -#include "FramingContent.h" #include "FieldTable.h" -#include "SequenceNumberSet.h" #include "SequenceSet.h" #include "Uuid.h" |