Ifdef out deprecated address member functions.
diff --git a/asio/include/asio/ip/address.hpp b/asio/include/asio/ip/address.hpp index 733bbe4..b18eb2e 100644 --- a/asio/include/asio/ip/address.hpp +++ b/asio/include/asio/ip/address.hpp
@@ -96,13 +96,13 @@ /// Get the address as an IP version 6 address. ASIO_DECL asio::ip::address_v6 to_v6() const; - /// Get the address as a string in dotted decimal format. + /// Get the address as a string. ASIO_DECL std::string to_string() const; - /// Get the address as a string in dotted decimal format. +#if !defined(ASIO_NO_DEPRECATED) + /// (Deprecated: Use other overload.) Get the address as a string. ASIO_DECL std::string to_string(asio::error_code& ec) const; -#if !defined(ASIO_NO_DEPRECATED) /// (Deprecated: Use make_address().) Create an address from an IPv4 address /// string in dotted decimal form, or from an IPv6 address in hexadecimal /// notation.
diff --git a/asio/include/asio/ip/address_v4.hpp b/asio/include/asio/ip/address_v4.hpp index 120210a..eeb22e9 100644 --- a/asio/include/asio/ip/address_v4.hpp +++ b/asio/include/asio/ip/address_v4.hpp
@@ -105,10 +105,11 @@ /// Get the address as a string in dotted decimal format. ASIO_DECL std::string to_string() const; - /// Get the address as a string in dotted decimal format. +#if !defined(ASIO_NO_DEPRECATED) + /// (Deprecated: Use other overload.) Get the address as a string in dotted + /// decimal format. ASIO_DECL std::string to_string(asio::error_code& ec) const; -#if !defined(ASIO_NO_DEPRECATED) /// (Deprecated: Use make_address_v4().) Create an address from an IP address /// string in dotted decimal form. static address_v4 from_string(const char* str); @@ -134,14 +135,19 @@ /// Determine whether the address is unspecified. ASIO_DECL bool is_unspecified() const; - /// Determine whether the address is a class A address. +#if !defined(ASIO_NO_DEPRECATED) + /// (Deprecated: Use network_v4 class.) Determine whether the address is a + /// class A address. ASIO_DECL bool is_class_a() const; - /// Determine whether the address is a class B address. + /// (Deprecated: Use network_v4 class.) Determine whether the address is a + /// class B address. ASIO_DECL bool is_class_b() const; - /// Determine whether the address is a class C address. + /// (Deprecated: Use network_v4 class.) Determine whether the address is a + /// class C address. ASIO_DECL bool is_class_c() const; +#endif // !defined(ASIO_NO_DEPRECATED) /// Determine whether the address is a multicast address. ASIO_DECL bool is_multicast() const; @@ -200,14 +206,17 @@ return address_v4(0xFFFFFFFF); } - /// Obtain an address object that represents the broadcast address that - /// corresponds to the specified address and netmask. +#if !defined(ASIO_NO_DEPRECATED) + /// (Deprecated: Use network_v4 class.) Obtain an address object that + /// represents the broadcast address that corresponds to the specified + /// address and netmask. ASIO_DECL static address_v4 broadcast( const address_v4& addr, const address_v4& mask); - /// Obtain the netmask that corresponds to the address, based on its address - /// class. + /// (Deprecated: Use network_v4 class.) Obtain the netmask that corresponds + /// to the address, based on its address class. ASIO_DECL static address_v4 netmask(const address_v4& addr); +#endif // !defined(ASIO_NO_DEPRECATED) private: // The underlying IPv4 address.
diff --git a/asio/include/asio/ip/address_v6.hpp b/asio/include/asio/ip/address_v6.hpp index 929bb93..4054fc1 100644 --- a/asio/include/asio/ip/address_v6.hpp +++ b/asio/include/asio/ip/address_v6.hpp
@@ -104,10 +104,10 @@ /// Get the address as a string. ASIO_DECL std::string to_string() const; - /// Get the address as a string. +#if !defined(ASIO_NO_DEPRECATED) + /// (Deprecated: Use other overload.) Get the address as a string. ASIO_DECL std::string to_string(asio::error_code& ec) const; -#if !defined(ASIO_NO_DEPRECATED) /// (Deprecated: Use make_address_v6().) Create an IPv6 address from an IP /// address string. static address_v6 from_string(const char* str);
diff --git a/asio/include/asio/ip/detail/endpoint.hpp b/asio/include/asio/ip/detail/endpoint.hpp index 847ca4c..2b985f4 100644 --- a/asio/include/asio/ip/detail/endpoint.hpp +++ b/asio/include/asio/ip/detail/endpoint.hpp
@@ -113,7 +113,7 @@ #if !defined(ASIO_NO_IOSTREAM) // Convert to a string. - ASIO_DECL std::string to_string(asio::error_code& ec) const; + ASIO_DECL std::string to_string() const; #endif // !defined(ASIO_NO_IOSTREAM) private:
diff --git a/asio/include/asio/ip/detail/impl/endpoint.ipp b/asio/include/asio/ip/detail/impl/endpoint.ipp index ec477ae..25b2343 100644 --- a/asio/include/asio/ip/detail/impl/endpoint.ipp +++ b/asio/include/asio/ip/detail/impl/endpoint.ipp
@@ -176,18 +176,14 @@ } #if !defined(ASIO_NO_IOSTREAM) -std::string endpoint::to_string(asio::error_code& ec) const +std::string endpoint::to_string() const { - std::string a = address().to_string(ec); - if (ec) - return std::string(); - std::ostringstream tmp_os; tmp_os.imbue(std::locale::classic()); if (is_v4()) - tmp_os << a; + tmp_os << address(); else - tmp_os << '[' << a << ']'; + tmp_os << '[' << address() << ']'; tmp_os << ':' << port(); return tmp_os.str();
diff --git a/asio/include/asio/ip/impl/address.hpp b/asio/include/asio/ip/impl/address.hpp index 5f2267c..0914413 100644 --- a/asio/include/asio/ip/impl/address.hpp +++ b/asio/include/asio/ip/impl/address.hpp
@@ -54,19 +54,7 @@ std::basic_ostream<Elem, Traits>& operator<<( std::basic_ostream<Elem, Traits>& os, const address& addr) { - asio::error_code ec; - std::string s = addr.to_string(ec); - if (ec) - { - if (os.exceptions() & std::basic_ostream<Elem, Traits>::failbit) - asio::detail::throw_error(ec); - else - os.setstate(std::basic_ostream<Elem, Traits>::failbit); - } - else - for (std::string::iterator i = s.begin(); i != s.end(); ++i) - os << os.widen(*i); - return os; + return os << addr.to_string().c_str(); } } // namespace ip
diff --git a/asio/include/asio/ip/impl/address.ipp b/asio/include/asio/ip/impl/address.ipp index 694be60..22b4424 100644 --- a/asio/include/asio/ip/impl/address.ipp +++ b/asio/include/asio/ip/impl/address.ipp
@@ -161,12 +161,14 @@ return ipv4_address_.to_string(); } +#if !defined(ASIO_NO_DEPRECATED) std::string address::to_string(asio::error_code& ec) const { if (type_ == ipv6) return ipv6_address_.to_string(ec); return ipv4_address_.to_string(ec); } +#endif // !defined(ASIO_NO_DEPRECATED) bool address::is_loopback() const {
diff --git a/asio/include/asio/ip/impl/address_v4.hpp b/asio/include/asio/ip/impl/address_v4.hpp index 4b848fb..78f1ab0 100644 --- a/asio/include/asio/ip/impl/address_v4.hpp +++ b/asio/include/asio/ip/impl/address_v4.hpp
@@ -54,19 +54,7 @@ std::basic_ostream<Elem, Traits>& operator<<( std::basic_ostream<Elem, Traits>& os, const address_v4& addr) { - asio::error_code ec; - std::string s = addr.to_string(ec); - if (ec) - { - if (os.exceptions() & std::basic_ostream<Elem, Traits>::failbit) - asio::detail::throw_error(ec); - else - os.setstate(std::basic_ostream<Elem, Traits>::failbit); - } - else - for (std::string::iterator i = s.begin(); i != s.end(); ++i) - os << os.widen(*i); - return os; + return os << addr.to_string().c_str(); } } // namespace ip
diff --git a/asio/include/asio/ip/impl/address_v4.ipp b/asio/include/asio/ip/impl/address_v4.ipp index c3caf3b..7d7056f 100644 --- a/asio/include/asio/ip/impl/address_v4.ipp +++ b/asio/include/asio/ip/impl/address_v4.ipp
@@ -78,11 +78,17 @@ std::string address_v4::to_string() const { asio::error_code ec; - std::string addr = to_string(ec); - asio::detail::throw_error(ec); + char addr_str[asio::detail::max_addr_v4_str_len]; + const char* addr = + asio::detail::socket_ops::inet_ntop( + ASIO_OS_DEF(AF_INET), &addr_, addr_str, + asio::detail::max_addr_v4_str_len, 0, ec); + if (addr == 0) + asio::detail::throw_error(ec); return addr; } +#if !defined(ASIO_NO_DEPRECATED) std::string address_v4::to_string(asio::error_code& ec) const { char addr_str[asio::detail::max_addr_v4_str_len]; @@ -94,6 +100,7 @@ return std::string(); return addr; } +#endif // !defined(ASIO_NO_DEPRECATED) bool address_v4::is_loopback() const { @@ -105,6 +112,7 @@ return to_ulong() == 0; } +#if !defined(ASIO_NO_DEPRECATED) bool address_v4::is_class_a() const { return (to_ulong() & 0x80000000) == 0; @@ -119,12 +127,14 @@ { return (to_ulong() & 0xE0000000) == 0xC0000000; } +#endif // !defined(ASIO_NO_DEPRECATED) bool address_v4::is_multicast() const { return (to_ulong() & 0xF0000000) == 0xE0000000; } +#if !defined(ASIO_NO_DEPRECATED) address_v4 address_v4::broadcast(const address_v4& addr, const address_v4& mask) { return address_v4(addr.to_ulong() | (mask.to_ulong() ^ 0xFFFFFFFF)); @@ -140,6 +150,7 @@ return address_v4(0xFFFFFF00); return address_v4(0xFFFFFFFF); } +#endif // !defined(ASIO_NO_DEPRECATED) address_v4 make_address_v4(const char* str) {
diff --git a/asio/include/asio/ip/impl/address_v6.hpp b/asio/include/asio/ip/impl/address_v6.hpp index 0aa3b8c..d4c5439 100644 --- a/asio/include/asio/ip/impl/address_v6.hpp +++ b/asio/include/asio/ip/impl/address_v6.hpp
@@ -54,19 +54,7 @@ std::basic_ostream<Elem, Traits>& operator<<( std::basic_ostream<Elem, Traits>& os, const address_v6& addr) { - asio::error_code ec; - std::string s = addr.to_string(ec); - if (ec) - { - if (os.exceptions() & std::basic_ostream<Elem, Traits>::failbit) - asio::detail::throw_error(ec); - else - os.setstate(std::basic_ostream<Elem, Traits>::failbit); - } - else - for (std::string::iterator i = s.begin(); i != s.end(); ++i) - os << os.widen(*i); - return os; + return os << addr.to_string().c_str(); } } // namespace ip
diff --git a/asio/include/asio/ip/impl/address_v6.ipp b/asio/include/asio/ip/impl/address_v6.ipp index 42e02b1..49f2418 100644 --- a/asio/include/asio/ip/impl/address_v6.ipp +++ b/asio/include/asio/ip/impl/address_v6.ipp
@@ -101,11 +101,17 @@ std::string address_v6::to_string() const { asio::error_code ec; - std::string addr = to_string(ec); - asio::detail::throw_error(ec); + char addr_str[asio::detail::max_addr_v6_str_len]; + const char* addr = + asio::detail::socket_ops::inet_ntop( + ASIO_OS_DEF(AF_INET6), &addr_, addr_str, + asio::detail::max_addr_v6_str_len, scope_id_, ec); + if (addr == 0) + asio::detail::throw_error(ec); return addr; } +#if !defined(ASIO_NO_DEPRECATED) std::string address_v6::to_string(asio::error_code& ec) const { char addr_str[asio::detail::max_addr_v6_str_len]; @@ -118,7 +124,6 @@ return addr; } -#if !defined(ASIO_NO_DEPRECATED) address_v4 address_v6::to_v4() const { if (!is_v4_mapped() && !is_v4_compatible())
diff --git a/asio/include/asio/ip/impl/basic_endpoint.hpp b/asio/include/asio/ip/impl/basic_endpoint.hpp index 2f15c4f..8c8949c 100644 --- a/asio/include/asio/ip/impl/basic_endpoint.hpp +++ b/asio/include/asio/ip/impl/basic_endpoint.hpp
@@ -30,19 +30,7 @@ const basic_endpoint<InternetProtocol>& endpoint) { asio::ip::detail::endpoint tmp_ep(endpoint.address(), endpoint.port()); - asio::error_code ec; - std::string s = tmp_ep.to_string(ec); - if (ec) - { - if (os.exceptions() & std::basic_ostream<Elem, Traits>::failbit) - asio::detail::throw_error(ec); - else - os.setstate(std::basic_ostream<Elem, Traits>::failbit); - } - else - for (std::string::iterator i = s.begin(); i != s.end(); ++i) - os << os.widen(*i); - return os; + return os << tmp_ep.to_string().c_str(); } } // namespace ip
diff --git a/asio/include/asio/ip/network_v4.hpp b/asio/include/asio/ip/network_v4.hpp index 103b055..71d9ddd 100644 --- a/asio/include/asio/ip/network_v4.hpp +++ b/asio/include/asio/ip/network_v4.hpp
@@ -112,7 +112,8 @@ /// Obtain an address object that represents the network's broadcast address. address_v4 broadcast() const ASIO_NOEXCEPT { - return address_v4::broadcast(network(), netmask()); + return address_v4(network().to_ulong() + | (netmask().to_ulong() ^ 0xFFFFFFFF)); } /// Obtain an address range corresponding to the hosts in the network.