diff options
author | Rajith Muditha Attapattu <rajith@apache.org> | 2007-11-19 15:51:11 +0000 |
---|---|---|
committer | Rajith Muditha Attapattu <rajith@apache.org> | 2007-11-19 15:51:11 +0000 |
commit | 5de8db83d669a00a8ac19023bbece140421316ab (patch) | |
tree | b576cec8a33157707585a5ca63b730765276ef69 /Final/cpp/lib/common/framing | |
parent | 45d36f36ad0aa45040e997f53c465b034d49d1d9 (diff) | |
download | qpid-python-5de8db83d669a00a8ac19023bbece140421316ab.tar.gz |
The eclipse License was missing from the NOTICE file
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/tags/M2@596339 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'Final/cpp/lib/common/framing')
38 files changed, 0 insertions, 2570 deletions
diff --git a/Final/cpp/lib/common/framing/AMQBody.cpp b/Final/cpp/lib/common/framing/AMQBody.cpp deleted file mode 100644 index b095312a16..0000000000 --- a/Final/cpp/lib/common/framing/AMQBody.cpp +++ /dev/null @@ -1,36 +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 <AMQBody.h> -#include <iostream> - -std::ostream& qpid::framing::operator<<(std::ostream& out, const qpid::framing::AMQBody& body) -{ - body.print(out); - return out; -} - - -qpid::framing::AMQBody::~AMQBody() {} - -void qpid::framing::AMQBody::print(std::ostream& out) const { - out << "unknown body"; -} diff --git a/Final/cpp/lib/common/framing/AMQBody.h b/Final/cpp/lib/common/framing/AMQBody.h deleted file mode 100644 index 5547d3c506..0000000000 --- a/Final/cpp/lib/common/framing/AMQBody.h +++ /dev/null @@ -1,51 +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 <boost/shared_ptr.hpp> -#include <amqp_types.h> -#include <Buffer.h> - -#ifndef _AMQBody_ -#define _AMQBody_ - -namespace qpid { - namespace framing { - - class AMQBody - { - public: - typedef boost::shared_ptr<AMQBody> shared_ptr; - - virtual ~AMQBody(); - virtual u_int32_t size() const = 0; - virtual u_int8_t type() const = 0; - virtual void encode(Buffer& buffer) const = 0; - virtual void decode(Buffer& buffer, u_int32_t size) = 0; - virtual void print(std::ostream& out) const; - }; - - std::ostream& operator<<(std::ostream& out, const AMQBody& body) ; - - enum body_types {METHOD_BODY = 1, HEADER_BODY = 2, CONTENT_BODY = 3, HEARTBEAT_BODY = 8}; - } -} - - -#endif diff --git a/Final/cpp/lib/common/framing/AMQContentBody.cpp b/Final/cpp/lib/common/framing/AMQContentBody.cpp deleted file mode 100644 index 4f51dca243..0000000000 --- a/Final/cpp/lib/common/framing/AMQContentBody.cpp +++ /dev/null @@ -1,43 +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 <AMQContentBody.h> -#include <iostream> - -qpid::framing::AMQContentBody::AMQContentBody(){ -} - -qpid::framing::AMQContentBody::AMQContentBody(const string& _data) : data(_data){ -} - -u_int32_t qpid::framing::AMQContentBody::size() const{ - return data.size(); -} -void qpid::framing::AMQContentBody::encode(Buffer& buffer) const{ - buffer.putRawData(data); -} -void qpid::framing::AMQContentBody::decode(Buffer& buffer, u_int32_t _size){ - buffer.getRawData(data, _size); -} - -void qpid::framing::AMQContentBody::print(std::ostream& out) const -{ - out << "content (" << size() << " bytes)"; -} diff --git a/Final/cpp/lib/common/framing/AMQContentBody.h b/Final/cpp/lib/common/framing/AMQContentBody.h deleted file mode 100644 index 172228671a..0000000000 --- a/Final/cpp/lib/common/framing/AMQContentBody.h +++ /dev/null @@ -1,53 +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 <amqp_types.h> -#include <AMQBody.h> -#include <Buffer.h> - -#ifndef _AMQContentBody_ -#define _AMQContentBody_ - -namespace qpid { -namespace framing { - -class AMQContentBody : virtual public AMQBody -{ - string data; - -public: - typedef boost::shared_ptr<AMQContentBody> shared_ptr; - - AMQContentBody(); - AMQContentBody(const string& data); - inline virtual ~AMQContentBody(){} - inline u_int8_t type() const { return CONTENT_BODY; }; - inline string& getData(){ return data; } - u_int32_t size() const; - void encode(Buffer& buffer) const; - void decode(Buffer& buffer, u_int32_t size); - void print(std::ostream& out) const; -}; - -} -} - - -#endif diff --git a/Final/cpp/lib/common/framing/AMQDataBlock.h b/Final/cpp/lib/common/framing/AMQDataBlock.h deleted file mode 100644 index ac91c52164..0000000000 --- a/Final/cpp/lib/common/framing/AMQDataBlock.h +++ /dev/null @@ -1,42 +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> - -#ifndef _AMQDataBlock_ -#define _AMQDataBlock_ - -namespace qpid { -namespace framing { - -class AMQDataBlock -{ -public: - virtual ~AMQDataBlock() {} - virtual void encode(Buffer& buffer) = 0; - virtual bool decode(Buffer& buffer) = 0; - virtual u_int32_t size() const = 0; -}; - -} -} - - -#endif diff --git a/Final/cpp/lib/common/framing/AMQFrame.cpp b/Final/cpp/lib/common/framing/AMQFrame.cpp deleted file mode 100644 index 6fa5b9ae51..0000000000 --- a/Final/cpp/lib/common/framing/AMQFrame.cpp +++ /dev/null @@ -1,132 +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 <AMQFrame.h> -#include <QpidError.h> - -using namespace qpid::framing; - - -AMQP_MethodVersionMap AMQFrame::versionMap; - - -AMQFrame::AMQFrame(qpid::framing::ProtocolVersion& _version): -version(_version) -{} - - -AMQFrame::AMQFrame(qpid::framing::ProtocolVersion& _version, u_int16_t _channel, AMQBody* _body) : -version(_version), channel(_channel), body(_body) -{} - - -AMQFrame::AMQFrame(qpid::framing::ProtocolVersion& _version, u_int16_t _channel, AMQBody::shared_ptr& _body) : -version(_version), channel(_channel), body(_body) -{} - -AMQFrame::~AMQFrame() {} - -u_int16_t AMQFrame::getChannel(){ - return channel; -} - -AMQBody::shared_ptr& AMQFrame::getBody(){ - return body; -} - -void AMQFrame::encode(Buffer& buffer) -{ - buffer.putOctet(body->type()); - buffer.putShort(channel); - buffer.putLong(body->size()); - body->encode(buffer); - buffer.putOctet(0xCE); -} - -AMQBody::shared_ptr AMQFrame::createMethodBody(Buffer& buffer){ - u_int16_t classId = buffer.getShort(); - u_int16_t methodId = buffer.getShort(); - AMQBody::shared_ptr body(versionMap.createMethodBody(classId, methodId, version.getMajor(), version.getMinor())); - return body; -} - -u_int32_t AMQFrame::size() const{ - if(!body.get()) THROW_QPID_ERROR(INTERNAL_ERROR, "Attempt to get size of frame with no body set!"); - return 1/*type*/ + 2/*channel*/ + 4/*body size*/ + body->size() + 1/*0xCE*/; -} - -bool AMQFrame::decode(Buffer& buffer) -{ - if(buffer.available() < 7) return false; - buffer.record(); - u_int32_t bufSize = decodeHead(buffer); - - if(buffer.available() < bufSize + 1){ - buffer.restore(); - return false; - } - decodeBody(buffer, bufSize); - u_int8_t end = buffer.getOctet(); - if(end != 0xCE) THROW_QPID_ERROR(FRAMING_ERROR, "Frame end not found"); - return true; -} - -u_int32_t AMQFrame::decodeHead(Buffer& buffer){ - type = buffer.getOctet(); - channel = buffer.getShort(); - return buffer.getLong(); -} - -void AMQFrame::decodeBody(Buffer& buffer, uint32_t bufSize) -{ - switch(type) - { - case METHOD_BODY: - body = createMethodBody(buffer); - break; - case HEADER_BODY: - body = AMQBody::shared_ptr(new AMQHeaderBody()); - break; - case CONTENT_BODY: - body = AMQBody::shared_ptr(new AMQContentBody()); - break; - case HEARTBEAT_BODY: - body = AMQBody::shared_ptr(new AMQHeartbeatBody()); - break; - default: - string msg("Unknown body type: "); - msg += type; - THROW_QPID_ERROR(FRAMING_ERROR, msg); - } - body->decode(buffer, bufSize); -} - -std::ostream& qpid::framing::operator<<(std::ostream& out, const AMQFrame& t) -{ - out << "Frame[channel=" << t.channel << "; "; - if (t.body.get() == 0) - out << "empty"; - else - out << *t.body; - out << "]"; - return out; -} - diff --git a/Final/cpp/lib/common/framing/AMQFrame.h b/Final/cpp/lib/common/framing/AMQFrame.h deleted file mode 100644 index d3c769087a..0000000000 --- a/Final/cpp/lib/common/framing/AMQFrame.h +++ /dev/null @@ -1,71 +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 <qpid/framing/amqp_methods.h>*/ -#include <amqp_types.h> -#include <AMQBody.h> -#include <AMQDataBlock.h> -#include <AMQMethodBody.h> -#include <AMQHeaderBody.h> -#include <AMQContentBody.h> -#include <AMQHeartbeatBody.h> -#include <AMQP_MethodVersionMap.h> -#include <AMQP_HighestVersion.h> -#include <Buffer.h> - -#ifndef _AMQFrame_ -#define _AMQFrame_ - -namespace qpid { - namespace framing { - - - class AMQFrame : virtual public AMQDataBlock - { - static AMQP_MethodVersionMap versionMap; - qpid::framing::ProtocolVersion version; - - u_int16_t channel; - u_int8_t type;//used if the body is decoded separately from the 'head' - AMQBody::shared_ptr body; - AMQBody::shared_ptr createMethodBody(Buffer& buffer); - - public: - AMQFrame(qpid::framing::ProtocolVersion& _version = highestProtocolVersion); - AMQFrame(qpid::framing::ProtocolVersion& _version, u_int16_t channel, AMQBody* body); - AMQFrame(qpid::framing::ProtocolVersion& _version, u_int16_t channel, AMQBody::shared_ptr& body); - virtual ~AMQFrame(); - virtual void encode(Buffer& buffer); - virtual bool decode(Buffer& buffer); - virtual u_int32_t size() const; - u_int16_t getChannel(); - AMQBody::shared_ptr& getBody(); - - u_int32_t decodeHead(Buffer& buffer); - void decodeBody(Buffer& buffer, uint32_t size); - - friend std::ostream& operator<<(std::ostream& out, const AMQFrame& body); - }; - - } -} - - -#endif diff --git a/Final/cpp/lib/common/framing/AMQHeaderBody.cpp b/Final/cpp/lib/common/framing/AMQHeaderBody.cpp deleted file mode 100644 index 3653073f29..0000000000 --- a/Final/cpp/lib/common/framing/AMQHeaderBody.cpp +++ /dev/null @@ -1,75 +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 <AMQHeaderBody.h> -#include <QpidError.h> -#include <BasicHeaderProperties.h> - -qpid::framing::AMQHeaderBody::AMQHeaderBody(int classId) : weight(0), contentSize(0){ - createProperties(classId); -} - -qpid::framing::AMQHeaderBody::AMQHeaderBody() : properties(0), weight(0), contentSize(0){ -} - -qpid::framing::AMQHeaderBody::~AMQHeaderBody(){ - delete properties; -} - -u_int32_t qpid::framing::AMQHeaderBody::size() const{ - return 12 + properties->size(); -} - -void qpid::framing::AMQHeaderBody::encode(Buffer& buffer) const { - buffer.putShort(properties->classId()); - buffer.putShort(weight); - buffer.putLongLong(contentSize); - properties->encode(buffer); -} - -void qpid::framing::AMQHeaderBody::decode(Buffer& buffer, u_int32_t bufSize){ - u_int16_t classId = buffer.getShort(); - weight = buffer.getShort(); - contentSize = buffer.getLongLong(); - createProperties(classId); - properties->decode(buffer, bufSize - 12); -} - -void qpid::framing::AMQHeaderBody::createProperties(int classId){ - switch(classId){ - case BASIC: - properties = new qpid::framing::BasicHeaderProperties(); - break; - default: - THROW_QPID_ERROR(FRAMING_ERROR, "Unknown header class"); - } -} - -void qpid::framing::AMQHeaderBody::print(std::ostream& out) const -{ - out << "header (" << size() << " bytes)" << " content_size=" << getContentSize(); - const BasicHeaderProperties* props = - dynamic_cast<const BasicHeaderProperties*>(getProperties()); - if (props) { - out << ", message_id=" << props->getMessageId(); - out << ", delivery_mode=" << (int) props->getDeliveryMode(); - out << ", headers=" << const_cast<BasicHeaderProperties*>(props)->getHeaders(); - } -} diff --git a/Final/cpp/lib/common/framing/AMQHeaderBody.h b/Final/cpp/lib/common/framing/AMQHeaderBody.h deleted file mode 100644 index 31cf7d575e..0000000000 --- a/Final/cpp/lib/common/framing/AMQHeaderBody.h +++ /dev/null @@ -1,60 +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 <amqp_types.h> -#include <AMQBody.h> -#include <Buffer.h> -#include <HeaderProperties.h> - -#ifndef _AMQHeaderBody_ -#define _AMQHeaderBody_ - -namespace qpid { -namespace framing { - -class AMQHeaderBody : virtual public AMQBody -{ - HeaderProperties* properties; - u_int16_t weight; - u_int64_t contentSize; - - void createProperties(int classId); -public: - typedef boost::shared_ptr<AMQHeaderBody> shared_ptr; - - AMQHeaderBody(int classId); - AMQHeaderBody(); - inline u_int8_t type() const { return HEADER_BODY; } - HeaderProperties* getProperties(){ return properties; } - const HeaderProperties* getProperties() const { return properties; } - inline u_int64_t getContentSize() const { return contentSize; } - inline void setContentSize(u_int64_t _size) { contentSize = _size; } - virtual ~AMQHeaderBody(); - virtual u_int32_t size() const; - virtual void encode(Buffer& buffer) const; - virtual void decode(Buffer& buffer, u_int32_t size); - virtual void print(std::ostream& out) const; -}; - -} -} - - -#endif diff --git a/Final/cpp/lib/common/framing/AMQHeartbeatBody.cpp b/Final/cpp/lib/common/framing/AMQHeartbeatBody.cpp deleted file mode 100644 index 63f83a3d29..0000000000 --- a/Final/cpp/lib/common/framing/AMQHeartbeatBody.cpp +++ /dev/null @@ -1,29 +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 <AMQHeartbeatBody.h> -#include <iostream> - -qpid::framing::AMQHeartbeatBody::~AMQHeartbeatBody() {} - -void qpid::framing::AMQHeartbeatBody::print(std::ostream& out) const { - out << "heartbeat"; -} diff --git a/Final/cpp/lib/common/framing/AMQHeartbeatBody.h b/Final/cpp/lib/common/framing/AMQHeartbeatBody.h deleted file mode 100644 index a2315119e4..0000000000 --- a/Final/cpp/lib/common/framing/AMQHeartbeatBody.h +++ /dev/null @@ -1,47 +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 <amqp_types.h> -#include <AMQBody.h> -#include <Buffer.h> - -#ifndef _AMQHeartbeatBody_ -#define _AMQHeartbeatBody_ - -namespace qpid { -namespace framing { - -class AMQHeartbeatBody : virtual public AMQBody -{ -public: - typedef boost::shared_ptr<AMQHeartbeatBody> shared_ptr; - - virtual ~AMQHeartbeatBody(); - inline u_int32_t size() const { return 0; } - inline u_int8_t type() const { return HEARTBEAT_BODY; } - inline void encode(Buffer& ) const {} - inline void decode(Buffer& , u_int32_t /*size*/) {} - virtual void print(std::ostream& out) const; -}; - -} -} - -#endif diff --git a/Final/cpp/lib/common/framing/AMQMethodBody.cpp b/Final/cpp/lib/common/framing/AMQMethodBody.cpp deleted file mode 100644 index 525310f3d4..0000000000 --- a/Final/cpp/lib/common/framing/AMQMethodBody.cpp +++ /dev/null @@ -1,46 +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 <AMQMethodBody.h> -#include <QpidError.h> - -void qpid::framing::AMQMethodBody::encode(Buffer& buffer) const{ - buffer.putShort(amqpClassId()); - buffer.putShort(amqpMethodId()); - encodeContent(buffer); -} - -void qpid::framing::AMQMethodBody::decode(Buffer& buffer, u_int32_t /*size*/){ - decodeContent(buffer); -} - -bool qpid::framing::AMQMethodBody::match(AMQMethodBody* other) const{ - return other != 0 && other->amqpClassId() == amqpClassId() && other->amqpMethodId() == amqpMethodId(); -} - -void qpid::framing::AMQMethodBody::invoke(AMQP_ServerOperations& /*target*/, u_int16_t /*channel*/){ - THROW_QPID_ERROR(PROTOCOL_ERROR, "Method not supported by AMQP Server."); -} - - -std::ostream& qpid::framing::operator<<(std::ostream& out, const AMQMethodBody& m){ - m.print(out); - return out; -} diff --git a/Final/cpp/lib/common/framing/AMQMethodBody.h b/Final/cpp/lib/common/framing/AMQMethodBody.h deleted file mode 100644 index da25c7c545..0000000000 --- a/Final/cpp/lib/common/framing/AMQMethodBody.h +++ /dev/null @@ -1,62 +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 <iostream> -#include <amqp_types.h> -#include <AMQBody.h> -#include <Buffer.h> -#include <AMQP_ServerOperations.h> - -#ifndef _AMQMethodBody_ -#define _AMQMethodBody_ - -namespace qpid { -namespace framing { - -class AMQMethodBody : virtual public AMQBody -{ -public: - typedef boost::shared_ptr<AMQMethodBody> shared_ptr; - - ProtocolVersion version; - inline u_int8_t type() const { return METHOD_BODY; } - inline u_int32_t size() const { return 4 + bodySize(); } - inline AMQMethodBody(u_int8_t major, u_int8_t minor) : version(major, minor) {} - inline AMQMethodBody(ProtocolVersion version) : version(version) {} - inline virtual ~AMQMethodBody() {} - virtual void print(std::ostream& out) const = 0; - virtual u_int16_t amqpMethodId() const = 0; - virtual u_int16_t amqpClassId() const = 0; - virtual void invoke(AMQP_ServerOperations& target, u_int16_t channel); - virtual void encodeContent(Buffer& buffer) const = 0; - virtual void decodeContent(Buffer& buffer) = 0; - virtual u_int32_t bodySize() const = 0; - void encode(Buffer& buffer) const; - void decode(Buffer& buffer, u_int32_t size); - bool match(AMQMethodBody* other) const; -}; - -std::ostream& operator<<(std::ostream& out, const AMQMethodBody& body); - -} -} - - -#endif diff --git a/Final/cpp/lib/common/framing/BasicHeaderProperties.cpp b/Final/cpp/lib/common/framing/BasicHeaderProperties.cpp deleted file mode 100644 index f673215536..0000000000 --- a/Final/cpp/lib/common/framing/BasicHeaderProperties.cpp +++ /dev/null @@ -1,103 +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 <BasicHeaderProperties.h> - -//TODO: This could be easily generated from the spec - -qpid::framing::BasicHeaderProperties::BasicHeaderProperties() : deliveryMode(0), priority(0), timestamp(0){} -qpid::framing::BasicHeaderProperties::~BasicHeaderProperties(){} - -u_int32_t qpid::framing::BasicHeaderProperties::size() const{ - u_int32_t bytes = 2;//flags - if(contentType.length() > 0) bytes += contentType.length() + 1; - if(contentEncoding.length() > 0) bytes += contentEncoding.length() + 1; - if(headers.count() > 0) bytes += headers.size(); - if(deliveryMode != 0) bytes += 1; - if(priority != 0) bytes += 1; - if(correlationId.length() > 0) bytes += correlationId.length() + 1; - if(replyTo.length() > 0) bytes += replyTo.length() + 1; - if(expiration.length() > 0) bytes += expiration.length() + 1; - if(messageId.length() > 0) bytes += messageId.length() + 1; - if(timestamp != 0) bytes += 8; - if(type.length() > 0) bytes += type.length() + 1; - if(userId.length() > 0) bytes += userId.length() + 1; - if(appId.length() > 0) bytes += appId.length() + 1; - if(clusterId.length() > 0) bytes += clusterId.length() + 1; - - return bytes; -} - -void qpid::framing::BasicHeaderProperties::encode(qpid::framing::Buffer& buffer) const{ - u_int16_t flags = getFlags(); - buffer.putShort(flags); - - if(contentType.length() > 0) buffer.putShortString(contentType); - if(contentEncoding.length() > 0) buffer.putShortString(contentEncoding); - if(headers.count() > 0) buffer.putFieldTable(headers); - if(deliveryMode != 0) buffer.putOctet(deliveryMode); - if(priority != 0) buffer.putOctet(priority); - if(correlationId.length() > 0) buffer.putShortString(correlationId); - if(replyTo.length() > 0) buffer.putShortString(replyTo); - if(expiration.length() > 0) buffer.putShortString(expiration); - if(messageId.length() > 0) buffer.putShortString(messageId); - if(timestamp != 0) buffer.putLongLong(timestamp);; - if(type.length() > 0) buffer.putShortString(type); - if(userId.length() > 0) buffer.putShortString(userId); - if(appId.length() > 0) buffer.putShortString(appId); - if(clusterId.length() > 0) buffer.putShortString(clusterId); -} - -void qpid::framing::BasicHeaderProperties::decode(qpid::framing::Buffer& buffer, u_int32_t /*size*/){ - u_int16_t flags = buffer.getShort(); - if(flags & (1 << 15)) buffer.getShortString(contentType); - if(flags & (1 << 14)) buffer.getShortString(contentEncoding); - if(flags & (1 << 13)) buffer.getFieldTable(headers); - if(flags & (1 << 12)) deliveryMode = buffer.getOctet(); - if(flags & (1 << 11)) priority = buffer.getOctet(); - if(flags & (1 << 10)) buffer.getShortString(correlationId); - if(flags & (1 << 9)) buffer.getShortString(replyTo); - if(flags & (1 << 8)) buffer.getShortString(expiration); - if(flags & (1 << 7)) buffer.getShortString(messageId); - if(flags & (1 << 6)) timestamp = buffer.getLongLong(); - if(flags & (1 << 5)) buffer.getShortString(type); - if(flags & (1 << 4)) buffer.getShortString(userId); - if(flags & (1 << 3)) buffer.getShortString(appId); - if(flags & (1 << 2)) buffer.getShortString(clusterId); -} - -u_int16_t qpid::framing::BasicHeaderProperties::getFlags() const{ - u_int16_t flags(0); - if(contentType.length() > 0) flags |= (1 << 15); - if(contentEncoding.length() > 0) flags |= (1 << 14); - if(headers.count() > 0) flags |= (1 << 13); - if(deliveryMode != 0) flags |= (1 << 12); - if(priority != 0) flags |= (1 << 11); - if(correlationId.length() > 0) flags |= (1 << 10); - if(replyTo.length() > 0) flags |= (1 << 9); - if(expiration.length() > 0) flags |= (1 << 8); - if(messageId.length() > 0) flags |= (1 << 7); - if(timestamp != 0) flags |= (1 << 6); - if(type.length() > 0) flags |= (1 << 5); - if(userId.length() > 0) flags |= (1 << 4); - if(appId.length() > 0) flags |= (1 << 3); - if(clusterId.length() > 0) flags |= (1 << 2); - return flags; -} diff --git a/Final/cpp/lib/common/framing/BasicHeaderProperties.h b/Final/cpp/lib/common/framing/BasicHeaderProperties.h deleted file mode 100644 index bcd81b4776..0000000000 --- a/Final/cpp/lib/common/framing/BasicHeaderProperties.h +++ /dev/null @@ -1,97 +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 <amqp_types.h> -#include <Buffer.h> -#include <FieldTable.h> -#include <HeaderProperties.h> - -#ifndef _BasicHeaderProperties_ -#define _BasicHeaderProperties_ - -namespace qpid { -namespace framing { - enum delivery_mode {TRANSIENT = 1, PERSISTENT = 2}; - - //TODO: This could be easily generated from the spec - class BasicHeaderProperties : public HeaderProperties - { - string contentType; - string contentEncoding; - FieldTable headers; - u_int8_t deliveryMode; - u_int8_t priority; - string correlationId; - string replyTo; - string expiration; - string messageId; - u_int64_t timestamp; - string type; - string userId; - string appId; - string clusterId; - - u_int16_t getFlags() const; - - public: - BasicHeaderProperties(); - virtual ~BasicHeaderProperties(); - virtual u_int32_t size() const; - virtual void encode(Buffer& buffer) const; - virtual void decode(Buffer& buffer, u_int32_t size); - - inline virtual u_int8_t classId() { return BASIC; } - - inline const string& getContentType() const { return contentType; } - inline const string& getContentEncoding() const { return contentEncoding; } - inline FieldTable& getHeaders() { return headers; } - inline u_int8_t getDeliveryMode() const { return deliveryMode; } - inline u_int8_t getPriority() const { return priority; } - inline const string& getCorrelationId() const {return correlationId; } - inline const string& getReplyTo() const { return replyTo; } - inline const string& getExpiration() const { return expiration; } - inline const string& getMessageId() const {return messageId; } - inline u_int64_t getTimestamp() const { return timestamp; } - inline const string& getType() const { return type; } - inline const string& getUserId() const { return userId; } - inline const string& getAppId() const { return appId; } - inline const string& getClusterId() const { return clusterId; } - - void inline setContentType(const string& _type){ contentType = _type; } - void inline setContentEncoding(const string& encoding){ contentEncoding = encoding; } - void inline setHeaders(const FieldTable& _headers){ headers = _headers; } - void inline setDeliveryMode(u_int8_t mode){ deliveryMode = mode; } - void inline setPriority(u_int8_t _priority){ priority = _priority; } - void inline setCorrelationId(const string& _correlationId){ correlationId = _correlationId; } - void inline setReplyTo(const string& _replyTo){ replyTo = _replyTo;} - void inline setExpiration(const string& _expiration){ expiration = _expiration; } - void inline setMessageId(const string& _messageId){ messageId = _messageId; } - void inline setTimestamp(u_int64_t _timestamp){ timestamp = _timestamp; } - void inline setType(const string& _type){ type = _type; } - void inline setUserId(const string& _userId){ userId = _userId; } - void inline setAppId(const string& _appId){appId = _appId; } - void inline setClusterId(const string& _clusterId){ clusterId = _clusterId; } - }; - -} -} - - -#endif diff --git a/Final/cpp/lib/common/framing/BodyHandler.cpp b/Final/cpp/lib/common/framing/BodyHandler.cpp deleted file mode 100644 index 8ccfb222df..0000000000 --- a/Final/cpp/lib/common/framing/BodyHandler.cpp +++ /dev/null @@ -1,54 +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 <boost/shared_ptr.hpp> -#include <BodyHandler.h> - -using namespace qpid::framing; -using namespace boost; - -BodyHandler::~BodyHandler() {} - -void BodyHandler::handleBody(AMQBody::shared_ptr& body){ - - switch(body->type()) - { - - case METHOD_BODY: - handleMethod(dynamic_pointer_cast<AMQMethodBody, AMQBody>(body)); - break; - - case HEADER_BODY: - handleHeader(dynamic_pointer_cast<AMQHeaderBody, AMQBody>(body)); - break; - - case CONTENT_BODY: - handleContent(dynamic_pointer_cast<AMQContentBody, AMQBody>(body)); - break; - - case HEARTBEAT_BODY: - handleHeartbeat(dynamic_pointer_cast<AMQHeartbeatBody, AMQBody>(body)); - break; - - default: - throw UnknownBodyType(body->type()); - } - -} diff --git a/Final/cpp/lib/common/framing/BodyHandler.h b/Final/cpp/lib/common/framing/BodyHandler.h deleted file mode 100644 index 3923258d1c..0000000000 --- a/Final/cpp/lib/common/framing/BodyHandler.h +++ /dev/null @@ -1,54 +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 <string> - -#ifndef _BodyHandler_ -#define _BodyHandler_ - -#include <AMQMethodBody.h> -#include <AMQHeaderBody.h> -#include <AMQContentBody.h> -#include <AMQHeartbeatBody.h> - -namespace qpid { -namespace framing { - - class BodyHandler{ - public: - virtual ~BodyHandler(); - virtual void handleMethod(AMQMethodBody::shared_ptr body) = 0; - virtual void handleHeader(AMQHeaderBody::shared_ptr body) = 0; - virtual void handleContent(AMQContentBody::shared_ptr body) = 0; - virtual void handleHeartbeat(AMQHeartbeatBody::shared_ptr body) = 0; - - void handleBody(AMQBody::shared_ptr& body); - }; - - class UnknownBodyType{ - public: - const u_int16_t type; - inline UnknownBodyType(u_int16_t _type) : type(_type){} - }; -} -} - - -#endif diff --git a/Final/cpp/lib/common/framing/Buffer.cpp b/Final/cpp/lib/common/framing/Buffer.cpp deleted file mode 100644 index 43815c2f1d..0000000000 --- a/Final/cpp/lib/common/framing/Buffer.cpp +++ /dev/null @@ -1,183 +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 <FieldTable.h> - -qpid::framing::Buffer::Buffer(u_int32_t _size) : size(_size), owner(true), position(0), limit(_size){ - data = new char[size]; -} - -qpid::framing::Buffer::Buffer(char* _data, u_int32_t _size) : size(_size), owner(false), data(_data), position(0), limit(_size){ -} - -qpid::framing::Buffer::~Buffer(){ - if(owner) delete[] data; -} - -void qpid::framing::Buffer::flip(){ - limit = position; - position = 0; -} - -void qpid::framing::Buffer::clear(){ - limit = size; - position = 0; -} - -void qpid::framing::Buffer::compact(){ - u_int32_t p = limit - position; - //copy p chars from position to 0 - memmove(data, data + position, p); - limit = size; - position = p; -} - -void qpid::framing::Buffer::record(){ - r_position = position; - r_limit = limit; -} - -void qpid::framing::Buffer::restore(){ - position = r_position; - limit = r_limit; -} - -u_int32_t qpid::framing::Buffer::available(){ - return limit - position; -} - -char* qpid::framing::Buffer::start(){ - return data + position; -} - -void qpid::framing::Buffer::move(u_int32_t bytes){ - position += bytes; -} - -void qpid::framing::Buffer::putOctet(u_int8_t i){ - data[position++] = i; -} - -void qpid::framing::Buffer::putShort(u_int16_t i){ - u_int16_t b = i; - data[position++] = (u_int8_t) (0xFF & (b >> 8)); - data[position++] = (u_int8_t) (0xFF & b); -} - -void qpid::framing::Buffer::putLong(u_int32_t i){ - u_int32_t b = i; - data[position++] = (u_int8_t) (0xFF & (b >> 24)); - data[position++] = (u_int8_t) (0xFF & (b >> 16)); - data[position++] = (u_int8_t) (0xFF & (b >> 8)); - data[position++] = (u_int8_t) (0xFF & b); -} - -void qpid::framing::Buffer::putLongLong(u_int64_t i){ - u_int32_t hi = i >> 32; - u_int32_t lo = i; - putLong(hi); - putLong(lo); -} - -u_int8_t qpid::framing::Buffer::getOctet(){ - return (u_int8_t) data[position++]; -} - -u_int16_t qpid::framing::Buffer::getShort(){ - u_int16_t hi = (unsigned char) data[position++]; - hi = hi << 8; - hi |= (unsigned char) data[position++]; - return hi; -} - -u_int32_t qpid::framing::Buffer::getLong(){ - u_int32_t a = (unsigned char) data[position++]; - u_int32_t b = (unsigned char) data[position++]; - u_int32_t c = (unsigned char) data[position++]; - u_int32_t d = (unsigned char) data[position++]; - a = a << 24; - a |= b << 16; - a |= c << 8; - a |= d; - return a; -} - -u_int64_t qpid::framing::Buffer::getLongLong(){ - u_int64_t hi = getLong(); - u_int64_t lo = getLong(); - hi = hi << 32; - return hi | lo; -} - - -void qpid::framing::Buffer::putShortString(const string& s){ - u_int8_t len = s.length(); - putOctet(len); - s.copy(data + position, len); - position += len; -} - -void qpid::framing::Buffer::putLongString(const string& s){ - u_int32_t len = s.length(); - putLong(len); - s.copy(data + position, len); - position += len; -} - -void qpid::framing::Buffer::getShortString(string& s){ - u_int8_t len = getOctet(); - s.assign(data + position, len); - position += len; -} - -void qpid::framing::Buffer::getLongString(string& s){ - u_int32_t len = getLong(); - s.assign(data + position, len); - position += len; -} - -void qpid::framing::Buffer::putFieldTable(const FieldTable& t){ - t.encode(*this); -} - -void qpid::framing::Buffer::getFieldTable(FieldTable& t){ - t.decode(*this); -} - -void qpid::framing::Buffer::putContent(const Content& c){ - c.encode(*this); -} - -void qpid::framing::Buffer::getContent(Content& c){ - c.decode(*this); -} - -void qpid::framing::Buffer::putRawData(const string& s){ - u_int32_t len = s.length(); - s.copy(data + position, len); - position += len; -} - -void qpid::framing::Buffer::getRawData(string& s, u_int32_t len){ - s.assign(data + position, len); - position += len; -} diff --git a/Final/cpp/lib/common/framing/Buffer.h b/Final/cpp/lib/common/framing/Buffer.h deleted file mode 100644 index b07c2a2ced..0000000000 --- a/Final/cpp/lib/common/framing/Buffer.h +++ /dev/null @@ -1,87 +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 <amqp_types.h> - -#ifndef _Buffer_ -#define _Buffer_ - -namespace qpid { -namespace framing { - -class Content; -class FieldTable; - -class Buffer -{ - const u_int32_t size; - const bool owner;//indicates whether the data is owned by this instance - char* data; - u_int32_t position; - u_int32_t limit; - u_int32_t r_position; - u_int32_t r_limit; - -public: - - Buffer(u_int32_t size); - Buffer(char* data, u_int32_t size); - ~Buffer(); - - void flip(); - void clear(); - void compact(); - void record(); - void restore(); - u_int32_t available(); - char* start(); - void move(u_int32_t bytes); - - void putOctet(u_int8_t i); - void putShort(u_int16_t i); - void putLong(u_int32_t i); - void putLongLong(u_int64_t i); - - u_int8_t getOctet(); - u_int16_t getShort(); - u_int32_t getLong(); - u_int64_t getLongLong(); - - void putShortString(const string& s); - void putLongString(const string& s); - void getShortString(string& s); - void getLongString(string& s); - - void putFieldTable(const FieldTable& t); - void getFieldTable(FieldTable& t); - - void putContent(const Content& c); - void getContent(Content& c); - - void putRawData(const string& s); - void getRawData(string& s, u_int32_t size); - -}; - -} -} - - -#endif diff --git a/Final/cpp/lib/common/framing/FieldTable.cpp b/Final/cpp/lib/common/framing/FieldTable.cpp deleted file mode 100644 index cf16e87272..0000000000 --- a/Final/cpp/lib/common/framing/FieldTable.cpp +++ /dev/null @@ -1,150 +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 <FieldTable.h> -#include <QpidError.h> -#include <Buffer.h> -#include <Value.h> -#include <assert.h> - -namespace qpid { -namespace framing { - -FieldTable::~FieldTable() {} - -u_int32_t FieldTable::size() const { - u_int32_t len(4); - for(ValueMap::const_iterator i = values.begin(); i != values.end(); ++i) { - // 2 = shortstr_len_byyte + type_char_byte - len += 2 + (i->first).size() + (i->second)->size(); - } - return len; -} - -int FieldTable::count() const { - return values.size(); -} - -namespace -{ -std::ostream& operator<<(std::ostream& out, const FieldTable::ValueMap::value_type& i) { - return out << i.first << ":" << *i.second; -} -} - -std::ostream& operator<<(std::ostream& out, const FieldTable& t) { - out << "{"; - FieldTable::ValueMap::const_iterator i = t.getMap().begin(); - if (i != t.getMap().end()) out << *i++; - while (i != t.getMap().end()) - { - out << "," << *i++; - } - return out << "}"; -} - -void FieldTable::setString(const std::string& name, const std::string& value){ - values[name] = ValuePtr(new StringValue(value)); -} - -void FieldTable::setInt(const std::string& name, int value){ - values[name] = ValuePtr(new IntegerValue(value)); -} - -void FieldTable::setTimestamp(const std::string& name, u_int64_t value){ - values[name] = ValuePtr(new TimeValue(value)); -} - -void FieldTable::setTable(const std::string& name, const FieldTable& value){ - values[name] = ValuePtr(new FieldTableValue(value)); -} - -namespace { -template <class T> T default_value() { return T(); } -template <> int default_value<int>() { return 0; } -template <> u_int64_t default_value<u_int64_t>() { return 0; } -} - -template <class T> -T FieldTable::getValue(const std::string& name) const -{ - ValueMap::const_iterator i = values.find(name); - if (i == values.end()) return default_value<T>(); - const ValueOps<T> *vt = dynamic_cast<const ValueOps<T>*>(i->second.get()); - return vt->getValue(); -} - -std::string FieldTable::getString(const std::string& name) const { - return getValue<std::string>(name); -} - -int FieldTable::getInt(const std::string& name) const { - return getValue<int>(name); -} - -u_int64_t FieldTable::getTimestamp(const std::string& name) const { - return getValue<u_int64_t>(name); -} - -void FieldTable::getTable(const std::string& name, FieldTable& value) const { - value = getValue<FieldTable>(name); -} - -void FieldTable::encode(Buffer& buffer) const{ - buffer.putLong(size() - 4); - for (ValueMap::const_iterator i = values.begin(); i!=values.end(); ++i) { - buffer.putShortString(i->first); - buffer.putOctet(i->second->getType()); - i->second->encode(buffer); - } -} - -void FieldTable::decode(Buffer& buffer){ - u_int32_t len = buffer.getLong(); - u_int32_t available = buffer.available(); - if (available < len) - THROW_QPID_ERROR(FRAMING_ERROR, "Not enough data for field table."); - u_int32_t leftover = available - len; - while(buffer.available() > leftover){ - std::string name; - buffer.getShortString(name); - std::auto_ptr<Value> value(Value::decode_value(buffer)); - values[name] = ValuePtr(value.release()); - } -} - - -bool FieldTable::operator==(const FieldTable& x) const { - if (values.size() != x.values.size()) return false; - for (ValueMap::const_iterator i = values.begin(); i != values.end(); ++i) { - ValueMap::const_iterator j = x.values.find(i->first); - if (j == x.values.end()) return false; - if (*(i->second) != *(j->second)) return false; - } - return true; -} - -void FieldTable::erase(const std::string& name) -{ - values.erase(values.find(name)); -} - -} -} diff --git a/Final/cpp/lib/common/framing/FieldTable.h b/Final/cpp/lib/common/framing/FieldTable.h deleted file mode 100644 index 6fa10ab108..0000000000 --- a/Final/cpp/lib/common/framing/FieldTable.h +++ /dev/null @@ -1,90 +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 <iostream> -#include <vector> -#include <boost/shared_ptr.hpp> -#include <map> -#include <amqp_types.h> - -#ifndef _FieldTable_ -#define _FieldTable_ - -namespace qpid { - /** - * The framing namespace contains classes that are used to create, - * send and receive the basic packets from which AMQP is built. - */ -namespace framing { - -class Value; -class Buffer; - -/** - * A set of name-value pairs. (See the AMQP spec for more details on - * AMQP field tables). - * - * \ingroup clientapi - */ -class FieldTable -{ - public: - typedef boost::shared_ptr<Value> ValuePtr; - typedef std::map<std::string, ValuePtr> ValueMap; - - ~FieldTable(); - u_int32_t size() const; - int count() const; - void setString(const std::string& name, const std::string& value); - void setInt(const std::string& name, int value); - void setTimestamp(const std::string& name, u_int64_t value); - void setTable(const std::string& name, const FieldTable& value); - //void setDecimal(string& name, xxx& value); - std::string getString(const std::string& name) const; - int getInt(const std::string& name) const; - u_int64_t getTimestamp(const std::string& name) const; - void getTable(const std::string& name, FieldTable& value) const; - //void getDecimal(string& name, xxx& value); - void erase(const std::string& name); - - void encode(Buffer& buffer) const; - void decode(Buffer& buffer); - - bool operator==(const FieldTable& other) const; - - // TODO aconway 2006-09-26: Yeuch! Rework FieldTable to have - // a map-like interface. - const ValueMap& getMap() const { return values; } - ValueMap& getMap() { return values; } - - private: - friend std::ostream& operator<<(std::ostream& out, const FieldTable& body); - ValueMap values; - template<class T> T getValue(const std::string& name) const; -}; - -class FieldNotFoundException{}; -class UnknownFieldName : public FieldNotFoundException{}; -class IncorrectFieldType : public FieldNotFoundException{}; -} -} - - -#endif diff --git a/Final/cpp/lib/common/framing/FramingContent.cpp b/Final/cpp/lib/common/framing/FramingContent.cpp deleted file mode 100644 index e5f50b5075..0000000000 --- a/Final/cpp/lib/common/framing/FramingContent.cpp +++ /dev/null @@ -1,41 +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> - -namespace qpid -{ -namespace framing -{ - -Content::~Content() {} - -void Content::encode(Buffer&) const -{ -} - -void Content::decode(Buffer&) -{ -} - - -} // namespace framing -} // namespace qpid diff --git a/Final/cpp/lib/common/framing/FramingContent.h b/Final/cpp/lib/common/framing/FramingContent.h deleted file mode 100644 index 1ab3ba468b..0000000000 --- a/Final/cpp/lib/common/framing/FramingContent.h +++ /dev/null @@ -1,47 +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 _Content_ -#define _Content_ - -namespace qpid -{ -namespace framing -{ - -/* - * TODO: New Content class required for AMQP 0-9. This is a stub only. - */ -class Content -{ - public: - ~Content(); - - void encode(Buffer& buffer) const; - void decode(Buffer& buffer); - -}; - -} // namespace framing -} // namespace qpid - - -#endif diff --git a/Final/cpp/lib/common/framing/HeaderProperties.h b/Final/cpp/lib/common/framing/HeaderProperties.h deleted file mode 100644 index 7a8c65549d..0000000000 --- a/Final/cpp/lib/common/framing/HeaderProperties.h +++ /dev/null @@ -1,46 +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 <amqp_types.h> -#include <Buffer.h> - -#ifndef _HeaderProperties_ -#define _HeaderProperties_ - -namespace qpid { -namespace framing { - - enum header_classes{BASIC = 60}; - - class HeaderProperties - { - - public: - inline virtual ~HeaderProperties(){} - virtual u_int8_t classId() = 0; - virtual u_int32_t size() const = 0; - virtual void encode(Buffer& buffer) const = 0; - virtual void decode(Buffer& buffer, u_int32_t size) = 0; - }; -} -} - - -#endif diff --git a/Final/cpp/lib/common/framing/InitiationHandler.cpp b/Final/cpp/lib/common/framing/InitiationHandler.cpp deleted file mode 100644 index dd92c9859b..0000000000 --- a/Final/cpp/lib/common/framing/InitiationHandler.cpp +++ /dev/null @@ -1,24 +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 <InitiationHandler.h> - -qpid::framing::InitiationHandler::~InitiationHandler() {} diff --git a/Final/cpp/lib/common/framing/InitiationHandler.h b/Final/cpp/lib/common/framing/InitiationHandler.h deleted file mode 100644 index d94fc58d2c..0000000000 --- a/Final/cpp/lib/common/framing/InitiationHandler.h +++ /dev/null @@ -1,41 +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 <string> - -#ifndef _InitiationHandler_ -#define _InitiationHandler_ - -#include <ProtocolInitiation.h> - -namespace qpid { -namespace framing { - - class InitiationHandler{ - public: - virtual ~InitiationHandler(); - virtual void initiated(ProtocolInitiation* header) = 0; - }; - -} -} - - -#endif diff --git a/Final/cpp/lib/common/framing/InputHandler.h b/Final/cpp/lib/common/framing/InputHandler.h deleted file mode 100644 index 4e2d4bcc9b..0000000000 --- a/Final/cpp/lib/common/framing/InputHandler.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef _InputHandler_ -#define _InputHandler_ -/* - * - * 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 <AMQFrame.h> -#include <boost/noncopyable.hpp> - -namespace qpid { -namespace framing { - -class InputHandler : private boost::noncopyable { - public: - virtual ~InputHandler() {} - virtual void received(AMQFrame* frame) = 0; -}; - -}} - - -#endif diff --git a/Final/cpp/lib/common/framing/OutputHandler.h b/Final/cpp/lib/common/framing/OutputHandler.h deleted file mode 100644 index 2e01e34df2..0000000000 --- a/Final/cpp/lib/common/framing/OutputHandler.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef _OutputHandler_ -#define _OutputHandler_ - -/* - * - * 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 <boost/noncopyable.hpp> -#include <AMQFrame.h> - -namespace qpid { -namespace framing { - -class OutputHandler : private boost::noncopyable { - public: - virtual ~OutputHandler() {} - virtual void send(AMQFrame* frame) = 0; -}; - -}} - - -#endif diff --git a/Final/cpp/lib/common/framing/ProtocolInitiation.cpp b/Final/cpp/lib/common/framing/ProtocolInitiation.cpp deleted file mode 100644 index 471f736a7d..0000000000 --- a/Final/cpp/lib/common/framing/ProtocolInitiation.cpp +++ /dev/null @@ -1,58 +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 <ProtocolInitiation.h> - -qpid::framing::ProtocolInitiation::ProtocolInitiation(){} - -qpid::framing::ProtocolInitiation::ProtocolInitiation(u_int8_t _major, u_int8_t _minor) : version(_major, _minor) {} - -qpid::framing::ProtocolInitiation::ProtocolInitiation(const qpid::framing::ProtocolVersion& p) : version(p) {} - -qpid::framing::ProtocolInitiation::~ProtocolInitiation(){} - -void qpid::framing::ProtocolInitiation::encode(Buffer& buffer){ - buffer.putOctet('A'); - buffer.putOctet('M'); - buffer.putOctet('Q'); - buffer.putOctet('P'); - buffer.putOctet(1);//class - buffer.putOctet(1);//instance - buffer.putOctet(version.getMajor()); - buffer.putOctet(version.getMinor()); -} - -bool qpid::framing::ProtocolInitiation::decode(Buffer& buffer){ - if(buffer.available() >= 8){ - buffer.getOctet();//A - buffer.getOctet();//M - buffer.getOctet();//Q - buffer.getOctet();//P - buffer.getOctet();//class - buffer.getOctet();//instance - version.setMajor(buffer.getOctet()); - version.setMinor(buffer.getOctet()); - return true; - }else{ - return false; - } -} - -//TODO: this should prbably be generated from the spec at some point to keep the version numbers up to date diff --git a/Final/cpp/lib/common/framing/ProtocolInitiation.h b/Final/cpp/lib/common/framing/ProtocolInitiation.h deleted file mode 100644 index 003c3bba81..0000000000 --- a/Final/cpp/lib/common/framing/ProtocolInitiation.h +++ /dev/null @@ -1,54 +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 <amqp_types.h> -#include <Buffer.h> -#include <AMQDataBlock.h> -#include <ProtocolVersion.h> - -#ifndef _ProtocolInitiation_ -#define _ProtocolInitiation_ - -namespace qpid { -namespace framing { - -class ProtocolInitiation : virtual public AMQDataBlock -{ -private: - ProtocolVersion version; - -public: - ProtocolInitiation(); - ProtocolInitiation(u_int8_t major, u_int8_t minor); - ProtocolInitiation(const ProtocolVersion& p); - virtual ~ProtocolInitiation(); - virtual void encode(Buffer& buffer); - virtual bool decode(Buffer& buffer); - inline virtual u_int32_t size() const { return 8; } - inline u_int8_t getMajor() const { return version.getMajor(); } - inline u_int8_t getMinor() const { return version.getMinor(); } - inline const ProtocolVersion& getVersion() const { return version; } -}; - -} -} - - -#endif diff --git a/Final/cpp/lib/common/framing/ProtocolVersion.cpp b/Final/cpp/lib/common/framing/ProtocolVersion.cpp deleted file mode 100644 index 69ff89ec32..0000000000 --- a/Final/cpp/lib/common/framing/ProtocolVersion.cpp +++ /dev/null @@ -1,64 +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 <ProtocolVersion.h> -#include <sstream> - -using namespace qpid::framing; - -ProtocolVersion::ProtocolVersion() {} - -ProtocolVersion::ProtocolVersion(u_int8_t _major, u_int8_t _minor) : - major_(_major), - minor_(_minor) -{} - -ProtocolVersion::ProtocolVersion(const ProtocolVersion::ProtocolVersion& p): - major_(p.major_), - minor_(p.minor_) -{} - -ProtocolVersion::~ProtocolVersion() -{} - -bool ProtocolVersion::equals(u_int8_t _major, u_int8_t _minor) const -{ - return major_ == _major && minor_ == _minor; -} - -bool ProtocolVersion::equals(const ProtocolVersion::ProtocolVersion& p) const -{ - return major_ == p.major_ && minor_ == p.minor_; -} - -const std::string ProtocolVersion::toString() const -{ - std::stringstream ss; - ss << major_ << "-" << minor_; - return ss.str(); -} - -ProtocolVersion::ProtocolVersion ProtocolVersion::operator=(const ProtocolVersion& p) -{ - major_ = p.major_; - minor_ = p.minor_; - return *this; -} - diff --git a/Final/cpp/lib/common/framing/ProtocolVersion.h b/Final/cpp/lib/common/framing/ProtocolVersion.h deleted file mode 100644 index 331cf53555..0000000000 --- a/Final/cpp/lib/common/framing/ProtocolVersion.h +++ /dev/null @@ -1,57 +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 _ProtocolVersion_ -#define _ProtocolVersion_ - -#include <amqp_types.h> - -namespace qpid -{ -namespace framing -{ - -class ProtocolVersion -{ -private: - u_int8_t major_; - u_int8_t minor_; - -public: - ProtocolVersion(); - ProtocolVersion(u_int8_t _major, u_int8_t _minor); - ProtocolVersion(const ProtocolVersion& p); - virtual ~ProtocolVersion(); - - inline u_int8_t getMajor() const { return major_; } - inline void setMajor(u_int8_t major) { major_ = major; } - inline u_int8_t getMinor() const { return minor_; } - inline void setMinor(u_int8_t minor) { minor_ = minor; } - virtual bool equals(u_int8_t _major, u_int8_t _minor) const; - virtual bool equals(const ProtocolVersion& p) const; - virtual const std::string toString() const; - ProtocolVersion operator=(const ProtocolVersion& p); -}; - -} // namespace framing -} // namespace qpid - - -#endif // ifndef _ProtocolVersion_ diff --git a/Final/cpp/lib/common/framing/ProtocolVersionException.cpp b/Final/cpp/lib/common/framing/ProtocolVersionException.cpp deleted file mode 100644 index 8249a88f4b..0000000000 --- a/Final/cpp/lib/common/framing/ProtocolVersionException.cpp +++ /dev/null @@ -1,66 +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 <ProtocolVersionException.h> -#include <sstream> - -using namespace qpid::framing; - -ProtocolVersionException::ProtocolVersionException() throw () -{ -} - -ProtocolVersionException::ProtocolVersionException(const std::string& str) throw () : Exception(str) -{ -} - -ProtocolVersionException::ProtocolVersionException(const char* str) throw () : Exception(str) -{ -} - -ProtocolVersionException::ProtocolVersionException(const ProtocolVersion& versionFound_, const std::string& str) throw () : Exception(str) - -{ - versionFound = versionFound_; -} - -ProtocolVersionException::ProtocolVersionException(const ProtocolVersion& versionFound_, const char* str) throw () : Exception(str) - -{ - versionFound = versionFound_; -} - -ProtocolVersionException::~ProtocolVersionException() throw () -{ -} - -const char* ProtocolVersionException::what() const throw() -{ - std::stringstream ss; - ss << "ProtocolVersionException: AMQP Version " << versionFound.toString() << " found: " << whatStr; - return ss.str().c_str(); -} - -std::string ProtocolVersionException::toString() const throw() -{ - std::stringstream ss; - ss << "ProtocolVersionException: AMQP Version " << versionFound.toString() << " found: " << whatStr; - return ss.str(); -} diff --git a/Final/cpp/lib/common/framing/ProtocolVersionException.h b/Final/cpp/lib/common/framing/ProtocolVersionException.h deleted file mode 100644 index 4494d87064..0000000000 --- a/Final/cpp/lib/common/framing/ProtocolVersionException.h +++ /dev/null @@ -1,55 +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 _ProtocolVersionException_ -#define _ProtocolVersionException_ - -#include <Exception.h> -#include <ProtocolVersion.h> -#include <string> -#include <vector> - -namespace qpid -{ -namespace framing -{ - -class ProtocolVersionException : virtual public qpid::Exception -{ -protected: - ProtocolVersion versionFound; - -public: - ProtocolVersionException() throw (); - ProtocolVersionException(const std::string& str) throw (); - ProtocolVersionException(const char* str) throw (); - ProtocolVersionException(const ProtocolVersion& versionFound_, const std::string& str) throw (); - ProtocolVersionException(const ProtocolVersion& versionFound_, const char* str) throw (); - virtual ~ProtocolVersionException() throw (); - - virtual const char* what() const throw(); - virtual std::string toString() const throw(); -}; // class ProtocolVersionException - -} // namespace framing -} // namespace qpid - -#endif //ifndef _ProtocolVersionException_ diff --git a/Final/cpp/lib/common/framing/Value.cpp b/Final/cpp/lib/common/framing/Value.cpp deleted file mode 100644 index 9b1f3bbc94..0000000000 --- a/Final/cpp/lib/common/framing/Value.cpp +++ /dev/null @@ -1,122 +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 <Value.h> -#include <Buffer.h> -#include <FieldTable.h> -#include <QpidError.h> -#include <sstream> - -namespace qpid { -namespace framing { - -Value::~Value() {} - -void StringValue::encode(Buffer& buffer){ - buffer.putLongString(value); -} -void StringValue::decode(Buffer& buffer){ - buffer.getLongString(value); -} - -void IntegerValue::encode(Buffer& buffer){ - buffer.putLong((u_int32_t) value); -} -void IntegerValue::decode(Buffer& buffer){ - value = buffer.getLong(); -} - -void TimeValue::encode(Buffer& buffer){ - buffer.putLongLong(value); -} -void TimeValue::decode(Buffer& buffer){ - value = buffer.getLongLong(); -} - -void DecimalValue::encode(Buffer& buffer){ - buffer.putOctet(value.decimals); - buffer.putLong(value.value); -} -void DecimalValue::decode(Buffer& buffer){ - value = Decimal(buffer.getLong(), buffer.getOctet()); -} - -void FieldTableValue::encode(Buffer& buffer){ - buffer.putFieldTable(value); -} -void FieldTableValue::decode(Buffer& buffer){ - buffer.getFieldTable(value); -} - -std::auto_ptr<Value> Value::decode_value(Buffer& buffer) -{ - std::auto_ptr<Value> value; - u_int8_t type = buffer.getOctet(); - switch(type){ - case 'S': - value.reset(new StringValue()); - break; - case 'I': - value.reset(new IntegerValue()); - break; - case 'D': - value.reset(new DecimalValue()); - break; - case 'T': - value.reset(new TimeValue()); - break; - case 'F': - value.reset(new FieldTableValue()); - break; - - //non-standard types, introduced in java client for JMS compliance - case 'x': - value.reset(new BinaryValue()); - break; - default: - std::stringstream out; - out << "Unknown field table value type: " << type; - THROW_QPID_ERROR(FRAMING_ERROR, out.str()); - } - value->decode(buffer); - return value; -} - -EmptyValue::~EmptyValue() {} - -void EmptyValue::print(std::ostream& out) const -{ - out << "<empty field value>"; -} - -std::ostream& operator<<(std::ostream& out, const Value& v) { - v.print(out); - return out; -} - -std::ostream& operator<<(std::ostream& out, const Decimal& d) -{ - return out << "Decimal(" << d.value << "," << d.decimals << ")"; -} - -}} - - - diff --git a/Final/cpp/lib/common/framing/Value.h b/Final/cpp/lib/common/framing/Value.h deleted file mode 100644 index e7ae865a70..0000000000 --- a/Final/cpp/lib/common/framing/Value.h +++ /dev/null @@ -1,171 +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 <iostream> -#include <vector> -#include <amqp_types.h> -#include <FieldTable.h> - -#ifndef _Value_ -#define _Value_ - -namespace qpid { -namespace framing { - -class Buffer; - -/** - * Represents a decimal value. - * No arithmetic functionality for now, we only care about encoding/decoding. - */ -struct Decimal { - u_int32_t value; - u_int8_t decimals; - - Decimal(u_int32_t value_=0, u_int8_t decimals_=0) : value(value_), decimals(decimals_) {} - bool operator==(const Decimal& d) const { - return decimals == d.decimals && value == d.value; - } - bool operator!=(const Decimal& d) const { return !(*this == d); } -}; - -std::ostream& operator<<(std::ostream& out, const Decimal& d); - -/** - * Polymorpic base class for values. - */ -class Value { - public: - virtual ~Value(); - virtual u_int32_t size() const = 0; - virtual char getType() const = 0; - virtual void encode(Buffer& buffer) = 0; - virtual void decode(Buffer& buffer) = 0; - virtual bool operator==(const Value&) const = 0; - bool operator!=(const Value& v) const { return !(*this == v); } - virtual void print(std::ostream& out) const = 0; - - /** Create a new value by decoding from the buffer */ - static std::auto_ptr<Value> decode_value(Buffer& buffer); -}; - -std::ostream& operator<<(std::ostream& out, const Value& d); - - -/** - * Template for common operations on Value sub-classes. - */ -template <class T> -class ValueOps : public Value -{ - protected: - T value; - public: - ValueOps() {} - ValueOps(const T& v) : value(v) {} - const T& getValue() const { return value; } - T& getValue() { return value; } - - virtual bool operator==(const Value& v) const { - const ValueOps<T>* vo = dynamic_cast<const ValueOps<T>*>(&v); - if (vo == 0) return false; - else return value == vo->value; - } - - void print(std::ostream& out) const { out << value; } -}; - - -class StringValue : public ValueOps<std::string> { - public: - StringValue(const std::string& v) : ValueOps<std::string>(v) {} - StringValue() {} - virtual u_int32_t size() const { return 4 + value.length(); } - virtual char getType() const { return 'S'; } - virtual void encode(Buffer& buffer); - virtual void decode(Buffer& buffer); -}; - -class IntegerValue : public ValueOps<int> { - public: - IntegerValue(int v) : ValueOps<int>(v) {} - IntegerValue(){} - virtual u_int32_t size() const { return 4; } - virtual char getType() const { return 'I'; } - virtual void encode(Buffer& buffer); - virtual void decode(Buffer& buffer); -}; - -class TimeValue : public ValueOps<u_int64_t> { - public: - TimeValue(u_int64_t v) : ValueOps<u_int64_t>(v){} - TimeValue(){} - virtual u_int32_t size() const { return 8; } - virtual char getType() const { return 'T'; } - virtual void encode(Buffer& buffer); - virtual void decode(Buffer& buffer); -}; - -class DecimalValue : public ValueOps<Decimal> { - public: - DecimalValue(const Decimal& d) : ValueOps<Decimal>(d) {} - DecimalValue(u_int32_t value_=0, u_int8_t decimals_=0) : - ValueOps<Decimal>(Decimal(value_, decimals_)){} - virtual u_int32_t size() const { return 5; } - virtual char getType() const { return 'D'; } - virtual void encode(Buffer& buffer); - virtual void decode(Buffer& buffer); -}; - - -class FieldTableValue : public ValueOps<FieldTable> { - public: - FieldTableValue(const FieldTable& v) : ValueOps<FieldTable>(v){} - FieldTableValue(){} - virtual u_int32_t size() const { return 4 + value.size(); } - virtual char getType() const { return 'F'; } - virtual void encode(Buffer& buffer); - virtual void decode(Buffer& buffer); -}; - -class EmptyValue : public Value { - public: - ~EmptyValue(); - virtual u_int32_t size() const { return 0; } - virtual char getType() const { return 0; } - virtual void encode(Buffer& ) {} - virtual void decode(Buffer& ) {} - virtual bool operator==(const Value& v) const { - return dynamic_cast<const EmptyValue*>(&v); - } - virtual void print(std::ostream& out) const; -}; - -//non-standard types, introduced in java client for JMS compliance -class BinaryValue : public StringValue { - public: - BinaryValue(const std::string& v) : StringValue(v) {} - BinaryValue() {} - virtual char getType() const { return 'x'; } -}; - -}} // qpid::framing - -#endif diff --git a/Final/cpp/lib/common/framing/amqp_framing.h b/Final/cpp/lib/common/framing/amqp_framing.h deleted file mode 100644 index 62f87352f8..0000000000 --- a/Final/cpp/lib/common/framing/amqp_framing.h +++ /dev/null @@ -1,36 +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 <amqp_types.h> -#include <AMQFrame.h> -#include <AMQBody.h> -#include <BodyHandler.h> -#include <AMQMethodBody.h> -#include <AMQHeaderBody.h> -#include <AMQContentBody.h> -#include <AMQHeartbeatBody.h> -#include <AMQP_MethodVersionMap.h> -#include <InputHandler.h> -#include <OutputHandler.h> -#include <InitiationHandler.h> -#include <ProtocolInitiation.h> -#include <BasicHeaderProperties.h> -#include <ProtocolVersion.h> -#include <ProtocolVersionException.h> diff --git a/Final/cpp/lib/common/framing/amqp_types.h b/Final/cpp/lib/common/framing/amqp_types.h deleted file mode 100644 index 3d8e9632c0..0000000000 --- a/Final/cpp/lib/common/framing/amqp_types.h +++ /dev/null @@ -1,45 +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 <string> -#ifdef _WINDOWS -#include "windows.h" -typedef unsigned char u_int8_t; -typedef unsigned short u_int16_t; -typedef unsigned int u_int32_t; -typedef unsigned __int64 u_int64_t; -#endif -#ifndef _WINDOWS -#include "stdint.h" -#endif - -#ifndef AMQP_TYPES_H -#define AMQP_TYPES_H - -namespace qpid -{ -namespace framing -{ - -using std::string; - -} -} -#endif |