Realistic 3D camera system
3D camera system components
address.hpp
Go to the documentation of this file.
1 //
2 // ip/address.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_HPP
12 #define ASIO_IP_ADDRESS_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/error_code.hpp"
21 #include "asio/ip/address_v4.hpp"
22 #include "asio/ip/address_v6.hpp"
23 
24 #if !defined(ASIO_NO_IOSTREAM)
25 # include <iosfwd>
26 #endif // !defined(ASIO_NO_IOSTREAM)
27 
29 
30 namespace asio {
31 namespace ip {
32 
34 
42 class address
43 {
44 public:
47 
49  ASIO_DECL address(const asio::ip::address_v4& ipv4_address);
50 
52  ASIO_DECL address(const asio::ip::address_v6& ipv6_address);
53 
55  ASIO_DECL address(const address& other);
56 
57 #if defined(ASIO_HAS_MOVE)
58  ASIO_DECL address(address&& other);
60 #endif // defined(ASIO_HAS_MOVE)
61 
63  ASIO_DECL address& operator=(const address& other);
64 
65 #if defined(ASIO_HAS_MOVE)
66  ASIO_DECL address& operator=(address&& other);
68 #endif // defined(ASIO_HAS_MOVE)
69 
71  ASIO_DECL address& operator=(
72  const asio::ip::address_v4& ipv4_address);
73 
75  ASIO_DECL address& operator=(
76  const asio::ip::address_v6& ipv6_address);
77 
79  bool is_v4() const
80  {
81  return type_ == ipv4;
82  }
83 
85  bool is_v6() const
86  {
87  return type_ == ipv6;
88  }
89 
92 
95 
97  ASIO_DECL std::string to_string() const;
98 
100  ASIO_DECL std::string to_string(asio::error_code& ec) const;
101 
104  ASIO_DECL static address from_string(const char* str);
105 
108  ASIO_DECL static address from_string(
109  const char* str, asio::error_code& ec);
110 
113  ASIO_DECL static address from_string(const std::string& str);
114 
117  ASIO_DECL static address from_string(
118  const std::string& str, asio::error_code& ec);
119 
121  ASIO_DECL bool is_loopback() const;
122 
124  ASIO_DECL bool is_unspecified() const;
125 
127  ASIO_DECL bool is_multicast() const;
128 
130  ASIO_DECL friend bool operator==(const address& a1, const address& a2);
131 
133  friend bool operator!=(const address& a1, const address& a2)
134  {
135  return !(a1 == a2);
136  }
137 
139  ASIO_DECL friend bool operator<(const address& a1, const address& a2);
140 
142  friend bool operator>(const address& a1, const address& a2)
143  {
144  return a2 < a1;
145  }
146 
148  friend bool operator<=(const address& a1, const address& a2)
149  {
150  return !(a2 < a1);
151  }
152 
154  friend bool operator>=(const address& a1, const address& a2)
155  {
156  return !(a1 < a2);
157  }
158 
159 private:
160  // The type of the address.
161  enum { ipv4, ipv6 } type_;
162 
163  // The underlying IPv4 address.
164  asio::ip::address_v4 ipv4_address_;
165 
166  // The underlying IPv6 address.
167  asio::ip::address_v6 ipv6_address_;
168 };
169 
170 #if !defined(ASIO_NO_IOSTREAM)
171 
173 
184 template <typename Elem, typename Traits>
185 std::basic_ostream<Elem, Traits>& operator<<(
186  std::basic_ostream<Elem, Traits>& os, const address& addr);
187 
188 #endif // !defined(ASIO_NO_IOSTREAM)
189 
190 } // namespace ip
191 } // namespace asio
192 
194 
195 #include "asio/ip/impl/address.hpp"
196 #if defined(ASIO_HEADER_ONLY)
197 # include "asio/ip/impl/address.ipp"
198 #endif // defined(ASIO_HEADER_ONLY)
199 
200 #endif // ASIO_IP_ADDRESS_HPP
friend bool operator<=(const address &a1, const address &a2)
Compare addresses for ordering.
Definition: address.hpp:148
ASIO_DECL bool is_loopback() const
Determine whether the address is a loopback address.
Definition: address.ipp:180
ASIO_DECL std::string to_string() const
Get the address as a string in dotted decimal format.
Definition: address.ipp:122
ASIO_DECL friend bool operator==(const address &a1, const address &a2)
Compare two addresses for equality.
Definition: address.ipp:201
friend bool operator>(const address &a1, const address &a2)
Compare addresses for ordering.
Definition: address.hpp:142
ASIO_DECL friend bool operator<(const address &a1, const address &a2)
Compare addresses for ordering.
Definition: address.ipp:210
std::basic_ostream< Elem, Traits > & operator<<(std::basic_ostream< Elem, Traits > &os, const address &addr)
Output an address as a string.
Definition: address.hpp:28
Implements IP version 4 style addresses.
Definition: address_v4.hpp:43
static ASIO_DECL address from_string(const char *str)
Definition: address.ipp:136
ASIO_DECL asio::ip::address_v6 to_v6() const
Get the address as an IP version 6 address.
Definition: address.ipp:112
ASIO_DECL address & operator=(const address &other)
Assign from another address.
Definition: address.ipp:68
ASIO_DECL asio::ip::address_v4 to_v4() const
Get the address as an IP version 4 address.
Definition: address.ipp:102
friend bool operator!=(const address &a1, const address &a2)
Compare two addresses for inequality.
Definition: address.hpp:133
Implements version-independent IP addresses.
Definition: address.hpp:42
ASIO_DECL address()
Default constructor.
Definition: address.ipp:31
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 bool is_unspecified() const
Determine whether the address is unspecified.
Definition: address.ipp:187
bool is_v4() const
Get whether the address is an IP version 4 address.
Definition: address.hpp:79
bool is_v6() const
Get whether the address is an IP version 6 address.
Definition: address.hpp:85
friend bool operator>=(const address &a1, const address &a2)
Compare addresses for ordering.
Definition: address.hpp:154
ASIO_DECL bool is_multicast() const
Determine whether the address is a multicast address.
Definition: address.ipp:194