diff options
author | Remko Tronçon <git@el-tramo.be> | 2010-11-24 20:33:19 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2010-11-24 20:35:17 (GMT) |
commit | 332d60c56dfaa11fdd135088279d15cd5983b3d4 (patch) | |
tree | dd77717a4e1732da929d5ff8a0471fa3f005e201 /3rdParty/Boost/src/boost/asio/ip/address_v4.hpp | |
parent | 90c44a10fec26d2a0935b2d62e82b6a5be028373 (diff) | |
download | swift-contrib-332d60c56dfaa11fdd135088279d15cd5983b3d4.zip swift-contrib-332d60c56dfaa11fdd135088279d15cd5983b3d4.tar.bz2 |
Upgraded Boost to 1.45.0.
Diffstat (limited to '3rdParty/Boost/src/boost/asio/ip/address_v4.hpp')
-rw-r--r-- | 3rdParty/Boost/src/boost/asio/ip/address_v4.hpp | 173 |
1 files changed, 34 insertions, 139 deletions
diff --git a/3rdParty/Boost/src/boost/asio/ip/address_v4.hpp b/3rdParty/Boost/src/boost/asio/ip/address_v4.hpp index 47d36b5..21c1a7f 100644 --- a/3rdParty/Boost/src/boost/asio/ip/address_v4.hpp +++ b/3rdParty/Boost/src/boost/asio/ip/address_v4.hpp @@ -1,6 +1,6 @@ // -// address_v4.hpp -// ~~~~~~~~~~~~~~ +// ip/address_v4.hpp +// ~~~~~~~~~~~~~~~~~ // // Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) // @@ -15,24 +15,18 @@ # pragma once #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) -#include <boost/asio/detail/push_options.hpp> +#include <boost/asio/detail/config.hpp> +#include <string> +#include <boost/array.hpp> +#include <boost/asio/detail/socket_types.hpp> +#include <boost/asio/detail/winsock_init.hpp> +#include <boost/system/error_code.hpp> -#include <boost/asio/detail/push_options.hpp> -#include <boost/config.hpp> #if !defined(BOOST_NO_IOSTREAM) # include <iosfwd> #endif // !defined(BOOST_NO_IOSTREAM) -#include <climits> -#include <string> -#include <stdexcept> -#include <boost/array.hpp> -#include <boost/throw_exception.hpp> -#include <boost/asio/detail/pop_options.hpp> -#include <boost/asio/error.hpp> -#include <boost/asio/detail/socket_ops.hpp> -#include <boost/asio/detail/socket_types.hpp> -#include <boost/asio/detail/throw_error.hpp> +#include <boost/asio/detail/push_options.hpp> namespace boost { namespace asio { @@ -60,34 +54,10 @@ public: } /// Construct an address from raw bytes. - explicit address_v4(const bytes_type& bytes) - { -#if UCHAR_MAX > 0xFF - if (bytes[0] > 0xFF || bytes[1] > 0xFF - || bytes[2] > 0xFF || bytes[3] > 0xFF) - { - std::out_of_range ex("address_v4 from bytes_type"); - boost::throw_exception(ex); - } -#endif // UCHAR_MAX > 0xFF - - using namespace std; // For memcpy. - memcpy(&addr_.s_addr, bytes.elems, 4); - } + BOOST_ASIO_DECL explicit address_v4(const bytes_type& bytes); /// Construct an address from a unsigned long in host byte order. - explicit address_v4(unsigned long addr) - { -#if ULONG_MAX > 0xFFFFFFFF - if (addr > 0xFFFFFFFF) - { - std::out_of_range ex("address_v4 from unsigned long"); - boost::throw_exception(ex); - } -#endif // ULONG_MAX > 0xFFFFFFFF - - addr_.s_addr = boost::asio::detail::socket_ops::host_to_network_long(addr); - } + BOOST_ASIO_DECL explicit address_v4(unsigned long addr); /// Copy constructor. address_v4(const address_v4& other) @@ -103,96 +73,42 @@ public: } /// Get the address in bytes, in network byte order. - bytes_type to_bytes() const - { - using namespace std; // For memcpy. - bytes_type bytes; - memcpy(bytes.elems, &addr_.s_addr, 4); - return bytes; - } + BOOST_ASIO_DECL bytes_type to_bytes() const; /// Get the address as an unsigned long in host byte order - unsigned long to_ulong() const - { - return boost::asio::detail::socket_ops::network_to_host_long(addr_.s_addr); - } + BOOST_ASIO_DECL unsigned long to_ulong() const; /// Get the address as a string in dotted decimal format. - std::string to_string() const - { - boost::system::error_code ec; - std::string addr = to_string(ec); - boost::asio::detail::throw_error(ec); - return addr; - } + BOOST_ASIO_DECL std::string to_string() const; /// Get the address as a string in dotted decimal format. - std::string to_string(boost::system::error_code& ec) const - { - char addr_str[boost::asio::detail::max_addr_v4_str_len]; - const char* addr = - boost::asio::detail::socket_ops::inet_ntop(AF_INET, &addr_, addr_str, - boost::asio::detail::max_addr_v4_str_len, 0, ec); - if (addr == 0) - return std::string(); - return addr; - } + BOOST_ASIO_DECL std::string to_string(boost::system::error_code& ec) const; /// Create an address from an IP address string in dotted decimal form. - static address_v4 from_string(const char* str) - { - boost::system::error_code ec; - address_v4 addr = from_string(str, ec); - boost::asio::detail::throw_error(ec); - return addr; - } + BOOST_ASIO_DECL static address_v4 from_string(const char* str); /// Create an address from an IP address string in dotted decimal form. - static address_v4 from_string(const char* str, boost::system::error_code& ec) - { - address_v4 tmp; - if (boost::asio::detail::socket_ops::inet_pton( - AF_INET, str, &tmp.addr_, 0, ec) <= 0) - return address_v4(); - return tmp; - } + BOOST_ASIO_DECL static address_v4 from_string( + const char* str, boost::system::error_code& ec); /// Create an address from an IP address string in dotted decimal form. - static address_v4 from_string(const std::string& str) - { - return from_string(str.c_str()); - } + BOOST_ASIO_DECL static address_v4 from_string(const std::string& str); /// Create an address from an IP address string in dotted decimal form. - static address_v4 from_string(const std::string& str, - boost::system::error_code& ec) - { - return from_string(str.c_str(), ec); - } + BOOST_ASIO_DECL static address_v4 from_string( + const std::string& str, boost::system::error_code& ec); /// Determine whether the address is a class A address. - bool is_class_a() const - { - return IN_CLASSA(to_ulong()); - } + BOOST_ASIO_DECL bool is_class_a() const; /// Determine whether the address is a class B address. - bool is_class_b() const - { - return IN_CLASSB(to_ulong()); - } + BOOST_ASIO_DECL bool is_class_b() const; /// Determine whether the address is a class C address. - bool is_class_c() const - { - return IN_CLASSC(to_ulong()); - } + BOOST_ASIO_DECL bool is_class_c() const; /// Determine whether the address is a multicast address. - bool is_multicast() const - { - return IN_MULTICAST(to_ulong()); - } + BOOST_ASIO_DECL bool is_multicast() const; /// Compare two addresses for equality. friend bool operator==(const address_v4& a1, const address_v4& a2) @@ -250,23 +166,12 @@ public: /// Obtain an address object that represents the broadcast address that /// corresponds to the specified address and netmask. - static address_v4 broadcast(const address_v4& addr, const address_v4& mask) - { - return address_v4(addr.to_ulong() | ~mask.to_ulong()); - } + BOOST_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. - static address_v4 netmask(const address_v4& addr) - { - if (addr.is_class_a()) - return address_v4(0xFF000000); - if (addr.is_class_b()) - return address_v4(0xFFFF0000); - if (addr.is_class_c()) - return address_v4(0xFFFFFF00); - return address_v4(0xFFFFFFFF); - } + BOOST_ASIO_DECL static address_v4 netmask(const address_v4& addr); private: // The underlying IPv4 address. @@ -289,22 +194,7 @@ private: */ template <typename Elem, typename Traits> std::basic_ostream<Elem, Traits>& operator<<( - std::basic_ostream<Elem, Traits>& os, const address_v4& addr) -{ - boost::system::error_code ec; - std::string s = addr.to_string(ec); - if (ec) - { - if (os.exceptions() & std::ios::failbit) - boost::asio::detail::throw_error(ec); - else - os.setstate(std::ios_base::failbit); - } - else - for (std::string::iterator i = s.begin(); i != s.end(); ++i) - os << os.widen(*i); - return os; -} + std::basic_ostream<Elem, Traits>& os, const address_v4& addr); #endif // !defined(BOOST_NO_IOSTREAM) @@ -314,4 +204,9 @@ std::basic_ostream<Elem, Traits>& operator<<( #include <boost/asio/detail/pop_options.hpp> +#include <boost/asio/ip/impl/address_v4.hpp> +#if defined(BOOST_ASIO_HEADER_ONLY) +# include <boost/asio/ip/impl/address_v4.ipp> +#endif // defined(BOOST_ASIO_HEADER_ONLY) + #endif // BOOST_ASIO_IP_ADDRESS_V4_HPP |