You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by kp...@apache.org on 2006/11/03 22:27:49 UTC
svn commit: r471002 - in /incubator/qpid/trunk/qpid/cpp/src/qpid/framing:
ProtocolInitiation.cpp ProtocolInitiation.h ProtocolVersion.cpp
ProtocolVersion.h ProtocolVersionException.cpp ProtocolVersionException.h
Author: kpvdr
Date: Fri Nov 3 13:27:48 2006
New Revision: 471002
URL: http://svn.apache.org/viewvc?view=rev&rev=471002
Log:
Added protocol version and version exception classes in preparation for multi-protocol generation.
Added:
incubator/qpid/trunk/qpid/cpp/src/qpid/framing/ProtocolVersion.cpp
incubator/qpid/trunk/qpid/cpp/src/qpid/framing/ProtocolVersion.h
incubator/qpid/trunk/qpid/cpp/src/qpid/framing/ProtocolVersionException.cpp
incubator/qpid/trunk/qpid/cpp/src/qpid/framing/ProtocolVersionException.h
Modified:
incubator/qpid/trunk/qpid/cpp/src/qpid/framing/ProtocolInitiation.cpp
incubator/qpid/trunk/qpid/cpp/src/qpid/framing/ProtocolInitiation.h
Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/framing/ProtocolInitiation.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/framing/ProtocolInitiation.cpp?view=diff&rev=471002&r1=471001&r2=471002
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/framing/ProtocolInitiation.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/framing/ProtocolInitiation.cpp Fri Nov 3 13:27:48 2006
@@ -19,7 +19,9 @@
qpid::framing::ProtocolInitiation::ProtocolInitiation(){}
-qpid::framing::ProtocolInitiation::ProtocolInitiation(u_int8_t _major, u_int8_t _minor) : pmajor(_major), pminor(_minor){}
+qpid::framing::ProtocolInitiation::ProtocolInitiation(u_int8_t _major, u_int8_t _minor) : version(_major, _minor) {}
+
+qpid::framing::ProtocolInitiation::ProtocolInitiation(const qpid::framing::ProtocolVersion& p) : version(p) {}
qpid::framing::ProtocolInitiation::~ProtocolInitiation(){}
@@ -30,8 +32,8 @@
buffer.putOctet('P');
buffer.putOctet(1);//class
buffer.putOctet(1);//instance
- buffer.putOctet(pmajor);
- buffer.putOctet(pminor);
+ buffer.putOctet(version.major_);
+ buffer.putOctet(version.minor_);
}
bool qpid::framing::ProtocolInitiation::decode(Buffer& buffer){
@@ -42,8 +44,8 @@
buffer.getOctet();//P
buffer.getOctet();//class
buffer.getOctet();//instance
- pmajor = buffer.getOctet();
- pminor = buffer.getOctet();
+ version.major_ = buffer.getOctet();
+ version.minor_ = buffer.getOctet();
return true;
}else{
return false;
Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/framing/ProtocolInitiation.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/framing/ProtocolInitiation.h?view=diff&rev=471002&r1=471001&r2=471002
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/framing/ProtocolInitiation.h (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/framing/ProtocolInitiation.h Fri Nov 3 13:27:48 2006
@@ -18,6 +18,7 @@
#include "qpid/framing/amqp_types.h"
#include "qpid/framing/Buffer.h"
#include "qpid/framing/AMQDataBlock.h"
+#include "qpid/framing/ProtocolVersion.h"
#ifndef _ProtocolInitiation_
#define _ProtocolInitiation_
@@ -27,18 +28,20 @@
class ProtocolInitiation : virtual public AMQDataBlock
{
- u_int8_t pmajor;
- u_int8_t pminor;
-
+private:
+ ProtocolVersion version;
+
public:
ProtocolInitiation();
ProtocolInitiation(u_int8_t major, u_int8_t minor);
+ ProtocolInitiation(const ProtocolVersion& p);
virtual ~ProtocolInitiation();
virtual void encode(Buffer& buffer);
virtual bool decode(Buffer& buffer);
inline virtual u_int32_t size() const { return 8; }
- inline u_int8_t getMajor(){ return pmajor; }
- inline u_int8_t getMinor(){ return pminor; }
+ inline u_int8_t getMajor(){ return version.major_; }
+ inline u_int8_t getMinor(){ return version.minor_; }
+ inline const ProtocolVersion& getVersion() const { return version; }
};
}
Added: incubator/qpid/trunk/qpid/cpp/src/qpid/framing/ProtocolVersion.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/framing/ProtocolVersion.cpp?view=auto&rev=471002
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/framing/ProtocolVersion.cpp (added)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/framing/ProtocolVersion.cpp Fri Nov 3 13:27:48 2006
@@ -0,0 +1,61 @@
+/*
+ *
+ * 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 "qpid/framing/ProtocolVersion.h"
+#include <sstream>
+
+using namespace qpid::framing;
+
+ProtocolVersion::ProtocolVersion() {}
+
+ProtocolVersion::ProtocolVersion(u_int8_t _major, u_int8_t _minor) :
+ major_(_major),
+ minor_(_minor)
+{}
+
+ProtocolVersion::ProtocolVersion(const ProtocolVersion::ProtocolVersion& p):
+ major_(p.major_),
+ minor_(p.minor_)
+{}
+
+ProtocolVersion::~ProtocolVersion()
+{}
+
+bool ProtocolVersion::equals(u_int8_t _major, u_int8_t _minor) const
+{
+ return major_ == _major && minor_ == _minor;
+}
+
+bool ProtocolVersion::equals(const ProtocolVersion::ProtocolVersion& p) const
+{
+ return major_ == p.major_ && minor_ == p.minor_;
+}
+
+const std::string ProtocolVersion::toString() const
+{
+ std::stringstream ss;
+ ss << major_ << "-" << minor_;
+ return ss.str();
+}
+
+ProtocolVersion::ProtocolVersion ProtocolVersion::operator=(const ProtocolVersion& p)
+{
+ major_ = p.major_;
+ minor_ = p.minor_;
+ return *this;
+}
+
Added: incubator/qpid/trunk/qpid/cpp/src/qpid/framing/ProtocolVersion.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/framing/ProtocolVersion.h?view=auto&rev=471002
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/framing/ProtocolVersion.h (added)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/framing/ProtocolVersion.h Fri Nov 3 13:27:48 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.
+ *
+ */
+#ifndef _ProtocolVersion_
+#define _ProtocolVersion_
+
+#include "qpid/framing/amqp_types.h"
+
+namespace qpid
+{
+namespace framing
+{
+
+class ProtocolVersion
+{
+public:
+ u_int8_t major_;
+ u_int8_t minor_;
+
+ ProtocolVersion();
+ ProtocolVersion(u_int8_t _major, u_int8_t _minor);
+ ProtocolVersion(const ProtocolVersion& p);
+ virtual ~ProtocolVersion();
+
+ virtual bool equals(u_int8_t _major, u_int8_t _minor) const;
+ virtual bool equals(const ProtocolVersion& p) const;
+ virtual const std::string toString() const;
+ ProtocolVersion operator=(const ProtocolVersion& p);
+};
+
+} // namespace framing
+} // namespace qpid
+
+
+#endif // ifndef _ProtocolVersion_
Added: incubator/qpid/trunk/qpid/cpp/src/qpid/framing/ProtocolVersionException.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/framing/ProtocolVersionException.cpp?view=auto&rev=471002
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/framing/ProtocolVersionException.cpp (added)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/framing/ProtocolVersionException.cpp Fri Nov 3 13:27:48 2006
@@ -0,0 +1,63 @@
+/*
+ *
+ * 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 "qpid/framing/ProtocolVersionException.h"
+#include <sstream>
+
+using namespace qpid::framing;
+
+ProtocolVersionException::ProtocolVersionException() throw ()
+{
+}
+
+ProtocolVersionException::ProtocolVersionException(const std::string& str) throw () : Exception(str)
+{
+}
+
+ProtocolVersionException::ProtocolVersionException(const char* str) throw () : Exception(str)
+{
+}
+
+ProtocolVersionException::ProtocolVersionException(const ProtocolVersion& versionFound_, const std::string& str) throw () : Exception(str)
+
+{
+ versionFound = versionFound_;
+}
+
+ProtocolVersionException::ProtocolVersionException(const ProtocolVersion& versionFound_, const char* str) throw () : Exception(str)
+
+{
+ versionFound = versionFound_;
+}
+
+ProtocolVersionException::~ProtocolVersionException() throw ()
+{
+}
+
+const char* ProtocolVersionException::what() const throw()
+{
+ std::stringstream ss;
+ ss << "ProtocolVersionException: AMQP Version " << versionFound.toString() << " found: " << whatStr;
+ return ss.str().c_str();
+}
+
+std::string ProtocolVersionException::toString() const throw()
+{
+ std::stringstream ss;
+ ss << "ProtocolVersionException: AMQP Version " << versionFound.toString() << " found: " << whatStr;
+ return ss.str();
+}
Added: incubator/qpid/trunk/qpid/cpp/src/qpid/framing/ProtocolVersionException.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/framing/ProtocolVersionException.h?view=auto&rev=471002
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/framing/ProtocolVersionException.h (added)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/framing/ProtocolVersionException.h Fri Nov 3 13:27:48 2006
@@ -0,0 +1,52 @@
+/*
+ *
+ * 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 _ProtocolVersionException_
+#define _ProtocolVersionException_
+
+#include "qpid/Exception.h"
+#include "qpid/framing/ProtocolVersion.h"
+#include <string>
+#include <vector>
+
+namespace qpid
+{
+namespace framing
+{
+
+class ProtocolVersionException : virtual public qpid::Exception
+{
+protected:
+ ProtocolVersion versionFound;
+
+public:
+ ProtocolVersionException() throw ();
+ ProtocolVersionException(const std::string& str) throw ();
+ ProtocolVersionException(const char* str) throw ();
+ ProtocolVersionException(const ProtocolVersion& versionFound_, const std::string& str) throw ();
+ ProtocolVersionException(const ProtocolVersion& versionFound_, const char* str) throw ();
+ virtual ~ProtocolVersionException() throw ();
+
+ virtual const char* what() const throw();
+ virtual std::string toString() const throw();
+}; // class ProtocolVersionException
+
+} // namespace framing
+} // namespace qpid
+
+#endif //ifndef _ProtocolVersionException_