You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by as...@apache.org on 2016/05/03 15:58:52 UTC

qpid-proton git commit: PROTON-1186: [C++ binding] Stop using proton::url in the core API - Leave the proton::url class available as a user convenience - Tidy up proton::url to be more value like.

Repository: qpid-proton
Updated Branches:
  refs/heads/master 3e72c288d -> 3dfb077c4


PROTON-1186: [C++ binding] Stop using proton::url in the core API
- Leave the proton::url class available as a user convenience
- Tidy up proton::url to be more value like.


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/3dfb077c
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/3dfb077c
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/3dfb077c

Branch: refs/heads/master
Commit: 3dfb077c4bcdc954eddf575e9b44fdf8cb62251f
Parents: 3e72c28
Author: Andrew Stitcher <as...@apache.org>
Authored: Thu Apr 28 17:43:05 2016 -0400
Committer: Andrew Stitcher <as...@apache.org>
Committed: Tue May 3 09:58:43 2016 -0400

----------------------------------------------------------------------
 examples/cpp/broker.cpp                         |  8 +--
 examples/cpp/broker.hpp                         |  1 -
 examples/cpp/client.cpp                         |  6 +-
 examples/cpp/connection_options.cpp             |  5 +-
 examples/cpp/direct_recv.cpp                    |  3 +-
 examples/cpp/direct_send.cpp                    |  2 +-
 examples/cpp/example_test.py                    |  6 +-
 examples/cpp/helloworld.cpp                     |  2 +-
 examples/cpp/helloworld_direct.cpp              |  4 +-
 examples/cpp/mt/broker.cpp                      |  1 -
 examples/cpp/mt/epoll_controller.cpp            |  2 +-
 examples/cpp/queue_browser.cpp                  |  4 +-
 examples/cpp/selected_recv.cpp                  |  4 +-
 examples/cpp/server_direct.cpp                  |  3 +-
 examples/cpp/simple_recv.cpp                    |  2 +-
 examples/cpp/simple_send.cpp                    |  2 +-
 examples/cpp/ssl.cpp                            |  4 +-
 examples/cpp/ssl_client_cert.cpp                |  4 +-
 .../bindings/cpp/include/proton/container.hpp   |  9 ++-
 proton-c/bindings/cpp/include/proton/url.hpp    | 46 +------------
 proton-c/bindings/cpp/src/connector.cpp         | 14 ++--
 proton-c/bindings/cpp/src/connector.hpp         |  5 +-
 proton-c/bindings/cpp/src/container.cpp         | 12 ++--
 proton-c/bindings/cpp/src/container_impl.cpp    |  5 +-
 proton-c/bindings/cpp/src/url.cpp               | 72 +++++++++-----------
 tests/tools/apps/cpp/reactor_send.cpp           |  2 +-
 26 files changed, 83 insertions(+), 145 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3dfb077c/examples/cpp/broker.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/broker.cpp b/examples/cpp/broker.cpp
