Statistics
| Revision:

root / tmp / org.txm.statsengine.r.core.win32 / res / win32 / library / BH / include / boost / asio / local / basic_endpoint.hpp @ 2486

History | View | Annotate | Download (5.6 kB)

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 BOOST_ASIO_LOCAL_BASIC_ENDPOINT_HPP
13
#define BOOST_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 <boost/asio/detail/config.hpp>
20

    
21
#if defined(BOOST_ASIO_HAS_LOCAL_SOCKETS) \
22
  || defined(GENERATING_DOCUMENTATION)
23

    
24
#include <boost/asio/local/detail/endpoint.hpp>
25

    
26
#if !defined(BOOST_ASIO_NO_IOSTREAM)
27
# include <iosfwd>
28
#endif // !defined(BOOST_ASIO_NO_IOSTREAM)
29

    
30
#include <boost/asio/detail/push_options.hpp>
31

    
32
namespace boost {
33
namespace asio {
34
namespace local {
35

    
36
/// Describes an endpoint for a UNIX socket.
37
/**
38
 * The boost::asio::local::basic_endpoint class template describes an endpoint
39
 * that may be associated with a particular UNIX socket.
40
 *
41
 * @par Thread Safety
42
 * @e Distinct @e objects: Safe.@n
43
 * @e Shared @e objects: Unsafe.
44
 *
45
 * @par Concepts:
46
 * Endpoint.
47
 */
48
template <typename Protocol>
49
class basic_endpoint
50
{
51
public:
52
  /// The protocol type associated with the endpoint.
53
  typedef Protocol protocol_type;
54

    
55
  /// The type of the endpoint structure. This type is dependent on the
56
  /// underlying implementation of the socket layer.
57
#if defined(GENERATING_DOCUMENTATION)
58
  typedef implementation_defined data_type;
59
#else
60
  typedef boost::asio::detail::socket_addr_type data_type;
61
#endif
62

    
63
  /// Default constructor.
64
  basic_endpoint()
65
  {
66
  }
67

    
68
  /// Construct an endpoint using the specified path name.
69
  basic_endpoint(const char* path_name)
70
    : impl_(path_name)
71
  {
72
  }
73

    
74
  /// Construct an endpoint using the specified path name.
75
  basic_endpoint(const std::string& path_name)
76
    : impl_(path_name)
77
  {
78
  }
79

    
80
  /// Copy constructor.
81
  basic_endpoint(const basic_endpoint& other)
82
    : impl_(other.impl_)
83
  {
84
  }
85

    
86
#if defined(BOOST_ASIO_HAS_MOVE)
87
  /// Move constructor.
88
  basic_endpoint(basic_endpoint&& other)
89
    : impl_(other.impl_)
90
  {
91
  }
92
#endif // defined(BOOST_ASIO_HAS_MOVE)
93

    
94
  /// Assign from another endpoint.
95
  basic_endpoint& operator=(const basic_endpoint& other)
96
  {
97
    impl_ = other.impl_;
98
    return *this;
99
  }
100

    
101
#if defined(BOOST_ASIO_HAS_MOVE)
102
  /// Move-assign from another endpoint.
103
  basic_endpoint& operator=(basic_endpoint&& other)
104
  {
105
    impl_ = other.impl_;
106
    return *this;
107
  }
108
#endif // defined(BOOST_ASIO_HAS_MOVE)
109

    
110
  /// The protocol associated with the endpoint.
111
  protocol_type protocol() const
112
  {
113
    return protocol_type();
114
  }
115

    
116
  /// Get the underlying endpoint in the native type.
117
  data_type* data()
118
  {
119
    return impl_.data();
120
  }
121

    
122
  /// Get the underlying endpoint in the native type.
123
  const data_type* data() const
124
  {
125
    return impl_.data();
126
  }
127

    
128
  /// Get the underlying size of the endpoint in the native type.
129
  std::size_t size() const
130
  {
131
    return impl_.size();
132
  }
133

    
134
  /// Set the underlying size of the endpoint in the native type.
135
  void resize(std::size_t new_size)
136
  {
137
    impl_.resize(new_size);
138
  }
139

    
140
  /// Get the capacity of the endpoint in the native type.
141
  std::size_t capacity() const
142
  {
143
    return impl_.capacity();
144
  }
145

    
146
  /// Get the path associated with the endpoint.
147
  std::string path() const
148
  {
149
    return impl_.path();
150
  }
151

    
152
  /// Set the path associated with the endpoint.
153
  void path(const char* p)
154
  {
155
    impl_.path(p);
156
  }
157

    
158
  /// Set the path associated with the endpoint.
159
  void path(const std::string& p)
160
  {
161
    impl_.path(p);
162
  }
163

    
164
  /// Compare two endpoints for equality.
165
  friend bool operator==(const basic_endpoint<Protocol>& e1,
166
      const basic_endpoint<Protocol>& e2)
167
  {
168
    return e1.impl_ == e2.impl_;
169
  }
170

    
171
  /// Compare two endpoints for inequality.
172
  friend bool operator!=(const basic_endpoint<Protocol>& e1,
173
      const basic_endpoint<Protocol>& e2)
174
  {
175
    return !(e1.impl_ == e2.impl_);
176
  }
177

    
178
  /// Compare endpoints for ordering.
179
  friend bool operator<(const basic_endpoint<Protocol>& e1,
180
      const basic_endpoint<Protocol>& e2)
181
  {
182
    return e1.impl_ < e2.impl_;
183
  }
184

    
185
  /// Compare endpoints for ordering.
186
  friend bool operator>(const basic_endpoint<Protocol>& e1,
187
      const basic_endpoint<Protocol>& e2)
188
  {
189
    return e2.impl_ < e1.impl_;
190
  }
191

    
192
  /// Compare endpoints for ordering.
193
  friend bool operator<=(const basic_endpoint<Protocol>& e1,
194
      const basic_endpoint<Protocol>& e2)
195
  {
196
    return !(e2 < e1);
197
  }
198

    
199
  /// Compare endpoints for ordering.
200
  friend bool operator>=(const basic_endpoint<Protocol>& e1,
201
      const basic_endpoint<Protocol>& e2)
202
  {
203
    return !(e1 < e2);
204
  }
205

    
206
private:
207
  // The underlying UNIX domain endpoint.
208
  boost::asio::local::detail::endpoint impl_;
209
};
210

    
211
/// Output an endpoint as a string.
212
/**
213
 * Used to output a human-readable string for a specified endpoint.
214
 *
215
 * @param os The output stream to which the string will be written.
216
 *
217
 * @param endpoint The endpoint to be written.
218
 *
219
 * @return The output stream.
220
 *
221
 * @relates boost::asio::local::basic_endpoint
222
 */
223
template <typename Elem, typename Traits, typename Protocol>
224
std::basic_ostream<Elem, Traits>& operator<<(
225
    std::basic_ostream<Elem, Traits>& os,
226
    const basic_endpoint<Protocol>& endpoint)
227
{
228
  os << endpoint.path();
229
  return os;
230
}
231

    
232
} // namespace local
233
} // namespace asio
234
} // namespace boost
235

    
236
#include <boost/asio/detail/pop_options.hpp>
237

    
238
#endif // defined(BOOST_ASIO_HAS_LOCAL_SOCKETS)
239
       //   || defined(GENERATING_DOCUMENTATION)
240

    
241
#endif // BOOST_ASIO_LOCAL_BASIC_ENDPOINT_HPP