summaryrefslogtreecommitdiff
path: root/cpp/include
diff options
context:
space:
mode:
authorAlan Conway <aconway@apache.org>2010-05-11 14:39:58 +0000
committerAlan Conway <aconway@apache.org>2010-05-11 14:39:58 +0000
commit16da0e0c511c0c1cf4ea592640c522754065200a (patch)
tree59fb80994db731fabe19897c95a6912e68716360 /cpp/include
parentbe8e1bf6b6a0d760bddbbe6642d477a95f36ab42 (diff)
downloadqpid-python-16da0e0c511c0c1cf4ea592640c522754065200a.tar.gz
Support for multiple protocols in qpid::Url.
- simplified qpid::Address to hold (protocol,host,port) triples. - protocol plugins call Url:addProtocol to add tags to Url parser. - use Address::protocol when establishing connections. - ssl_test: tests using URL to connect. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@943130 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/include')
-rwxr-xr-xcpp/include/qpid/Address.h62
-rw-r--r--cpp/include/qpid/Url.h19
-rw-r--r--cpp/include/qpid/sys/SystemInfo.h5
3 files changed, 29 insertions, 57 deletions
diff --git a/cpp/include/qpid/Address.h b/cpp/include/qpid/Address.h
index fe82b21b9e..71da7b25db 100755
--- a/cpp/include/qpid/Address.h
+++ b/cpp/include/qpid/Address.h
@@ -21,64 +21,34 @@
#include "qpid/sys/IntegerTypes.h"
#include "qpid/CommonImportExport.h"
-#include <boost/variant.hpp>
#include <iosfwd>
#include <string>
-#include <vector>
namespace qpid {
+namespace client { class ConnectionSettings; }
-/** TCP address of a broker - host:port */
-struct TcpAddress {
- static const uint16_t DEFAULT_PORT=5672;
- QPID_COMMON_EXTERN explicit TcpAddress(const std::string& host_=std::string(),uint16_t port_=DEFAULT_PORT);
- std::string host;
- uint16_t port;
-};
-bool operator==(const TcpAddress& x, const TcpAddress& y);
-QPID_COMMON_EXTERN std::ostream& operator<<(std::ostream& os, const TcpAddress& a);
-
-/**@internal Not a real address type, this is a placeholder to
- * demonstrate and validate multi-protocol Urls for unit tests and
- * developer education only. An example address holds just a char.
- */
-struct ExampleAddress {
- explicit ExampleAddress(char data);
- char data;
-};
-bool operator==(const ExampleAddress& x, const ExampleAddress& y);
-std::ostream& operator<<(std::ostream& os, const ExampleAddress& a);
/**
- * Contains the address of an AMQP broker. Can any supported type of
- * broker address. Currently only TcpAddress is supported.
+ * Contains the protocol address of an AMQP broker.
*/
struct Address {
public:
- Address(const Address& a) : value(a.value) {}
- Address(const TcpAddress& tcp) : value(tcp) {}
- Address(const ExampleAddress& eg) : value(eg) {} ///<@internal
-
- template <class AddressType> Address& operator=(const AddressType& t) { value=t; return *this; }
-
- /** Get the address of type AddressType.
- *@return AddressType* pointing to the contained address or 0 if
- *contained address is not of type AddressType.
- */
- template <class AddressType> AddressType* get() { return boost::get<AddressType>(&value); }
-
- /** Get the address of type AddressType.
- *@return AddressType* pointing to the contained address or 0 if
- *contained address is not of type AddressType.
- */
- template <class AddressType> const AddressType* get() const { return boost::get<AddressType>(&value); }
-
-private:
- boost::variant<TcpAddress,ExampleAddress> value;
- friend std::ostream& operator<<(std::ostream& os, const Address& addr);
+ static const std::string TCP; // Default TCP protocol tag.
+ static const uint16_t AMQP_PORT=5672; // Default AMQP port.
+
+ QPID_COMMON_EXTERN explicit Address(
+ const std::string& protocol_=std::string(),
+ const std::string& host_=std::string(),
+ uint16_t port_=0
+ ) : protocol(protocol_), host(host_), port(port_) {}
+
+ std::string protocol;
+ std::string host;
+ uint16_t port;
};
-
+QPID_COMMON_EXTERN std::ostream& operator<<(std::ostream& os, const Address& addr);
+QPID_COMMON_EXTERN bool operator==(const Address& x, const Address& y);
} // namespace qpid
diff --git a/cpp/include/qpid/Url.h b/cpp/include/qpid/Url.h
index d0f4bb0c22..44b13b0c2a 100644
--- a/cpp/include/qpid/Url.h
+++ b/cpp/include/qpid/Url.h
@@ -29,13 +29,11 @@
namespace qpid {
-QPID_COMMON_EXTERN std::ostream& operator<<(std::ostream& os, const TcpAddress& a);
-
/** An AMQP URL contains a list of addresses */
struct Url : public std::vector<Address> {
/** Url with the hostname as returned by gethostname(2) */
- static Url getHostNameUrl(uint16_t port);
+ QPID_COMMON_EXTERN static Url getHostNameUrl(uint16_t port);
/** Url with local IP address(es), may be more than one address
* on a multi-homed host. */
@@ -65,21 +63,24 @@ struct Url : public std::vector<Address> {
/** Throw Invalid if the URL does not contain any addresses. */
QPID_COMMON_EXTERN void throwIfEmpty() const;
- /** Replace contents with parsed URL as defined in
- * https://wiki.108.redhat.com/jira/browse/AMQP-95
+ /** Replace contents with parsed url
*@exception Invalid if the url is invalid.
*/
QPID_COMMON_EXTERN void parse(const char* url);
QPID_COMMON_EXTERN void parse(const std::string& url) { parse(url.c_str()); }
- /** Replace contesnts with parsed URL as defined in
- * https://wiki.108.redhat.com/jira/browse/AMQP-95
- * url.empty() will be true if url is invalid.
- */
+ /** Replace contesnts with parsed URL. Replace with empty URL if invalid. */
void parseNoThrow(const char* url);
+ /** Add a protocol tag to be recognzed in URLs.
+ * Only for use by protcol plug-in initializers.
+ */
+ static void addProtocol(const std::string& tag);
+
private:
mutable std::string cache; // cache string form for efficiency.
+ static std::vector<std::string> protocols;
+ friend class UrlParser;
};
inline bool operator==(const Url& a, const Url& b) { return a.str()==b.str(); }
diff --git a/cpp/include/qpid/sys/SystemInfo.h b/cpp/include/qpid/sys/SystemInfo.h
index 09f9980173..23594cf650 100644
--- a/cpp/include/qpid/sys/SystemInfo.h
+++ b/cpp/include/qpid/sys/SystemInfo.h
@@ -24,6 +24,7 @@
#include "qpid/sys/IntegerTypes.h"
#include "qpid/Address.h"
#include "qpid/CommonImportExport.h"
+#include <vector>
namespace qpid {
namespace sys {
@@ -40,10 +41,10 @@ namespace SystemInfo {
QPID_COMMON_EXTERN long concurrency();
/**
- * Get the local host name and set it in the specified TcpAddress.
+ * Get the local host name and set it in the specified.
* Returns false if it can't be obtained and sets errno to any error value.
*/
- QPID_COMMON_EXTERN bool getLocalHostname (TcpAddress &address);
+ QPID_COMMON_EXTERN bool getLocalHostname (Address &address);
QPID_COMMON_EXTERN void getLocalIpAddresses (uint16_t port, std::vector<Address> &addrList);