index a19997f..4c74f67 100644
--- a/examples/cpp/broker.cpp
+++ b/examples/cpp/broker.cpp
@@ -36,14 +36,14 @@
 
 class broker {
   public:
-    broker(const proton::url& url) : handler_(url, queues_) {}
+    broker(const std::string& url) : handler_(url, queues_) {}
 
     proton::handler& handler() { return handler_; }
 
   private:
     class my_handler : public broker_handler {
       public:
-        my_handler(const proton::url& u, queues& qs) : broker_handler(qs), url_(u) {}
+        my_handler(const std::string& u, queues& qs) : broker_handler(qs), url_(u) {}
 
         void on_container_start(proton::container &c) override {
             c.listen(url_);
@@ -51,7 +51,7 @@ class broker {
         }
 
       private:
-        const proton::url& url_;
+        const std::string& url_;
     };
 
   private:
@@ -60,7 +60,7 @@ class broker {
 };
 
 int main(int argc, char **argv) {
-    proton::url url("0.0.0.0");
+    std::string url("0.0.0.0");
     example::options opts(argc, argv);
 
     opts.add_value(url, 'a', "address", "listen on URL", "URL");

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3dfb077c/examples/cpp/broker.hpp
----------------------------------------------------------------------
diff --git a/examples/cpp/broker.hpp b/examples/cpp/broker.hpp
index 470e28a..68a6354 100644
--- a/examples/cpp/broker.hpp
+++ b/examples/cpp/broker.hpp
@@ -34,7 +34,6 @@
 #include "proton/sender.hpp"
 #include "proton/tracker.hpp"
 #include "proton/transport.hpp"
-#include "proton/url.hpp"
 #include "proton/sender_options.hpp"
 #include "proton/receiver_options.hpp"
 #include "proton/source_options.hpp"

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3dfb077c/examples/cpp/client.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/client.cpp b/examples/cpp/client.cpp
index 494294e..c74aaec 100644
--- a/examples/cpp/client.cpp
+++ b/examples/cpp/client.cpp
@@ -37,13 +37,13 @@ using proton::source_options;
 
 class client : public proton::handler {
   private:
-    proton::url url;
+    std::string url;
     std::vector<std::string> requests;
     proton::sender sender;
     proton::receiver receiver;
 
   public:
-    client(const proton::url &u, const std::vector<std::string>& r) : url(u), requests(r) {}
+    client(const std::string &u, const std::vector<std::string>& r) : url(u), requests(r) {}
 
     void on_container_start(proton::container &c) override {
         sender = c.open_sender(url);
@@ -79,7 +79,7 @@ class client : public proton::handler {
 };
 
 int main(int argc, char **argv) {
-    proton::url url("127.0.0.1:5672/examples");
+    std::string url("127.0.0.1:5672/examples");
     example::options opts(argc, argv);
 
     opts.add_value(url, 'a', "address", "connect and send to URL", "URL");

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3dfb077c/examples/cpp/connection_options.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/connection_options.cpp b/examples/cpp/connection_options.cpp
index 2002030..d80dc7a 100644
--- a/examples/cpp/connection_options.cpp
+++ b/examples/cpp/connection_options.cpp
@@ -22,7 +22,6 @@
 #include "proton/connection.hpp"
 #include "proton/container.hpp"
 #include "proton/handler.hpp"
-#include "proton/url.hpp"
 #include "proton/transport.hpp"
 
 #include <iostream>
@@ -42,11 +41,11 @@ class handler_2 : public proton::handler {
 
 class main_handler : public proton::handler {
   private:
-    proton::url url;
+    std::string url;
     handler_2 conn_handler;
 
   public:
-    main_handler(const proton::url& u) : url(u) {}
+    main_handler(const std::string& u) : url(u) {}
 
     void on_container_start(proton::container &c) override {
         // Connection options for this connection.  Merged with and overriding the container's

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3dfb077c/examples/cpp/direct_recv.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/direct_recv.cpp b/examples/cpp/direct_recv.cpp
index 76bbaf9..4197785 100644
--- a/examples/cpp/direct_recv.cpp
+++ b/examples/cpp/direct_recv.cpp
@@ -27,7 +27,6 @@
 #include "proton/delivery.hpp"
 #include "proton/handler.hpp"
 #include "proton/link.hpp"
-#include "proton/url.hpp"
 #include "proton/value.hpp"
 
 #include <iostream>
@@ -37,7 +36,7 @@
 
 class direct_recv : public proton::handler {
   private:
-    proton::url url;
+    std::string url;
     uint64_t expected;
     uint64_t received;
     proton::acceptor acceptor;

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3dfb077c/examples/cpp/direct_send.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/direct_send.cpp b/examples/cpp/direct_send.cpp
index 860acc4..b972714 100644
--- a/examples/cpp/direct_send.cpp
+++ b/examples/cpp/direct_send.cpp
@@ -35,7 +35,7 @@
 
 class simple_send : public proton::handler {
   private:
-    proton::url url;
+    std::string url;
     int sent;
     int confirmed;
     int total;

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3dfb077c/examples/cpp/example_test.py
----------------------------------------------------------------------
diff --git a/examples/cpp/example_test.py b/examples/cpp/example_test.py
index 4ea0484..274efcf 100644
--- a/examples/cpp/example_test.py
+++ b/examples/cpp/example_test.py
@@ -203,7 +203,7 @@ And the mome raths outgrabe. => AND THE MOME RATHS OUTGRABE.
 """
 
 def recv_expect(name, addr):
-    return "%s listening on amqp://%s\n%s" % (
+    return "%s listening on %s\n%s" % (
         name, addr, "".join(['{"sequence"=%s}\n' % (i+1) for i in range(100)]))
 
 class ContainerExampleTest(BrokerTestCase):
@@ -244,7 +244,7 @@ class ContainerExampleTest(BrokerTestCase):
                          self.proc(["simple_recv", "-a", addr]).wait_exit())
 
         self.assertEqual(
-            "direct_send listening on amqp://%s\nall messages confirmed\n" % addr,
+            "direct_send listening on %s\nall messages confirmed\n" % addr,
             send.wait_exit())
 
     def test_request_response(self):
@@ -344,7 +344,7 @@ class EngineTestCase(BrokerTestCase):
         send = self.proc(["direct_send", "-a", addr], "listening")
         self.assertEqual(recv_expect("simple_recv", addr),
                          self.proc(["simple_recv", "-a", addr]).wait_exit())
-        self.assertEqual("direct_send listening on amqp://%s\nall messages confirmed\n" % addr,
+        self.assertEqual("direct_send listening on %s\nall messages confirmed\n" % addr,
                          send.wait_exit())
 
     def test_request_response(self):

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3dfb077c/examples/cpp/helloworld.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/helloworld.cpp b/examples/cpp/helloworld.cpp
index 7568e20..07b717b 100644
--- a/examples/cpp/helloworld.cpp
+++ b/examples/cpp/helloworld.cpp
@@ -35,7 +35,7 @@ class hello_world : public proton::handler {
     proton::url url;
 
   public:
-    hello_world(const proton::url& u) : url(u) {}
+    hello_world(const std::string& u) : url(u) {}
 
     void on_container_start(proton::container &c) override {
         proton::connection conn = c.connect(url);

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3dfb077c/examples/cpp/helloworld_direct.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/helloworld_direct.cpp b/examples/cpp/helloworld_direct.cpp
index 88db8f8..856cd18 100644
--- a/examples/cpp/helloworld_direct.cpp
+++ b/examples/cpp/helloworld_direct.cpp
@@ -32,11 +32,11 @@
 
 class hello_world_direct : public proton::handler {
   private:
-    proton::url url;
+    std::string url;
     proton::acceptor acceptor;
 
   public:
-    hello_world_direct(const proton::url& u) : url(u) {}
+    hello_world_direct(const std::string& u) : url(u) {}
 
     void on_container_start(proton::container &c) override {
         acceptor = c.listen(url);

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3dfb077c/examples/cpp/mt/broker.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/mt/broker.cpp b/examples/cpp/mt/broker.cpp
index 48738c9..ff8e051 100644
--- a/examples/cpp/mt/broker.cpp
+++ b/examples/cpp/mt/broker.cpp
@@ -23,7 +23,6 @@
 #include <proton/controller.hpp>
 #include <proton/delivery.hpp>
 #include <proton/handler.hpp>
-#include <proton/url.hpp>
 #include <proton/work_queue.hpp>
 
 #include <atomic>

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3dfb077c/examples/cpp/mt/epoll_controller.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/mt/epoll_controller.cpp b/examples/cpp/mt/epoll_controller.cpp
index 6c75b04..01983c0 100644
--- a/examples/cpp/mt/epoll_controller.cpp
+++ b/examples/cpp/mt/epoll_controller.cpp
@@ -18,8 +18,8 @@
  */
 
 #include <proton/controller.hpp>
-#include <proton/url.hpp>
 #include <proton/work_queue.hpp>
+#include <proton/url.hpp>
 
 #include <proton/io/connection_engine.hpp>
 #include <proton/io/default_controller.hpp>

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3dfb077c/examples/cpp/queue_browser.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/queue_browser.cpp b/examples/cpp/queue_browser.cpp
index dc76f9a..2a1d9be 100644
--- a/examples/cpp/queue_browser.cpp
+++ b/examples/cpp/queue_browser.cpp
@@ -23,10 +23,10 @@
 #include "proton/container.hpp"
 #include "proton/delivery.hpp"
 #include "proton/handler.hpp"
-#include "proton/url.hpp"
 #include "proton/receiver_options.hpp"
 #include "proton/source_options.hpp"
 #include "proton/settings.hpp"
+#include "proton/url.hpp"
 
 #include <iostream>
 
@@ -39,7 +39,7 @@ class browser : public proton::handler {
     proton::url url;
 
   public:
-    browser(const proton::url& u) : url(u) {}
+    browser(const std::string& u) : url(u) {}
 
     void on_container_start(proton::container &c) override {
         proton::connection conn = c.connect(url);

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3dfb077c/examples/cpp/selected_recv.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/selected_recv.cpp b/examples/cpp/selected_recv.cpp
index af3a5eb..e1529e4 100644
--- a/examples/cpp/selected_recv.cpp
+++ b/examples/cpp/selected_recv.cpp
@@ -22,9 +22,9 @@
 #include "proton/connection.hpp"
 #include "proton/container.hpp"
 #include "proton/handler.hpp"
-#include "proton/url.hpp"
 #include "proton/receiver_options.hpp"
 #include "proton/source_options.hpp"
+#include "proton/url.hpp"
 
 #include <iostream>
 
@@ -58,7 +58,7 @@ class selected_recv : public proton::handler {
     proton::url url;
 
   public:
-    selected_recv(const proton::url& u) : url(u) {}
+    selected_recv(const std::string& u) : url(u) {}
 
     void on_container_start(proton::container &c) override {
         proton::source_options opts;

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3dfb077c/examples/cpp/server_direct.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/server_direct.cpp b/examples/cpp/server_direct.cpp
index c4ecf8f..28fd7a2 100644
--- a/examples/cpp/server_direct.cpp
+++ b/examples/cpp/server_direct.cpp
@@ -27,7 +27,6 @@
 #include "proton/sender.hpp"
 #include "proton/source_options.hpp"
 #include "proton/tracker.hpp"
-#include "proton/url.hpp"
 
 #include <iostream>
 #include <map>
@@ -40,7 +39,7 @@
 class server : public proton::handler {
   private:
     typedef std::map<std::string, proton::sender> sender_map;
-    proton::url url;
+    std::string url;
     sender_map senders;
     int address_counter;
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3dfb077c/examples/cpp/simple_recv.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/simple_recv.cpp b/examples/cpp/simple_recv.cpp
index 53f87d9..3eadf32 100644
--- a/examples/cpp/simple_recv.cpp
+++ b/examples/cpp/simple_recv.cpp
@@ -36,7 +36,7 @@
 
 class simple_recv : public proton::handler {
   private:
-    proton::url url;
+    std::string url;
     proton::receiver receiver;
     uint64_t expected;
     uint64_t received;

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3dfb077c/examples/cpp/simple_send.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/simple_send.cpp b/examples/cpp/simple_send.cpp
index f2a2477..3a70651 100644
--- a/examples/cpp/simple_send.cpp
+++ b/examples/cpp/simple_send.cpp
@@ -34,7 +34,7 @@
 
 class simple_send : public proton::handler {
   private:
-    proton::url url;
+    std::string url;
     proton::sender sender;
     int sent;
     int confirmed;

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3dfb077c/examples/cpp/ssl.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/ssl.cpp b/examples/cpp/ssl.cpp
index c9bf79c..6ecf2cc 100644
--- a/examples/cpp/ssl.cpp
+++ b/examples/cpp/ssl.cpp
@@ -62,11 +62,11 @@ struct server_handler : public proton::handler {
 
 class hello_world_direct : public proton::handler {
   private:
-    proton::url url;
+    std::string url;
     server_handler s_handler;
 
   public:
-    hello_world_direct(const proton::url& u) : url(u) {}
+    hello_world_direct(const std::string& u) : url(u) {}
 
     void on_container_start(proton::container &c) override {
         // Configure listener.  Details vary by platform.

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3dfb077c/examples/cpp/ssl_client_cert.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/ssl_client_cert.cpp b/examples/cpp/ssl_client_cert.cpp
index e4053bd..58e3e9e 100644
--- a/examples/cpp/ssl_client_cert.cpp
+++ b/examples/cpp/ssl_client_cert.cpp
@@ -72,11 +72,11 @@ struct server_handler : public proton::handler {
 
 class hello_world_direct : public proton::handler {
   private:
-    proton::url url;
+    std::string url;
     server_handler s_handler;
 
   public:
-    hello_world_direct(const proton::url& u) : url(u) {}
+    hello_world_direct(const std::string& u) : url(u) {}
 
     void on_container_start(proton::container &c) override {
         // Configure listener.  Details vary by platform.

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3dfb077c/proton-c/bindings/cpp/include/proton/container.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/container.hpp b/proton-c/bindings/cpp/include/proton/container.hpp
index 9759c67..ae5f08c 100644
--- a/proton-c/bindings/cpp/include/proton/container.hpp
+++ b/proton-c/bindings/cpp/include/proton/container.hpp
@@ -25,7 +25,6 @@
 #include "proton/duration.hpp"
 #include "proton/export.hpp"
 #include "proton/pn_unique_ptr.hpp"
-#include "proton/url.hpp"
 #include "proton/connection_options.hpp"
 #include "proton/sender_options.hpp"
 #include "proton/receiver_options.hpp"
@@ -75,11 +74,11 @@ class container {
     PN_CPP_EXTERN ~container();
 
     /// Open a connection to `url`.
-    PN_CPP_EXTERN connection connect(const proton::url&,
+    PN_CPP_EXTERN connection connect(const std::string& url,
                                      const connection_options &opts = connection_options());
 
     /// Listen on `url` for incoming connections.
-    PN_CPP_EXTERN acceptor listen(const proton::url&,
+    PN_CPP_EXTERN acceptor listen(const std::string &url,
                                   const connection_options &opts = connection_options());
 
     /// Start processing events. It returns when all connections and
@@ -89,14 +88,14 @@ class container {
     /// Open a connection to `url` and open a sender for `url.path()`.
     /// Any supplied sender or connection options will override the
     /// container's template options.
-    PN_CPP_EXTERN sender open_sender(const proton::url &,
+    PN_CPP_EXTERN sender open_sender(const std::string &url,
                                      const proton::sender_options &o = proton::sender_options(),
                                      const connection_options &c = connection_options());
 
     /// Open a connection to `url` and open a receiver for
     /// `url.path()`.  Any supplied receiver or connection options will
     /// override the container's template options.
-    PN_CPP_EXTERN receiver open_receiver(const url &,
+    PN_CPP_EXTERN receiver open_receiver(const std::string&url,
                                          const proton::receiver_options &o = proton::receiver_options(),
                                          const connection_options &c = connection_options());
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3dfb077c/proton-c/bindings/cpp/include/proton/url.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/url.hpp b/proton-c/bindings/cpp/include/proton/url.hpp
index 869692c..2bf2bd6 100644
--- a/proton-c/bindings/cpp/include/proton/url.hpp
+++ b/proton-c/bindings/cpp/include/proton/url.hpp
@@ -54,9 +54,6 @@ class url {
     static const std::string AMQP;     ///< "amqp" prefix
     static const std::string AMQPS;    ///< "amqps" prefix
 
-    /// Create an empty URL
-    PN_CPP_EXTERN url();
-
     /// Parse `url_str` as an AMQP URL. If defaults is true, fill in
     /// defaults for missing values otherwise return an empty string
     /// for missing values.
@@ -66,56 +63,27 @@ class url {
     /// @throw url_error if URL is invalid.
     PN_CPP_EXTERN url(const std::string& url_str, bool defaults=true);
 
-    /// Parse `url_str` as an AMQP URL. If defaults is true, fill in
-    /// defaults for missing values otherwise return an empty string
-    /// for missing values.
-    ///
-    /// @note Converts automatically from string.
-    ///
-    /// @throw url_error if URL is invalid.
-    PN_CPP_EXTERN url(const char* url_str, bool defaults=true);
-
     /// Copy a URL.
     PN_CPP_EXTERN url(const url&);
     PN_CPP_EXTERN ~url();
     /// Copy a URL.
     PN_CPP_EXTERN url& operator=(const url&);
 
-    /// Parse a string as a URL.
-    ///
-    /// @throws url_error if URL is invalid.
-    PN_CPP_EXTERN void parse(const std::string&);
-
-    /// Parse a string as a URL.
-    ///
-    /// @throws url_error if URL is invalid.
-    PN_CPP_EXTERN void parse(const char*);
-
     /// True if the URL is empty.
     PN_CPP_EXTERN bool empty() const;
 
-    /// `str` returns the URL as a string
-    PN_CPP_EXTERN std::string str() const;
+    /// returns the URL as a string
+    PN_CPP_EXTERN operator std::string() const;
 
     /// @name URL fields
     ///
     /// @{
 
     PN_CPP_EXTERN std::string scheme() const;
-    PN_CPP_EXTERN void scheme(const std::string&);
-
-    /// @cond INTERNAL
-    PN_CPP_EXTERN std::string username() const;
-    PN_CPP_EXTERN void username(const std::string&);
-    /// @endcond
-
+    PN_CPP_EXTERN std::string user() const;
     PN_CPP_EXTERN std::string password() const;
-    PN_CPP_EXTERN void password(const std::string&);
-
     PN_CPP_EXTERN std::string host() const;
-    PN_CPP_EXTERN void host(const std::string&);
     /// `port` can be a number or a symbolic name such as "amqp".
-    PN_CPP_EXTERN void port(const std::string&);
     PN_CPP_EXTERN std::string port() const;
     /// `port_int` is the numeric value of the port.
     PN_CPP_EXTERN uint16_t port_int() const;
@@ -124,17 +92,9 @@ class url {
 
     /// `path` is everything after the final "/".
     PN_CPP_EXTERN std::string path() const;
-    PN_CPP_EXTERN void path(const std::string&);
 
     /// @}
 
-    /// @cond INTERNAL
-    /// XXX need to discuss
-    /// defaults fills in default values for missing parts of the URL.
-    PN_CPP_EXTERN void defaults();
-    /// @endcond
-
-    /// @cond INTERNAL
   private:
     pn_url_t* url_;
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3dfb077c/proton-c/bindings/cpp/src/connector.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/connector.cpp b/proton-c/bindings/cpp/src/connector.cpp
index f2e1776..c007dd6 100644
--- a/proton-c/bindings/cpp/src/connector.cpp
+++ b/proton-c/bindings/cpp/src/connector.cpp
@@ -24,10 +24,10 @@
 #include "proton/connection.hpp"
 #include "proton/transport.hpp"
 #include "proton/container.hpp"
-#include "proton/url.hpp"
 #include "proton/reconnect_timer.hpp"
 #include "proton/task.hpp"
 #include "proton/sasl.hpp"
+#include "proton/url.hpp"
 
 #include "container_impl.hpp"
 #include "proton_bits.hpp"
@@ -38,16 +38,12 @@
 
 namespace proton {
 
-connector::connector(connection&c, const connection_options &opts) :
-    connection_(c), options_(opts), reconnect_timer_(0), transport_configured_(false)
+connector::connector(connection&c, const url& a, const connection_options &opts) :
+    connection_(c), address_(a), options_(opts), reconnect_timer_(0), transport_configured_(false)
 {}
 
 connector::~connector() { delete reconnect_timer_; }
 
-void connector::address(const url &a) {
-    address_ = a;
-}
-
 void connector::apply_options() {
     if (!connection_) return;
     options_.apply(connection_);
@@ -64,8 +60,8 @@ void connector::connect() {
     connection_.host(address_.host_port());
     pn_transport_t *pnt = pn_transport();
     transport t(make_wrapper(pnt));
-    if (!address_.username().empty())
-        connection_.user(address_.username());
+    if (!address_.user().empty())
+        connection_.user(address_.user());
     if (!address_.password().empty())
         connection_.password(address_.password());
     t.bind(connection_);

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3dfb077c/proton-c/bindings/cpp/src/connector.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/connector.hpp b/proton-c/bindings/cpp/src/connector.hpp
index 0f98235..9449cd1 100644
--- a/proton-c/bindings/cpp/src/connector.hpp
+++ b/proton-c/bindings/cpp/src/connector.hpp
@@ -24,9 +24,9 @@
 
 #include "proton/connection.hpp"
 #include "proton/connection_options.hpp"
-#include "proton/url.hpp"
 #include "proton/event.h"
 #include "proton/reactor.h"
+#include "proton/url.hpp"
 
 #include "proton_handler.hpp"
 
@@ -40,9 +40,8 @@ class reconnect_timer;
 class connector : public proton_handler
 {
   public:
-    connector(connection &c, const connection_options &opts);
+    connector(connection &c, const url&, const connection_options &opts);
     ~connector();
-    void address(const url&);
     const url &address() const { return address_; }
     void connect();
     void apply_options();

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3dfb077c/proton-c/bindings/cpp/src/container.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/container.cpp b/proton-c/bindings/cpp/src/container.cpp
index e1ca05f..7562cc7 100644
--- a/proton-c/bindings/cpp/src/container.cpp
+++ b/proton-c/bindings/cpp/src/container.cpp
@@ -26,10 +26,10 @@
 #include "proton/session.hpp"
 #include "proton/acceptor.hpp"
 #include "proton/error.hpp"
-#include "proton/url.hpp"
 #include "proton/sender.hpp"
 #include "proton/receiver.hpp"
 #include "proton/task.hpp"
+#include "proton/url.hpp"
 
 #include "container_impl.hpp"
 #include "connector.hpp"
@@ -53,23 +53,23 @@ container::container(handler &mhandler, const std::string& id) {
 
 container::~container() {}
 
-connection container::connect(const url &host, const connection_options &opts) {
-    return impl_->connect(host, opts);
+connection container::connect(const std::string &url, const connection_options &opts) {
+    return impl_->connect(url, opts);
 }
 
 std::string container::id() const { return impl_->id_; }
 
 void container::run() { impl_->reactor_.run(); }
 
-sender container::open_sender(const proton::url &url, const proton::sender_options &lo, const connection_options &co) {
+sender container::open_sender(const std::string &url, const proton::sender_options &lo, const connection_options &co) {
     return impl_->open_sender(url, lo, co);
 }
 
-receiver container::open_receiver(const proton::url &url, const proton::receiver_options &lo, const connection_options &co) {
+receiver container::open_receiver(const std::string &url, const proton::receiver_options &lo, const connection_options &co) {
     return impl_->open_receiver(url, lo, co);
 }
 
-acceptor container::listen(const proton::url &url, const connection_options &opts) {
+acceptor container::listen(const std::string &url, const connection_options &opts) {
     return impl_->listen(url, opts);
 }
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3dfb077c/proton-c/bindings/cpp/src/container_impl.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/container_impl.cpp b/proton-c/bindings/cpp/src/container_impl.cpp
index 62e626f..477d5bc 100644
--- a/proton-c/bindings/cpp/src/container_impl.cpp
+++ b/proton-c/bindings/cpp/src/container_impl.cpp
@@ -24,13 +24,13 @@
 #include "proton/session.hpp"
 #include "proton/acceptor.hpp"
 #include "proton/error.hpp"
-#include "proton/url.hpp"
 #include "proton/sender.hpp"
 #include "proton/receiver.hpp"
 #include "proton/task.hpp"
 #include "proton/ssl.hpp"
 #include "proton/sasl.hpp"
 #include "proton/transport.hpp"
+#include "proton/url.hpp"
 #include "proton/uuid.hpp"
 
 #include "connector.hpp"
@@ -148,8 +148,7 @@ connection container_impl::connect(const proton::url &url, const connection_opti
 
     internal::pn_ptr<pn_handler_t> chandler = h ? cpp_handler(h) : internal::pn_ptr<pn_handler_t>();
     connection conn(reactor_.connection(chandler.get()));
-    internal::pn_unique_ptr<connector> ctor(new connector(conn, opts));
-    ctor->address(url);  // TODO: url vector
+    internal::pn_unique_ptr<connector> ctor(new connector(conn, url, opts));
     connection_context& cc(connection_context::get(conn));
     cc.handler.reset(ctor.release());
     cc.link_gen.prefix(id_gen_.next() + "/");

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3dfb077c/proton-c/bindings/cpp/src/url.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/url.cpp b/proton-c/bindings/cpp/src/url.cpp
index acd6527..32b2c0a 100644
--- a/proton-c/bindings/cpp/src/url.cpp
+++ b/proton-c/bindings/cpp/src/url.cpp
@@ -19,9 +19,14 @@
  *
  */
 
-#include "proton/error.hpp"
 #include "proton/url.hpp"
+
+#include "proton/error.hpp"
+
 #include "proton/url.h"
+
+#include "proton_bits.hpp"
+
 #include <sstream>
 
 namespace proton {
@@ -30,68 +35,53 @@ url_error::url_error(const std::string& s) : error(s) {}
 
 namespace {
 
-pn_url_t* parse_throw(const std::string& s) {
-    pn_url_t* u = pn_url_parse(s.c_str());
-    if (!u) throw url_error("invalid URL: " + s);
+pn_url_t* parse_throw(const char* s) {
+    pn_url_t* u = pn_url_parse(s);
+    if (!u) throw url_error("invalid URL: " + std::string(s));
     return u;
 }
 
-pn_url_t* parse_allow_empty(const std::string& s) {
-    return s.empty() ? pn_url() : parse_throw(s);
+pn_url_t* parse_allow_empty(const char* s) {
+    return s && *s ? parse_throw(s) : pn_url();
 }
 
-std::string char_str(const char* s) { return s ? std::string(s) : std::string(); }
-
 void replace(pn_url_t*& var, pn_url_t* val) {
     if (var) pn_url_free(var);
     var = val;
 }
 
-} // namespace
-
-url::url() : url_(pn_url()) {}
+void defaults(pn_url_t* u) {
+  const char* scheme = pn_url_get_scheme(u);
+  const char* port = pn_url_get_port(u);
+  if (!scheme || *scheme=='\0' ) pn_url_set_scheme(u, url::AMQP.c_str());
+  if (!port || *port=='\0' ) pn_url_set_port(u, pn_url_get_scheme(u));
+}
 
-url::url(const std::string &s, bool d) : url_(parse_throw(s)) { if (d) defaults(); }
+} // namespace
 
-url::url(const char *s, bool d) : url_(parse_throw(s)) { if (d) defaults(); }
+url::url(const std::string &s, bool d) : url_(parse_throw(s.c_str())) { if (d) defaults(url_); }
 
-url::url(const url& u) : url_(parse_allow_empty(u.str())) {}
+url::url(const url& u) : url_(parse_allow_empty(pn_url_str(u.url_))) {}
 
 url::~url() { pn_url_free(url_); }
 
 url& url::operator=(const url& u) {
-    if (this != &u) replace(url_, parse_allow_empty(u.str()));
+    if (this != &u) replace(url_, parse_allow_empty(pn_url_str(u.url_)));
     return *this;
 }
 
-void url::parse(const std::string& s) { replace(url_, parse_throw(s)); }
-
-void url::parse(const char *s) { replace(url_, parse_throw(s)); }
+url::operator std::string() const { return str(pn_url_str(url_)); }
 
-std::string url::str() const { return char_str(pn_url_str(url_)); }
-
-std::string url::scheme() const { return char_str(pn_url_get_scheme(url_)); }
-std::string url::username() const { return char_str(pn_url_get_username(url_)); }
-std::string url::password() const { return char_str(pn_url_get_password(url_)); }
-std::string url::host() const { return char_str(pn_url_get_host(url_)); }
-std::string url::port() const { return char_str(pn_url_get_port(url_)); }
-std::string url::path() const { return char_str(pn_url_get_path(url_)); }
+std::string url::scheme() const { return str(pn_url_get_scheme(url_)); }
+std::string url::user() const { return str(pn_url_get_username(url_)); }
+std::string url::password() const { return str(pn_url_get_password(url_)); }
+std::string url::host() const { return str(pn_url_get_host(url_)); }
+std::string url::port() const { return str(pn_url_get_port(url_)); }
+std::string url::path() const { return str(pn_url_get_path(url_)); }
 
 std::string url::host_port() const { return host() + ":" + port(); }
 
-bool url::empty() const { return str().empty(); }
-
-void url::scheme(const std::string& s) { pn_url_set_scheme(url_, s.c_str()); }
-void url::username(const std::string& s) { pn_url_set_username(url_, s.c_str()); }
-void url::password(const std::string& s) { pn_url_set_password(url_, s.c_str()); }
-void url::host(const std::string& s) { pn_url_set_host(url_, s.c_str()); }
-void url::port(const std::string& s) { pn_url_set_port(url_, s.c_str()); }
-void url::path(const std::string& s) { pn_url_set_path(url_, s.c_str()); }
-
-void url::defaults() {
-    if (scheme().empty()) scheme(AMQP);
-    if (port().empty()) port(scheme());
-}
+bool url::empty() const { return *pn_url_str(url_) == '\0'; }
 
 const std::string url::AMQP("amqp");
 const std::string url::AMQPS("amqps");
@@ -108,7 +98,7 @@ uint16_t url::port_int() const {
     return result;
 }
 
-std::ostream& operator<<(std::ostream& o, const url& u) { return o << u.str(); }
+std::ostream& operator<<(std::ostream& o, const url& u) { return o << pn_url_str(u.url_); }
 
 std::istream& operator>>(std::istream& i, url& u) {
     std::string s;
@@ -117,7 +107,7 @@ std::istream& operator>>(std::istream& i, url& u) {
         pn_url_t* p = pn_url_parse(s.c_str());
         if (p) {
             replace(u.url_, p);
-            u.defaults();
+            defaults(u.url_);
         } else {
             i.clear(std::ios::failbit);
         }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3dfb077c/tests/tools/apps/cpp/reactor_send.cpp
----------------------------------------------------------------------
diff --git a/tests/tools/apps/cpp/reactor_send.cpp b/tests/tools/apps/cpp/reactor_send.cpp
index d4045b4..b99db0c 100644
--- a/tests/tools/apps/cpp/reactor_send.cpp
+++ b/tests/tools/apps/cpp/reactor_send.cpp
@@ -42,7 +42,7 @@
 
 class reactor_send : public proton::handler {
   private:
-    proton::url url_;
+    std::string url_;
     proton::message message_;
     std::string reply_to_;
     int sent_;


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org