You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by rh...@apache.org on 2006/09/20 00:07:25 UTC
svn commit: r447994 [7/46] - in /incubator/qpid/trunk/qpid: ./ cpp/ cpp/bin/
cpp/broker/ cpp/broker/inc/ cpp/broker/src/ cpp/broker/test/ cpp/client/
cpp/client/inc/ cpp/client/src/ cpp/client/test/ cpp/common/
cpp/common/concurrent/ cpp/common/concurr...
Added: incubator/qpid/trunk/qpid/cpp/common/framing/inc/NamedValue.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/common/framing/inc/NamedValue.h?view=auto&rev=447994
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/common/framing/inc/NamedValue.h (added)
+++ incubator/qpid/trunk/qpid/cpp/common/framing/inc/NamedValue.h Tue Sep 19 15:06:50 2006
@@ -0,0 +1,49 @@
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#include <iostream>
+#include <vector>
+#include "amqp_types.h"
+#include "Value.h"
+
+#ifndef _NamedValue_
+#define _NamedValue_
+
+namespace qpid {
+namespace framing {
+
+ class Buffer;
+
+ class NamedValue{
+ string name;
+ Value* value;
+ public:
+ NamedValue();
+ NamedValue(const string& name, Value* value);
+ ~NamedValue();
+ void encode(Buffer& buffer);
+ void decode(Buffer& buffer);
+ u_int32_t size() const;
+ inline const string& getName() const { return name; }
+ inline Value* getValue() const { return value; }
+ inline void setValue(Value* val) { value = val; }
+ };
+}
+}
+
+
+#endif
Propchange: incubator/qpid/trunk/qpid/cpp/common/framing/inc/NamedValue.h
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/qpid/trunk/qpid/cpp/common/framing/inc/OutputHandler.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/common/framing/inc/OutputHandler.h?view=auto&rev=447994
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/common/framing/inc/OutputHandler.h (added)
+++ incubator/qpid/trunk/qpid/cpp/common/framing/inc/OutputHandler.h Tue Sep 19 15:06:50 2006
@@ -0,0 +1,37 @@
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#include <string>
+
+#ifndef _OutputHandler_
+#define _OutputHandler_
+
+#include "AMQFrame.h"
+
+namespace qpid {
+namespace framing {
+
+ class OutputHandler{
+ public:
+ virtual void send(AMQFrame* frame) = 0;
+ };
+
+}
+}
+
+
+#endif
Propchange: incubator/qpid/trunk/qpid/cpp/common/framing/inc/OutputHandler.h
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/qpid/trunk/qpid/cpp/common/framing/inc/ProtocolInitiation.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/common/framing/inc/ProtocolInitiation.h?view=auto&rev=447994
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/common/framing/inc/ProtocolInitiation.h (added)
+++ incubator/qpid/trunk/qpid/cpp/common/framing/inc/ProtocolInitiation.h Tue Sep 19 15:06:50 2006
@@ -0,0 +1,48 @@
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#include "amqp_types.h"
+#include "Buffer.h"
+#include "AMQDataBlock.h"
+
+#ifndef _ProtocolInitiation_
+#define _ProtocolInitiation_
+
+namespace qpid {
+namespace framing {
+
+class ProtocolInitiation : virtual public AMQDataBlock
+{
+ u_int8_t pmajor;
+ u_int8_t pminor;
+
+public:
+ ProtocolInitiation();
+ ProtocolInitiation(u_int8_t major, u_int8_t minor);
+ virtual ~ProtocolInitiation();
+ virtual void encode(Buffer& buffer);
+ virtual bool decode(Buffer& buffer);
+ inline virtual u_int32_t size() const { return 8; }
+ inline u_int8_t getMajor(){ return pmajor; }
+ inline u_int8_t getMinor(){ return pminor; }
+};
+
+}
+}
+
+
+#endif
Propchange: incubator/qpid/trunk/qpid/cpp/common/framing/inc/ProtocolInitiation.h
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/qpid/trunk/qpid/cpp/common/framing/inc/Value.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/common/framing/inc/Value.h?view=auto&rev=447994
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/common/framing/inc/Value.h (added)
+++ incubator/qpid/trunk/qpid/cpp/common/framing/inc/Value.h Tue Sep 19 15:06:50 2006
@@ -0,0 +1,109 @@
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#include <iostream>
+#include <vector>
+#include "amqp_types.h"
+#include "FieldTable.h"
+
+#ifndef _Value_
+#define _Value_
+
+namespace qpid {
+namespace framing {
+
+ class Buffer;
+
+ class Value{
+ public:
+ inline virtual ~Value(){}
+ virtual u_int32_t size() const = 0;
+ virtual char getType() const = 0;
+ virtual void encode(Buffer& buffer) = 0;
+ virtual void decode(Buffer& buffer) = 0;
+ };
+
+ class StringValue : public virtual Value{
+ string value;
+
+ public:
+ inline StringValue(const string& v) : value(v){}
+ inline StringValue(){}
+ inline string getValue(){ return value; }
+ ~StringValue(){}
+ inline virtual u_int32_t size() const { return 4 + value.length(); }
+ inline virtual char getType() const { return 'S'; }
+ virtual void encode(Buffer& buffer);
+ virtual void decode(Buffer& buffer);
+ };
+
+ class IntegerValue : public virtual Value{
+ int value;
+ public:
+ inline IntegerValue(int v) : value(v){}
+ inline IntegerValue(){}
+ inline int getValue(){ return value; }
+ ~IntegerValue(){}
+ inline virtual u_int32_t size() const { return 4; }
+ inline virtual char getType() const { return 'I'; }
+ virtual void encode(Buffer& buffer);
+ virtual void decode(Buffer& buffer);
+ };
+
+ class TimeValue : public virtual Value{
+ u_int64_t value;
+ public:
+ inline TimeValue(int v) : value(v){}
+ inline TimeValue(){}
+ inline u_int64_t getValue(){ return value; }
+ ~TimeValue(){}
+ inline virtual u_int32_t size() const { return 8; }
+ inline virtual char getType() const { return 'T'; }
+ virtual void encode(Buffer& buffer);
+ virtual void decode(Buffer& buffer);
+ };
+
+ class DecimalValue : public virtual Value{
+ u_int8_t decimals;
+ u_int32_t value;
+ public:
+ inline DecimalValue(int v) : value(v){}
+ inline DecimalValue(){}
+ ~DecimalValue(){}
+ inline virtual u_int32_t size() const { return 5; }
+ inline virtual char getType() const { return 'D'; }
+ virtual void encode(Buffer& buffer);
+ virtual void decode(Buffer& buffer);
+ };
+
+ class FieldTableValue : public virtual Value{
+ FieldTable value;
+ public:
+ inline FieldTableValue(const FieldTable& v) : value(v){}
+ inline FieldTableValue(){}
+ inline FieldTable getValue(){ return value; }
+ ~FieldTableValue(){}
+ inline virtual u_int32_t size() const { return 4 + value.size(); }
+ inline virtual char getType() const { return 'F'; }
+ virtual void encode(Buffer& buffer);
+ virtual void decode(Buffer& buffer);
+ };
+}
+}
+
+
+#endif
Propchange: incubator/qpid/trunk/qpid/cpp/common/framing/inc/Value.h
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/qpid/trunk/qpid/cpp/common/framing/inc/amqp_framing.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/common/framing/inc/amqp_framing.h?view=auto&rev=447994
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/common/framing/inc/amqp_framing.h (added)
+++ incubator/qpid/trunk/qpid/cpp/common/framing/inc/amqp_framing.h Tue Sep 19 15:06:50 2006
@@ -0,0 +1,31 @@
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#include "amqp_types.h"
+#include "AMQFrame.h"
+#include "AMQBody.h"
+#include "BodyHandler.h"
+#include "AMQMethodBody.h"
+#include "AMQHeaderBody.h"
+#include "AMQContentBody.h"
+#include "AMQHeartbeatBody.h"
+#include "amqp_methods.h"
+#include "InputHandler.h"
+#include "OutputHandler.h"
+#include "InitiationHandler.h"
+#include "ProtocolInitiation.h"
+#include "BasicHeaderProperties.h"
Propchange: incubator/qpid/trunk/qpid/cpp/common/framing/inc/amqp_framing.h
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/qpid/trunk/qpid/cpp/common/framing/inc/amqp_types.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/common/framing/inc/amqp_types.h?view=auto&rev=447994
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/common/framing/inc/amqp_types.h (added)
+++ incubator/qpid/trunk/qpid/cpp/common/framing/inc/amqp_types.h Tue Sep 19 15:06:50 2006
@@ -0,0 +1,36 @@
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#include <string>
+#ifdef _WINDOWS
+#include "windows.h"
+typedef unsigned char u_int8_t;
+typedef unsigned short u_int16_t;
+typedef unsigned int u_int32_t;
+typedef unsigned __int64 u_int64_t;
+#endif
+#ifndef _WINDOWS
+#include "sys/types.h"
+#endif
+
+#ifndef AMQP_TYPES_H
+#define AMQP_TYPES_H
+
+
+typedef std::string string;
+
+#endif
Propchange: incubator/qpid/trunk/qpid/cpp/common/framing/inc/amqp_types.h
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/qpid/trunk/qpid/cpp/common/framing/src/AMQContentBody.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/common/framing/src/AMQContentBody.cpp?view=auto&rev=447994
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/common/framing/src/AMQContentBody.cpp (added)
+++ incubator/qpid/trunk/qpid/cpp/common/framing/src/AMQContentBody.cpp Tue Sep 19 15:06:50 2006
@@ -0,0 +1,35 @@
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#include "AMQContentBody.h"
+
+qpid::framing::AMQContentBody::AMQContentBody(){
+}
+
+qpid::framing::AMQContentBody::AMQContentBody(string& _data) : data(_data){
+}
+
+u_int32_t qpid::framing::AMQContentBody::size() const{
+ return data.size();
+}
+void qpid::framing::AMQContentBody::encode(Buffer& buffer) const{
+ buffer.putRawData(data);
+}
+void qpid::framing::AMQContentBody::decode(Buffer& buffer, u_int32_t size){
+ buffer.getRawData(data, size);
+}
+
Propchange: incubator/qpid/trunk/qpid/cpp/common/framing/src/AMQContentBody.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/qpid/trunk/qpid/cpp/common/framing/src/AMQFrame.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/common/framing/src/AMQFrame.cpp?view=auto&rev=447994
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/common/framing/src/AMQFrame.cpp (added)
+++ incubator/qpid/trunk/qpid/cpp/common/framing/src/AMQFrame.cpp Tue Sep 19 15:06:50 2006
@@ -0,0 +1,147 @@
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#include "AMQFrame.h"
+#include "QpidError.h"
+
+using namespace qpid::framing;
+
+AMQFrame::AMQFrame(){}
+
+AMQFrame::AMQFrame(u_int16_t _channel, AMQBody* _body) : channel(_channel), body(_body){}
+
+AMQFrame::AMQFrame(u_int16_t _channel, AMQBody::shared_ptr& _body) : channel(_channel), body(_body){}
+
+AMQFrame::~AMQFrame(){
+}
+
+u_int16_t AMQFrame::getChannel(){
+ return channel;
+}
+
+AMQBody::shared_ptr& AMQFrame::getBody(){
+ return body;
+}
+
+void AMQFrame::encode(Buffer& buffer)
+{
+ buffer.putOctet(body->type());
+ buffer.putShort(channel);
+ buffer.putLong(body->size());
+ body->encode(buffer);
+ buffer.putOctet(0xCE);
+}
+
+AMQBody::shared_ptr createMethodBody(Buffer& buffer){
+ u_int16_t classId = buffer.getShort();
+ u_int16_t methodId = buffer.getShort();
+ AMQBody::shared_ptr body(createAMQMethodBody(classId, methodId));
+ return body;
+}
+
+u_int32_t AMQFrame::size() const{
+ if(!body.get()) THROW_QPID_ERROR(INTERNAL_ERROR, "Attempt to get size of frame with no body set!");
+ return 1/*type*/ + 2/*channel*/ + 4/*body size*/ + body->size() + 1/*0xCE*/;
+}
+
+bool AMQFrame::decode(Buffer& buffer)
+{
+ if(buffer.available() < 7) return false;
+ buffer.record();
+ u_int8_t type = buffer.getOctet();
+ channel = buffer.getShort();
+ u_int32_t size = buffer.getLong();
+ if(buffer.available() < size + 1){
+ buffer.restore();
+ return false;
+ }
+ switch(type)
+ {
+ case METHOD_BODY:
+ body = createMethodBody(buffer);
+ break;
+ case HEADER_BODY:
+ body = AMQBody::shared_ptr(new AMQHeaderBody());
+ break;
+ case CONTENT_BODY:
+ body = AMQBody::shared_ptr(new AMQContentBody());
+ break;
+ case HEARTBEAT_BODY:
+ body = AMQBody::shared_ptr(new AMQHeartbeatBody());
+ break;
+ default:
+ string msg("Unknown body type: ");
+ msg += type;
+ THROW_QPID_ERROR(FRAMING_ERROR, msg);
+ }
+ body->decode(buffer, size);
+ u_int8_t end = buffer.getOctet();
+ if(end != 0xCE) THROW_QPID_ERROR(FRAMING_ERROR, "Frame end not found");
+ return true;
+}
+
+u_int32_t AMQFrame::decodeHead(Buffer& buffer){
+ type = buffer.getOctet();
+ channel = buffer.getShort();
+ return buffer.getLong();
+}
+
+void AMQFrame::decodeBody(Buffer& buffer, uint32_t size)
+{
+ switch(type)
+ {
+ case METHOD_BODY:
+ body = createMethodBody(buffer);
+ break;
+ case HEADER_BODY:
+ body = AMQBody::shared_ptr(new AMQHeaderBody());
+ break;
+ case CONTENT_BODY:
+ body = AMQBody::shared_ptr(new AMQContentBody());
+ break;
+ case HEARTBEAT_BODY:
+ body = AMQBody::shared_ptr(new AMQHeartbeatBody());
+ break;
+ default:
+ string msg("Unknown body type: ");
+ msg += type;
+ THROW_QPID_ERROR(FRAMING_ERROR, msg);
+ }
+ body->decode(buffer, size);
+}
+
+std::ostream& qpid::framing::operator<<(std::ostream& out, const AMQFrame& t){
+ out << "Frame[channel=" << t.channel << "; ";
+ if(t.body.get() == 0){
+ out << "empty";
+ }else if(t.body->type() == METHOD_BODY){
+ (dynamic_cast<AMQMethodBody*>(t.body.get()))->print(out);
+ }else if(t.body->type() == HEADER_BODY){
+ out << "header, content_size=" <<
+ (dynamic_cast<AMQHeaderBody*>(t.body.get()))->getContentSize()
+ << " (" << t.body->size() << " bytes)";
+ }else if(t.body->type() == CONTENT_BODY){
+ out << "content (" << t.body->size() << " bytes)";
+ }else if(t.body->type() == HEARTBEAT_BODY){
+ out << "heartbeat";
+ }else{
+ out << "unknown type, " << t.body->type();
+ }
+ out << "]";
+ return out;
+}
+
Propchange: incubator/qpid/trunk/qpid/cpp/common/framing/src/AMQFrame.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/qpid/trunk/qpid/cpp/common/framing/src/AMQHeaderBody.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/common/framing/src/AMQHeaderBody.cpp?view=auto&rev=447994
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/common/framing/src/AMQHeaderBody.cpp (added)
+++ incubator/qpid/trunk/qpid/cpp/common/framing/src/AMQHeaderBody.cpp Tue Sep 19 15:06:50 2006
@@ -0,0 +1,60 @@
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#include "AMQHeaderBody.h"
+#include "QpidError.h"
+#include "BasicHeaderProperties.h"
+
+qpid::framing::AMQHeaderBody::AMQHeaderBody(int classId) : weight(0), contentSize(0){
+ createProperties(classId);
+}
+
+qpid::framing::AMQHeaderBody::AMQHeaderBody() : properties(0), weight(0), contentSize(0){
+}
+
+qpid::framing::AMQHeaderBody::~AMQHeaderBody(){
+ delete properties;
+}
+
+u_int32_t qpid::framing::AMQHeaderBody::size() const{
+ return 12 + properties->size();
+}
+
+void qpid::framing::AMQHeaderBody::encode(Buffer& buffer) const {
+ buffer.putShort(properties->classId());
+ buffer.putShort(weight);
+ buffer.putLongLong(contentSize);
+ properties->encode(buffer);
+}
+
+void qpid::framing::AMQHeaderBody::decode(Buffer& buffer, u_int32_t size){
+ u_int16_t classId = buffer.getShort();
+ weight = buffer.getShort();
+ contentSize = buffer.getLongLong();
+ createProperties(classId);
+ properties->decode(buffer, size - 12);
+}
+
+void qpid::framing::AMQHeaderBody::createProperties(int classId){
+ switch(classId){
+ case BASIC:
+ properties = new qpid::framing::BasicHeaderProperties();
+ break;
+ default:
+ THROW_QPID_ERROR(FRAMING_ERROR, "Unknown header class");
+ }
+}
Propchange: incubator/qpid/trunk/qpid/cpp/common/framing/src/AMQHeaderBody.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/qpid/trunk/qpid/cpp/common/framing/src/AMQMethodBody.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/common/framing/src/AMQMethodBody.cpp?view=auto&rev=447994
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/common/framing/src/AMQMethodBody.cpp (added)
+++ incubator/qpid/trunk/qpid/cpp/common/framing/src/AMQMethodBody.cpp Tue Sep 19 15:06:50 2006
@@ -0,0 +1,43 @@
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#include "AMQMethodBody.h"
+#include "QpidError.h"
+
+void qpid::framing::AMQMethodBody::encode(Buffer& buffer) const{
+ buffer.putShort(amqpClassId());
+ buffer.putShort(amqpMethodId());
+ encodeContent(buffer);
+}
+
+void qpid::framing::AMQMethodBody::decode(Buffer& buffer, u_int32_t size){
+ decodeContent(buffer);
+}
+
+bool qpid::framing::AMQMethodBody::match(AMQMethodBody* other) const{
+ return other != 0 && other->amqpClassId() == amqpClassId() && other->amqpMethodId() == amqpMethodId();
+}
+
+void qpid::framing::AMQMethodBody::invoke(AMQP_ServerOperations& target, u_int16_t channel){
+ THROW_QPID_ERROR(PROTOCOL_ERROR, "Method not supported by AMQP Server.");
+}
+
+
+std::ostream& qpid::framing::operator<<(std::ostream& out, const AMQMethodBody& m){
+ m.print(out);
+ return out;
+}
Propchange: incubator/qpid/trunk/qpid/cpp/common/framing/src/AMQMethodBody.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/qpid/trunk/qpid/cpp/common/framing/src/BasicHeaderProperties.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/common/framing/src/BasicHeaderProperties.cpp?view=auto&rev=447994
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/common/framing/src/BasicHeaderProperties.cpp (added)
+++ incubator/qpid/trunk/qpid/cpp/common/framing/src/BasicHeaderProperties.cpp Tue Sep 19 15:06:50 2006
@@ -0,0 +1,102 @@
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#include "BasicHeaderProperties.h"
+
+//TODO: This could be easily generated from the spec
+
+qpid::framing::BasicHeaderProperties::BasicHeaderProperties() : deliveryMode(0), priority(0), timestamp(0){}
+qpid::framing::BasicHeaderProperties::~BasicHeaderProperties(){}
+
+u_int32_t qpid::framing::BasicHeaderProperties::size() const{
+ u_int32_t size = 2;//flags
+ if(contentType.length() > 0) size += contentType.length() + 1;
+ if(contentEncoding.length() > 0) size += contentEncoding.length() + 1;
+ if(headers.count() > 0) size += headers.size();
+ if(deliveryMode != 0) size += 1;
+ if(priority != 0) size += 1;
+ if(correlationId.length() > 0) size += correlationId.length() + 1;
+ if(replyTo.length() > 0) size += replyTo.length() + 1;
+ if(expiration.length() > 0) size += expiration.length() + 1;
+ if(messageId.length() > 0) size += messageId.length() + 1;
+ if(timestamp != 0) size += 8;
+ if(type.length() > 0) size += type.length() + 1;
+ if(userId.length() > 0) size += userId.length() + 1;
+ if(appId.length() > 0) size += appId.length() + 1;
+ if(clusterId.length() > 0) size += clusterId.length() + 1;
+
+ return size;
+}
+
+void qpid::framing::BasicHeaderProperties::encode(qpid::framing::Buffer& buffer) const{
+ u_int16_t flags = getFlags();
+ buffer.putShort(flags);
+
+ if(contentType.length() > 0) buffer.putShortString(contentType);
+ if(contentEncoding.length() > 0) buffer.putShortString(contentEncoding);
+ if(headers.count() > 0) buffer.putFieldTable(headers);
+ if(deliveryMode != 0) buffer.putOctet(deliveryMode);
+ if(priority != 0) buffer.putOctet(priority);
+ if(correlationId.length() > 0) buffer.putShortString(correlationId);
+ if(replyTo.length() > 0) buffer.putShortString(replyTo);
+ if(expiration.length() > 0) buffer.putShortString(expiration);
+ if(messageId.length() > 0) buffer.putShortString(messageId);
+ if(timestamp != 0) buffer.putLongLong(timestamp);;
+ if(type.length() > 0) buffer.putShortString(type);
+ if(userId.length() > 0) buffer.putShortString(userId);
+ if(appId.length() > 0) buffer.putShortString(appId);
+ if(clusterId.length() > 0) buffer.putShortString(clusterId);
+}
+
+void qpid::framing::BasicHeaderProperties::decode(qpid::framing::Buffer& buffer, u_int32_t size){
+ u_int16_t flags = buffer.getShort();
+ int shift = 15;
+ if(flags & (1 << 15)) buffer.getShortString(contentType);
+ if(flags & (1 << 14)) buffer.getShortString(contentEncoding);
+ if(flags & (1 << 13)) buffer.getFieldTable(headers);
+ if(flags & (1 << 12)) deliveryMode = buffer.getOctet();
+ if(flags & (1 << 11)) priority = buffer.getOctet();
+ if(flags & (1 << 10)) buffer.getShortString(correlationId);
+ if(flags & (1 << 9)) buffer.getShortString(replyTo);
+ if(flags & (1 << 8)) buffer.getShortString(expiration);
+ if(flags & (1 << 7)) buffer.getShortString(messageId);
+ if(flags & (1 << 6)) timestamp = buffer.getLongLong();
+ if(flags & (1 << 5)) buffer.getShortString(type);
+ if(flags & (1 << 4)) buffer.getShortString(userId);
+ if(flags & (1 << 3)) buffer.getShortString(appId);
+ if(flags & (1 << 2)) buffer.getShortString(clusterId);
+}
+
+u_int16_t qpid::framing::BasicHeaderProperties::getFlags() const{
+ u_int16_t flags(0);
+ int shift = 15;
+ if(contentType.length() > 0) flags |= (1 << 15);
+ if(contentEncoding.length() > 0) flags |= (1 << 14);
+ if(headers.count() > 0) flags |= (1 << 13);
+ if(deliveryMode != 0) flags |= (1 << 12);
+ if(priority != 0) flags |= (1 << 11);
+ if(correlationId.length() > 0) flags |= (1 << 10);
+ if(replyTo.length() > 0) flags |= (1 << 9);
+ if(expiration.length() > 0) flags |= (1 << 8);
+ if(messageId.length() > 0) flags |= (1 << 7);
+ if(timestamp != 0) flags |= (1 << 6);
+ if(type.length() > 0) flags |= (1 << 5);
+ if(userId.length() > 0) flags |= (1 << 4);
+ if(appId.length() > 0) flags |= (1 << 3);
+ if(clusterId.length() > 0) flags |= (1 << 2);
+ return flags;
+}
Propchange: incubator/qpid/trunk/qpid/cpp/common/framing/src/BasicHeaderProperties.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/qpid/trunk/qpid/cpp/common/framing/src/BodyHandler.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/common/framing/src/BodyHandler.cpp?view=auto&rev=447994
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/common/framing/src/BodyHandler.cpp (added)
+++ incubator/qpid/trunk/qpid/cpp/common/framing/src/BodyHandler.cpp Tue Sep 19 15:06:50 2006
@@ -0,0 +1,49 @@
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * Licensed 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 "memory.h"
+#include "BodyHandler.h"
+
+using namespace qpid::framing;
+using namespace std::tr1;
+
+void BodyHandler::handleBody(AMQBody::shared_ptr& body){
+
+ switch(body->type())
+ {
+
+ case METHOD_BODY:
+ handleMethod(dynamic_pointer_cast<AMQMethodBody, AMQBody>(body));
+ break;
+
+ case HEADER_BODY:
+ handleHeader(dynamic_pointer_cast<AMQHeaderBody, AMQBody>(body));
+ break;
+
+ case CONTENT_BODY:
+ handleContent(dynamic_pointer_cast<AMQContentBody, AMQBody>(body));
+ break;
+
+ case HEARTBEAT_BODY:
+ handleHeartbeat(dynamic_pointer_cast<AMQHeartbeatBody, AMQBody>(body));
+ break;
+
+ default:
+ throw UnknownBodyType(body->type());
+ }
+
+}
Propchange: incubator/qpid/trunk/qpid/cpp/common/framing/src/BodyHandler.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/qpid/trunk/qpid/cpp/common/framing/src/Buffer.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/common/framing/src/Buffer.cpp?view=auto&rev=447994
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/common/framing/src/Buffer.cpp (added)
+++ incubator/qpid/trunk/qpid/cpp/common/framing/src/Buffer.cpp Tue Sep 19 15:06:50 2006
@@ -0,0 +1,167 @@
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#include "Buffer.h"
+
+qpid::framing::Buffer::Buffer(int _size) : size(_size), position(0), limit(_size){
+ data = new char[size];
+}
+
+qpid::framing::Buffer::~Buffer(){
+ delete[] data;
+}
+
+void qpid::framing::Buffer::flip(){
+ limit = position;
+ position = 0;
+}
+
+void qpid::framing::Buffer::clear(){
+ limit = size;
+ position = 0;
+}
+
+void qpid::framing::Buffer::compact(){
+ int p = limit - position;
+ //copy p chars from position to 0
+ memmove(data, data + position, p);
+ limit = size;
+ position = p;
+}
+
+void qpid::framing::Buffer::record(){
+ r_position = position;
+ r_limit = limit;
+}
+
+void qpid::framing::Buffer::restore(){
+ position = r_position;
+ limit = r_limit;
+}
+
+int qpid::framing::Buffer::available(){
+ return limit - position;
+}
+
+char* qpid::framing::Buffer::start(){
+ return data + position;
+}
+
+void qpid::framing::Buffer::move(int bytes){
+ position += bytes;
+}
+
+void qpid::framing::Buffer::putOctet(u_int8_t i){
+ data[position++] = i;
+}
+
+void qpid::framing::Buffer::putShort(u_int16_t i){
+ u_int16_t b = i;
+ data[position++] = (u_int8_t) (0xFF & (b >> 8));
+ data[position++] = (u_int8_t) (0xFF & b);
+}
+
+void qpid::framing::Buffer::putLong(u_int32_t i){
+ u_int32_t b = i;
+ data[position++] = (u_int8_t) (0xFF & (b >> 24));
+ data[position++] = (u_int8_t) (0xFF & (b >> 16));
+ data[position++] = (u_int8_t) (0xFF & (b >> 8));
+ data[position++] = (u_int8_t) (0xFF & b);
+}
+
+void qpid::framing::Buffer::putLongLong(u_int64_t i){
+ u_int32_t hi = i >> 32;
+ u_int32_t lo = i;
+ putLong(hi);
+ putLong(lo);
+}
+
+u_int8_t qpid::framing::Buffer::getOctet(){
+ return (u_int8_t) data[position++];
+}
+
+u_int16_t qpid::framing::Buffer::getShort(){
+ u_int16_t hi = (unsigned char) data[position++];
+ hi = hi << 8;
+ hi |= (unsigned char) data[position++];
+ return hi;
+}
+
+u_int32_t qpid::framing::Buffer::getLong(){
+ u_int32_t a = (unsigned char) data[position++];
+ u_int32_t b = (unsigned char) data[position++];
+ u_int32_t c = (unsigned char) data[position++];
+ u_int32_t d = (unsigned char) data[position++];
+ a = a << 24;
+ a |= b << 16;
+ a |= c << 8;
+ a |= d;
+ return a;
+}
+
+u_int64_t qpid::framing::Buffer::getLongLong(){
+ u_int64_t hi = getLong();
+ u_int64_t lo = getLong();
+ hi = hi << 32;
+ return hi | lo;
+}
+
+
+void qpid::framing::Buffer::putShortString(const string& s){
+ u_int8_t size = s.length();
+ putOctet(size);
+ s.copy(data + position, size);
+ position += size;
+}
+
+void qpid::framing::Buffer::putLongString(const string& s){
+ u_int32_t size = s.length();
+ putLong(size);
+ s.copy(data + position, size);
+ position += size;
+}
+
+void qpid::framing::Buffer::getShortString(string& s){
+ u_int8_t size = getOctet();
+ s.assign(data + position, size);
+ position += size;
+}
+
+void qpid::framing::Buffer::getLongString(string& s){
+ u_int32_t size = getLong();
+ s.assign(data + position, size);
+ position += size;
+}
+
+void qpid::framing::Buffer::putFieldTable(const FieldTable& t){
+ t.encode(*this);
+}
+
+void qpid::framing::Buffer::getFieldTable(FieldTable& t){
+ t.decode(*this);
+}
+
+void qpid::framing::Buffer::putRawData(const string& s){
+ u_int32_t size = s.length();
+ s.copy(data + position, size);
+ position += size;
+}
+
+void qpid::framing::Buffer::getRawData(string& s, u_int32_t size){
+ s.assign(data + position, size);
+ position += size;
+}
Propchange: incubator/qpid/trunk/qpid/cpp/common/framing/src/Buffer.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/qpid/trunk/qpid/cpp/common/framing/src/FieldTable.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/common/framing/src/FieldTable.cpp?view=auto&rev=447994
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/common/framing/src/FieldTable.cpp (added)
+++ incubator/qpid/trunk/qpid/cpp/common/framing/src/FieldTable.cpp Tue Sep 19 15:06:50 2006
@@ -0,0 +1,127 @@
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#include "FieldTable.h"
+#include "NamedValue.h"
+#include "QpidError.h"
+#include "Buffer.h"
+#include "Value.h"
+
+qpid::framing::FieldTable::~FieldTable(){
+ int count(values.size());
+ for(int i = 0; i < count; i++){
+ delete values[i];
+ }
+}
+
+u_int32_t qpid::framing::FieldTable::size() const {
+ u_int32_t size(4);
+ int count(values.size());
+ for(int i = 0; i < count; i++){
+ size += values[i]->size();
+ }
+ return size;
+}
+
+int qpid::framing::FieldTable::count() const {
+ return values.size();
+}
+
+std::ostream& qpid::framing::operator<<(std::ostream& out, const FieldTable& t){
+ out << "field_table{}";
+ return out;
+}
+
+void qpid::framing::FieldTable::setString(const std::string& name, const std::string& value){
+ setValue(name, new StringValue(value));
+}
+
+void qpid::framing::FieldTable::setInt(const std::string& name, int value){
+ setValue(name, new IntegerValue(value));
+}
+
+void qpid::framing::FieldTable::setTimestamp(const std::string& name, u_int64_t value){
+ setValue(name, new TimeValue(value));
+}
+
+void qpid::framing::FieldTable::setTable(const std::string& name, const FieldTable& value){
+ setValue(name, new FieldTableValue(value));
+}
+
+std::string qpid::framing::FieldTable::getString(const std::string& name){
+ StringValue* val = dynamic_cast<StringValue*>(getValue(name));
+ return (val == 0 ? "" : val->getValue());
+}
+
+int qpid::framing::FieldTable::getInt(const std::string& name){
+ IntegerValue* val = dynamic_cast<IntegerValue*>(getValue(name));
+ return (val == 0 ? 0 : val->getValue());
+}
+
+u_int64_t qpid::framing::FieldTable::getTimestamp(const std::string& name){
+ TimeValue* val = dynamic_cast<TimeValue*>(getValue(name));
+ return (val == 0 ? 0 : val->getValue());
+}
+
+void qpid::framing::FieldTable::getTable(const std::string& name, FieldTable& value){
+ FieldTableValue* val = dynamic_cast<FieldTableValue*>(getValue(name));
+ if(val != 0) value = val->getValue();
+}
+
+qpid::framing::NamedValue* qpid::framing::FieldTable::find(const std::string& name) const{
+ int count(values.size());
+ for(int i = 0; i < count; i++){
+ if(values[i]->getName() == name) return values[i];
+ }
+ return 0;
+}
+
+qpid::framing::Value* qpid::framing::FieldTable::getValue(const std::string& name) const{
+ NamedValue* val = find(name);
+ return val == 0 ? 0 : val->getValue();
+}
+
+void qpid::framing::FieldTable::setValue(const std::string& name, Value* value){
+ NamedValue* val = find(name);
+ if(val == 0){
+ val = new NamedValue(name, value);
+ values.push_back(val);
+ }else{
+ Value* old = val->getValue();
+ if(old != 0) delete old;
+ val->setValue(value);
+ }
+}
+
+void qpid::framing::FieldTable::encode(Buffer& buffer) const{
+ buffer.putLong(size() - 4);
+ int count(values.size());
+ for(int i = 0; i < count; i++){
+ values[i]->encode(buffer);
+ }
+}
+
+void qpid::framing::FieldTable::decode(Buffer& buffer){
+ u_int32_t size = buffer.getLong();
+ int leftover = buffer.available() - size;
+
+ while(buffer.available() > leftover){
+ NamedValue* value = new NamedValue();
+ value->decode(buffer);
+ values.push_back(value);
+ }
+}
Propchange: incubator/qpid/trunk/qpid/cpp/common/framing/src/FieldTable.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/qpid/trunk/qpid/cpp/common/framing/src/NamedValue.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/common/framing/src/NamedValue.cpp?view=auto&rev=447994
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/common/framing/src/NamedValue.cpp (added)
+++ incubator/qpid/trunk/qpid/cpp/common/framing/src/NamedValue.cpp Tue Sep 19 15:06:50 2006
@@ -0,0 +1,67 @@
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * Licensed 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 "NamedValue.h"
+#include "QpidError.h"
+#include "Buffer.h"
+#include "FieldTable.h"
+
+qpid::framing::NamedValue::NamedValue() : value(0){}
+
+qpid::framing::NamedValue::NamedValue(const string& n, Value* v) : name(n), value(v){}
+
+qpid::framing::NamedValue::~NamedValue(){
+ if(value != 0){
+ delete value;
+ }
+}
+
+u_int32_t qpid::framing::NamedValue::size() const{
+ return value ? 1/*size of name*/ + name.length() + 1/*type char*/ + value->size() : 0;
+}
+
+void qpid::framing::NamedValue::encode(Buffer& buffer){
+ buffer.putShortString(name);
+ u_int8_t type = value->getType();
+ buffer.putOctet(type);
+ value->encode(buffer);
+}
+
+void qpid::framing::NamedValue::decode(Buffer& buffer){
+ buffer.getShortString(name);
+ u_int8_t type = buffer.getOctet();
+ switch(type){
+ case 'S':
+ value = new StringValue();
+ break;
+ case 'I':
+ value = new IntegerValue();
+ break;
+ case 'D':
+ value = new DecimalValue();
+ break;
+ case 'T':
+ value = new TimeValue();
+ break;
+ case 'F':
+ value = new FieldTableValue();
+ break;
+ default:
+ THROW_QPID_ERROR(FRAMING_ERROR, "Unknown field table value type");
+ }
+ value->decode(buffer);
+}
Propchange: incubator/qpid/trunk/qpid/cpp/common/framing/src/NamedValue.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/qpid/trunk/qpid/cpp/common/framing/src/ProtocolInitiation.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/common/framing/src/ProtocolInitiation.cpp?view=auto&rev=447994
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/common/framing/src/ProtocolInitiation.cpp (added)
+++ incubator/qpid/trunk/qpid/cpp/common/framing/src/ProtocolInitiation.cpp Tue Sep 19 15:06:50 2006
@@ -0,0 +1,53 @@
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#include "ProtocolInitiation.h"
+
+qpid::framing::ProtocolInitiation::ProtocolInitiation(){}
+
+qpid::framing::ProtocolInitiation::ProtocolInitiation(u_int8_t _major, u_int8_t _minor) : pmajor(_major), pminor(_minor){}
+
+qpid::framing::ProtocolInitiation::~ProtocolInitiation(){}
+
+void qpid::framing::ProtocolInitiation::encode(Buffer& buffer){
+ buffer.putOctet('A');
+ buffer.putOctet('M');
+ buffer.putOctet('Q');
+ buffer.putOctet('P');
+ buffer.putOctet(1);//class
+ buffer.putOctet(1);//instance
+ buffer.putOctet(pmajor);
+ buffer.putOctet(pminor);
+}
+
+bool qpid::framing::ProtocolInitiation::decode(Buffer& buffer){
+ if(buffer.available() >= 8){
+ buffer.getOctet();//A
+ buffer.getOctet();//M
+ buffer.getOctet();//Q
+ buffer.getOctet();//P
+ buffer.getOctet();//class
+ buffer.getOctet();//instance
+ pmajor = buffer.getOctet();
+ pminor = buffer.getOctet();
+ return true;
+ }else{
+ return false;
+ }
+}
+
+//TODO: this should prbably be generated from the spec at some point to keep the version numbers up to date
Propchange: incubator/qpid/trunk/qpid/cpp/common/framing/src/ProtocolInitiation.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/qpid/trunk/qpid/cpp/common/framing/src/Value.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/common/framing/src/Value.cpp?view=auto&rev=447994
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/common/framing/src/Value.cpp (added)
+++ incubator/qpid/trunk/qpid/cpp/common/framing/src/Value.cpp Tue Sep 19 15:06:50 2006
@@ -0,0 +1,57 @@
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#include "Value.h"
+#include "Buffer.h"
+#include "FieldTable.h"
+
+void qpid::framing::StringValue::encode(Buffer& buffer){
+ buffer.putLongString(value);
+}
+void qpid::framing::StringValue::decode(Buffer& buffer){
+ buffer.getLongString(value);
+}
+
+void qpid::framing::IntegerValue::encode(Buffer& buffer){
+ buffer.putLong((u_int32_t) value);
+}
+void qpid::framing::IntegerValue::decode(Buffer& buffer){
+ value = buffer.getLong();
+}
+
+void qpid::framing::TimeValue::encode(Buffer& buffer){
+ buffer.putLongLong(value);
+}
+void qpid::framing::TimeValue::decode(Buffer& buffer){
+ value = buffer.getLongLong();
+}
+
+void qpid::framing::DecimalValue::encode(Buffer& buffer){
+ buffer.putOctet(decimals);
+ buffer.putLong(value);
+}
+void qpid::framing::DecimalValue::decode(Buffer& buffer){
+ decimals = buffer.getOctet();
+ value = buffer.getLong();
+}
+
+void qpid::framing::FieldTableValue::encode(Buffer& buffer){
+ buffer.putFieldTable(value);
+}
+void qpid::framing::FieldTableValue::decode(Buffer& buffer){
+ buffer.getFieldTable(value);
+}
Propchange: incubator/qpid/trunk/qpid/cpp/common/framing/src/Value.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/qpid/trunk/qpid/cpp/common/framing/test/BodyHandlerTest.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/common/framing/test/BodyHandlerTest.cpp?view=auto&rev=447994
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/common/framing/test/BodyHandlerTest.cpp (added)
+++ incubator/qpid/trunk/qpid/cpp/common/framing/test/BodyHandlerTest.cpp Tue Sep 19 15:06:50 2006
@@ -0,0 +1,107 @@
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#include <iostream>
+#include "amqp_framing.h"
+#include <cppunit/TestCase.h>
+#include <cppunit/TextTestRunner.h>
+#include <cppunit/extensions/HelperMacros.h>
+#include <cppunit/plugin/TestPlugIn.h>
+
+using namespace qpid::framing;
+
+class BodyHandlerTest : public CppUnit::TestCase
+{
+ CPPUNIT_TEST_SUITE(BodyHandlerTest);
+ CPPUNIT_TEST(testMethod);
+ CPPUNIT_TEST(testHeader);
+ CPPUNIT_TEST(testContent);
+ CPPUNIT_TEST(testHeartbeat);
+ CPPUNIT_TEST_SUITE_END();
+private:
+
+ class TestBodyHandler : public BodyHandler{
+ AMQMethodBody* const method;
+ AMQHeaderBody* const header;
+ AMQContentBody* const content;
+ AMQHeartbeatBody* const heartbeat;
+
+ public:
+
+ TestBodyHandler(AMQMethodBody* _method) : method(_method), header(0), content(0), heartbeat(0){}
+ TestBodyHandler(AMQHeaderBody* _header) : method(0), header(_header), content(0), heartbeat(0){}
+ TestBodyHandler(AMQContentBody* _content) : method(0), header(0), content(_content), heartbeat(0){}
+ TestBodyHandler(AMQHeartbeatBody* _heartbeat) : method(0), header(0), content(0), heartbeat(_heartbeat){}
+
+ virtual void handleMethod(AMQMethodBody::shared_ptr body){
+ CPPUNIT_ASSERT(method);
+ CPPUNIT_ASSERT_EQUAL(method, body.get());
+ }
+ virtual void handleHeader(AMQHeaderBody::shared_ptr body){
+ CPPUNIT_ASSERT(header);
+ CPPUNIT_ASSERT_EQUAL(header, body.get());
+ }
+ virtual void handleContent(AMQContentBody::shared_ptr body){
+ CPPUNIT_ASSERT(content);
+ CPPUNIT_ASSERT_EQUAL(content, body.get());
+ }
+ virtual void handleHeartbeat(AMQHeartbeatBody::shared_ptr body){
+ CPPUNIT_ASSERT(heartbeat);
+ CPPUNIT_ASSERT_EQUAL(heartbeat, body.get());
+ }
+ };
+
+public:
+
+ void testMethod()
+ {
+ AMQMethodBody* method = new QueueDeclareBody();
+ AMQFrame frame(0, method);
+ TestBodyHandler handler(method);
+ handler.handleBody(frame.getBody());
+ }
+
+ void testHeader()
+ {
+ AMQHeaderBody* header = new AMQHeaderBody();
+ AMQFrame frame(0, header);
+ TestBodyHandler handler(header);
+ handler.handleBody(frame.getBody());
+ }
+
+ void testContent()
+ {
+ AMQContentBody* content = new AMQContentBody();
+ AMQFrame frame(0, content);
+ TestBodyHandler handler(content);
+ handler.handleBody(frame.getBody());
+ }
+
+ void testHeartbeat()
+ {
+ AMQHeartbeatBody* heartbeat = new AMQHeartbeatBody();
+ AMQFrame frame(0, heartbeat);
+ TestBodyHandler handler(heartbeat);
+ handler.handleBody(frame.getBody());
+ }
+};
+
+
+// Make this test suite a plugin.
+CPPUNIT_PLUGIN_IMPLEMENT();
+CPPUNIT_TEST_SUITE_REGISTRATION(BodyHandlerTest);
+
Propchange: incubator/qpid/trunk/qpid/cpp/common/framing/test/BodyHandlerTest.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/qpid/trunk/qpid/cpp/common/framing/test/Makefile
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/common/framing/test/Makefile?view=auto&rev=447994
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/common/framing/test/Makefile (added)
+++ incubator/qpid/trunk/qpid/cpp/common/framing/test/Makefile Tue Sep 19 15:06:50 2006
@@ -0,0 +1,21 @@
+#
+# Copyright (c) 2006 The Apache Software Foundation
+#
+# Licensed 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.
+#
+
+QPID_HOME = ../../../..
+LDLIBS=-lapr-1 -lcppunit $(COMMON_LIB)
+INCLUDES=$(TEST_INCLUDES) -I ../generated
+include ${QPID_HOME}/cpp/test_plugins.mk
+
Propchange: incubator/qpid/trunk/qpid/cpp/common/framing/test/Makefile
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/qpid/trunk/qpid/cpp/common/framing/test/field_table_test.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/common/framing/test/field_table_test.cpp?view=auto&rev=447994
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/common/framing/test/field_table_test.cpp (added)
+++ incubator/qpid/trunk/qpid/cpp/common/framing/test/field_table_test.cpp Tue Sep 19 15:06:50 2006
@@ -0,0 +1,55 @@
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#include <iostream>
+#include "amqp_framing.h"
+#include <cppunit/TestCase.h>
+#include <cppunit/TextTestRunner.h>
+#include <cppunit/extensions/HelperMacros.h>
+#include <cppunit/plugin/TestPlugIn.h>
+
+using namespace qpid::framing;
+
+class FieldTableTest : public CppUnit::TestCase
+{
+ CPPUNIT_TEST_SUITE(FieldTableTest);
+ CPPUNIT_TEST(testMe);
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+
+ void testMe()
+ {
+ FieldTable ft;
+ ft.setString("A", "BCDE");
+ CPPUNIT_ASSERT_EQUAL(std::string("BCDE"), ft.getString("A"));
+
+ Buffer buffer(100);
+ buffer.putFieldTable(ft);
+ buffer.flip();
+ FieldTable ft2;
+ buffer.getFieldTable(ft2);
+ CPPUNIT_ASSERT_EQUAL(std::string("BCDE"), ft2.getString("A"));
+
+ }
+};
+
+
+// Make this test suite a plugin.
+CPPUNIT_PLUGIN_IMPLEMENT();
+CPPUNIT_TEST_SUITE_REGISTRATION(FieldTableTest);
+
Propchange: incubator/qpid/trunk/qpid/cpp/common/framing/test/field_table_test.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/qpid/trunk/qpid/cpp/common/framing/test/framing_test.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/common/framing/test/framing_test.cpp?view=auto&rev=447994
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/common/framing/test/framing_test.cpp (added)
+++ incubator/qpid/trunk/qpid/cpp/common/framing/test/framing_test.cpp Tue Sep 19 15:06:50 2006
@@ -0,0 +1,147 @@
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#include "amqp_framing.h"
+#include "ConnectionRedirectBody.h"
+#include <iostream>
+#include <sstream>
+#include <cppunit/TestCase.h>
+#include <cppunit/TextTestRunner.h>
+#include <cppunit/extensions/HelperMacros.h>
+#include <cppunit/plugin/TestPlugIn.h>
+#include <typeinfo>
+
+using namespace qpid::framing;
+
+// TODO aconway 2006-09-12: Why do we need explicit qpid::framing:: below?
+
+template <class T>
+std::string tostring(const T& x)
+{
+ std::ostringstream out;
+ out << x;
+ return out.str();
+}
+
+class FramingTest : public CppUnit::TestCase
+{
+ CPPUNIT_TEST_SUITE(FramingTest);
+ CPPUNIT_TEST(testBasicQosBody);
+ CPPUNIT_TEST(testConnectionSecureBody);
+ CPPUNIT_TEST(testConnectionRedirectBody);
+ CPPUNIT_TEST(testAccessRequestBody);
+ CPPUNIT_TEST(testBasicConsumeBody);
+ CPPUNIT_TEST(ConnectionRedirectBody);
+ CPPUNIT_TEST(BasicConsumeOkBody);
+ CPPUNIT_TEST_SUITE_END();
+
+ private:
+ Buffer buffer;
+
+ public:
+
+ FramingTest() : buffer(100) {}
+
+ void testBasicQosBody()
+ {
+ BasicQosBody in(0xCAFEBABE, 0xABBA, true);
+ in.encodeContent(buffer);
+ buffer.flip();
+ BasicQosBody out;
+ out.decodeContent(buffer);
+ CPPUNIT_ASSERT_EQUAL(tostring(in), tostring(out));
+ }
+
+ void testConnectionSecureBody()
+ {
+ std::string s = "security credential";
+ ConnectionSecureBody in(s);
+ in.encodeContent(buffer);
+ buffer.flip();
+ ConnectionSecureBody out;
+ out.decodeContent(buffer);
+ CPPUNIT_ASSERT_EQUAL(tostring(in), tostring(out));
+ }
+
+ void testConnectionRedirectBody()
+ {
+ std::string a = "hostA";
+ std::string b = "hostB";
+ qpid::framing::ConnectionRedirectBody in(a, b);
+ in.encodeContent(buffer);
+ buffer.flip();
+ qpid::framing::ConnectionRedirectBody out;
+ out.decodeContent(buffer);
+ CPPUNIT_ASSERT_EQUAL(tostring(in), tostring(out));
+ }
+
+ void testAccessRequestBody()
+ {
+ std::string s = "text";
+ AccessRequestBody in(s, true, false, true, false, true);
+ in.encodeContent(buffer);
+ buffer.flip();
+ AccessRequestBody out;
+ out.decodeContent(buffer);
+ CPPUNIT_ASSERT_EQUAL(tostring(in), tostring(out));
+ }
+
+ void testBasicConsumeBody()
+ {
+ std::string q = "queue";
+ std::string t = "tag";
+ BasicConsumeBody in(0, q, t, false, true, false, false);
+ in.encodeContent(buffer);
+ buffer.flip();
+ BasicConsumeBody out;
+ out.decodeContent(buffer);
+ CPPUNIT_ASSERT_EQUAL(tostring(in), tostring(out));
+ }
+
+
+ void ConnectionRedirectBody()
+ {
+ std::string a = "hostA";
+ std::string b = "hostB";
+ AMQFrame in(999, new qpid::framing::ConnectionRedirectBody(a, b));
+ in.encode(buffer);
+ buffer.flip();
+ AMQFrame out;
+ out.decode(buffer);
+ CPPUNIT_ASSERT_EQUAL(tostring(in), tostring(out));
+ }
+
+ void BasicConsumeOkBody()
+ {
+ std::string s = "hostA";
+ AMQFrame in(999, new qpid::framing::BasicConsumeOkBody(s));
+ in.encode(buffer);
+ buffer.flip();
+ AMQFrame out;
+ for(int i = 0; i < 5; i++){
+ out.decode(buffer);
+ CPPUNIT_ASSERT_EQUAL(tostring(in), tostring(out));
+ }
+ }
+};
+
+// Make this test suite a plugin.
+CPPUNIT_PLUGIN_IMPLEMENT();
+CPPUNIT_TEST_SUITE_REGISTRATION(FramingTest);
+
+
+
Propchange: incubator/qpid/trunk/qpid/cpp/common/framing/test/framing_test.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/qpid/trunk/qpid/cpp/common/framing/test/header_test.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/common/framing/test/header_test.cpp?view=auto&rev=447994
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/common/framing/test/header_test.cpp (added)
+++ incubator/qpid/trunk/qpid/cpp/common/framing/test/header_test.cpp Tue Sep 19 15:06:50 2006
@@ -0,0 +1,144 @@
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#include <iostream>
+#include "amqp_framing.h"
+#include <cppunit/TestCase.h>
+#include <cppunit/TextTestRunner.h>
+#include <cppunit/extensions/HelperMacros.h>
+#include <cppunit/plugin/TestPlugIn.h>
+
+using namespace qpid::framing;
+
+class HeaderTest : public CppUnit::TestCase
+{
+ CPPUNIT_TEST_SUITE(HeaderTest);
+ CPPUNIT_TEST(testGenericProperties);
+ CPPUNIT_TEST(testAllSpecificProperties);
+ CPPUNIT_TEST(testSomeSpecificProperties);
+ CPPUNIT_TEST_SUITE_END();
+
+public:
+
+ // TODO aconway 2006-09-12: Need more detailed tests,
+ // need tests to assert something!
+ //
+ void testGenericProperties()
+ {
+ AMQHeaderBody body(BASIC);
+ dynamic_cast<BasicHeaderProperties*>(body.getProperties())->getHeaders().setString("A", "BCDE");
+ Buffer buffer(100);
+
+ body.encode(buffer);
+ buffer.flip();
+ AMQHeaderBody body2;
+ body2.decode(buffer, body.size());
+ BasicHeaderProperties* props =
+ dynamic_cast<BasicHeaderProperties*>(body2.getProperties());
+ CPPUNIT_ASSERT_EQUAL(std::string("BCDE"),
+ props->getHeaders().getString("A"));
+ }
+
+ void testAllSpecificProperties(){
+ string contentType("text/html");
+ string contentEncoding("UTF8");
+ u_int8_t deliveryMode(2);
+ u_int8_t priority(3);
+ string correlationId("abc");
+ string replyTo("no-address");
+ string expiration("why is this a string?");
+ string messageId("xyz");
+ u_int64_t timestamp(0xabcd);
+ string type("eh?");
+ string userId("guest");
+ string appId("just testing");
+ string clusterId("no clustering required");
+
+ AMQHeaderBody body(BASIC);
+ BasicHeaderProperties* properties =
+ dynamic_cast<BasicHeaderProperties*>(body.getProperties());
+ properties->setContentType(contentType);
+ properties->getHeaders().setString("A", "BCDE");
+ properties->setDeliveryMode(deliveryMode);
+ properties->setPriority(priority);
+ properties->setCorrelationId(correlationId);
+ properties->setReplyTo(replyTo);
+ properties->setExpiration(expiration);
+ properties->setMessageId(messageId);
+ properties->setTimestamp(timestamp);
+ properties->setType(type);
+ properties->setUserId(userId);
+ properties->setAppId(appId);
+ properties->setClusterId(clusterId);
+
+ Buffer buffer(10000);
+ body.encode(buffer);
+ buffer.flip();
+ AMQHeaderBody temp;
+ temp.decode(buffer, body.size());
+ properties = dynamic_cast<BasicHeaderProperties*>(temp.getProperties());
+
+ CPPUNIT_ASSERT_EQUAL(contentType, properties->getContentType());
+ CPPUNIT_ASSERT_EQUAL(std::string("BCDE"), properties->getHeaders().getString("A"));
+ CPPUNIT_ASSERT_EQUAL(deliveryMode, properties->getDeliveryMode());
+ CPPUNIT_ASSERT_EQUAL(priority, properties->getPriority());
+ CPPUNIT_ASSERT_EQUAL(correlationId, properties->getCorrelationId());
+ CPPUNIT_ASSERT_EQUAL(replyTo, properties->getReplyTo());
+ CPPUNIT_ASSERT_EQUAL(expiration, properties->getExpiration());
+ CPPUNIT_ASSERT_EQUAL(messageId, properties->getMessageId());
+ CPPUNIT_ASSERT_EQUAL(timestamp, properties->getTimestamp());
+ CPPUNIT_ASSERT_EQUAL(type, properties->getType());
+ CPPUNIT_ASSERT_EQUAL(userId, properties->getUserId());
+ CPPUNIT_ASSERT_EQUAL(appId, properties->getAppId());
+ CPPUNIT_ASSERT_EQUAL(clusterId, properties->getClusterId());
+ }
+
+ void testSomeSpecificProperties(){
+ string contentType("application/octet-stream");
+ u_int8_t deliveryMode(5);
+ u_int8_t priority(6);
+ string expiration("Z");
+ u_int64_t timestamp(0xabe4a34a);
+
+ AMQHeaderBody body(BASIC);
+ BasicHeaderProperties* properties =
+ dynamic_cast<BasicHeaderProperties*>(body.getProperties());
+ properties->setContentType(contentType);
+ properties->setDeliveryMode(deliveryMode);
+ properties->setPriority(priority);
+ properties->setExpiration(expiration);
+ properties->setTimestamp(timestamp);
+
+ Buffer buffer(100);
+ body.encode(buffer);
+ buffer.flip();
+ AMQHeaderBody temp;
+ temp.decode(buffer, body.size());
+ properties = dynamic_cast<BasicHeaderProperties*>(temp.getProperties());
+
+ CPPUNIT_ASSERT_EQUAL(contentType, properties->getContentType());
+ CPPUNIT_ASSERT_EQUAL((int) deliveryMode, (int) properties->getDeliveryMode());
+ CPPUNIT_ASSERT_EQUAL((int) priority, (int) properties->getPriority());
+ CPPUNIT_ASSERT_EQUAL(expiration, properties->getExpiration());
+ CPPUNIT_ASSERT_EQUAL(timestamp, properties->getTimestamp());
+ }
+};
+
+// Make this test suite a plugin.
+CPPUNIT_PLUGIN_IMPLEMENT();
+CPPUNIT_TEST_SUITE_REGISTRATION(HeaderTest);
+
Propchange: incubator/qpid/trunk/qpid/cpp/common/framing/test/header_test.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/qpid/trunk/qpid/cpp/common/io/Makefile
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/common/io/Makefile?view=auto&rev=447994
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/common/io/Makefile (added)
+++ incubator/qpid/trunk/qpid/cpp/common/io/Makefile Tue Sep 19 15:06:50 2006
@@ -0,0 +1,35 @@
+ #
+ # Copyright (c) 2006 The Apache Software Foundation
+ #
+ # Licensed 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.
+ #
+
+QPID_HOME = ../../..
+include ${QPID_HOME}/cpp/options.mk
+
+# Compiler flags
+CXXFLAGS = ${DEBUG} ${OPT} -MMD -I inc -I ../concurrent/inc -I ../error/inc -I ../framing/inc -I ../framing/generated -I ${APR_HOME}/include/apr-1/
+
+SOURCES := $(wildcard src/*.cpp)
+OBJECTS := $(subst .cpp,.o,$(SOURCES))
+DEPS := $(subst .cpp,.d,$(SOURCES))
+
+.PHONY: all clean
+
+all: ${OBJECTS}
+
+-include $(DEPS)
+
+clean :
+ -@rm -f ${OBJECTS} src/*.d
+
Propchange: incubator/qpid/trunk/qpid/cpp/common/io/Makefile
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/qpid/trunk/qpid/cpp/common/io/inc/APRConnector.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/common/io/inc/APRConnector.h?view=auto&rev=447994
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/common/io/inc/APRConnector.h (added)
+++ incubator/qpid/trunk/qpid/cpp/common/io/inc/APRConnector.h Tue Sep 19 15:06:50 2006
@@ -0,0 +1,95 @@
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * Licensed 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 _APRConnector_
+#define _APRConnector_
+
+#include "apr_network_io.h"
+#include "apr_time.h"
+
+#include "InputHandler.h"
+#include "OutputHandler.h"
+#include "InitiationHandler.h"
+#include "ProtocolInitiation.h"
+#include "ShutdownHandler.h"
+#include "Thread.h"
+#include "ThreadFactory.h"
+#include "Connector.h"
+#include "APRMonitor.h"
+
+namespace qpid {
+namespace io {
+
+ class APRConnector : public virtual qpid::framing::OutputHandler,
+ public virtual Connector,
+ private virtual qpid::concurrent::Runnable
+ {
+ const bool debug;
+ const int receive_buffer_size;
+ const int send_buffer_size;
+
+ bool closed;
+
+ apr_time_t lastIn;
+ apr_time_t lastOut;
+ apr_interval_time_t timeout;
+ u_int32_t idleIn;
+ u_int32_t idleOut;
+
+ TimeoutHandler* timeoutHandler;
+ ShutdownHandler* shutdownHandler;
+ qpid::framing::InputHandler* input;
+ qpid::framing::InitiationHandler* initialiser;
+ qpid::framing::OutputHandler* output;
+
+ qpid::framing::Buffer inbuf;
+ qpid::framing::Buffer outbuf;
+
+ qpid::concurrent::APRMonitor* writeLock;
+ qpid::concurrent::ThreadFactory* threadFactory;
+ qpid::concurrent::Thread* receiver;
+
+ apr_pool_t* pool;
+ apr_socket_t* socket;
+
+ void checkIdle(apr_status_t status);
+ void writeBlock(qpid::framing::AMQDataBlock* data);
+ void writeToSocket(char* data, int available);
+ void setSocketTimeout();
+
+ void run();
+
+ public:
+ APRConnector(bool debug = false, u_int32_t buffer_size = 1024);
+ virtual ~APRConnector();
+ virtual void connect(const std::string& host, int port);
+ virtual void init(qpid::framing::ProtocolInitiation* header);
+ virtual void close();
+ virtual void setInputHandler(qpid::framing::InputHandler* handler);
+ virtual void setTimeoutHandler(TimeoutHandler* handler);
+ virtual void setShutdownHandler(ShutdownHandler* handler);
+ virtual qpid::framing::OutputHandler* getOutputHandler();
+ virtual void send(qpid::framing::AMQFrame* frame);
+ virtual void setReadTimeout(u_int16_t timeout);
+ virtual void setWriteTimeout(u_int16_t timeout);
+ };
+
+}
+}
+
+
+#endif
Propchange: incubator/qpid/trunk/qpid/cpp/common/io/inc/APRConnector.h
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/qpid/trunk/qpid/cpp/common/io/inc/APRIOProcessor.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/common/io/inc/APRIOProcessor.h?view=auto&rev=447994
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/common/io/inc/APRIOProcessor.h (added)
+++ incubator/qpid/trunk/qpid/cpp/common/io/inc/APRIOProcessor.h Tue Sep 19 15:06:50 2006
@@ -0,0 +1,86 @@
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * Licensed 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 _APRIOProcessor_
+#define _APRIOProcessor_
+
+#include "apr_poll.h"
+#include <queue>
+#include <iostream>
+#include "APRMonitor.h"
+#include "APRThread.h"
+#include "IOSession.h"
+#include "Runnable.h"
+
+namespace qpid {
+namespace io {
+
+ /**
+ * Manages non-blocking io through the APR polling
+ * routines. Interacts with the actual io tasks to be performed
+ * through the IOSession interface, an implementing instance of
+ * which must be set as the client_data of the apr_pollfd_t
+ * structures registered.
+ */
+ class APRIOProcessor : private virtual qpid::concurrent::Runnable
+ {
+ const int size;
+ const apr_interval_time_t timeout;
+ apr_pollset_t* pollset;
+ int count;
+ qpid::concurrent::APRThread thread;
+ qpid::concurrent::APRMonitor lock;
+ volatile bool stopped;
+
+ void poll();
+ virtual void run();
+
+ public:
+ APRIOProcessor(apr_pool_t* pool, int size, int timeout);
+ /**
+ * Add the fd to the poll set. Relies on the client_data being
+ * an instance implementing IOSession, through which the write
+ * and read operations will be performed when readiness is
+ * indicated by the poll response.
+ */
+ void add(apr_pollfd_t* const fd);
+ /**
+ * Remove the fd from the poll set.
+ */
+ void remove(apr_pollfd_t* const fd);
+ /**
+ * Indicates whether the capacity of this processor has been
+ * reached (or whether it can still handle further fd's).
+ */
+ bool full();
+ /**
+ * Indicates whether there are any fd's registered.
+ */
+ bool empty();
+ /**
+ * Stop processing.
+ */
+ void stop();
+
+ ~APRIOProcessor();
+ };
+
+}
+}
+
+
+#endif
Propchange: incubator/qpid/trunk/qpid/cpp/common/io/inc/APRIOProcessor.h
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/qpid/trunk/qpid/cpp/common/io/inc/APRSocket.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/common/io/inc/APRSocket.h?view=auto&rev=447994
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/common/io/inc/APRSocket.h (added)
+++ incubator/qpid/trunk/qpid/cpp/common/io/inc/APRSocket.h Tue Sep 19 15:06:50 2006
@@ -0,0 +1,45 @@
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * Licensed 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 _APRSocket_
+#define _APRSocket_
+
+#include "apr_network_io.h"
+#include "Buffer.h"
+
+namespace qpid {
+namespace io {
+
+ class APRSocket
+ {
+ apr_socket_t* const socket;
+ volatile bool closed;
+ public:
+ APRSocket(apr_socket_t* socket);
+ void read(qpid::framing::Buffer& b);
+ void write(qpid::framing::Buffer& b);
+ void close();
+ bool isOpen();
+ u_int8_t read();
+ ~APRSocket();
+ };
+
+}
+}
+
+
+#endif
Propchange: incubator/qpid/trunk/qpid/cpp/common/io/inc/APRSocket.h
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/qpid/trunk/qpid/cpp/common/io/inc/Acceptor.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/common/io/inc/Acceptor.h?view=auto&rev=447994
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/common/io/inc/Acceptor.h (added)
+++ incubator/qpid/trunk/qpid/cpp/common/io/inc/Acceptor.h Tue Sep 19 15:06:50 2006
@@ -0,0 +1,38 @@
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * Licensed 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 _Acceptor_
+#define _Acceptor_
+
+#include "SessionHandlerFactory.h"
+
+
+namespace qpid {
+namespace io {
+
+ class Acceptor
+ {
+ public:
+ virtual void bind(int port, SessionHandlerFactory* factory) = 0;
+ virtual ~Acceptor(){}
+ };
+
+}
+}
+
+
+#endif
Propchange: incubator/qpid/trunk/qpid/cpp/common/io/inc/Acceptor.h
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/qpid/trunk/qpid/cpp/common/io/inc/BlockingAPRAcceptor.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/common/io/inc/BlockingAPRAcceptor.h?view=auto&rev=447994
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/common/io/inc/BlockingAPRAcceptor.h (added)
+++ incubator/qpid/trunk/qpid/cpp/common/io/inc/BlockingAPRAcceptor.h Tue Sep 19 15:06:50 2006
@@ -0,0 +1,62 @@
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * Licensed 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 _BlockingAPRAcceptor_
+#define _BlockingAPRAcceptor_
+
+#include <vector>
+#include "apr_network_io.h"
+#include "apr_poll.h"
+#include "apr_time.h"
+
+#include "Acceptor.h"
+#include "APRMonitor.h"
+#include "BlockingAPRSessionContext.h"
+#include "Runnable.h"
+#include "SessionContext.h"
+#include "SessionHandlerFactory.h"
+#include "Thread.h"
+#include "ThreadFactory.h"
+#include "ThreadPool.h"
+
+namespace qpid {
+namespace io {
+
+ class BlockingAPRAcceptor : public virtual Acceptor
+ {
+ typedef std::vector<BlockingAPRSessionContext*>::iterator iterator;
+
+ const bool debug;
+ apr_pool_t* apr_pool;
+ qpid::concurrent::ThreadFactory* threadFactory;
+ std::vector<BlockingAPRSessionContext*> sessions;
+ apr_socket_t* socket;
+ const int connectionBacklog;
+ volatile bool running;
+
+ public:
+ BlockingAPRAcceptor(bool debug = false, int connectionBacklog = 10);
+ virtual void bind(int port, SessionHandlerFactory* factory);
+ virtual ~BlockingAPRAcceptor();
+ void closed(BlockingAPRSessionContext* session);
+ };
+
+}
+}
+
+
+#endif
Propchange: incubator/qpid/trunk/qpid/cpp/common/io/inc/BlockingAPRAcceptor.h
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/qpid/trunk/qpid/cpp/common/io/inc/BlockingAPRSessionContext.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/common/io/inc/BlockingAPRSessionContext.h?view=auto&rev=447994
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/common/io/inc/BlockingAPRSessionContext.h (added)
+++ incubator/qpid/trunk/qpid/cpp/common/io/inc/BlockingAPRSessionContext.h Tue Sep 19 15:06:50 2006
@@ -0,0 +1,94 @@
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * Licensed 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 _BlockingAPRSessionContext_
+#define _BlockingAPRSessionContext_
+
+#include <queue>
+#include <vector>
+
+#include "apr_network_io.h"
+#include "apr_time.h"
+
+#include "AMQFrame.h"
+#include "APRMonitor.h"
+#include "Buffer.h"
+#include "Runnable.h"
+#include "SessionContext.h"
+#include "SessionHandler.h"
+#include "SessionHandlerFactory.h"
+#include "ShutdownHandler.h"
+#include "Thread.h"
+#include "ThreadFactory.h"
+
+namespace qpid {
+namespace io {
+
+ class BlockingAPRAcceptor;
+
+ class BlockingAPRSessionContext : public virtual SessionContext
+ {
+ class Reader : public virtual qpid::concurrent::Runnable{
+ BlockingAPRSessionContext* parent;
+ public:
+ inline Reader(BlockingAPRSessionContext* p) : parent(p){}
+ inline virtual void run(){ parent->read(); }
+ inline virtual ~Reader(){}
+ };
+
+ class Writer : public virtual qpid::concurrent::Runnable{
+ BlockingAPRSessionContext* parent;
+ public:
+ inline Writer(BlockingAPRSessionContext* p) : parent(p){}
+ inline virtual void run(){ parent->write(); }
+ inline virtual ~Writer(){}
+ };
+
+ apr_socket_t* socket;
+ const bool debug;
+ SessionHandler* handler;
+ BlockingAPRAcceptor* acceptor;
+ std::queue<qpid::framing::AMQFrame*> outframes;
+ qpid::framing::Buffer inbuf;
+ qpid::framing::Buffer outbuf;
+ qpid::concurrent::APRMonitor outlock;
+ Reader* reader;
+ Writer* writer;
+ qpid::concurrent::Thread* rThread;
+ qpid::concurrent::Thread* wThread;
+
+ volatile bool closed;
+
+ void read();
+ void write();
+ public:
+ BlockingAPRSessionContext(apr_socket_t* socket,
+ qpid::concurrent::ThreadFactory* factory,
+ BlockingAPRAcceptor* acceptor,
+ bool debug = false);
+ ~BlockingAPRSessionContext();
+ virtual void send(qpid::framing::AMQFrame* frame);
+ virtual void close();
+ void shutdown();
+ void init(SessionHandler* handler);
+ };
+
+}
+}
+
+
+#endif
Propchange: incubator/qpid/trunk/qpid/cpp/common/io/inc/BlockingAPRSessionContext.h
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/qpid/trunk/qpid/cpp/common/io/inc/Connector.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/common/io/inc/Connector.h?view=auto&rev=447994
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/common/io/inc/Connector.h (added)
+++ incubator/qpid/trunk/qpid/cpp/common/io/inc/Connector.h Tue Sep 19 15:06:50 2006
@@ -0,0 +1,56 @@
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * Licensed 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 _Connector_
+#define _Connector_
+
+#include "InputHandler.h"
+#include "OutputHandler.h"
+#include "InitiationHandler.h"
+#include "ProtocolInitiation.h"
+#include "ShutdownHandler.h"
+#include "TimeoutHandler.h"
+
+namespace qpid {
+namespace io {
+
+ class Connector
+ {
+ public:
+ virtual void connect(const std::string& host, int port) = 0;
+ virtual void init(qpid::framing::ProtocolInitiation* header) = 0;
+ virtual void close() = 0;
+ virtual void setInputHandler(qpid::framing::InputHandler* handler) = 0;
+ virtual void setTimeoutHandler(TimeoutHandler* handler) = 0;
+ virtual void setShutdownHandler(ShutdownHandler* handler) = 0;
+ virtual qpid::framing::OutputHandler* getOutputHandler() = 0;
+ /**
+ * Set the timeout for reads, in secs.
+ */
+ virtual void setReadTimeout(u_int16_t timeout) = 0;
+ /**
+ * Set the timeout for writes, in secs.
+ */
+ virtual void setWriteTimeout(u_int16_t timeout) = 0;
+ virtual ~Connector(){}
+ };
+
+}
+}
+
+
+#endif
Propchange: incubator/qpid/trunk/qpid/cpp/common/io/inc/Connector.h
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/qpid/trunk/qpid/cpp/common/io/inc/ConnectorImpl.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/common/io/inc/ConnectorImpl.h?view=auto&rev=447994
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/common/io/inc/ConnectorImpl.h (added)
+++ incubator/qpid/trunk/qpid/cpp/common/io/inc/ConnectorImpl.h Tue Sep 19 15:06:50 2006
@@ -0,0 +1,53 @@
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * Licensed 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 _APRConnectorImpl_
+#define _APRConnectorImpl_
+
+#ifdef _USE_APR_IO_
+#include "APRConnector.h"
+#else
+#include "LConnector.h"
+#endif
+
+namespace qpid {
+namespace io {
+
+#ifdef _USE_APR_IO_
+ class ConnectorImpl : public virtual APRConnector
+ {
+
+ public:
+ ConnectorImpl(bool debug = false, u_int32_t buffer_size = 1024):APRConnector(debug,buffer_size){};
+ virtual ~ConnectorImpl(){};
+ };
+#else
+ class ConnectorImpl : public virtual LConnector
+ {
+
+ public:
+ ConnectorImpl(bool debug = false, u_int32_t buffer_size = 1024):LConnector(debug, buffer_size){};
+ virtual ~ConnectorImpl(){};
+ };
+
+#endif
+
+}
+}
+
+
+#endif
Propchange: incubator/qpid/trunk/qpid/cpp/common/io/inc/ConnectorImpl.h
------------------------------------------------------------------------------
svn:eol-style = native