Realistic 3D camera system
3D camera system components
address_v6.hpp
Go to the documentation of this file.
1 //
2 // ip/address_v6.hpp
3 // ~~~~~~~~~~~~~~~~~
4 //
5 // Copyright (c) 2003-2015 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 
11 #ifndef ASIO_IP_ADDRESS_V6_HPP
12 #define ASIO_IP_ADDRESS_V6_HPP
13 
14 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 # pragma once
16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 
18 #include "asio/detail/config.hpp"
19 #include <string>
20 #include "asio/detail/array.hpp"
23 #include "asio/error_code.hpp"
24 #include "asio/ip/address_v4.hpp"
25 
26 #if !defined(ASIO_NO_IOSTREAM)
27 # include <iosfwd>
28 #endif // !defined(ASIO_NO_IOSTREAM)
29 
31 
32 namespace asio {
33 namespace ip {
34 
36 
45 {
46 public:
48 
52 #if defined(GENERATING_DOCUMENTATION)
53  typedef array<unsigned char, 16> bytes_type;
54 #else
56 #endif
57 
60 
62  ASIO_DECL explicit address_v6(const bytes_type& bytes,
63  unsigned long scope_id = 0);
64 
66  ASIO_DECL address_v6(const address_v6& other);
67 
68 #if defined(ASIO_HAS_MOVE)
71 #endif // defined(ASIO_HAS_MOVE)
72 
75 
76 #if defined(ASIO_HAS_MOVE)
79 #endif // defined(ASIO_HAS_MOVE)
80 
82 
85  unsigned long scope_id() const
86  {
87  return scope_id_;
88  }
89 
91 
94  void scope_id(unsigned long id)
95  {
96  scope_id_ = id;
97  }
98 
100  ASIO_DECL bytes_type to_bytes() const;
101 
103  ASIO_DECL std::string to_string() const;
104 
106  ASIO_DECL std::string to_string(asio::error_code& ec) const;
107 
109  ASIO_DECL static address_v6 from_string(const char* str);
110 
113  const char* str, asio::error_code& ec);
114 
116  ASIO_DECL static address_v6 from_string(const std::string& str);
117 
120  const std::string& str, asio::error_code& ec);
121 
123  ASIO_DECL address_v4 to_v4() const;
124 
126  ASIO_DECL bool is_loopback() const;
127 
129  ASIO_DECL bool is_unspecified() const;
130 
132  ASIO_DECL bool is_link_local() const;
133 
135  ASIO_DECL bool is_site_local() const;
136 
138  ASIO_DECL bool is_v4_mapped() const;
139 
141  ASIO_DECL bool is_v4_compatible() const;
142 
144  ASIO_DECL bool is_multicast() const;
145 
147  ASIO_DECL bool is_multicast_global() const;
148 
150  ASIO_DECL bool is_multicast_link_local() const;
151 
153  ASIO_DECL bool is_multicast_node_local() const;
154 
156  ASIO_DECL bool is_multicast_org_local() const;
157 
159  ASIO_DECL bool is_multicast_site_local() const;
160 
162  ASIO_DECL friend bool operator==(
163  const address_v6& a1, const address_v6& a2);
164 
166  friend bool operator!=(const address_v6& a1, const address_v6& a2)
167  {
168  return !(a1 == a2);
169  }
170 
172  ASIO_DECL friend bool operator<(
173  const address_v6& a1, const address_v6& a2);
174 
176  friend bool operator>(const address_v6& a1, const address_v6& a2)
177  {
178  return a2 < a1;
179  }
180 
182  friend bool operator<=(const address_v6& a1, const address_v6& a2)
183  {
184  return !(a2 < a1);
185  }
186 
188  friend bool operator>=(const address_v6& a1, const address_v6& a2)
189  {
190  return !(a1 < a2);
191  }
192 
194  static address_v6 any()
195  {
196  return address_v6();
197  }
198 
200  ASIO_DECL static address_v6 loopback();
201 
203  ASIO_DECL static address_v6 v4_mapped(const address_v4& addr);
204 
206  ASIO_DECL static address_v6 v4_compatible(const address_v4& addr);
207 
208 private:
209  // The underlying IPv6 address.
211 
212  // The scope ID associated with the address.
213  unsigned long scope_id_;
214 };
215 
216 #if !defined(ASIO_NO_IOSTREAM)
217 
219 
230 template <typename Elem, typename Traits>
231 std::basic_ostream<Elem, Traits>& operator<<(
232  std::basic_ostream<Elem, Traits>& os, const address_v6& addr);
233 
234 #endif // !defined(ASIO_NO_IOSTREAM)
235 
236 } // namespace ip
237 } // namespace asio
238 
240 
242 #if defined(ASIO_HEADER_ONLY)
243 # include "asio/ip/impl/address_v6.ipp"
244 #endif // defined(ASIO_HEADER_ONLY)
245 
246 #endif // ASIO_IP_ADDRESS_V6_HPP
ASIO_DECL bool is_multicast_link_local() const
Determine whether the address is a link-local multicast address.
Definition: address_v6.ipp:230
ASIO_DECL friend bool operator==(const address_v6 &a1, const address_v6 &a2)
Compare two addresses for equality.
Definition: address_v6.ipp:250
ASIO_DECL bool is_multicast() const
Determine whether the address is a multicast address.
Definition: address_v6.ipp:220
ASIO_DECL address_v6 & operator=(const address_v6 &other)
Assign from another address.
Definition: address_v6.ipp:72
ASIO_DECL bool is_multicast_node_local() const
Determine whether the address is a node-local multicast address.
Definition: address_v6.ipp:235
friend bool operator>=(const address_v6 &a1, const address_v6 &a2)
Compare addresses for ordering.
Definition: address_v6.hpp:188
static ASIO_DECL address_v6 v4_mapped(const address_v4 &addr)
Create an IPv4-mapped IPv6 address.
Definition: address_v6.ipp:277
Implements IP version 4 style addresses.
Definition: address_v4.hpp:43
asio::detail::array< unsigned char, 16 > bytes_type
The type used to represent an address as an array of bytes.
Definition: address_v6.hpp:55
ASIO_DECL bool is_multicast_org_local() const
Determine whether the address is a org-local multicast address.
Definition: address_v6.ipp:240
ASIO_DECL bool is_site_local() const
Determine whether the address is site local.
Definition: address_v6.ipp:191
ASIO_DECL bytes_type to_bytes() const
Get the address in bytes, in network byte order.
Definition: address_v6.ipp:88
static address_v6 any()
Obtain an address object that represents any address.
Definition: address_v6.hpp:194
ASIO_DECL address_v6()
Default constructor.
Definition: address_v6.ipp:33
static ASIO_DECL address_v6 from_string(const char *str)
Create an address from an IP address string.
Definition: address_v6.ipp:120
friend bool operator<=(const address_v6 &a1, const address_v6 &a2)
Compare addresses for ordering.
Definition: address_v6.hpp:182
ASIO_DECL bool is_v4_compatible() const
Determine whether the address is an IPv4-compatible address.
Definition: address_v6.ipp:206
unsigned long scope_id() const
The scope ID of the address.
Definition: address_v6.hpp:85
friend bool operator!=(const address_v6 &a1, const address_v6 &a2)
Compare two addresses for inequality.
Definition: address_v6.hpp:166
friend bool operator>(const address_v6 &a1, const address_v6 &a2)
Compare addresses for ordering.
Definition: address_v6.hpp:176
void scope_id(unsigned long id)
The scope ID of the address.
Definition: address_v6.hpp:94
in6_addr in6_addr_type
Class to represent an error code value.
Definition: error_code.hpp:80
Implements IP version 6 style addresses.
Definition: address_v6.hpp:44
#define ASIO_DECL
Definition: config.hpp:43
ASIO_DECL address_v4 to_v4() const
Converts an IPv4-mapped or IPv4-compatible address to an IPv4 address.
Definition: address_v6.ipp:149
ASIO_DECL bool is_loopback() const
Determine whether the address is a loopback address.
Definition: address_v6.ipp:162
ASIO_DECL bool is_multicast_global() const
Determine whether the address is a global multicast address.
Definition: address_v6.ipp:225
ASIO_DECL std::string to_string() const
Get the address as a string.
Definition: address_v6.ipp:100
ASIO_DECL bool is_multicast_site_local() const
Determine whether the address is a site-local multicast address.
Definition: address_v6.ipp:245
std::basic_ostream< Elem, Traits > & operator<<(std::basic_ostream< Elem, Traits > &os, const address_v6 &addr)
Output an address as a string.
Definition: address_v6.hpp:28
ASIO_DECL friend bool operator<(const address_v6 &a1, const address_v6 &a2)
Compare addresses for ordering.
Definition: address_v6.ipp:258
ASIO_DECL bool is_v4_mapped() const
Determine whether the address is a mapped IPv4 address.
Definition: address_v6.ipp:196
ASIO_DECL bool is_unspecified() const
Determine whether the address is unspecified.
Definition: address_v6.ipp:174
static ASIO_DECL address_v6 loopback()
Obtain an address object that represents the loopback address.
Definition: address_v6.ipp:270
ASIO_DECL bool is_link_local() const
Determine whether the address is link local.
Definition: address_v6.ipp:186
static ASIO_DECL address_v6 v4_compatible(const address_v4 &addr)
Create an IPv4-compatible IPv6 address.
Definition: address_v6.ipp:285