annotate DEPENDENCIES/generic/include/boost/asio/ip/address_v4.hpp @ 125:34e428693f5d vext

Vext -> Repoint
author Chris Cannam
date Thu, 14 Jun 2018 11:15:39 +0100
parents c530137014c0
children
rev   line source
Chris@16 1 //
Chris@16 2 // ip/address_v4.hpp
Chris@16 3 // ~~~~~~~~~~~~~~~~~
Chris@16 4 //
Chris@101 5 // Copyright (c) 2003-2015 Christopher M. Kohlhoff (chris at kohlhoff dot com)
Chris@16 6 //
Chris@16 7 // Distributed under the Boost Software License, Version 1.0. (See accompanying
Chris@16 8 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Chris@16 9 //
Chris@16 10
Chris@16 11 #ifndef BOOST_ASIO_IP_ADDRESS_V4_HPP
Chris@16 12 #define BOOST_ASIO_IP_ADDRESS_V4_HPP
Chris@16 13
Chris@16 14 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
Chris@16 15 # pragma once
Chris@16 16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
Chris@16 17
Chris@16 18 #include <boost/asio/detail/config.hpp>
Chris@16 19 #include <string>
Chris@16 20 #include <boost/asio/detail/array.hpp>
Chris@16 21 #include <boost/asio/detail/socket_types.hpp>
Chris@16 22 #include <boost/asio/detail/winsock_init.hpp>
Chris@16 23 #include <boost/system/error_code.hpp>
Chris@16 24
Chris@16 25 #if !defined(BOOST_ASIO_NO_IOSTREAM)
Chris@16 26 # include <iosfwd>
Chris@16 27 #endif // !defined(BOOST_ASIO_NO_IOSTREAM)
Chris@16 28
Chris@16 29 #include <boost/asio/detail/push_options.hpp>
Chris@16 30
Chris@16 31 namespace boost {
Chris@16 32 namespace asio {
Chris@16 33 namespace ip {
Chris@16 34
Chris@16 35 /// Implements IP version 4 style addresses.
Chris@16 36 /**
Chris@16 37 * The boost::asio::ip::address_v4 class provides the ability to use and
Chris@16 38 * manipulate IP version 4 addresses.
Chris@16 39 *
Chris@16 40 * @par Thread Safety
Chris@16 41 * @e Distinct @e objects: Safe.@n
Chris@16 42 * @e Shared @e objects: Unsafe.
Chris@16 43 */
Chris@16 44 class address_v4
Chris@16 45 {
Chris@16 46 public:
Chris@16 47 /// The type used to represent an address as an array of bytes.
Chris@16 48 /**
Chris@16 49 * @note This type is defined in terms of the C++0x template @c std::array
Chris@16 50 * when it is available. Otherwise, it uses @c boost:array.
Chris@16 51 */
Chris@16 52 #if defined(GENERATING_DOCUMENTATION)
Chris@16 53 typedef array<unsigned char, 4> bytes_type;
Chris@16 54 #else
Chris@16 55 typedef boost::asio::detail::array<unsigned char, 4> bytes_type;
Chris@16 56 #endif
Chris@16 57
Chris@16 58 /// Default constructor.
Chris@16 59 address_v4()
Chris@16 60 {
Chris@16 61 addr_.s_addr = 0;
Chris@16 62 }
Chris@16 63
Chris@16 64 /// Construct an address from raw bytes.
Chris@16 65 BOOST_ASIO_DECL explicit address_v4(const bytes_type& bytes);
Chris@16 66
Chris@16 67 /// Construct an address from a unsigned long in host byte order.
Chris@16 68 BOOST_ASIO_DECL explicit address_v4(unsigned long addr);
Chris@16 69
Chris@16 70 /// Copy constructor.
Chris@16 71 address_v4(const address_v4& other)
Chris@16 72 : addr_(other.addr_)
Chris@16 73 {
Chris@16 74 }
Chris@16 75
Chris@16 76 #if defined(BOOST_ASIO_HAS_MOVE)
Chris@16 77 /// Move constructor.
Chris@16 78 address_v4(address_v4&& other)
Chris@16 79 : addr_(other.addr_)
Chris@16 80 {
Chris@16 81 }
Chris@16 82 #endif // defined(BOOST_ASIO_HAS_MOVE)
Chris@16 83
Chris@16 84 /// Assign from another address.
Chris@16 85 address_v4& operator=(const address_v4& other)
Chris@16 86 {
Chris@16 87 addr_ = other.addr_;
Chris@16 88 return *this;
Chris@16 89 }
Chris@16 90
Chris@16 91 #if defined(BOOST_ASIO_HAS_MOVE)
Chris@16 92 /// Move-assign from another address.
Chris@16 93 address_v4& operator=(address_v4&& other)
Chris@16 94 {
Chris@16 95 addr_ = other.addr_;
Chris@16 96 return *this;
Chris@16 97 }
Chris@16 98 #endif // defined(BOOST_ASIO_HAS_MOVE)
Chris@16 99
Chris@16 100 /// Get the address in bytes, in network byte order.
Chris@16 101 BOOST_ASIO_DECL bytes_type to_bytes() const;
Chris@16 102
Chris@16 103 /// Get the address as an unsigned long in host byte order
Chris@16 104 BOOST_ASIO_DECL unsigned long to_ulong() const;
Chris@16 105
Chris@16 106 /// Get the address as a string in dotted decimal format.
Chris@16 107 BOOST_ASIO_DECL std::string to_string() const;
Chris@16 108
Chris@16 109 /// Get the address as a string in dotted decimal format.
Chris@16 110 BOOST_ASIO_DECL std::string to_string(boost::system::error_code& ec) const;
Chris@16 111
Chris@16 112 /// Create an address from an IP address string in dotted decimal form.
Chris@16 113 BOOST_ASIO_DECL static address_v4 from_string(const char* str);
Chris@16 114
Chris@16 115 /// Create an address from an IP address string in dotted decimal form.
Chris@16 116 BOOST_ASIO_DECL static address_v4 from_string(
Chris@16 117 const char* str, boost::system::error_code& ec);
Chris@16 118
Chris@16 119 /// Create an address from an IP address string in dotted decimal form.
Chris@16 120 BOOST_ASIO_DECL static address_v4 from_string(const std::string& str);
Chris@16 121
Chris@16 122 /// Create an address from an IP address string in dotted decimal form.
Chris@16 123 BOOST_ASIO_DECL static address_v4 from_string(
Chris@16 124 const std::string& str, boost::system::error_code& ec);
Chris@16 125
Chris@16 126 /// Determine whether the address is a loopback address.
Chris@16 127 BOOST_ASIO_DECL bool is_loopback() const;
Chris@16 128
Chris@16 129 /// Determine whether the address is unspecified.
Chris@16 130 BOOST_ASIO_DECL bool is_unspecified() const;
Chris@16 131
Chris@16 132 /// Determine whether the address is a class A address.
Chris@16 133 BOOST_ASIO_DECL bool is_class_a() const;
Chris@16 134
Chris@16 135 /// Determine whether the address is a class B address.
Chris@16 136 BOOST_ASIO_DECL bool is_class_b() const;
Chris@16 137
Chris@16 138 /// Determine whether the address is a class C address.
Chris@16 139 BOOST_ASIO_DECL bool is_class_c() const;
Chris@16 140
Chris@16 141 /// Determine whether the address is a multicast address.
Chris@16 142 BOOST_ASIO_DECL bool is_multicast() const;
Chris@16 143
Chris@16 144 /// Compare two addresses for equality.
Chris@16 145 friend bool operator==(const address_v4& a1, const address_v4& a2)
Chris@16 146 {
Chris@16 147 return a1.addr_.s_addr == a2.addr_.s_addr;
Chris@16 148 }
Chris@16 149
Chris@16 150 /// Compare two addresses for inequality.
Chris@16 151 friend bool operator!=(const address_v4& a1, const address_v4& a2)
Chris@16 152 {
Chris@16 153 return a1.addr_.s_addr != a2.addr_.s_addr;
Chris@16 154 }
Chris@16 155
Chris@16 156 /// Compare addresses for ordering.
Chris@16 157 friend bool operator<(const address_v4& a1, const address_v4& a2)
Chris@16 158 {
Chris@16 159 return a1.to_ulong() < a2.to_ulong();
Chris@16 160 }
Chris@16 161
Chris@16 162 /// Compare addresses for ordering.
Chris@16 163 friend bool operator>(const address_v4& a1, const address_v4& a2)
Chris@16 164 {
Chris@16 165 return a1.to_ulong() > a2.to_ulong();
Chris@16 166 }
Chris@16 167
Chris@16 168 /// Compare addresses for ordering.
Chris@16 169 friend bool operator<=(const address_v4& a1, const address_v4& a2)
Chris@16 170 {
Chris@16 171 return a1.to_ulong() <= a2.to_ulong();
Chris@16 172 }
Chris@16 173
Chris@16 174 /// Compare addresses for ordering.
Chris@16 175 friend bool operator>=(const address_v4& a1, const address_v4& a2)
Chris@16 176 {
Chris@16 177 return a1.to_ulong() >= a2.to_ulong();
Chris@16 178 }
Chris@16 179
Chris@16 180 /// Obtain an address object that represents any address.
Chris@16 181 static address_v4 any()
Chris@16 182 {
Chris@16 183 return address_v4();
Chris@16 184 }
Chris@16 185
Chris@16 186 /// Obtain an address object that represents the loopback address.
Chris@16 187 static address_v4 loopback()
Chris@16 188 {
Chris@16 189 return address_v4(0x7F000001);
Chris@16 190 }
Chris@16 191
Chris@16 192 /// Obtain an address object that represents the broadcast address.
Chris@16 193 static address_v4 broadcast()
Chris@16 194 {
Chris@16 195 return address_v4(0xFFFFFFFF);
Chris@16 196 }
Chris@16 197
Chris@16 198 /// Obtain an address object that represents the broadcast address that
Chris@16 199 /// corresponds to the specified address and netmask.
Chris@16 200 BOOST_ASIO_DECL static address_v4 broadcast(
Chris@16 201 const address_v4& addr, const address_v4& mask);
Chris@16 202
Chris@16 203 /// Obtain the netmask that corresponds to the address, based on its address
Chris@16 204 /// class.
Chris@16 205 BOOST_ASIO_DECL static address_v4 netmask(const address_v4& addr);
Chris@16 206
Chris@16 207 private:
Chris@16 208 // The underlying IPv4 address.
Chris@16 209 boost::asio::detail::in4_addr_type addr_;
Chris@16 210 };
Chris@16 211
Chris@16 212 #if !defined(BOOST_ASIO_NO_IOSTREAM)
Chris@16 213
Chris@16 214 /// Output an address as a string.
Chris@16 215 /**
Chris@16 216 * Used to output a human-readable string for a specified address.
Chris@16 217 *
Chris@16 218 * @param os The output stream to which the string will be written.
Chris@16 219 *
Chris@16 220 * @param addr The address to be written.
Chris@16 221 *
Chris@16 222 * @return The output stream.
Chris@16 223 *
Chris@16 224 * @relates boost::asio::ip::address_v4
Chris@16 225 */
Chris@16 226 template <typename Elem, typename Traits>
Chris@16 227 std::basic_ostream<Elem, Traits>& operator<<(
Chris@16 228 std::basic_ostream<Elem, Traits>& os, const address_v4& addr);
Chris@16 229
Chris@16 230 #endif // !defined(BOOST_ASIO_NO_IOSTREAM)
Chris@16 231
Chris@16 232 } // namespace ip
Chris@16 233 } // namespace asio
Chris@16 234 } // namespace boost
Chris@16 235
Chris@16 236 #include <boost/asio/detail/pop_options.hpp>
Chris@16 237
Chris@16 238 #include <boost/asio/ip/impl/address_v4.hpp>
Chris@16 239 #if defined(BOOST_ASIO_HEADER_ONLY)
Chris@16 240 # include <boost/asio/ip/impl/address_v4.ipp>
Chris@16 241 #endif // defined(BOOST_ASIO_HEADER_ONLY)
Chris@16 242
Chris@16 243 #endif // BOOST_ASIO_IP_ADDRESS_V4_HPP