PageRenderTime 23ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 1ms

/Core/Dependencies/Boost/boost/asio/ip/address_v6.hpp

https://bitbucket.org/barakianc/nvidia-physx-and-apex-in-gge
C++ Header | 248 lines | 113 code | 54 blank | 81 comment | 2 complexity | 2c55850e62be5d223890ddff18183b51 MD5 | raw file
  1. //
  2. // ip/address_v6.hpp
  3. // ~~~~~~~~~~~~~~~~~
  4. //
  5. // Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
  6. //
  7. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  8. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  9. //
  10. #ifndef BOOST_ASIO_IP_ADDRESS_V6_HPP
  11. #define BOOST_ASIO_IP_ADDRESS_V6_HPP
  12. #if defined(_MSC_VER) && (_MSC_VER >= 1200)
  13. # pragma once
  14. #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
  15. #include <boost/asio/detail/config.hpp>
  16. #include <string>
  17. #include <boost/asio/detail/array.hpp>
  18. #include <boost/asio/detail/socket_types.hpp>
  19. #include <boost/asio/detail/winsock_init.hpp>
  20. #include <boost/system/error_code.hpp>
  21. #include <boost/asio/ip/address_v4.hpp>
  22. #if !defined(BOOST_NO_IOSTREAM)
  23. # include <iosfwd>
  24. #endif // !defined(BOOST_NO_IOSTREAM)
  25. #include <boost/asio/detail/push_options.hpp>
  26. namespace boost {
  27. namespace asio {
  28. namespace ip {
  29. /// Implements IP version 6 style addresses.
  30. /**
  31. * The boost::asio::ip::address_v6 class provides the ability to use and
  32. * manipulate IP version 6 addresses.
  33. *
  34. * @par Thread Safety
  35. * @e Distinct @e objects: Safe.@n
  36. * @e Shared @e objects: Unsafe.
  37. */
  38. class address_v6
  39. {
  40. public:
  41. /// The type used to represent an address as an array of bytes.
  42. /**
  43. * @note This type is defined in terms of the C++0x template @c std::array
  44. * when it is available. Otherwise, it uses @c boost:array.
  45. */
  46. #if defined(GENERATING_DOCUMENTATION)
  47. typedef array<unsigned char, 16> bytes_type;
  48. #else
  49. typedef boost::asio::detail::array<unsigned char, 16> bytes_type;
  50. #endif
  51. /// Default constructor.
  52. BOOST_ASIO_DECL address_v6();
  53. /// Construct an address from raw bytes and scope ID.
  54. BOOST_ASIO_DECL explicit address_v6(const bytes_type& bytes,
  55. unsigned long scope_id = 0);
  56. /// Copy constructor.
  57. BOOST_ASIO_DECL address_v6(const address_v6& other);
  58. #if defined(BOOST_ASIO_HAS_MOVE)
  59. /// Move constructor.
  60. BOOST_ASIO_DECL address_v6(address_v6&& other);
  61. #endif // defined(BOOST_ASIO_HAS_MOVE)
  62. /// Assign from another address.
  63. BOOST_ASIO_DECL address_v6& operator=(const address_v6& other);
  64. #if defined(BOOST_ASIO_HAS_MOVE)
  65. /// Move-assign from another address.
  66. BOOST_ASIO_DECL address_v6& operator=(address_v6&& other);
  67. #endif // defined(BOOST_ASIO_HAS_MOVE)
  68. /// The scope ID of the address.
  69. /**
  70. * Returns the scope ID associated with the IPv6 address.
  71. */
  72. unsigned long scope_id() const
  73. {
  74. return scope_id_;
  75. }
  76. /// The scope ID of the address.
  77. /**
  78. * Modifies the scope ID associated with the IPv6 address.
  79. */
  80. void scope_id(unsigned long id)
  81. {
  82. scope_id_ = id;
  83. }
  84. /// Get the address in bytes, in network byte order.
  85. BOOST_ASIO_DECL bytes_type to_bytes() const;
  86. /// Get the address as a string.
  87. BOOST_ASIO_DECL std::string to_string() const;
  88. /// Get the address as a string.
  89. BOOST_ASIO_DECL std::string to_string(boost::system::error_code& ec) const;
  90. /// Create an address from an IP address string.
  91. BOOST_ASIO_DECL static address_v6 from_string(const char* str);
  92. /// Create an address from an IP address string.
  93. BOOST_ASIO_DECL static address_v6 from_string(
  94. const char* str, boost::system::error_code& ec);
  95. /// Create an address from an IP address string.
  96. BOOST_ASIO_DECL static address_v6 from_string(const std::string& str);
  97. /// Create an address from an IP address string.
  98. BOOST_ASIO_DECL static address_v6 from_string(
  99. const std::string& str, boost::system::error_code& ec);
  100. /// Converts an IPv4-mapped or IPv4-compatible address to an IPv4 address.
  101. BOOST_ASIO_DECL address_v4 to_v4() const;
  102. /// Determine whether the address is a loopback address.
  103. BOOST_ASIO_DECL bool is_loopback() const;
  104. /// Determine whether the address is unspecified.
  105. BOOST_ASIO_DECL bool is_unspecified() const;
  106. /// Determine whether the address is link local.
  107. BOOST_ASIO_DECL bool is_link_local() const;
  108. /// Determine whether the address is site local.
  109. BOOST_ASIO_DECL bool is_site_local() const;
  110. /// Determine whether the address is a mapped IPv4 address.
  111. BOOST_ASIO_DECL bool is_v4_mapped() const;
  112. /// Determine whether the address is an IPv4-compatible address.
  113. BOOST_ASIO_DECL bool is_v4_compatible() const;
  114. /// Determine whether the address is a multicast address.
  115. BOOST_ASIO_DECL bool is_multicast() const;
  116. /// Determine whether the address is a global multicast address.
  117. BOOST_ASIO_DECL bool is_multicast_global() const;
  118. /// Determine whether the address is a link-local multicast address.
  119. BOOST_ASIO_DECL bool is_multicast_link_local() const;
  120. /// Determine whether the address is a node-local multicast address.
  121. BOOST_ASIO_DECL bool is_multicast_node_local() const;
  122. /// Determine whether the address is a org-local multicast address.
  123. BOOST_ASIO_DECL bool is_multicast_org_local() const;
  124. /// Determine whether the address is a site-local multicast address.
  125. BOOST_ASIO_DECL bool is_multicast_site_local() const;
  126. /// Compare two addresses for equality.
  127. BOOST_ASIO_DECL friend bool operator==(
  128. const address_v6& a1, const address_v6& a2);
  129. /// Compare two addresses for inequality.
  130. friend bool operator!=(const address_v6& a1, const address_v6& a2)
  131. {
  132. return !(a1 == a2);
  133. }
  134. /// Compare addresses for ordering.
  135. BOOST_ASIO_DECL friend bool operator<(
  136. const address_v6& a1, const address_v6& a2);
  137. /// Compare addresses for ordering.
  138. friend bool operator>(const address_v6& a1, const address_v6& a2)
  139. {
  140. return a2 < a1;
  141. }
  142. /// Compare addresses for ordering.
  143. friend bool operator<=(const address_v6& a1, const address_v6& a2)
  144. {
  145. return !(a2 < a1);
  146. }
  147. /// Compare addresses for ordering.
  148. friend bool operator>=(const address_v6& a1, const address_v6& a2)
  149. {
  150. return !(a1 < a2);
  151. }
  152. /// Obtain an address object that represents any address.
  153. static address_v6 any()
  154. {
  155. return address_v6();
  156. }
  157. /// Obtain an address object that represents the loopback address.
  158. BOOST_ASIO_DECL static address_v6 loopback();
  159. /// Create an IPv4-mapped IPv6 address.
  160. BOOST_ASIO_DECL static address_v6 v4_mapped(const address_v4& addr);
  161. /// Create an IPv4-compatible IPv6 address.
  162. BOOST_ASIO_DECL static address_v6 v4_compatible(const address_v4& addr);
  163. private:
  164. // The underlying IPv6 address.
  165. boost::asio::detail::in6_addr_type addr_;
  166. // The scope ID associated with the address.
  167. unsigned long scope_id_;
  168. };
  169. #if !defined(BOOST_NO_IOSTREAM)
  170. /// Output an address as a string.
  171. /**
  172. * Used to output a human-readable string for a specified address.
  173. *
  174. * @param os The output stream to which the string will be written.
  175. *
  176. * @param addr The address to be written.
  177. *
  178. * @return The output stream.
  179. *
  180. * @relates boost::asio::ip::address_v6
  181. */
  182. template <typename Elem, typename Traits>
  183. std::basic_ostream<Elem, Traits>& operator<<(
  184. std::basic_ostream<Elem, Traits>& os, const address_v6& addr);
  185. #endif // !defined(BOOST_NO_IOSTREAM)
  186. } // namespace ip
  187. } // namespace asio
  188. } // namespace boost
  189. #include <boost/asio/detail/pop_options.hpp>
  190. #include <boost/asio/ip/impl/address_v6.hpp>
  191. #if defined(BOOST_ASIO_HEADER_ONLY)
  192. # include <boost/asio/ip/impl/address_v6.ipp>
  193. #endif // defined(BOOST_ASIO_HEADER_ONLY)
  194. #endif // BOOST_ASIO_IP_ADDRESS_V6_HPP