summaryrefslogtreecommitdiff
path: root/cpp/src/qpid/framing
diff options
context:
space:
mode:
authorGordon Sim <gsim@apache.org>2007-09-10 08:41:05 +0000
committerGordon Sim <gsim@apache.org>2007-09-10 08:41:05 +0000
commita5c0fde5d0b96ae0b747f0cea21414753d6ee654 (patch)
tree4a809a880691db3e04fa3c7374db500b767ca85b /cpp/src/qpid/framing
parent783b718d0b270121cd2e597424d0c81adea77a38 (diff)
downloadqpid-python-a5c0fde5d0b96ae0b747f0cea21414753d6ee654.tar.gz
Client side support for message and delivery properties in header segments.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@574176 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/framing')
-rw-r--r--cpp/src/qpid/framing/AMQContentBody.cpp2
-rw-r--r--cpp/src/qpid/framing/FrameSet.cpp13
-rw-r--r--cpp/src/qpid/framing/FrameSet.h1
-rw-r--r--cpp/src/qpid/framing/MethodContent.h5
-rw-r--r--cpp/src/qpid/framing/TransferContent.cpp64
-rw-r--r--cpp/src/qpid/framing/TransferContent.h46
6 files changed, 125 insertions, 6 deletions
diff --git a/cpp/src/qpid/framing/AMQContentBody.cpp b/cpp/src/qpid/framing/AMQContentBody.cpp
index b0850ea434..176114ea0c 100644
--- a/cpp/src/qpid/framing/AMQContentBody.cpp
+++ b/cpp/src/qpid/framing/AMQContentBody.cpp
@@ -41,6 +41,6 @@ void qpid::framing::AMQContentBody::print(std::ostream& out) const
{
out << "content (" << size() << " bytes)";
#ifndef NDEBUG
- out << data.substr(0,10);
+ out << " " << data.substr(0,10);
#endif
}
diff --git a/cpp/src/qpid/framing/FrameSet.cpp b/cpp/src/qpid/framing/FrameSet.cpp
index 434f1b3aad..12579f53cb 100644
--- a/cpp/src/qpid/framing/FrameSet.cpp
+++ b/cpp/src/qpid/framing/FrameSet.cpp
@@ -56,17 +56,17 @@ bool FrameSet::isComplete() const
const AMQMethodBody* FrameSet::getMethod() const
{
- return parts.empty() ? 0 : dynamic_cast<const AMQMethodBody*>(parts[0].getBody());
+ return parts.empty() ? 0 : parts[0].getMethod();
}
const AMQHeaderBody* FrameSet::getHeaders() const
{
- return parts.size() < 2 ? 0 : dynamic_cast<const AMQHeaderBody*>(parts[1].getBody());
+ return parts.size() < 2 ? 0 : parts[1].castBody<AMQHeaderBody>();
}
AMQHeaderBody* FrameSet::getHeaders()
{
- return parts.size() < 2 ? 0 : dynamic_cast<AMQHeaderBody*>(parts[1].getBody());
+ return parts.size() < 2 ? 0 : parts[1].castBody<AMQHeaderBody>();
}
uint64_t FrameSet::getContentSize() const
@@ -81,3 +81,10 @@ void FrameSet::getContent(std::string& out) const
AccumulateContent accumulator(out);
map_if(accumulator, TypeFilter(CONTENT_BODY));
}
+
+std::string FrameSet::getContent() const
+{
+ std::string out;
+ getContent(out);
+ return out;
+}
diff --git a/cpp/src/qpid/framing/FrameSet.h b/cpp/src/qpid/framing/FrameSet.h
index d6d5cd7a13..9a9512a6d4 100644
--- a/cpp/src/qpid/framing/FrameSet.h
+++ b/cpp/src/qpid/framing/FrameSet.h
@@ -48,6 +48,7 @@ public:
uint64_t getContentSize() const;
void getContent(std::string&) const;
+ std::string getContent() const;
const AMQMethodBody* getMethod() const;
const AMQHeaderBody* getHeaders() const;
diff --git a/cpp/src/qpid/framing/MethodContent.h b/cpp/src/qpid/framing/MethodContent.h
index 11d8d42cab..737c0d6b7b 100644
--- a/cpp/src/qpid/framing/MethodContent.h
+++ b/cpp/src/qpid/framing/MethodContent.h
@@ -21,7 +21,8 @@
#ifndef _MethodContent_
#define _MethodContent_
-#include "HeaderProperties.h"
+#include <string>
+#include "AMQHeaderBody.h"
namespace qpid {
namespace framing {
@@ -31,7 +32,7 @@ class MethodContent
public:
virtual ~MethodContent() {}
//TODO: rethink this interface
- virtual const HeaderProperties& getMethodHeaders() const = 0;
+ virtual AMQHeaderBody getHeader() const = 0;
virtual const std::string& getData() const = 0;
};
diff --git a/cpp/src/qpid/framing/TransferContent.cpp b/cpp/src/qpid/framing/TransferContent.cpp
new file mode 100644
index 0000000000..1faa24ae0c
--- /dev/null
+++ b/cpp/src/qpid/framing/TransferContent.cpp
@@ -0,0 +1,64 @@
+/*
+ *
+ * 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 "TransferContent.h"
+
+namespace qpid {
+namespace framing {
+
+TransferContent::TransferContent(const std::string& _data)
+{
+ setData(_data);
+}
+
+AMQHeaderBody TransferContent::getHeader() const
+{
+ return header;
+}
+
+const std::string& TransferContent::getData() const
+{
+ return data;
+}
+
+void TransferContent::setData(const std::string& _data)
+{
+ data = _data;
+ header.get<MessageProperties>(true)->setContentLength(data.size());
+}
+
+void TransferContent::appendData(const std::string& _data)
+{
+ data += _data;
+ header.get<MessageProperties>(true)->setContentLength(data.size());
+}
+
+MessageProperties& TransferContent::getMessageProperties()
+{
+ return *header.get<MessageProperties>(true);
+}
+
+DeliveryProperties& TransferContent::getDeliveryProperties()
+{
+ return *header.get<DeliveryProperties>(true);
+}
+
+}}
diff --git a/cpp/src/qpid/framing/TransferContent.h b/cpp/src/qpid/framing/TransferContent.h
new file mode 100644
index 0000000000..14ba209f4b
--- /dev/null
+++ b/cpp/src/qpid/framing/TransferContent.h
@@ -0,0 +1,46 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+#ifndef _TransferContent_
+#define _TransferContent_
+
+#include "MethodContent.h"
+#include "qpid/framing/MessageProperties.h"
+#include "qpid/framing/DeliveryProperties.h"
+
+namespace qpid {
+namespace framing {
+
+class TransferContent : public MethodContent
+{
+ AMQHeaderBody header;
+ std::string data;
+public:
+ TransferContent(const std::string& data);
+ AMQHeaderBody getHeader() const;
+ void setData(const std::string&);
+ void appendData(const std::string&);
+ const std::string& getData() const;
+ MessageProperties& getMessageProperties();
+ DeliveryProperties& getDeliveryProperties();
+};
+
+}}
+#endif