From 019efd3773a2f6986ef8eef3749ecb2dfbef2147 Mon Sep 17 00:00:00 2001 From: Andrew Stitcher Date: Thu, 3 Jul 2014 03:00:18 +0000 Subject: QPID-5871: Remove unused generated code and dependent code git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1607521 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/qpid/amqp_0_10/Array.cpp | 34 ---- qpid/cpp/src/qpid/amqp_0_10/Array.h | 124 ------------- qpid/cpp/src/qpid/amqp_0_10/Body.h | 55 ------ qpid/cpp/src/qpid/amqp_0_10/Codec.h | 213 ----------------------- qpid/cpp/src/qpid/amqp_0_10/Command.h | 62 ------- qpid/cpp/src/qpid/amqp_0_10/CommmandPacker.h | 60 ------- qpid/cpp/src/qpid/amqp_0_10/Connection.cpp | 3 +- qpid/cpp/src/qpid/amqp_0_10/Control.h | 70 -------- qpid/cpp/src/qpid/amqp_0_10/Decimal.h | 51 ------ qpid/cpp/src/qpid/amqp_0_10/Exception.h | 96 ---------- qpid/cpp/src/qpid/amqp_0_10/FrameHeader.cpp | 50 ------ qpid/cpp/src/qpid/amqp_0_10/FrameHeader.h | 90 ---------- qpid/cpp/src/qpid/amqp_0_10/Header.cpp | 34 ---- qpid/cpp/src/qpid/amqp_0_10/Header.h | 53 ------ qpid/cpp/src/qpid/amqp_0_10/Holder.h | 103 ----------- qpid/cpp/src/qpid/amqp_0_10/Map.cpp | 66 ------- qpid/cpp/src/qpid/amqp_0_10/Map.h | 188 -------------------- qpid/cpp/src/qpid/amqp_0_10/Packer.h | 195 --------------------- qpid/cpp/src/qpid/amqp_0_10/SerializableString.h | 62 ------- qpid/cpp/src/qpid/amqp_0_10/Struct.h | 60 ------- qpid/cpp/src/qpid/amqp_0_10/Struct32.cpp | 36 ---- qpid/cpp/src/qpid/amqp_0_10/Struct32.h | 64 ------- qpid/cpp/src/qpid/amqp_0_10/Unit.cpp | 65 ------- qpid/cpp/src/qpid/amqp_0_10/Unit.h | 82 --------- qpid/cpp/src/qpid/amqp_0_10/UnitHandler.h | 35 ---- qpid/cpp/src/qpid/amqp_0_10/UnknownStruct.cpp | 34 ---- qpid/cpp/src/qpid/amqp_0_10/UnknownStruct.h | 55 ------ qpid/cpp/src/qpid/amqp_0_10/UnknownType.cpp | 56 ------ qpid/cpp/src/qpid/amqp_0_10/UnknownType.h | 87 --------- qpid/cpp/src/qpid/amqp_0_10/apply.h | 86 --------- qpid/cpp/src/qpid/amqp_0_10/built_in_types.h | 171 ------------------ qpid/cpp/src/qpid/amqp_0_10/complex_types.cpp | 84 --------- qpid/cpp/src/qpid/framing/TemplateVisitor.h | 89 ---------- qpid/cpp/src/qpid/framing/Visitor.h | 92 ---------- 34 files changed, 2 insertions(+), 2703 deletions(-) delete mode 100644 qpid/cpp/src/qpid/amqp_0_10/Array.cpp delete mode 100644 qpid/cpp/src/qpid/amqp_0_10/Array.h delete mode 100644 qpid/cpp/src/qpid/amqp_0_10/Body.h delete mode 100644 qpid/cpp/src/qpid/amqp_0_10/Codec.h delete mode 100644 qpid/cpp/src/qpid/amqp_0_10/Command.h delete mode 100644 qpid/cpp/src/qpid/amqp_0_10/CommmandPacker.h delete mode 100644 qpid/cpp/src/qpid/amqp_0_10/Control.h delete mode 100644 qpid/cpp/src/qpid/amqp_0_10/Decimal.h delete mode 100644 qpid/cpp/src/qpid/amqp_0_10/Exception.h delete mode 100644 qpid/cpp/src/qpid/amqp_0_10/FrameHeader.cpp delete mode 100644 qpid/cpp/src/qpid/amqp_0_10/FrameHeader.h delete mode 100644 qpid/cpp/src/qpid/amqp_0_10/Header.cpp delete mode 100644 qpid/cpp/src/qpid/amqp_0_10/Header.h delete mode 100644 qpid/cpp/src/qpid/amqp_0_10/Holder.h delete mode 100644 qpid/cpp/src/qpid/amqp_0_10/Map.cpp delete mode 100644 qpid/cpp/src/qpid/amqp_0_10/Map.h delete mode 100644 qpid/cpp/src/qpid/amqp_0_10/Packer.h delete mode 100644 qpid/cpp/src/qpid/amqp_0_10/SerializableString.h delete mode 100644 qpid/cpp/src/qpid/amqp_0_10/Struct.h delete mode 100644 qpid/cpp/src/qpid/amqp_0_10/Struct32.cpp delete mode 100644 qpid/cpp/src/qpid/amqp_0_10/Struct32.h delete mode 100644 qpid/cpp/src/qpid/amqp_0_10/Unit.cpp delete mode 100644 qpid/cpp/src/qpid/amqp_0_10/Unit.h delete mode 100644 qpid/cpp/src/qpid/amqp_0_10/UnitHandler.h delete mode 100644 qpid/cpp/src/qpid/amqp_0_10/UnknownStruct.cpp delete mode 100644 qpid/cpp/src/qpid/amqp_0_10/UnknownStruct.h delete mode 100644 qpid/cpp/src/qpid/amqp_0_10/UnknownType.cpp delete mode 100644 qpid/cpp/src/qpid/amqp_0_10/UnknownType.h delete mode 100644 qpid/cpp/src/qpid/amqp_0_10/apply.h delete mode 100644 qpid/cpp/src/qpid/amqp_0_10/built_in_types.h delete mode 100644 qpid/cpp/src/qpid/amqp_0_10/complex_types.cpp delete mode 100644 qpid/cpp/src/qpid/framing/TemplateVisitor.h delete mode 100644 qpid/cpp/src/qpid/framing/Visitor.h (limited to 'qpid/cpp/src') diff --git a/qpid/cpp/src/qpid/amqp_0_10/Array.cpp b/qpid/cpp/src/qpid/amqp_0_10/Array.cpp deleted file mode 100644 index 2ee47546f2..0000000000 --- a/qpid/cpp/src/qpid/amqp_0_10/Array.cpp +++ /dev/null @@ -1,34 +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/amqp_0_10/Array.h" - -namespace qpid { -namespace amqp_0_10 { - -std::ostream& operator<<(std::ostream& o, const Array& a) { - std::ostream_iterator i(o, " "); - o << "Array<" << typeName(a.getType()) << "["; - std::copy(a.begin(), a.end(), i); - o << "]"; - return o; -} - -}} // namespace qpid::amqp_0_10 diff --git a/qpid/cpp/src/qpid/amqp_0_10/Array.h b/qpid/cpp/src/qpid/amqp_0_10/Array.h deleted file mode 100644 index 6e8a419df7..0000000000 --- a/qpid/cpp/src/qpid/amqp_0_10/Array.h +++ /dev/null @@ -1,124 +0,0 @@ -#ifndef QPID_AMQP_0_10_ARRAY_H -#define QPID_AMQP_0_10_ARRAY_H - -/* - * - * 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/amqp_0_10/TypeForCode.h" -#include "qpid/amqp_0_10/CodeForType.h" -#include "qpid/amqp_0_10/UnknownType.h" -#include "qpid/amqp_0_10/exceptions.h" -#include "qpid/amqp_0_10/Codec.h" -#include -#include - -namespace qpid { -namespace amqp_0_10 { - -template class ArrayDomain : public std::vector { - public: - template void serialize(S& s) { s.split(*this); } - - template void encode(S& s) const { - s(contentSize())(CodeForType::value)(uint32_t(this->size())); - s(this->begin(), this->end()); - } - - void encode(Codec::Size& s) const { s.raw(0, contentSize() + 4/*size*/); } - - template void decode(S& s) { - uint32_t size; uint8_t type; uint32_t count; - s(size); - typename S::ScopedLimit l(s, size); - s(type); - if (type != CodeForType::value) - throw InvalidArgumentException(QPID_MSG("Array domain expected type " << CodeForType::value << " but found " << type)); - s(count); - this->resize(count); - s(this->begin(), this->end()); - } - - private: - uint32_t contentSize() const { - return Codec::size(this->begin(), this->end()) + sizeof(uint32_t) /*count*/ + sizeof(uint8_t) /*type*/; - } -}; - -template -std::ostream& operator<<(std::ostream& o, const ArrayDomain& ad) { - std::ostream_iterator i(o, " "); - o << "Array<" << typeName(CodeForType::value) << ">["; - std::copy(ad.begin(), ad.end(), i); - o << "]"; - return o; -} - -/** A non-domain array is represented as and array of UnknownType. - * Special case templat. - */ -template<> class ArrayDomain : public std::vector { - public: - ArrayDomain(uint8_t type_=0) : type(type_) {} - - template void serialize(S& s) { s.split(*this); } - - template void encode(S& s) const { - s(contentSize())(type)(uint32_t(this->size())); - s(this->begin(), this->end()); - } - - void encode(Codec::Size& s) const { s.raw(0, contentSize() + 4/*size*/); } - - template void decode(S& s) { - uint32_t size; uint32_t count; - s(size); - typename S::ScopedLimit l(s, size); - s(type)(count); - this->clear(); - this->resize(count, UnknownType(type)); - s(this->begin(), this->end()); - } - - uint8_t getType() const { return type; } - - private: - uint32_t contentSize() const { - return Codec::size(this->begin(), this->end()) + sizeof(uint32_t) /*count*/ + sizeof(uint8_t) /*type*/; - } - uint8_t type; -}; - -std::ostream& operator<<(std::ostream& o, const Array& a); - -// FIXME aconway 2008-04-08: hack to supress encoding of -// command-fragments and in-doubt as there is a problem with the spec -// (command-fragments does not have a one byte type code.) -namespace session { class CommandFragment; } -namespace dtx { class Xid; } - -template <> struct ArrayDomain : public Void {}; -template <> struct ArrayDomain : public Void {}; -inline std::ostream& operator<<(std::ostream& o, const ArrayDomain&) { return o; } -inline std::ostream& operator<<(std::ostream& o, const ArrayDomain&) { return o; } - -}} // namespace qpid::amqp_0_10 - -#endif /*!QPID_AMQP_0_10_ARRAY_H*/ diff --git a/qpid/cpp/src/qpid/amqp_0_10/Body.h b/qpid/cpp/src/qpid/amqp_0_10/Body.h deleted file mode 100644 index c96931551c..0000000000 --- a/qpid/cpp/src/qpid/amqp_0_10/Body.h +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef QPID_AMQP_0_10_BODY_H -#define QPID_AMQP_0_10_BODY_H - -/* - * - * 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 -#include - -namespace qpid { -namespace amqp_0_10 { - -/** Holds data from a body frame. */ -class Body { - public: - Body() {} - Body(size_t size_) : str(size_, '\0') {} - Body(const char* data_, size_t size_) : str(data_, size_) {} - - size_t size() const { return str.size(); }; - const char* data() const { return str.data(); } - char* data() { return const_cast(str.data()); } - - template void serialize(S& s) { s.raw(data(), size()); } - - private: - std::string str; - - friend std::ostream& operator<<(std::ostream&, const Body&); -}; - -inline std::ostream& operator<<(std::ostream& o, const Body& b) { - return o << b.str.substr(0, 16) << "... (" << b.size() << ")"; -} - -}} // namespace qpid::amqp_0_10 - -#endif /*!QPID_AMQP_0_10_BODY_H*/ diff --git a/qpid/cpp/src/qpid/amqp_0_10/Codec.h b/qpid/cpp/src/qpid/amqp_0_10/Codec.h deleted file mode 100644 index fd006a348e..0000000000 --- a/qpid/cpp/src/qpid/amqp_0_10/Codec.h +++ /dev/null @@ -1,213 +0,0 @@ -#ifndef QPID_AMQP_0_10_CODEC_H -#define QPID_AMQP_0_10_CODEC_H - -/* - * - * 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/amqp_0_10/built_in_types.h" -#include "qpid/Serializer.h" -#include -#include -#include -#include -#include -#include - -namespace qpid { -namespace amqp_0_10 { - -template void reverse(T& t) { - char*p =reinterpret_cast(&t); - std::reverse(p, p+sizeof(T)); -} - -#ifdef BOOST_LITTLE_ENDIAN -template void bigEndian(T& t) { reverse(t); } -template void littleEndian(T&) {} -#else -template void littleEndian(T& t) { reverse(t); } -template void bigEndian(T&) {} -#endif - -/** - * AMQP 0-10 encoding and decoding. - */ -struct Codec { - /** Encode to an output byte iterator */ - template - class Encoder : public EncoderBase > - { - public: - typedef EncoderBase > Base; - typedef OutIter Iterator; - - Encoder(OutIter o, size_t limit=Base::maxLimit()) : out(o) { - this->setLimit(limit); - } - - using EncoderBase >::operator(); - - Encoder& operator()(bool x) { raw(x); return *this;} - Encoder& operator()(char x) { raw(x); return *this; } - Encoder& operator()(int8_t x) { raw(x); return *this; } - Encoder& operator()(uint8_t x) { raw(x); return *this; } - - Encoder& operator()(int16_t x) { return networkByteOrder(x); } - Encoder& operator()(int32_t x) { return networkByteOrder(x); } - Encoder& operator()(int64_t x) { return networkByteOrder(x); } - - Encoder& operator()(uint16_t x) { return networkByteOrder(x); } - Encoder& operator()(uint32_t x) { return networkByteOrder(x); } - Encoder& operator()(uint64_t x) { return networkByteOrder(x); } - - Encoder& operator()(float x) { return networkByteOrder(x); } - Encoder& operator()(double x) { return networkByteOrder(x); } - - void raw(const void* p, size_t n) { - this->addBytes(n); - out = std::copy((const char*)p, (const char*)p+n, out); - } - - void raw(char b) { this->addBytes(1); *out++=b; } - - template Encoder& littleEnd(T x) { - littleEndian(x); raw(&x, sizeof(x)); return *this; - } - - OutIter pos() const { return out; } - - private: - - template Encoder& networkByteOrder(T x) { - bigEndian(x); raw(&x, sizeof(x)); return *this; - } - - OutIter out; - }; - - template - class Decoder : public DecoderBase > { - public: - typedef DecoderBase > Base; - typedef InIter Iterator; - - Decoder(InIter i, size_t limit=Base::maxLimit()) : in(i) { - this->setLimit(limit); - } - - using DecoderBase >::operator(); - - // FIXME aconway 2008-03-10: wrong encoding, need packing support - Decoder& operator()(bool& x) { raw((char&)x); return *this; } - - Decoder& operator()(char& x) { raw((char&)x); return *this; } - Decoder& operator()(int8_t& x) { raw((char&)x); return *this; } - Decoder& operator()(uint8_t& x) { raw((char&)x); return *this; } - - Decoder& operator()(int16_t& x) { return networkByteOrder(x); } - Decoder& operator()(int32_t& x) { return networkByteOrder(x); } - Decoder& operator()(int64_t& x) { return networkByteOrder(x); } - - Decoder& operator()(uint16_t& x) { return networkByteOrder(x); } - Decoder& operator()(uint32_t& x) { return networkByteOrder(x); } - Decoder& operator()(uint64_t& x) { return networkByteOrder(x); } - - Decoder& operator()(float& x) { return networkByteOrder(x); } - Decoder& operator()(double& x) { return networkByteOrder(x); } - - void raw(void *p, size_t n) { - this->addBytes(n); - std::copy(in, in+n, (char*)p); - std::advance(in, n); - } - - void raw(char &b) { this->addBytes(1); b=*in++; } - - template Decoder& littleEnd(T& x) { - raw(&x, sizeof(x)); littleEndian(x); return *this; - } - - InIter pos() const { return in; } - - private: - - template Decoder& networkByteOrder(T& x) { - raw(&x, sizeof(x)); bigEndian(x); return *this; - } - - InIter in; - }; - - - class Size : public EncoderBase { - public: - Size() : size(0) {} - - operator size_t() const { return size; } - - using EncoderBase::operator(); - - // FIXME aconway 2008-03-10: wrong encoding, need packing support - Size& operator()(bool x) { size += sizeof(x); return *this; } - - Size& operator()(char x) { size += sizeof(x); return *this; } - Size& operator()(int8_t x) { size += sizeof(x); return *this; } - Size& operator()(uint8_t x) { size += sizeof(x); return *this; } - - Size& operator()(int16_t x) { size += sizeof(x); return *this; } - Size& operator()(int32_t x) { size += sizeof(x); return *this; } - Size& operator()(int64_t x) { size += sizeof(x); return *this; } - - Size& operator()(uint16_t x) { size += sizeof(x); return *this; } - Size& operator()(uint32_t x) { size += sizeof(x); return *this; } - Size& operator()(uint64_t x) { size += sizeof(x); return *this; } - - Size& operator()(float x) { size += sizeof(x); return *this; } - Size& operator()(double x) { size += sizeof(x); return *this; } - - // FIXME aconway 2008-04-03: optimize op()(Iter,Iter) - // for Iter with fixed-size value_type: - // distance(begin,end)*sizeof(value_type) - - void raw(const void*, size_t n){ size += n; } - - template Size& littleEnd(T) { size+= sizeof(T); return *this; } - - private: - size_t size; - }; - - // FIXME aconway 2008-03-11: rename to encoder(), decoder() - template static Decoder decode(const InIter &i) { - return Decoder(i); - } - - template static Encoder encode(OutIter i) { - return Encoder(i); - } - - template static size_t size(const T& x) { return Size()(x); } - template static size_t size(const Iter& a, const Iter& z) { return Size()(a,z); } -}; - -}} // namespace qpid::amqp_0_10 - -#endif /*!QPID_AMQP_0_10_CODEC_H*/ diff --git a/qpid/cpp/src/qpid/amqp_0_10/Command.h b/qpid/cpp/src/qpid/amqp_0_10/Command.h deleted file mode 100644 index b1d3607a84..0000000000 --- a/qpid/cpp/src/qpid/amqp_0_10/Command.h +++ /dev/null @@ -1,62 +0,0 @@ -#ifndef QPID_AMQP_0_10_COMMAND_H -#define QPID_AMQP_0_10_COMMAND_H - -/* - * - * 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/amqp_0_10/Control.h" -#include "qpid/amqp_0_10/structs.h" - -namespace qpid { -namespace amqp_0_10 { - -struct CommandVisitor; -struct ConstCommandVisitor; -struct CommandHolder; -struct Command - : public Action, - public Visitable -{ - using Action::getCommand; - Command* getCommand() { return this; } - uint8_t getCode() const; - uint8_t getClassCode() const; - const char* getName() const; - const char* getClassName() const; - - session::Header sessionHeader; -}; - -std::ostream& operator<<(std::ostream&, const Command&); - -template -struct CommandPacker : Packer { - CommandPacker(T& t) : Packer(t) {} - - template void serialize(S& s) { - s(this->data.sessionHeader); - Packer::serialize(s); - } -}; - -}} // namespace qpid::amqp_0_10 - -#endif /*!QPID_AMQP_0_10_COMMAND_H*/ diff --git a/qpid/cpp/src/qpid/amqp_0_10/CommmandPacker.h b/qpid/cpp/src/qpid/amqp_0_10/CommmandPacker.h deleted file mode 100644 index 51ebfe8186..0000000000 --- a/qpid/cpp/src/qpid/amqp_0_10/CommmandPacker.h +++ /dev/null @@ -1,60 +0,0 @@ -#ifndef QPID_AMQP_0_10_COMMMANDPACKER_H -#define QPID_AMQP_0_10_COMMMANDPACKER_H - -/* - * - * 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/amqp_0_10/structs.h" - -namespace qpid { -namespace amqp_0_10 { - -/** - * Packer for commands - serialize session.header before pack bits. - */ -template -class CommmandPacker : public Packer -{ - public: - CommmandPacker(T& t) : Packer(t) {} - template void serialize(S& s) { s.split(*this); } - - template void encode(S& s) const { - s.sessionHeader( - Packer::encode(s); - } - - template void decode(S& s) { - Bits bits; - s.littleEnd(bits); - PackedDecoder decode(s, bits); - data.serialize(decode); - } - - - protected: - T& data; - - -}; -}} // namespace qpid::amqp_0_10 - -#endif /*!QPID_AMQP_0_10_COMMMANDPACKER_H*/ diff --git a/qpid/cpp/src/qpid/amqp_0_10/Connection.cpp b/qpid/cpp/src/qpid/amqp_0_10/Connection.cpp index 751ca15b74..5ff73b2d4d 100644 --- a/qpid/cpp/src/qpid/amqp_0_10/Connection.cpp +++ b/qpid/cpp/src/qpid/amqp_0_10/Connection.cpp @@ -20,7 +20,7 @@ */ #include "qpid/amqp_0_10/Connection.h" #include "qpid/log/Statement.h" -#include "qpid/amqp_0_10/exceptions.h" +#include "qpid/framing/reply_exceptions.h" #include "qpid/framing/AMQFrame.h" #include "qpid/framing/Buffer.h" #include "qpid/framing/ProtocolInitiation.h" @@ -28,6 +28,7 @@ namespace qpid { namespace amqp_0_10 { +using framing::InternalErrorException; using sys::Mutex; Connection::Connection(sys::OutputControl& o, const std::string& id, bool _isClient) diff --git a/qpid/cpp/src/qpid/amqp_0_10/Control.h b/qpid/cpp/src/qpid/amqp_0_10/Control.h deleted file mode 100644 index ce188ae6d8..0000000000 --- a/qpid/cpp/src/qpid/amqp_0_10/Control.h +++ /dev/null @@ -1,70 +0,0 @@ -#ifndef QPID_AMQP_0_10_CONTROL_H -#define QPID_AMQP_0_10_CONTROL_H - -/* - * - * 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/amqp_0_10/Struct.h" - -namespace qpid { -namespace amqp_0_10 { - -struct Command; -struct Control; - -struct Action { // Base for commands & controls - virtual ~Action() {} - virtual Command* getCommand() { return 0; } - virtual Control* getControl() { return 0; } - - virtual const Command* getCommand() const { - return const_cast(this)->getCommand(); - } - virtual const Control* getControl() const { - return const_cast(this)->getControl(); - } - static const uint8_t SIZE=0; - static const uint8_t PACK=2; -}; - -struct ControlVisitor; -struct ConstControlVisitor; -struct ControlHolder; -struct Control - : public Action, - public Visitable -{ - using Action::getControl; - Control* getControl() { return this; } - uint8_t getCode() const; - uint8_t getClassCode() const; - const char* getName() const; - const char* getClassName() const; -}; -std::ostream& operator<<(std::ostream&, const Control&); - -template struct ActionType; -template <> struct ActionType { typedef Control type; }; -template <> struct ActionType { typedef Command type; }; - -}} // namespace qpid::amqp_0_10 - -#endif /*!QPID_AMQP_0_10_CONTROL_H*/ diff --git a/qpid/cpp/src/qpid/amqp_0_10/Decimal.h b/qpid/cpp/src/qpid/amqp_0_10/Decimal.h deleted file mode 100644 index 50fc457c76..0000000000 --- a/qpid/cpp/src/qpid/amqp_0_10/Decimal.h +++ /dev/null @@ -1,51 +0,0 @@ -#ifndef TESTS_DECIMAL_H -#define TESTS_DECIMAL_H - -/* - * - * 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 - -namespace qpid { -namespace amqp_0_10 { - -template struct Decimal { - E exponent; - M mantissa; - - Decimal(E exp=0, M man=0) : exponent(exp), mantissa(man) {} - - bool operator==(const Decimal& d) const { - return exponent == d.exponent && mantissa == d.mantissa; - } - - // TODO aconway 2008-02-20: We could provide arithmetic operators - // if anybody really cares about this type. - - template void serialize(S& s) { s(exponent)(mantissa); } -}; - -template -inline std::ostream& operator<<(std::ostream& o, const Decimal& d) { - return o << "Decimal{" << d.mantissa << "/10^" << (int)d.exponent << "}"; -} -}} - -#endif /*!TESTS_DECIMAL_H*/ diff --git a/qpid/cpp/src/qpid/amqp_0_10/Exception.h b/qpid/cpp/src/qpid/amqp_0_10/Exception.h deleted file mode 100644 index 6d526c1706..0000000000 --- a/qpid/cpp/src/qpid/amqp_0_10/Exception.h +++ /dev/null @@ -1,96 +0,0 @@ -#ifndef QPID_AMQP_0_10_EXCEPTION_H -#define QPID_AMQP_0_10_EXCEPTION_H - -/* - * - * 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/Exception.h" -#include "qpid/amqp_0_10/specification_fwd.h" - -namespace qpid { -namespace amqp_0_10 { - -/** - * Raised when the connection is unexpectedly closed. Sessions with - * non-0 timeout may be available for re-attachment on another connection. - */ -struct ConnectionException : public qpid::Exception { - // FIXME aconway 2008-04-04: Merge qpid::ConnectionException - // into this when the old code is removed. - typedef connection::CloseCode Code; - ConnectionException(Code c, const std::string m) - : qpid::Exception(m), code(c) {} - Code code; -}; - -/** - * Raised when a session is unexpectedly detached for any reason, or - * if an attempt is made to use a session that is not attached. - */ -struct SessionException : public qpid::Exception { - // FIXME aconway 2008-04-04: should not have a code at this level. - // Leave in place till old preview code is gone. - SessionException(int /*code*/, const std::string& msg) : qpid::Exception(msg) {} -}; - -/** Raised when the state of a session has been destroyed */ -struct SessionDestroyedException : public SessionException { - // FIXME aconway 2008-04-04: should not have a code at this level. - // Leave in place till old preview code is gone. - SessionDestroyedException(int code, const std::string& msg) : SessionException(code, msg){} -}; - -/** Raised when a session is destroyed due to an execution.exception */ -struct SessionAbortedException : public SessionDestroyedException { - typedef execution::ErrorCode Code; - SessionAbortedException(Code c, const std::string m) - : SessionDestroyedException(c, m), code(c) {} - Code code; -}; - -/** - * Raised when a session with 0 timeout is unexpectedly detached - * and therefore expires and is destroyed. - */ -struct SessionExpiredException : public SessionDestroyedException { - typedef session::DetachCode Code; - SessionExpiredException(Code c, const std::string m) - : SessionDestroyedException(c, m), code(c) {} - Code code; -}; - -/** - * Raised when a session with non-0 timeout is unexpectedly detached - * or if an attempt is made to use a session that is not attached. - * - * The session is not necessarily destroyed, it may be possible to - * re-attach. - */ -struct SessionDetachedException : public SessionException { - typedef session::DetachCode Code; - SessionDetachedException(Code c, const std::string m) - : SessionException(c, m), code(c) {} - Code code; -}; - -}} // namespace qpid::amqp_0_10 - -#endif /*!QPID_AMQP_0_10_EXCEPTION_H*/ diff --git a/qpid/cpp/src/qpid/amqp_0_10/FrameHeader.cpp b/qpid/cpp/src/qpid/amqp_0_10/FrameHeader.cpp deleted file mode 100644 index 371e3c1bcb..0000000000 --- a/qpid/cpp/src/qpid/amqp_0_10/FrameHeader.cpp +++ /dev/null @@ -1,50 +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/amqp_0_10/FrameHeader.h" -#include -#include -#include - -using namespace std; - -namespace qpid { -namespace amqp_0_10 { - -bool FrameHeader::operator==(const FrameHeader& x) const { - return flags == x.flags && - type == x.type && - size == x.size && - track == x.track && - channel == x.channel; -} - -std::ostream& operator<<(std::ostream& o, const FrameHeader& f) { - std::ios::fmtflags saveFlags = o.flags(); - return o << "Frame[" - << "flags=" << std::hex << std::showbase << int(f.getFlags()) << std::setiosflags(saveFlags) - << " type=" << f.getType() - << " size=" << f.getSize() - << " track=" << int(f.getTrack()) - << " channel=" << f.getChannel() - << "]"; -} - -}} // namespace qpid::amqp_0_10 diff --git a/qpid/cpp/src/qpid/amqp_0_10/FrameHeader.h b/qpid/cpp/src/qpid/amqp_0_10/FrameHeader.h deleted file mode 100644 index b2f0619f9b..0000000000 --- a/qpid/cpp/src/qpid/amqp_0_10/FrameHeader.h +++ /dev/null @@ -1,90 +0,0 @@ -#ifndef QPID_AMQP_0_10_FRAMEHEADER_H -#define QPID_AMQP_0_10_FRAMEHEADER_H - -/* - * - * 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/amqp_0_10/built_in_types.h" -#include -#include -#include -#include - -namespace qpid { -namespace amqp_0_10 { - -enum FrameFlags { FIRST_SEGMENT=8, LAST_SEGMENT=4, FIRST_FRAME=2, LAST_FRAME=1 }; - -class FrameHeader { - public: - static const size_t SIZE=12; - static uint8_t trackFor(SegmentType type) { return type == 0 ? 0 : 1; } - - FrameHeader(uint8_t flags_=0, SegmentType type_=SegmentType(), uint16_t size_=0, uint8_t track_=0, uint16_t channel_=0) - : flags(flags_), type(type_), size(size_), track(track_), channel(channel_) - {} - - uint8_t getFlags() const { return flags; } - SegmentType getType() const { return type; } - /** @return size total size of of frame, including frame header. */ - uint16_t getSize() const { return size; } - /** @return size of frame data, excluding frame header. */ - uint16_t getDataSize() const { return size - SIZE; } - uint8_t getTrack() const { return track; } - uint16_t getChannel() const { return channel; } - - void setFlags(uint8_t flags_) { flags=flags_; } - /** Also sets the track. There is no setTrack() */ - void setType(SegmentType type_) { type=type_; track=trackFor(type); } - /** @param size total size of of frame, including frame header. */ - void setSize(uint16_t size_) { size = size_; } - /** @param size size of frame data, excluding frame header. */ - void setDataSize(uint16_t size_) { size = size_+SIZE; } - void setChannel(uint8_t channel_) { channel=channel_; } - - bool allFlags(uint8_t f) const { return (flags & f) == f; } - bool anyFlags(uint8_t f) const { return (flags & f); } - - void raiseFlags(uint8_t f) { flags |= f; } - void clearFlags(uint8_t f) { flags &= ~f; } - - bool isComplete() const { return allFlags(FIRST_FRAME | LAST_FRAME); } - - bool operator==(const FrameHeader&) const; - - template void serialize(S& s) { - uint8_t pad8=0; uint32_t pad32=0; - s(flags)(type)(size)(pad8)(track)(channel)(pad32); - } - - private: - uint8_t flags; - SegmentType type; - uint16_t size; - uint8_t track; - uint16_t channel; -}; - -std::ostream& operator<<(std::ostream&, const FrameHeader&); - -}} // namespace qpid::amqp_0_10 - -#endif /*!QPID_AMQP_0_10_FRAMEHEADER_H*/ diff --git a/qpid/cpp/src/qpid/amqp_0_10/Header.cpp b/qpid/cpp/src/qpid/amqp_0_10/Header.cpp deleted file mode 100644 index d83814e969..0000000000 --- a/qpid/cpp/src/qpid/amqp_0_10/Header.cpp +++ /dev/null @@ -1,34 +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/amqp_0_10/Header.h" - -namespace qpid { -namespace amqp_0_10 { - -std::ostream& operator<<(std::ostream& o, const Header& h) { - o << "Header["; - std::ostream_iterator i(o, " "); - std::copy(h.begin(), h.end(), i); - o << "]"; - return o; -} - -}} // namespace qpid::amqp_0_10 diff --git a/qpid/cpp/src/qpid/amqp_0_10/Header.h b/qpid/cpp/src/qpid/amqp_0_10/Header.h deleted file mode 100644 index 0ce6ad9135..0000000000 --- a/qpid/cpp/src/qpid/amqp_0_10/Header.h +++ /dev/null @@ -1,53 +0,0 @@ -#ifndef QPID_AMQP_0_10_HEADER_H -#define QPID_AMQP_0_10_HEADER_H - -/* - * - * 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/amqp_0_10/built_in_types.h" -#include "qpid/amqp_0_10/Struct32.h" -#include -#include - -namespace qpid { -namespace amqp_0_10 { - -class Header : public std::vector { - public: - Header() {} - - template void serialize(S& s) { s.split(*this); } - template void encode(S& s) const { s(this->begin(), this->end()); } - template void decode(S& s); -}; - -template void Header::decode(S& s) { - this->clear(); - while (s.bytesRemaining() > 0) { - this->push_back(Struct32()); - s(this->back()); - } -} - -std::ostream& operator<<(std::ostream& o, const Header&); - -}} // namespace qpid::amqp_0_10 - -#endif /*!QPID_AMQP_0_10_HEADER_H*/ diff --git a/qpid/cpp/src/qpid/amqp_0_10/Holder.h b/qpid/cpp/src/qpid/amqp_0_10/Holder.h deleted file mode 100644 index 605d2e0ed5..0000000000 --- a/qpid/cpp/src/qpid/amqp_0_10/Holder.h +++ /dev/null @@ -1,103 +0,0 @@ -#ifndef QPID_AMQP_0_10_HOLDER_H -#define QPID_AMQP_0_10_HOLDER_H - -/* - * - * 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/Blob.h" -#include "qpid/amqp_0_10/apply.h" - -namespace qpid { -namespace amqp_0_10 { - -using framing::in_place; - -template struct InvokeVisitor { - typedef void result_type; - Invokable& target; - InvokeVisitor(Invokable& i) : target(i) {} - - template - void operator()(const Action& action) { action.invoke(target); } -}; - -template -class Holder : public framing::Blob { - typedef framing::Blob Base; - - public: - - Holder() {} - template explicit Holder(const T& value) : Base(value) {} - - using Base::operator=; - Holder& operator=(const BaseHeld& rhs); - - uint8_t getCode() const { return this->get()->getCode(); } - uint8_t getClassCode() const { return this->get()->getClassCode(); } - - template void invoke(Invokable& i) const { - InvokeVisitor v(i); - apply(v, *this->get()); - } - - template void encode(S& s) const { - s(getClassCode())(getCode()); - } - - template void decode(S& s) { - uint8_t code, classCode; - s(classCode)(code); - static_cast(this)->set(classCode, code); - } - - template void serialize(S& s) { - s.split(*this); - qpid::amqp_0_10::apply(s, *this->get()); - } - - template T* getIf() { - return (getClassCode()==T::CLASS_CODE && getCode()==T::CODE) ? static_cast(this->get()) : 0; - } - - template const T* getIf() const { - return (getClassCode()==T::CLASS_CODE && getCode()==T::CODE) ? static_cast(this->get()) : 0; - } - - private: - struct Assign : public ApplyFunctor { - Holder& holder; - Assign(Holder& x) : holder(x) {} - template void operator()(const T& rhs) { holder=rhs; } - }; -}; - -template -Holder& Holder::operator=(const B& rhs) { - Assign assign(*this); - qpid::amqp_0_10::apply(assign, rhs); - return *this; -} - - - -}} // namespace qpid::amqp_0_10 - -#endif /*!QPID_AMQP_0_10_HOLDER_H*/ diff --git a/qpid/cpp/src/qpid/amqp_0_10/Map.cpp b/qpid/cpp/src/qpid/amqp_0_10/Map.cpp deleted file mode 100644 index af3b302d25..0000000000 --- a/qpid/cpp/src/qpid/amqp_0_10/Map.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 "qpid/amqp_0_10/Map.h" -#include "qpid/amqp_0_10/Struct32.h" -#include "qpid/amqp_0_10/Array.h" -#include - -namespace qpid { -namespace amqp_0_10 { - -MapValue::MapValue() : code(codeFor(uint8_t(0))), blob(in_place(0)) {} - -MapValue::MapValue(const MapValue& x) : code(x.code), blob(x.blob) {} - -bool MapValue::operator==(const MapValue& x) const { - return code == x.code; // FIXME aconway 2008-04-01: incomplete -} - -struct OstreamVisitor : public MapValue::Visitor { - std::ostream& out; - OstreamVisitor(std::ostream& o) : out(o) {} - template std::ostream& operator()(const T& t) { - return out << t; - } -}; - -std::ostream& operator<<(std::ostream& o, const MapValue& m) { - o << typeName(m.getCode()) << ":"; - const_cast(m).apply_visitor(OstreamVisitor(o)); - return o; -} - -std::ostream& operator<<(std::ostream& o, const Map::value_type& v) { - return o << v.first << "=" << v.second; -} -std::ostream& operator<<(std::ostream& o, const Map& map) { - o << "map["; - std::ostream_iterator i(o, " "); - std::copy(map.begin(), map.end(), i); - return o << "]"; -} - -uint32_t Map::contentSize() const { - // FIXME aconway 2008-04-03: preview to 0-10 mapping: +4 for count. - return /*4 +*/ Codec::Size()(begin(), end()); -} - -}} // namespace qpid::amqp_0_10 diff --git a/qpid/cpp/src/qpid/amqp_0_10/Map.h b/qpid/cpp/src/qpid/amqp_0_10/Map.h deleted file mode 100644 index 4093b1a0aa..0000000000 --- a/qpid/cpp/src/qpid/amqp_0_10/Map.h +++ /dev/null @@ -1,188 +0,0 @@ -#ifndef QPID_AMQP_0_10_MAP_H -#define QPID_AMQP_0_10_MAP_H - -/* - * - * 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 ang - * "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/Exception.h" -#include "qpid/amqp_0_10/built_in_types.h" -#include "qpid/amqp_0_10/UnknownType.h" -#include "qpid/amqp_0_10/CodeForType.h" -#include "qpid/amqp_0_10/TypeForCode.h" -#include "qpid/amqp_0_10/Codec.h" -#include "qpid/framing/Blob.h" -#include -#include -#include - -namespace qpid { -namespace amqp_0_10 { - -class Map; - -class MapValue { - public: - struct BadTypeException : public Exception {}; - - template struct Visitor { typedef R result_type; }; - - MapValue(); - MapValue(const MapValue& x); - template explicit MapValue(const T& t); - template MapValue& operator=(const T& t); - - template T* get(); - template const T* get() const; - - template typename V::result_type apply_visitor(V&); - template typename V::result_type apply_visitor(const V&); - - uint8_t getCode() const { return code; } - - bool operator==(const MapValue&) const; - - template void serialize(S& s) { s(code); s.split(*this); } - template void encode(S& s) const { - const_cast(this)->apply_visitor(s); - } - template void decode(S& s) { - DecodeVisitor dv(blob, s); - qpid::amqp_0_10::apply_visitor(dv, code); - } - - - private: - // TODO aconway 2008-04-15: Estimate required size, we will get a - // compile error from static_assert in Blob.h if the estimate is too - // low. We can't use sizeof() directly because #include Struct32.h - // creates a circular dependency. Needs a better solution. - static const size_t SIZE=256; - typedef framing::Blob Blob; - - template struct VisitVisitor; - template struct GetVisitor; - template struct DecodeVisitor; - - uint8_t code; - Blob blob; -}; - -class Map : public std::map { - public: - template void serialize(S& s) { s.split(*this); } - template void encode(S& s) const; - // Shortcut calculation for size. - void encode(Codec::Size& s) const { s.raw(0, contentSize() + 4/*size*/); } - - template void decode(S& s); - - private: - uint32_t contentSize() const; -}; - -std::ostream& operator<<(std::ostream&, const MapValue&); -std::ostream& operator<<(std::ostream&, const Map::value_type&); -std::ostream& operator<<(std::ostream&, const Map&); - -using framing::in_place; - -template MapValue::MapValue(const T& t) : code(codeFor(t)), blob(in_place()) {} - -template MapValue& MapValue::operator=(const T& t) { - code=codeFor(t); - blob=t; - return *this; -} - -template struct MapValue::VisitVisitor { - typedef typename V::result_type result_type; - V& visitor; - Blob& blob; - VisitVisitor(V& v, Blob& b) : visitor(v), blob(b) {} - - template result_type operator()(T*) { - return visitor(*reinterpret_cast(blob.get())); - } -}; - -template typename V::result_type MapValue::apply_visitor(V& v) { - VisitVisitor visitor(v, blob); - return qpid::amqp_0_10::apply_visitor(visitor, code); -} - -template struct MapValue::GetVisitor { - typedef R* result_type; - const MapValue::Blob& blob; - - GetVisitor(const MapValue::Blob& b) : blob(b) {} - - R* operator()(R& r) { return &r; } - template R* operator()(T&) { return 0; } -}; - -template struct MapValue::DecodeVisitor { - typedef void result_type; - MapValue::Blob& blob; - D& decoder; - DecodeVisitor(Blob& b, D& d) : blob(b), decoder(d) {} - - template void operator()(T*) { - T t; - decoder(t); - blob = t; - } -}; - -template T* MapValue::get() { return apply_visitor(GetVisitor(blob)); } -template const T* MapValue::get() const { return apply_visitor(GetVisitor()); } - -template typename V::result_type MapValue::apply_visitor(const V& v) { - return apply_visitor(const_cast(v)); -} - -template void Map::encode(S& s) const { - // FIXME aconway 2008-04-03: replace preview mapping with 0-10 mapping: - // s(contentSize())(uint32_t(size())); // size, count - s(contentSize()); - for (const_iterator i = begin(); i != end(); ++i) - s(i->first)(i->second); // key (type value) -} - -template void Map::decode(S& s) { - uint32_t decodedSize /*, count*/; - // FIXME aconway 2008-04-03: replace preview mapping with 0-10 mapping: - // s(contentSize())(uint32_t(size())); // size, count - // s(decodedSize)(count); - s(decodedSize); - typename S::ScopedLimit l(s, decodedSize); // Make sure we don't overrun. - // FIXME aconway 2008-04-03: replace preview with 0-10: - // for ( ; count > 0; --count) { - while (s.bytesRemaining() > 0) { - key_type k; MapValue v; - s(k)(v); - insert(value_type(k,v)); - } -} - - -}} // namespace qpid::amqp_0_10 - -#endif /*!QPID_AMQP_0_10_MAP_H*/ diff --git a/qpid/cpp/src/qpid/amqp_0_10/Packer.h b/qpid/cpp/src/qpid/amqp_0_10/Packer.h deleted file mode 100644 index c38e3a7efa..0000000000 --- a/qpid/cpp/src/qpid/amqp_0_10/Packer.h +++ /dev/null @@ -1,195 +0,0 @@ -#ifndef QPID_PACKER_H -#define QPID_PACKER_H - -/* - * - * 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 -#include -#include "qpid/amqp_0_10/built_in_types.h" - -namespace qpid { -namespace amqp_0_10 { - -/** Serialization for optional values */ -template struct SerializableOptional { - boost::optional& optional; - SerializableOptional(boost::optional& x) : optional(x) {} - template void serialize(S& s) { - if (optional) - s(*optional); - } -}; - -}} - - -namespace boost { // For argument dependent lookup. - -template -qpid::amqp_0_10::SerializableOptional serializable(boost::optional& x) { - return qpid::amqp_0_10::SerializableOptional(x); -} - -} // namespace boost - -namespace qpid { -namespace amqp_0_10 { - -/** "Encoder" that encodes a struct as a set of bit flags - * for all non-empty members. - */ -class PackBits { - public: - PackBits() : bit(1), bits(0) {} - - void setBit(bool b) { if (b) bits |= bit; bit <<= 1; } - uint32_t getBits() { return bits; } - - /** The bit is always set for non-optional values. */ - template - PackBits& operator()(const T&) { setBit(1); return *this; } - - /** For optional values the bit is set if the value is present. */ - template PackBits& operator()(const boost::optional& opt) { - setBit(opt); return *this; - } - - /** Bits are special optional values */ - PackBits& operator()(Bit b) { setBit(b); return *this; } - - private: - uint32_t bit; - uint32_t bits; -}; - -/** Bit mask to encode a packable struct */ -template uint32_t packBits(const T& t) { - PackBits pack; - const_cast(t).serialize(pack); - return pack.getBits(); -} - -/** Decode members enabled by Bits */ -template -class PackedDecoder { - public: - PackedDecoder(Decoder& d, Bits b) : decode(d), bits(b) {} - - template PackedDecoder& operator()(T& t) { - if (bits & 1) - decode(t); - else - t = T(); - // FIXME aconway 2008-04-10: When we have all optionals - // represented by boost::optional the line above should be: - // throw CommandInvalidException("A required value was omitted."); - bits >>= 1; - return *this; - } - - template PackedDecoder& operator()(boost::optional& opt) { - if (bits & 1) { - opt = T(); - decode(*opt); - } - else - opt = boost::none; - bits >>= 1; - return *this; - } - - private: - Decoder& decode; - Bits bits; -}; - -/** Metafunction to compute type to contain pack bits. */ -template struct UintOfSize; -template <> struct UintOfSize<1> { typedef uint8_t type; }; -template <> struct UintOfSize<2> { typedef uint16_t type; }; -template <> struct UintOfSize<4> { typedef uint32_t type; }; - -/** - * Helper to serialize packed structs. - */ -template class Packer -{ - public: - typedef typename UintOfSize::type Bits; - - Packer(T& t) : data(t) {} - - template void serialize(S& s) { s.split(*this); } - - template void encode(S& s) const { - Bits bits = packBits(data); - s.littleEnd(bits); - data.serialize(s); - } - - template void decode(S& s) { - Bits bits; - s.littleEnd(bits); - PackedDecoder decode(s, bits); - data.serialize(decode); - } - - - protected: - T& data; -}; - -template struct SizedPacker : public Packer { - typedef typename UintOfSize::type Size; - - SizedPacker(T& t) : Packer(t) {} - - template void serialize(S& s) { - s.split(*this); - } - - template void encode(S& s) const { - Codec::Size sizer; - this->data.serialize(sizer); - Size size=size_t(sizer)+T::PACK; // Size with pack bits. - s(size); - Packer::encode(s); - } - - template void decode(S& s) { - Size size; - s(size); - typename S::ScopedLimit l(s, size); - Packer::decode(s); - } - -}; - -template struct SizedPacker : public Packer { - SizedPacker(T& t) : Packer(t) {} -}; - -}} // namespace qpid::amqp_0_10 - - - -#endif /*!QPID_PACKER_H*/ diff --git a/qpid/cpp/src/qpid/amqp_0_10/SerializableString.h b/qpid/cpp/src/qpid/amqp_0_10/SerializableString.h deleted file mode 100644 index 485b7ca6a8..0000000000 --- a/qpid/cpp/src/qpid/amqp_0_10/SerializableString.h +++ /dev/null @@ -1,62 +0,0 @@ -#ifndef QPID_AMQP_0_10_SERIALIZABLESTRING_H -#define QPID_AMQP_0_10_SERIALIZABLESTRING_H - -/* - * - * 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. - * - */ -namespace qpid { -namespace amqp_0_10 { - -/** Template for length-prefixed strings/arrays. - * Unique parameter allows creation of distinct SerializableString - * types with the smae T/SizeType - */ -template -struct SerializableString : public std::basic_string { - SerializableString() {} - template SerializableString(const U& u) : std::basic_string(u) {} - template SerializableString(const I& i, const I& j) : std::basic_string(i,j) {} - - using std::basic_string::operator=; - - template void serialize(S& s) { s.split(*this); } - - template void encode(S& s) const { - s(SizeType(this->size()))(this->begin(), this->end()); - } - - template void decode(S& s) { - SizeType newSize; - s(newSize); - this->resize(newSize); - s(this->begin(), this->end()); - } -}; - -// TODO aconway 2008-02-29: separate ostream ops -template -std::ostream& operator<<(std::ostream& o, const SerializableString& s) { - const std::basic_string str(s); - return o << str.c_str(); // TODO aconway 2008-02-29: why doesn't o< - -namespace qpid { -namespace amqp_0_10 { - -// Base classes for complex types. - -template struct Visitable { - typedef V Visitor; - typedef CV ConstVisitor; - typedef H Holder; - - virtual ~Visitable() {} - virtual void accept(Visitor&) = 0; - virtual void accept(ConstVisitor&) const = 0; -}; - - -// Note: only coded structs inherit from Struct. -struct StructVisitor; -struct ConstStructVisitor; -struct StructHolder; -struct Struct - : public Visitable -{ - uint8_t getCode() const; - uint8_t getPack() const; - uint8_t getSize() const; - uint8_t getClassCode() const; -}; -std::ostream& operator<<(std::ostream&, const Struct&); - -}} // namespace qpid::amqp_0_10 - -#endif /*!QPID_AMQP_0_10_STRUCT_H*/ diff --git a/qpid/cpp/src/qpid/amqp_0_10/Struct32.cpp b/qpid/cpp/src/qpid/amqp_0_10/Struct32.cpp deleted file mode 100644 index 2d38c09c21..0000000000 --- a/qpid/cpp/src/qpid/amqp_0_10/Struct32.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 "qpid/amqp_0_10/Struct32.h" - -namespace qpid { -namespace amqp_0_10 { - -Struct32::Struct32() { - // FIXME aconway 2008-04-16: this is only here to force a valid - // default-constructed Struct32 for serialize tests, clean up. - *this = in_place(); -} - -std::ostream& operator<<(std::ostream& o, const Struct32& s) { - return o << static_cast(s); -} - -}} // namespace qpid::amqp_0_10 diff --git a/qpid/cpp/src/qpid/amqp_0_10/Struct32.h b/qpid/cpp/src/qpid/amqp_0_10/Struct32.h deleted file mode 100644 index 2ed73e0b4c..0000000000 --- a/qpid/cpp/src/qpid/amqp_0_10/Struct32.h +++ /dev/null @@ -1,64 +0,0 @@ -#ifndef QPID_AMQP_0_10_STRUCT32_H -#define QPID_AMQP_0_10_STRUCT32_H - -/* - * - * 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/amqp_0_10/StructHolder.h" - -namespace qpid { -namespace amqp_0_10 { - -class Struct32 : public StructHolder -{ - public: - Struct32(); - - template explicit Struct32(const T& t) : StructHolder(t) {} - - template void serialize(S& s) { s.split(*this); } - - using StructHolder::operator=; - - template void encode(S& s) const { - s(contentSize()); - const_cast(this)->StructHolder::serialize(s); - } - - template void decode(S& s) { - uint32_t contentSz; - s(contentSz); - typename S::ScopedLimit l(s, contentSz); - StructHolder::serialize(s); - } - - private: - uint32_t contentSize() const { - return Codec::size(static_cast(*this)); - } - -}; - -std::ostream& operator<<(std::ostream&, const Struct32&); - -}} // namespace qpid::amqp_0_10 - -#endif /*!QPID_AMQP_0_10_STRUCT32_H*/ diff --git a/qpid/cpp/src/qpid/amqp_0_10/Unit.cpp b/qpid/cpp/src/qpid/amqp_0_10/Unit.cpp deleted file mode 100644 index 381de76dcc..0000000000 --- a/qpid/cpp/src/qpid/amqp_0_10/Unit.cpp +++ /dev/null @@ -1,65 +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/amqp_0_10/Unit.h" -#include "qpid/amqp_0_10/Codec.h" - -namespace qpid { -namespace amqp_0_10 { - -void Unit::updateVariant() { - switch (header.getType()) { - case CONTROL: variant=ControlHolder(); break; - case COMMAND: variant=CommandHolder(); break; - case HEADER: variant=Header(); break; - case BODY: variant=Body(header.getDataSize()); break; - default: assert(0); // FIXME aconway 2008-04-14: exception? - } -} - -struct GetTypeVisitor : public boost::static_visitor { - SegmentType operator()(const CommandHolder& ) const { return COMMAND; } - SegmentType operator()(const ControlHolder& ) const { return CONTROL; } - SegmentType operator()(const Header& ) const { return HEADER; } - SegmentType operator()(const Body&) const { return BODY; } -}; - -struct GetFlagsVisitor : public boost::static_visitor { - uint8_t operator()(const CommandHolder& ) const { return FIRST_FRAME|LAST_FRAME|FIRST_SEGMENT; } - uint8_t operator()(const ControlHolder& ) const { return FIRST_FRAME|LAST_FRAME|FIRST_SEGMENT; } - uint8_t operator()(const Header& ) const { return FIRST_FRAME|LAST_FRAME; } - uint8_t operator()(const Body&) const { return 0; } -}; - -void Unit::updateHeader(uint8_t flags) { - GetFlagsVisitor flagger; - header.setFlags(flags | variant.apply_visitor(flagger)); - GetTypeVisitor getter; - header.setType(variant.apply_visitor(getter)); - header.setDataSize(Codec::size(*this)); - // track automatically set from type. - // no channel specified at this point. -} - -std::ostream& operator<<(std::ostream& o, const Unit& u) { - return o << u.getHeader() << " " << u.variant.type().name() << "[" << u.variant << "]"; -} - -}} // namespace qpid::amqp_0_10 diff --git a/qpid/cpp/src/qpid/amqp_0_10/Unit.h b/qpid/cpp/src/qpid/amqp_0_10/Unit.h deleted file mode 100644 index 0229e07419..0000000000 --- a/qpid/cpp/src/qpid/amqp_0_10/Unit.h +++ /dev/null @@ -1,82 +0,0 @@ -#ifndef QPID_AMQP_0_10_UNIT_H -#define QPID_AMQP_0_10_UNIT_H - -/* - * - * 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/amqp_0_10/ControlHolder.h" -#include "qpid/amqp_0_10/CommandHolder.h" -#include "qpid/amqp_0_10/Header.h" -#include "qpid/amqp_0_10/Body.h" -#include "qpid/amqp_0_10/FrameHeader.h" - -#include -#include - -namespace qpid { -namespace amqp_0_10 { - -/** - * A Unit contains a frame header and associated value. - * For all types except BODY the frame header is for a complete segment. - */ -class Unit { - public: - explicit Unit(const FrameHeader& h=FrameHeader()) : header(h) { updateVariant(); } - - /** - *@param flags: is ORed with the required flags for type T. - */ - template - explicit Unit(const T& t, uint8_t flags=0) : variant(t) { updateHeader(flags); } - - void setHeader(FrameHeader& h) { header = h; updateVariant(); } - const FrameHeader& getHeader() const { return header; } - - template const T* get() const { return boost::get(&variant); } - template T* get() { return boost::get(&variant); } - template Unit& operator=(const T& t) { variant=t; return *this; } - - template typename V::result_type applyVisitor(V& v) const { - variant.apply_visitor(v); - } - - template void serialize(S& s) { variant.apply_visitor(s); s.split(*this); } - template void encode(S&) const {} - template void decode(S&) { updateHeader(header.getFlags()); } - - private: - typedef boost::variant Variant; - - void updateHeader(uint8_t flags); - void updateVariant(); - - Variant variant; - FrameHeader header; - - friend std::ostream& operator<<(std::ostream& o, const Unit& u); -}; - -std::ostream& operator<<(std::ostream& o, const Unit& u); - -}} // namespace qpid::amqp_0_10 - -#endif /*!QPID_AMQP_0_10_UNIT_H*/ diff --git a/qpid/cpp/src/qpid/amqp_0_10/UnitHandler.h b/qpid/cpp/src/qpid/amqp_0_10/UnitHandler.h deleted file mode 100644 index 93a8ce573a..0000000000 --- a/qpid/cpp/src/qpid/amqp_0_10/UnitHandler.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef QPID_AMQP_0_10_UNITHANDLER_H -#define QPID_AMQP_0_10_UNITHANDLER_H - -/* - * - * 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/Handler.h" - -namespace qpid { -namespace amqp_0_10 { - -class Unit; -typedef framing::Handler UnitHandler; - -}} // namespace qpid::amqp_0_10 - -#endif /*!QPID_AMQP_0_10_UNITHANDLER_H*/ diff --git a/qpid/cpp/src/qpid/amqp_0_10/UnknownStruct.cpp b/qpid/cpp/src/qpid/amqp_0_10/UnknownStruct.cpp deleted file mode 100644 index 35445054c9..0000000000 --- a/qpid/cpp/src/qpid/amqp_0_10/UnknownStruct.cpp +++ /dev/null @@ -1,34 +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/amqp_0_10/StructVisitor.h" -#include "qpid/amqp_0_10/UnknownStruct.h" - -namespace qpid { -namespace amqp_0_10 { - -void UnknownStruct::accept(Visitor& v) { v.visit(*this); } -void UnknownStruct::accept(ConstVisitor& v) const { v.visit(*this); } -std::ostream& operator<<(std::ostream& o, const UnknownStruct& u) { - return o << "UnknownStruct[class=" << u.getClassCode() << " code=" << u.getCode() << "]"; -} - -}} // namespace qpid::amqp_0_10 diff --git a/qpid/cpp/src/qpid/amqp_0_10/UnknownStruct.h b/qpid/cpp/src/qpid/amqp_0_10/UnknownStruct.h deleted file mode 100644 index 1c66d8e6af..0000000000 --- a/qpid/cpp/src/qpid/amqp_0_10/UnknownStruct.h +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef QPID_AMQP_0_10_UNKNOWNSTRUCT_H -#define QPID_AMQP_0_10_UNKNOWNSTRUCT_H - -/* - * - * 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/amqp_0_10/Struct.h" -#include - -namespace qpid { -namespace amqp_0_10 { - -class UnknownStruct : public Struct { - public: - static const uint8_t SIZE=4; - static const uint8_t PACK=2; - - template void serialize(S& s) { s.split(*this); s(data.begin(), data.end()); } - template void encode(S&) const { } - template void decode(S& s) { data.resize(s.bytesRemaining()); } - - UnknownStruct(uint8_t cc=0, uint8_t c=0) : classCode(cc), code(c) {} - void accept(Visitor&); - void accept(ConstVisitor&) const; - - uint8_t getClassCode() const { return classCode; } - uint8_t getCode() const { return code; } - - private: - uint8_t classCode, code; - std::string data; -}; - -std::ostream& operator<<(std::ostream&, const UnknownStruct&); - -}} // namespace qpid::amqp_0_10 - -#endif /*!QPID_AMQP_0_10_UNKNOWNSTRUCT_H*/ diff --git a/qpid/cpp/src/qpid/amqp_0_10/UnknownType.cpp b/qpid/cpp/src/qpid/amqp_0_10/UnknownType.cpp deleted file mode 100644 index cd45dd76db..0000000000 --- a/qpid/cpp/src/qpid/amqp_0_10/UnknownType.cpp +++ /dev/null @@ -1,56 +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/amqp_0_10/UnknownType.h" -#include -#include - -namespace qpid { -namespace amqp_0_10 { - -UnknownType::Width UnknownType::WidthTable[16] = { - { 1, 0 }, - { 2, 0 }, - { 4, 0 }, - { 8, 0 }, - { 16, 0 }, - { 32, 0 }, - { 64, 0 }, - { 128, 0 }, - { 0, 1 }, - { 0, 2 }, - { 0, 4 }, - { -1, -1 }, // Invalid - { 5, 0 }, - { 9, 0 }, - { -1, -1 }, // Invalid - { 0, 0 } -}; - -int UnknownType::fixed() const { return WidthTable[code>>4].fixed; } -int UnknownType::variable() const { return WidthTable[code>>4].variable; } -UnknownType::UnknownType(uint8_t c) : code(c) { data.resize(fixed()); } - -std::ostream& operator<<(std::ostream& o, const UnknownType& u) { - return o << boost::make_iterator_range(u.begin(), u.end()) << std::endl; -} - -}} // namespace qpid::amqp_0_10 - diff --git a/qpid/cpp/src/qpid/amqp_0_10/UnknownType.h b/qpid/cpp/src/qpid/amqp_0_10/UnknownType.h deleted file mode 100644 index 77498871b3..0000000000 --- a/qpid/cpp/src/qpid/amqp_0_10/UnknownType.h +++ /dev/null @@ -1,87 +0,0 @@ -#ifndef QPID_AMQP_0_10_UNKNOWNTYPE_H -#define QPID_AMQP_0_10_UNKNOWNTYPE_H - -/* - * - * 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/sys/IntegerTypes.h" -#include -#include - -namespace qpid { -namespace amqp_0_10 { - -/** Encode/decode an unknown type based on typecode. */ -class UnknownType { - public: - UnknownType(uint8_t code=0); - uint8_t getCode() const { return code; } - /** Size of fixed type or 0 if not fixed/0-length. -1 invalid */ - int fixed() const; - /** Bytes in size type for variable width. -1 invalid */ - int variable() const; - - typedef std::vector::const_iterator const_iterator; - const_iterator begin() const { return data.begin(); } - const_iterator end() const { return data.end(); } - size_t size() const { return data.size(); } - - template void serialize(S& s) { s.split(*this); } - template void encode(S& s) const; - template void decode(S& s); - - private: - uint8_t code; - struct Width { int fixed; int variable; }; - static Width WidthTable[16]; - - std::vector data; -}; - -template void UnknownType::encode(S& s) const { - switch (variable()) { - case 0: break; - case 1: s(uint8_t(data.size())); break; - case 2: s(uint16_t(data.size())); break; - case 4: s(uint32_t(data.size())); break; - } - s(data.begin(), data.end()); -} - -template void UnknownType::decode(S& s) { - uint32_t s8; - uint32_t s16; - uint32_t s32; - switch (variable()) { - case 0: break; - case 1: s(s8); data.resize(s8); break; - case 2: s(s16); data.resize(s16); break; - case 4: s(s32); data.resize(s32); break; - } - s(data.begin(), data.end()); -} - -inline uint8_t codeFor(const UnknownType& u) { return u.getCode(); } - -std::ostream& operator<<(std::ostream&, const UnknownType&); - -}} // namespace qpid::amqp_0_10 - -#endif /*!QPID_AMQP_0_10_UNKNOWNTYPE_H*/ diff --git a/qpid/cpp/src/qpid/amqp_0_10/apply.h b/qpid/cpp/src/qpid/amqp_0_10/apply.h deleted file mode 100644 index f32b3482ef..0000000000 --- a/qpid/cpp/src/qpid/amqp_0_10/apply.h +++ /dev/null @@ -1,86 +0,0 @@ -#ifndef QPID_AMQP_0_10_APPLY_H -#define QPID_AMQP_0_10_APPLY_H - -/* - * - * 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 - -namespace qpid { -namespace amqp_0_10 { - -template struct FunctionAndResult { - F* functor; - boost::optional result; - - FunctionAndResult() : functor(0) {} - template void invoke(T& t) { result=(*functor)(t); } - template void invoke(const T& t) { result=(*functor)(t); } - R getResult() { return *result; } -}; - -// void result is special case. -template struct FunctionAndResult { - F* functor; - - FunctionAndResult() : functor(0) {} - template void invoke(T& t) { (*functor)(t); } - void getResult() {} -}; - -// Metafunction returning correct abstract visitor for Visitable type. -template struct VisitorType { - typedef typename Visitable::Visitor type; -}; -template struct VisitorType { - typedef typename Visitable::ConstVisitor type; -}; - -template -struct ApplyVisitorBase : public Visitor, public FunctionAndResult {}; - -// Specialize for each visitor type -template struct ApplyVisitor; - -/** Apply a functor to a visitable object. - * The functor can have operator() overloads for each visitable type - * and/or templated operator(). - */ -template -typename F::result_type apply(F& functor, Visitable& visitable) { - ApplyVisitor::type, F> visitor; - visitor.functor=&functor; - visitable.accept(visitor); - return visitor.getResult(); -} - -template -typename F::result_type apply(const F& functor, Visitable& visitable) { - ApplyVisitor::type, const F> visitor; - visitor.functor=&functor; - visitable.accept(visitor); - return visitor.getResult(); -} - -template struct ApplyFunctor { typedef R result_type; }; - -}} // namespace qpid::amqp_0_10 - -#endif /*!QPID_AMQP_0_10_APPLY_H*/ diff --git a/qpid/cpp/src/qpid/amqp_0_10/built_in_types.h b/qpid/cpp/src/qpid/amqp_0_10/built_in_types.h deleted file mode 100644 index e95d1cf3e9..0000000000 --- a/qpid/cpp/src/qpid/amqp_0_10/built_in_types.h +++ /dev/null @@ -1,171 +0,0 @@ -#ifndef QPID_AMQP_0_10_BUILT_IN_TYPES_H -#define QPID_AMQP_0_10_BUILT_IN_TYPES_H -/* - * - * 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/Serializer.h" -#include "qpid/framing/Uuid.h" -#include "qpid/sys/IntegerTypes.h" -#include "qpid/sys/Time.h" -#include "qpid/amqp_0_10/Decimal.h" -#include "qpid/amqp_0_10/SerializableString.h" -#include -#include -#include -#include -#include - -/**@file Mapping from built-in AMQP types to C++ types */ - -namespace qpid { - -namespace framing { -class SequenceNumber; -class SequenceSet; -} - -namespace amqp_0_10 { - -/** Wrapper that behaves like type T but is a distinct type for - * overloading purposes. Unique allows multiple distinc wrappers. - */ -template struct Wrapper { - T value; - Wrapper() {} - Wrapper(const T& x) : value(x) {} - Wrapper& operator=(const T& x) { value=x; return *this; } - operator T&() { return value; } - operator const T&() const { return value; } - template void serialize(S& s) { s(value); } -}; - -template -inline std::ostream& operator<<(std::ostream& o, const Wrapper& w) { - return o << w.value; -} - -/** Void type */ -struct Void { template void serialize(S&) {} }; -inline std::ostream& operator<<(std::ostream& o, const Void&) { return o; } - -/** Bit is a presence indicator - an optional value with no encoding. */ -struct Bit : public Wrapper { - Bit(bool b=false) : Wrapper(b) {} - using Wrapper::operator=; - template void serialize(S& s) { s.split(*this); } - template void encode(S&) const { } - template void decode(S&) { *this = true; } -}; - -inline std::ostream& operator<<(std::ostream& o, const Bit& b) { - return o << bool(b); -} - -// Fixed size types -typedef bool Boolean; -typedef char Char; -typedef int8_t Int8; -typedef int16_t Int16; -typedef int32_t Int32; -typedef int64_t Int64; -typedef uint8_t Uint8; -typedef uint16_t Uint16; -typedef uint32_t Uint32; -typedef uint64_t Uint64; -typedef Wrapper CharUtf32; - -template struct Bin : public boost::array { - template void serialize(S& s) { s.raw(this->begin(), this->size()); } -}; - -template std::ostream& operator<<(std::ostream& o, const Bin& b) { - return o << boost::make_iterator_range(b.begin(), b.end()); -} - -template <> struct Bin<1> : public boost::array { - Bin(char c=0) { this->front() = c; } - operator char() { return this->front(); } - template void serialize(S& s) { s(front()); } -}; - -typedef Bin<1> Bin8; -typedef Bin<128> Bin1024; -typedef Bin<16> Bin128; -typedef Bin<2> Bin16; -typedef Bin<32> Bin256; -typedef Bin<4> Bin32; -typedef Bin<5> Bin40; -typedef Bin<64> Bin512; -typedef Bin<8> Bin64; -typedef Bin<9> Bin72; - -typedef double Double; -typedef float Float; -typedef framing::SequenceNumber SequenceNo; -using framing::Uuid; -typedef sys::AbsTime Datetime; - -typedef Decimal Dec32; -typedef Decimal Dec64; - -// Variable width types - -typedef SerializableString Vbin8; -typedef SerializableString Str8Latin; -typedef SerializableString Str8; -typedef SerializableString Str8Utf16; - -typedef SerializableString Vbin16; -typedef SerializableString Str16Latin; -typedef SerializableString Str16; -typedef SerializableString Str16Utf16; - -typedef SerializableString Vbin32; - -typedef framing::SequenceSet SequenceSet; - -// Forward declare class types. -class Map; -class Struct32; -class UnknownType; - -template struct ArrayDomain; -typedef ArrayDomain Array; - -// FIXME aconway 2008-04-08: TODO -struct ByteRanges { template void serialize(S&) {} }; -struct List { template void serialize(S&) {} }; - -// FIXME aconway 2008-03-10: dummy ostream operators -inline std::ostream& operator<<(std::ostream& o, const ByteRanges&) { return o; } -inline std::ostream& operator<<(std::ostream& o, const SequenceSet&) { return o; } -inline std::ostream& operator<<(std::ostream& o, const List&) { return o; } - -enum SegmentType { CONTROL, COMMAND, HEADER, BODY }; - -inline SerializeAs serializable(SegmentType& st) { - return SerializeAs(st); -} - - -}} // namespace qpid::amqp_0_10 - -#endif diff --git a/qpid/cpp/src/qpid/amqp_0_10/complex_types.cpp b/qpid/cpp/src/qpid/amqp_0_10/complex_types.cpp deleted file mode 100644 index 656d363ba6..0000000000 --- a/qpid/cpp/src/qpid/amqp_0_10/complex_types.cpp +++ /dev/null @@ -1,84 +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/amqp_0_10/UnknownStruct.h" -#include "qpid/amqp_0_10/ApplyCommand.h" -#include "qpid/amqp_0_10/ApplyControl.h" -#include "qpid/amqp_0_10/ApplyStruct.h" -#include "qpid/amqp_0_10/apply.h" -#include - -namespace qpid { -namespace amqp_0_10 { -// Functors for getting static values from a visitable base type. - -#define QPID_STATIC_VALUE_GETTER(NAME, TYPE, VALUE) \ - struct NAME : public ApplyFunctor { \ - template TYPE operator()(const T&) const { return T::VALUE; }\ - } - -QPID_STATIC_VALUE_GETTER(GetCode, uint8_t, CODE); -QPID_STATIC_VALUE_GETTER(GetSize, uint8_t, SIZE); -QPID_STATIC_VALUE_GETTER(GetPack, uint8_t, PACK); -QPID_STATIC_VALUE_GETTER(GetClassCode, uint8_t, CLASS_CODE); -QPID_STATIC_VALUE_GETTER(GetName, const char*, NAME); -QPID_STATIC_VALUE_GETTER(GetClassName, const char*, CLASS_NAME); - - -uint8_t Command::getCode() const { return apply(GetCode(), *this); } -uint8_t Command::getClassCode() const { return apply(GetClassCode(), *this); } -const char* Command::getName() const { return apply(GetName(), *this); } -const char* Command::getClassName() const { return apply(GetClassName(), *this); } - -uint8_t Control::getCode() const { return apply(GetCode(), *this); } -uint8_t Control::getClassCode() const { return apply(GetClassCode(), *this); } -const char* Control::getName() const { return apply(GetName(), *this); } -const char* Control::getClassName() const { return apply(GetClassName(), *this); } - -// Special cases for UnknownStruct -struct GetStructCode : public GetCode { - using GetCode::operator(); - uint8_t operator()(const UnknownStruct& u) const { return u.getCode(); } -}; - -struct GetStructClassCode : public GetClassCode { - using GetClassCode::operator(); - uint8_t operator()(const UnknownStruct& u) const { return u.getClassCode(); } -}; - -uint8_t Struct::getCode() const { return apply(GetStructCode(), *this); } -uint8_t Struct::getClassCode() const { return apply(GetStructClassCode(), *this); } -uint8_t Struct::getPack() const { return apply(GetPack(), *this); } -uint8_t Struct::getSize() const { return apply(GetSize(), *this); } - -struct PrintVisitor { - typedef std::ostream& result_type; - std::ostream& out; - PrintVisitor(std::ostream& o) : out(o) {} - template result_type operator()(const T& t) const { return out << t; } -}; - -std::ostream& operator<<(std::ostream& o, const Command& x) { return apply(PrintVisitor(o), x); } -std::ostream& operator<<(std::ostream& o, const Control& x) { return apply(PrintVisitor(o), x); } -std::ostream& operator<<(std::ostream& o, const Struct& x) { return apply(PrintVisitor(o), x); } - -}} // namespace qpid::amqp_0_10 - diff --git a/qpid/cpp/src/qpid/framing/TemplateVisitor.h b/qpid/cpp/src/qpid/framing/TemplateVisitor.h deleted file mode 100644 index d6d59603f7..0000000000 --- a/qpid/cpp/src/qpid/framing/TemplateVisitor.h +++ /dev/null @@ -1,89 +0,0 @@ -#ifndef QPID_FRAMING_TEMPLATEVISITOR_H -#define QPID_FRAMING_TEMPLATEVISITOR_H - -/* - * 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 -#include - -namespace qpid { -namespace framing { - -/** - * Metafunction to generate a visitor class derived from Base, with a - * visit for each type in TypeList calling functor F. TypeList may be - * any boost::mpl type collection e.g. mpl::list. - * - * Generated class is: TemplateVisitor::type - * - * @see make_visitor - */ -template -class TemplateVisitor -{ - struct Base : public VisitorBase { - F action; - Base(F f) : action(f) {} - using VisitorBase::visit; - }; - - template struct Visit : public B { - Visit(F action) : B(action) {} - using B::visit; - void visit(const T& body) { action(body); } - }; - - typedef typename boost::mpl::fold< - TypeList, Base, Visit - >::type type; -}; - -/** - * Construct a TemplateVisitor to perform the given action, - * for example: - * @code - */ -template -TemplateVisitor::type make_visitor(F action) { - return TemplateVisitor::type(action); -}; - -/** - * For method body classes in TypeList, invoke the corresponding function - * on Target and return true. For other body types return false. - */ -template -bool invoke(const AMQBody& body, Target& target) { - typename InvokeVisitor::type v(target); - body.accept(v); - return v.target; -} - -}} // namespace qpid::framing - - -#endif /*!QPID_FRAMING_INVOKEVISITOR_H*/ - -}} // namespace qpid::framing - - - -#endif /*!QPID_FRAMING_TEMPLATEVISITOR_H*/ diff --git a/qpid/cpp/src/qpid/framing/Visitor.h b/qpid/cpp/src/qpid/framing/Visitor.h deleted file mode 100644 index 759ee65914..0000000000 --- a/qpid/cpp/src/qpid/framing/Visitor.h +++ /dev/null @@ -1,92 +0,0 @@ -#ifndef QPID_FRAMING_VISITOR_H -#define QPID_FRAMING_VISITOR_H - -/* - * 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 -#include -#include - -namespace qpid { -namespace framing { - -/** @file Generic visitor pattern. */ - -/** visit() interface for type T (optional return type R, default is void.) - * To create a visitor for a set of types T1, T2 ... do this: - * struct MyVisitor : public Visit, public Visit ... {}; - *@param T Type to visit. This must be forward declared, and need not be defined. - */ -template struct Visit { - typedef R ReturnType; - typedef T VisitType; - - virtual ~Visit() {} - virtual R visit(T&) = 0; -}; - - -#define QPID_VISITOR_DECL(_1,_2,T) class T; - -#define QPID_VISITOR_BASE(_1,_2,T) , public ::qpid::framing::Visit - -/** Convenience macro to generate a visitor interface. - * QPID_VISITOR(MyVisitor,(A)(B)(C)); is equivalent to: - * @code - * class A; class B; class C; - * class MyVisitor : public Visit , public Visit , public Visit {}; - * @endcode - * @param visitor name of the generated visitor class. - * @param bases a sequence of visitable types in the form (T1)(T2)... - * Any parenthesized notations are due to quirks of the preprocesser. - */ -#define QPID_VISITOR(visitor,types) \ - BOOST_PP_SEQ_FOR_EACH(QPID_VISITOR_DECL, _, types) \ - class visitor : public ::qpid::framing::Visit \ - BOOST_PP_SEQ_FOR_EACH(QPID_VISITOR_BASE, _, BOOST_PP_SEQ_TAIL(types)) \ - {} - -/** The root class for the hierarchy of objects visitable by Visitor V. - * Defines virtual accept(). - */ -template -struct VisitableRoot { - typedef V VisitorType; - typedef R ReturnType; - virtual ~VisitableRoot() {} - virtual R accept(V& v) = 0; -}; - -/** The base class for concrete visitable classes. - * Implements accept(). - * @param T type of visitable class (CRTP). - * @param Base base class to inherit from. - */ -template -struct Visitable : public Base { - void accept(typename Base::VisitorType& v) { - static_cast& >(v).visit(static_cast(*this)); - } -}; - -}} // namespace qpid::framing - -#endif /*!QPID_FRAMING_VISITOR_H*/ -- cgit v1.2.1