[svn] commit: r2171 - in /branches/trac221/src/bin/auth: asio_link.cc asio_link.h

BIND 10 source code commits bind10-changes at lists.isc.org
Sat Jun 19 06:42:01 UTC 2010


Author: jinmei
Date: Sat Jun 19 06:42:01 2010
New Revision: 2171

Log:
completed implementation of IOAddress

Modified:
    branches/trac221/src/bin/auth/asio_link.cc
    branches/trac221/src/bin/auth/asio_link.h

Modified: branches/trac221/src/bin/auth/asio_link.cc
==============================================================================
--- branches/trac221/src/bin/auth/asio_link.cc (original)
+++ branches/trac221/src/bin/auth/asio_link.cc Sat Jun 19 06:42:01 2010
@@ -92,8 +92,23 @@
 
 namespace asio_link {
 IOAddress::IOAddress(const string& address_str) :
-    asio_address_placeholder_(NULL),
-    asio_address_(*asio_address_placeholder_) // XXX
+    // XXX: we cannot simply construct the address in the initialization list
+    // because we'd like to throw our own exception on failure.
+    asio_address_placeholder_(new ip::address()),
+    asio_address_(*asio_address_placeholder_)
+{
+    error_code err;
+    const ip::address address = ip::address::from_string(address_str, err);
+    if (err) {
+        delete asio_address_placeholder_;
+        isc_throw(IOError, "Failed to convert string to address '"
+                  << address_str << "': " << err.message());
+    }
+    *asio_address_placeholder_ = address;
+}
+
+IOAddress::IOAddress(const ip::address& asio_address) :
+    asio_address_placeholder_(NULL), asio_address_(asio_address)
 {}
 
 IOAddress::~IOAddress() {
@@ -102,7 +117,7 @@
 
 string
 IOAddress::toText() const {
-    return ("dummy");
+    return (asio_address_.to_string());
 }
 
 //

Modified: branches/trac221/src/bin/auth/asio_link.h
==============================================================================
--- branches/trac221/src/bin/auth/asio_link.h (original)
+++ branches/trac221/src/bin/auth/asio_link.h Sat Jun 19 06:42:01 2010
@@ -44,6 +44,9 @@
 };
 
 class IOAddress {
+private:
+    IOAddress(const IOAddress& source);
+    IOAddress& operator=(const IOAddress& source);
 public:
     IOAddress(const std::string& adress_str);
     IOAddress(const asio::ip::address& asio_adress);
@@ -51,10 +54,13 @@
     ~IOAddress();
 private:
     asio::ip::address* asio_address_placeholder_;
-    asio::ip::address& asio_address_;
+    const asio::ip::address& asio_address_;
 };
 
 class IOMessage {
+private:
+    IOMessage(const IOMessage& source);
+    IOMessage& operator=(const IOMessage& source);
 public:
     IOMessage();
     ~IOMessage();




More information about the bind10-changes mailing list