Author: aconway
Date: Mon Apr 7 16:22:36 2008
New Revision: 645733
URL: http://svn.apache.org/viewvc?rev=645733&view=rev
Log:
src/qpid/amqp_0_10/Body.h, Header.h: placeholders.
src/qpid/amqp_0_10/Unit.h,.cpp
- Decode "units" - command/control/header segments or body frames.
Equivalent to preview AMQFrame class.
Added:
incubator/qpid/trunk/qpid/cpp/src/qpid/amqp_0_10/Body.h (with props)
incubator/qpid/trunk/qpid/cpp/src/qpid/amqp_0_10/FrameHeader.cpp (with
props)
incubator/qpid/trunk/qpid/cpp/src/qpid/amqp_0_10/FrameHeader.h (with
props)
incubator/qpid/trunk/qpid/cpp/src/qpid/amqp_0_10/Header.h (with props)
incubator/qpid/trunk/qpid/cpp/src/qpid/amqp_0_10/Unit.cpp (with props)
incubator/qpid/trunk/qpid/cpp/src/qpid/amqp_0_10/Unit.h (with props)
incubator/qpid/trunk/qpid/cpp/src/qpid/amqp_0_10/UnitHandler.h (with
props)
Removed:
incubator/qpid/trunk/qpid/cpp/src/qpid/amqp_0_10/Frame.h
incubator/qpid/trunk/qpid/cpp/src/qpid/amqp_0_10/Segment.cpp
incubator/qpid/trunk/qpid/cpp/src/qpid/amqp_0_10/Segment.h
Modified:
incubator/qpid/trunk/qpid/cpp/rubygen/0-10/specification.rb
incubator/qpid/trunk/qpid/cpp/src/Makefile.am
incubator/qpid/trunk/qpid/cpp/src/tests/amqp_0_10/serialize.cpp
incubator/qpid/trunk/qpid/cpp/src/tests/python_tests
Modified: incubator/qpid/trunk/qpid/cpp/rubygen/0-10/specification.rb
URL:
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/rubygen/0-10/specification.rb?rev=645733&r1=645732&r2=645733&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/rubygen/0-10/specification.rb (original)
+++ incubator/qpid/trunk/qpid/cpp/rubygen/0-10/specification.rb Mon Apr 7
16:22:36 2008
@@ -65,6 +65,7 @@
yield if block
}
genl "std::ostream& operator << (std::ostream&, const #{x.classname}&);"
+ genl "bool operator==(const #{x.classname}&, const #{x.classname}&);"
end
# FIXME aconway 2008-03-10: packing, coding
Modified: incubator/qpid/trunk/qpid/cpp/src/Makefile.am
URL:
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/Makefile.am?rev=645733&r1=645732&r2=645733&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/Makefile.am (original)
+++ incubator/qpid/trunk/qpid/cpp/src/Makefile.am Mon Apr 7 16:22:36 2008
@@ -107,16 +107,19 @@
qpid/amqp_0_10/built_in_types.h \
qpid/amqp_0_10/complex_types.h \
qpid/amqp_0_10/complex_types.cpp \
+ qpid/amqp_0_10/Body.h \
+ qpid/amqp_0_10/Header.h \
+ qpid/amqp_0_10/FrameHeader.h \
+ qpid/amqp_0_10/FrameHeader.cpp \
qpid/amqp_0_10/Holder.h \
qpid/amqp_0_10/Codec.h \
qpid/amqp_0_10/Packer.h \
qpid/amqp_0_10/Decimal.h \
- qpid/amqp_0_10/Frame.h \
- qpid/amqp_0_10/Segment.h \
- qpid/amqp_0_10/Segment.cpp \
qpid/amqp_0_10/SerializableString.h \
qpid/amqp_0_10/Map.h \
qpid/amqp_0_10/Map.cpp \
+ qpid/amqp_0_10/Unit.h \
+ qpid/amqp_0_10/Unit.cpp \
qpid/amqp_0_10/UnknownType.h \
qpid/amqp_0_10/UnknownType.cpp \
qpid/Serializer.h \
Added: incubator/qpid/trunk/qpid/cpp/src/qpid/amqp_0_10/Body.h
URL:
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/amqp_0_10/Body.h?rev=645733&view=auto
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/amqp_0_10/Body.h (added)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/amqp_0_10/Body.h Mon Apr 7 16:22:36
2008
@@ -0,0 +1,55 @@
+#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 <string>
+#include <ostream>
+
+namespace qpid {
+namespace amqp_0_10 {
+
+/** Holds data from a body frame. */
+class Body {
+ public:
+ Body() {}
+ Body(size_t size_) : str('\0', size_) {}
+ 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<char*>(str.data()); }
+
+ template <class S> 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(16) << "... (" << b.size() << ")";
+}
+
+}} // namespace qpid::amqp_0_10
+
+#endif /*!QPID_AMQP_0_10_BODY_H*/
Propchange: incubator/qpid/trunk/qpid/cpp/src/qpid/amqp_0_10/Body.h
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/qpid/trunk/qpid/cpp/src/qpid/amqp_0_10/Body.h
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/qpid/trunk/qpid/cpp/src/qpid/amqp_0_10/FrameHeader.cpp
URL:
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/amqp_0_10/FrameHeader.cpp?rev=645733&view=auto
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/amqp_0_10/FrameHeader.cpp (added)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/amqp_0_10/FrameHeader.cpp Mon Apr 7
16:22:36 2008
@@ -0,0 +1,50 @@
+/*
+ *
+ * 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 "FrameHeader.h"
+#include <ios>
+#include <iomanip>
+#include <ostream>
+
+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
Propchange: incubator/qpid/trunk/qpid/cpp/src/qpid/amqp_0_10/FrameHeader.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/qpid/trunk/qpid/cpp/src/qpid/amqp_0_10/FrameHeader.cpp
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/qpid/trunk/qpid/cpp/src/qpid/amqp_0_10/FrameHeader.h
URL:
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/amqp_0_10/FrameHeader.h?rev=645733&view=auto
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/amqp_0_10/FrameHeader.h (added)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/amqp_0_10/FrameHeader.h Mon Apr 7
16:22:36 2008
@@ -0,0 +1,90 @@
+#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 <boost/shared_array.hpp>
+#include <string.h>
+#include <assert.h>
+#include <iosfwd>
+
+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 <class S> 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*/
Propchange: incubator/qpid/trunk/qpid/cpp/src/qpid/amqp_0_10/FrameHeader.h
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/qpid/trunk/qpid/cpp/src/qpid/amqp_0_10/FrameHeader.h
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/qpid/trunk/qpid/cpp/src/qpid/amqp_0_10/Header.h
URL:
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/amqp_0_10/Header.h?rev=645733&view=auto
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/amqp_0_10/Header.h (added)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/amqp_0_10/Header.h Mon Apr 7
16:22:36 2008
@@ -0,0 +1,42 @@
+#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 <ostream>
+
+namespace qpid {
+namespace amqp_0_10 {
+
+// FIXME aconway 2008-03-27: TODO
+class Header
+{
+ public:
+ template <class S> void serialize(S&) {}
+ private:
+};
+
+// FIXME aconway 2008-03-28: TODO
+inline std::ostream& operator<<(std::ostream& o, const Header&) { return o; }
+
+}} // namespace qpid::amqp_0_10
+
+#endif /*!QPID_AMQP_0_10_HEADER_H*/
Propchange: incubator/qpid/trunk/qpid/cpp/src/qpid/amqp_0_10/Header.h
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/qpid/trunk/qpid/cpp/src/qpid/amqp_0_10/Header.h
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/qpid/trunk/qpid/cpp/src/qpid/amqp_0_10/Unit.cpp
URL:
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/amqp_0_10/Unit.cpp?rev=645733&view=auto
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/amqp_0_10/Unit.cpp (added)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/amqp_0_10/Unit.cpp Mon Apr 7
16:22:36 2008
@@ -0,0 +1,56 @@
+/*
+ *
+ * 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 "Unit.h"
+#include "Codec.h"
+
+namespace qpid {
+namespace amqp_0_10 {
+
+void Unit::setVariant() {
+ switch (header.getType()) {
+ case CONTROL: variant=ControlHolder(); break;
+ case COMMAND: variant=CommandHolder();
+ case HEADER: variant=Header();
+ case BODY: variant=Body(header.getDataSize());
+ }
+}
+
+struct GetTypeVisitor : public boost::static_visitor<SegmentType> {
+ 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; }
+};
+
+void Unit::setHeader(uint8_t flags) {
+ header.setFlags(flags);
+ 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.getVariant();
+}
+
+}} // namespace qpid::amqp_0_10
Propchange: incubator/qpid/trunk/qpid/cpp/src/qpid/amqp_0_10/Unit.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/qpid/trunk/qpid/cpp/src/qpid/amqp_0_10/Unit.cpp
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/qpid/trunk/qpid/cpp/src/qpid/amqp_0_10/Unit.h
URL:
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/amqp_0_10/Unit.h?rev=645733&view=auto
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/amqp_0_10/Unit.h (added)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/amqp_0_10/Unit.h Mon Apr 7 16:22:36
2008
@@ -0,0 +1,76 @@
+#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 <boost/variant.hpp>
+#include <ostream>
+
+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:
+ typedef boost::variant<ControlHolder, CommandHolder, Header, Body> Variant;
+
+ Unit(const FrameHeader& h=FrameHeader()) : header(h) { setVariant(); }
+
+ template <class T>
+ Unit(const T& t, uint8_t flags) : variant(t) { setHeader(flags); }
+
+ const FrameHeader& getHeader() const { return header; }
+
+ template<class T> const T* get() const { return boost::get<T>(&variant); }
+ template<class T> T* get() { return boost::get<T>(&variant); }
+ template<class T> Unit& operator==(const T& t) { variant=t; return *this; }
+
+ template <class S> void serialize(S& s) { variant.apply_visitor(s);
s.split(*this); }
+ template <class S> void encode(S&) const {}
+ template <class S> void decode(S&) { setHeader(header.getFlags()); }
+
+ const Variant& getVariant() const { return variant; }
+ Variant& getVariant() { return variant; }
+
+ private:
+ void setHeader(uint8_t flags);
+ void setVariant();
+
+ Variant variant;
+ FrameHeader header;
+};
+
+std::ostream& operator<<(std::ostream& o, const Unit& u);
+
+}} // namespace qpid::amqp_0_10
+
+#endif /*!QPID_AMQP_0_10_UNIT_H*/
Propchange: incubator/qpid/trunk/qpid/cpp/src/qpid/amqp_0_10/Unit.h
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/qpid/trunk/qpid/cpp/src/qpid/amqp_0_10/Unit.h
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/qpid/trunk/qpid/cpp/src/qpid/amqp_0_10/UnitHandler.h
URL:
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/amqp_0_10/UnitHandler.h?rev=645733&view=auto
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/amqp_0_10/UnitHandler.h (added)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/amqp_0_10/UnitHandler.h Mon Apr 7
16:22:36 2008
@@ -0,0 +1,35 @@
+#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<const Unit&> UnitHandler;
+
+}} // namespace qpid::amqp_0_10
+
+#endif /*!QPID_AMQP_0_10_UNITHANDLER_H*/
Propchange: incubator/qpid/trunk/qpid/cpp/src/qpid/amqp_0_10/UnitHandler.h
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/qpid/trunk/qpid/cpp/src/qpid/amqp_0_10/UnitHandler.h
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/qpid/trunk/qpid/cpp/src/tests/amqp_0_10/serialize.cpp
URL:
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/tests/amqp_0_10/serialize.cpp?rev=645733&r1=645732&r2=645733&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/tests/amqp_0_10/serialize.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/tests/amqp_0_10/serialize.cpp Mon Apr 7
16:22:36 2008
@@ -25,8 +25,9 @@
#include "qpid/amqp_0_10/Codec.h"
#include "qpid/amqp_0_10/specification.h"
#include "qpid/amqp_0_10/ControlHolder.h"
-#include "qpid/amqp_0_10/Frame.h"
+#include "qpid/amqp_0_10/FrameHeader.h"
#include "qpid/amqp_0_10/Map.h"
+#include "qpid/amqp_0_10/Unit.h"
#include <boost/test/test_case_template.hpp>
#include <boost/type_traits/is_arithmetic.hpp>
@@ -204,48 +205,6 @@
BOOST_CHECK_EQUAL(tune.heartbeatMax, 4u);
}
-BOOST_AUTO_TEST_CASE(testFrameEncodeDecode) {
- static const int overhead=12;
- string data;
- Frame r, c;
- char d1[]="abcdefg";
- r.refer(d1, d1+sizeof(d1));
- r.setFlags(Frame::FIRST_FRAME);
- r.setType(CONTROL);
- r.setChannel(32);
- r.setTrack(1);
- char d2[]="01234567";
- c.copy(d2, d2+sizeof(d2));
-
- BOOST_CHECK_EQUAL(overhead+sizeof(d1), Codec::size(r));
- BOOST_CHECK_EQUAL(overhead+sizeof(d2), Codec::size(c));
- Codec::encode(std::back_inserter(data))(r)(c);
- BOOST_CHECK_EQUAL(data.size(), Codec::size(r)+Codec::size(c));
-
- FrameHeader fh;
- std::string::iterator i = Codec::decode(data.begin())(fh).pos();
- size_t s = fh.size();
- BOOST_CHECK_EQUAL(s, sizeof(d1));
- BOOST_CHECK_EQUAL(std::string(i, i+s), std::string(d1, d1+s));
-
-
- Frame f1, f2;
- Codec::decode(data.begin())(f1)(f2);
- BOOST_CHECK_EQUAL(f1.size(), sizeof(d1));
- BOOST_CHECK_EQUAL(std::string(f1.begin(), f1.size()),
- std::string(d1, sizeof(d1)));
- BOOST_CHECK_EQUAL(f1.size(), r.size());
- BOOST_CHECK_EQUAL(f1.getFlags(), Frame::FIRST_FRAME);
- BOOST_CHECK_EQUAL(f1.getType(), CONTROL);
- BOOST_CHECK_EQUAL(f1.getChannel(), 32);
- BOOST_CHECK_EQUAL(f1.getTrack(), 1);
-
- BOOST_CHECK_EQUAL(f2.size(), c.size());
- BOOST_CHECK_EQUAL(std::string(f2.begin(), f2.end()),
- std::string(d2, d2+sizeof(d2)));
-
-}
-
struct DummyPacked {
static const uint8_t PACK=1;
boost::optional<char> i, j;
@@ -290,5 +249,38 @@
BOOST_CHECK(!dummy.j);
BOOST_CHECK_EQUAL(dummy.k, 'y');
}
+
+BOOST_AUTO_TEST_CASE(testUnit) {
+ string data;
+ Control::Holder h(in_place<connection::Tune>(1,2,3,4));
+ Codec::encode(std::back_inserter(data))(h);
+
+ Unit unit(FrameHeader(FIRST_FRAME|LAST_FRAME, CONTROL));
+ Codec::decode(data.begin())(unit);
+
+ BOOST_REQUIRE(unit.get<ControlHolder>());
+
+ string data2;
+ Codec::encode(back_inserter(data2))(unit);
+
+ BOOST_CHECK_EQUAL(data, data2);
+}
+
+// FIXME aconway 2008-04-07: TODO
+// BOOST_AUTO_TEST_CASE(testAllSegmentTypes) {
+// string data;
+// int n = allSegmentTypes(Codec::encode(data));
+
+// string data2;
+// Codec::Decoder<string::iterator> decode(data.begin(), data.size());
+// while (decode.pos() != data.end()) {
+// Unit unit;
+// decode(unit);
+// Codec::encode(back_insert(data));
+// --n;
+// }
+// BOOST_CHECK_EQUAL(n, 0);
+// BOOST_CHECK_EQUAL(data, data2);
+// }
QPID_AUTO_TEST_SUITE_END()
Modified: incubator/qpid/trunk/qpid/cpp/src/tests/python_tests
URL:
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/tests/python_tests?rev=645733&r1=645732&r2=645733&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/tests/python_tests (original)
+++ incubator/qpid/trunk/qpid/cpp/src/tests/python_tests Mon Apr 7 16:22:36
2008
@@ -2,10 +2,17 @@
# Run the python tests.
QPID_PORT=${QPID_PORT:-5672}
PYTHON_TESTS=${PYTHON_TESTS:-$*}
+
+run() {
+ SPEC=$1
+ FAILING=$2
+ ./run-tests --skip-self-test -v -s $SPEC -I $FAILING -b
localhost:$QPID_PORT $PYTHON_TESTS || exit 1
+}
+
if test -d ../../../python ; then
cd ../../../python
- test -z "$QPID_NO_PREVIEW" && ./run-tests --skip-self-test -v -s
../specs/amqp.0-10-preview.xml -I cpp_failing_0-10_preview.txt -b
localhost:$QPID_PORT $PYTHON_TESTS
- ./run-tests --skip-self-test -v -s "0-10" -I cpp_failing_0-10.txt -b
localhost:$QPID_PORT $PYTHON_TESTS
+ run 0-10 cpp_failing_0-10.txt
+ test -z "$QPID_NO_PREVIEW" && run ../specs/amqp.0-10-preview.xml
cpp_failing_0-10_preview.txt
else
echo Warning: python tests not found.
fi