Author: shuston
Date: Fri Oct 24 14:37:57 2008
New Revision: 707754

URL: http://svn.apache.org/viewvc?rev=707754&view=rev
Log:
Fix Address wrapper to compile on MS VC8; discussed with Alan Conway

Added:
    incubator/qpid/trunk/qpid/cpp/src/qpid/Address.cpp   (with props)
Modified:
    incubator/qpid/trunk/qpid/cpp/src/Makefile.am
    incubator/qpid/trunk/qpid/cpp/src/qpid/Address.h

Modified: incubator/qpid/trunk/qpid/cpp/src/Makefile.am
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/Makefile.am?rev=707754&r1=707753&r2=707754&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/Makefile.am (original)
+++ incubator/qpid/trunk/qpid/cpp/src/Makefile.am Fri Oct 24 14:37:57 2008
@@ -232,6 +232,7 @@
   $(platform_src) \
   qpid/assert.cpp qpid/assert.h \
   qpid/pointer_to_other.h \
+  qpid/Address.cpp \
   qpid/DataDir.cpp \
   qpid/Exception.cpp \
   qpid/Options.cpp \
@@ -543,6 +544,7 @@
   qpid/framing/Array.h \
   qpid/framing/Blob.h \
   qpid/framing/BodyHandler.h \
+  qpid/framing/BodyHolder.h \
   qpid/framing/Buffer.h \
   qpid/framing/ChannelHandler.h \
   qpid/framing/Endian.h \
@@ -558,7 +560,6 @@
   qpid/framing/InputHandler.h \
   qpid/framing/InitiationHandler.h \
   qpid/framing/MethodContent.h \
-  qpid/framing/BodyHolder.h \
   qpid/framing/MaxMethodBodySize.h \
   qpid/framing/ModelMethod.h \
   qpid/framing/OutputHandler.h \
@@ -613,6 +614,7 @@
   qpid/sys/FileSysDir.h \
   qpid/sys/IntegerTypes.h \
   qpid/sys/IOHandle.h \
+  qpid/sys/LockFile.h \
   qpid/sys/LockPtr.h \
   qpid/sys/Monitor.h \
   qpid/sys/Mutex.h \
@@ -622,7 +624,6 @@
   qpid/sys/ProtocolFactory.h \
   qpid/sys/Runnable.h \
   qpid/sys/Fork.h \
-  qpid/sys/LockFile.h \
   qpid/sys/ScopedIncrement.h \
   qpid/sys/Semaphore.h \
   qpid/sys/SystemInfo.h \

Added: incubator/qpid/trunk/qpid/cpp/src/qpid/Address.cpp
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/Address.cpp?rev=707754&view=auto
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/Address.cpp (added)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/Address.cpp Fri Oct 24 14:37:57 2008
@@ -0,0 +1,34 @@
+/*
+ *
+ * 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 "Address.h"
+
+namespace qpid {
+
+std::ostream& operator<<(std::ostream& os, const Address& addr) {
+    const TcpAddress *t = addr.get<TcpAddress>();
+    if (t)
+        os << *t;
+    return os;
+}
+
+std::ostream& operator<<(std::ostream& os, const TcpAddress& a) {
+    return os << "tcp:" << a.host << ":" << a.port;
+}
+
+} // namespace qpid

Propchange: incubator/qpid/trunk/qpid/cpp/src/qpid/Address.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/qpid/trunk/qpid/cpp/src/qpid/Address.cpp
------------------------------------------------------------------------------
    svn:keywords = 

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/Address.h
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/Address.h?rev=707754&r1=707753&r2=707754&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/Address.h (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/Address.h Fri Oct 24 14:37:57 2008
@@ -22,6 +22,7 @@
 #include "qpid/sys/IntegerTypes.h"
 
 #include <boost/variant.hpp>
+#include <ostream>
 #include <string>
 #include <vector>
 
@@ -41,13 +42,29 @@
     return y.host==x.host && y.port == x.port;
 }
 
-/** Address is a variant of all address types, more coming in future. */
-struct Address : public boost::variant<TcpAddress> {
-    template <class T> Address(const T& t) : boost::variant<TcpAddress>(t) {}
-    template <class T> T* get() { return boost::get<T>(this); }
-    template <class T> const T* get() const { return boost::get<T>(this); }
+std::ostream& operator<<(std::ostream& os, const TcpAddress& a);
+
+/**
+ * Address is a variant of all address types, more coming in future.
+ *
+ * Address wraps a boost::variant rather than be defined in terms of
+ * boost::variant to prevent users from having to deal directly with
+ * boost.
+ */
+struct Address  {
+public:
+    Address(const Address& a) : value(a.value) {}
+    template <class T> Address(const T& t) : value(t) {}
+    template <class T> Address& operator=(const T& t) { value=t; return *this; 
}
+    template <class T> T* get() { return boost::get<T>(&value); }
+    template <class T> const T* get() const { return boost::get<T>(&value); }
+
+private:
+    boost::variant<TcpAddress> value;
 };
 
+std::ostream& operator<<(std::ostream& os, const Address& addr);
+
 } // namespace qpid
 
 #endif  /*!QPID_ADDRESS_H*/


Reply via email to