Realistic 3D camera system
3D camera system components
basic_endpoint.hpp
Go to the documentation of this file.
1 //
2 // local/basic_endpoint.hpp
3 // ~~~~~~~~~~~~~~~~~~~~~~~~
4 //
5 // Copyright (c) 2003-2015 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 // Derived from a public domain implementation written by Daniel Casimiro.
7 //
8 // Distributed under the Boost Software License, Version 1.0. (See accompanying
9 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
10 //
11 
12 #ifndef ASIO_LOCAL_BASIC_ENDPOINT_HPP
13 #define ASIO_LOCAL_BASIC_ENDPOINT_HPP
14 
15 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
16 # pragma once
17 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
18 
19 #include "asio/detail/config.hpp"
20 
21 #if defined(ASIO_HAS_LOCAL_SOCKETS) \
22  || defined(GENERATING_DOCUMENTATION)
23 
25 
26 #if !defined(ASIO_NO_IOSTREAM)
27 # include <iosfwd>
28 #endif // !defined(ASIO_NO_IOSTREAM)
29 
31 
32 namespace asio {
33 namespace local {
34 
36 
47 template <typename Protocol>
48 class basic_endpoint
49 {
50 public:
52  typedef Protocol protocol_type;
53 
56 #if defined(GENERATING_DOCUMENTATION)
57  typedef implementation_defined data_type;
58 #else
59  typedef asio::detail::socket_addr_type data_type;
60 #endif
61 
63  basic_endpoint()
64  {
65  }
66 
68  basic_endpoint(const char* path_name)
69  : impl_(path_name)
70  {
71  }
72 
74  basic_endpoint(const std::string& path_name)
75  : impl_(path_name)
76  {
77  }
78 
80  basic_endpoint(const basic_endpoint& other)
81  : impl_(other.impl_)
82  {
83  }
84 
85 #if defined(ASIO_HAS_MOVE)
86  basic_endpoint(basic_endpoint&& other)
88  : impl_(other.impl_)
89  {
90  }
91 #endif // defined(ASIO_HAS_MOVE)
92 
94  basic_endpoint& operator=(const basic_endpoint& other)
95  {
96  impl_ = other.impl_;
97  return *this;
98  }
99 
100 #if defined(ASIO_HAS_MOVE)
101  basic_endpoint& operator=(basic_endpoint&& other)
103  {
104  impl_ = other.impl_;
105  return *this;
106  }
107 #endif // defined(ASIO_HAS_MOVE)
108 
110  protocol_type protocol() const
111  {
112  return protocol_type();
113  }
114 
116  data_type* data()
117  {
118  return impl_.data();
119  }
120 
122  const data_type* data() const
123  {
124  return impl_.data();
125  }
126 
128  std::size_t size() const
129  {
130  return impl_.size();
131  }
132 
134  void resize(std::size_t new_size)
135  {
136  impl_.resize(new_size);
137  }
138 
140  std::size_t capacity() const
141  {
142  return impl_.capacity();
143  }
144 
146  std::string path() const
147  {
148  return impl_.path();
149  }
150 
152  void path(const char* p)
153  {
154  impl_.path(p);
155  }
156 
158  void path(const std::string& p)
159  {
160  impl_.path(p);
161  }
162 
164  friend bool operator==(const basic_endpoint<Protocol>& e1,
165  const basic_endpoint<Protocol>& e2)
166  {
167  return e1.impl_ == e2.impl_;
168  }
169 
171  friend bool operator!=(const basic_endpoint<Protocol>& e1,
172  const basic_endpoint<Protocol>& e2)
173  {
174  return !(e1.impl_ == e2.impl_);
175  }
176 
178  friend bool operator<(const basic_endpoint<Protocol>& e1,
179  const basic_endpoint<Protocol>& e2)
180  {
181  return e1.impl_ < e2.impl_;
182  }
183 
185  friend bool operator>(const basic_endpoint<Protocol>& e1,
186  const basic_endpoint<Protocol>& e2)
187  {
188  return e2.impl_ < e1.impl_;
189  }
190 
192  friend bool operator<=(const basic_endpoint<Protocol>& e1,
193  const basic_endpoint<Protocol>& e2)
194  {
195  return !(e2 < e1);
196  }
197 
199  friend bool operator>=(const basic_endpoint<Protocol>& e1,
200  const basic_endpoint<Protocol>& e2)
201  {
202  return !(e1 < e2);
203  }
204 
205 private:
206  // The underlying UNIX domain endpoint.
207  asio::local::detail::endpoint impl_;
208 };
209 
211 
222 template <typename Elem, typename Traits, typename Protocol>
223 std::basic_ostream<Elem, Traits>& operator<<(
224  std::basic_ostream<Elem, Traits>& os,
225  const basic_endpoint<Protocol>& endpoint)
226 {
227  os << endpoint.path();
228  return os;
229 }
230 
231 } // namespace local
232 } // namespace asio
233 
235 
236 #endif // defined(ASIO_HAS_LOCAL_SOCKETS)
237  // || defined(GENERATING_DOCUMENTATION)
238 
239 #endif // ASIO_LOCAL_BASIC_ENDPOINT_HPP
std::basic_ostream< Elem, Traits > & operator<<(std::basic_ostream< Elem, Traits > &os, const error_code &ec)
Output an error code.
Definition: error_code.hpp:169
sockaddr socket_addr_type
bool operator==(const endpoint &e1, const endpoint &e2)
Definition: endpoint.ipp:59