annotate DEPENDENCIES/generic/include/boost/asio/local/basic_endpoint.hpp @ 125:34e428693f5d vext

Vext -> Repoint
author Chris Cannam
date Thu, 14 Jun 2018 11:15:39 +0100
parents c530137014c0
children
rev   line source
Chris@16 1 //
Chris@16 2 // local/basic_endpoint.hpp
Chris@16 3 // ~~~~~~~~~~~~~~~~~~~~~~~~
Chris@16 4 //
Chris@101 5 // Copyright (c) 2003-2015 Christopher M. Kohlhoff (chris at kohlhoff dot com)
Chris@16 6 // Derived from a public domain implementation written by Daniel Casimiro.
Chris@16 7 //
Chris@16 8 // Distributed under the Boost Software License, Version 1.0. (See accompanying
Chris@16 9 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Chris@16 10 //
Chris@16 11
Chris@16 12 #ifndef BOOST_ASIO_LOCAL_BASIC_ENDPOINT_HPP
Chris@16 13 #define BOOST_ASIO_LOCAL_BASIC_ENDPOINT_HPP
Chris@16 14
Chris@16 15 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
Chris@16 16 # pragma once
Chris@16 17 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
Chris@16 18
Chris@16 19 #include <boost/asio/detail/config.hpp>
Chris@16 20
Chris@16 21 #if defined(BOOST_ASIO_HAS_LOCAL_SOCKETS) \
Chris@16 22 || defined(GENERATING_DOCUMENTATION)
Chris@16 23
Chris@16 24 #include <boost/asio/local/detail/endpoint.hpp>
Chris@16 25
Chris@16 26 #if !defined(BOOST_ASIO_NO_IOSTREAM)
Chris@16 27 # include <iosfwd>
Chris@16 28 #endif // !defined(BOOST_ASIO_NO_IOSTREAM)
Chris@16 29
Chris@16 30 #include <boost/asio/detail/push_options.hpp>
Chris@16 31
Chris@16 32 namespace boost {
Chris@16 33 namespace asio {
Chris@16 34 namespace local {
Chris@16 35
Chris@16 36 /// Describes an endpoint for a UNIX socket.
Chris@16 37 /**
Chris@16 38 * The boost::asio::local::basic_endpoint class template describes an endpoint
Chris@16 39 * that may be associated with a particular UNIX socket.
Chris@16 40 *
Chris@16 41 * @par Thread Safety
Chris@16 42 * @e Distinct @e objects: Safe.@n
Chris@16 43 * @e Shared @e objects: Unsafe.
Chris@16 44 *
Chris@16 45 * @par Concepts:
Chris@16 46 * Endpoint.
Chris@16 47 */
Chris@16 48 template <typename Protocol>
Chris@16 49 class basic_endpoint
Chris@16 50 {
Chris@16 51 public:
Chris@16 52 /// The protocol type associated with the endpoint.
Chris@16 53 typedef Protocol protocol_type;
Chris@16 54
Chris@16 55 /// The type of the endpoint structure. This type is dependent on the
Chris@16 56 /// underlying implementation of the socket layer.
Chris@16 57 #if defined(GENERATING_DOCUMENTATION)
Chris@16 58 typedef implementation_defined data_type;
Chris@16 59 #else
Chris@16 60 typedef boost::asio::detail::socket_addr_type data_type;
Chris@16 61 #endif
Chris@16 62
Chris@16 63 /// Default constructor.
Chris@16 64 basic_endpoint()
Chris@16 65 {
Chris@16 66 }
Chris@16 67
Chris@16 68 /// Construct an endpoint using the specified path name.
Chris@16 69 basic_endpoint(const char* path_name)
Chris@16 70 : impl_(path_name)
Chris@16 71 {
Chris@16 72 }
Chris@16 73
Chris@16 74 /// Construct an endpoint using the specified path name.
Chris@16 75 basic_endpoint(const std::string& path_name)
Chris@16 76 : impl_(path_name)
Chris@16 77 {
Chris@16 78 }
Chris@16 79
Chris@16 80 /// Copy constructor.
Chris@16 81 basic_endpoint(const basic_endpoint& other)
Chris@16 82 : impl_(other.impl_)
Chris@16 83 {
Chris@16 84 }
Chris@16 85
Chris@16 86 #if defined(BOOST_ASIO_HAS_MOVE)
Chris@16 87 /// Move constructor.
Chris@16 88 basic_endpoint(basic_endpoint&& other)
Chris@16 89 : impl_(other.impl_)
Chris@16 90 {
Chris@16 91 }
Chris@16 92 #endif // defined(BOOST_ASIO_HAS_MOVE)
Chris@16 93
Chris@16 94 /// Assign from another endpoint.
Chris@16 95 basic_endpoint& operator=(const basic_endpoint& other)
Chris@16 96 {
Chris@16 97 impl_ = other.impl_;
Chris@16 98 return *this;
Chris@16 99 }
Chris@16 100
Chris@16 101 #if defined(BOOST_ASIO_HAS_MOVE)
Chris@16 102 /// Move-assign from another endpoint.
Chris@16 103 basic_endpoint& operator=(basic_endpoint&& other)
Chris@16 104 {
Chris@16 105 impl_ = other.impl_;
Chris@16 106 return *this;
Chris@16 107 }
Chris@16 108 #endif // defined(BOOST_ASIO_HAS_MOVE)
Chris@16 109
Chris@16 110 /// The protocol associated with the endpoint.
Chris@16 111 protocol_type protocol() const
Chris@16 112 {
Chris@16 113 return protocol_type();
Chris@16 114 }
Chris@16 115
Chris@16 116 /// Get the underlying endpoint in the native type.
Chris@16 117 data_type* data()
Chris@16 118 {
Chris@16 119 return impl_.data();
Chris@16 120 }
Chris@16 121
Chris@16 122 /// Get the underlying endpoint in the native type.
Chris@16 123 const data_type* data() const
Chris@16 124 {
Chris@16 125 return impl_.data();
Chris@16 126 }
Chris@16 127
Chris@16 128 /// Get the underlying size of the endpoint in the native type.
Chris@16 129 std::size_t size() const
Chris@16 130 {
Chris@16 131 return impl_.size();
Chris@16 132 }
Chris@16 133
Chris@16 134 /// Set the underlying size of the endpoint in the native type.
Chris@16 135 void resize(std::size_t new_size)
Chris@16 136 {
Chris@16 137 impl_.resize(new_size);
Chris@16 138 }
Chris@16 139
Chris@16 140 /// Get the capacity of the endpoint in the native type.
Chris@16 141 std::size_t capacity() const
Chris@16 142 {
Chris@16 143 return impl_.capacity();
Chris@16 144 }
Chris@16 145
Chris@16 146 /// Get the path associated with the endpoint.
Chris@16 147 std::string path() const
Chris@16 148 {
Chris@16 149 return impl_.path();
Chris@16 150 }
Chris@16 151
Chris@16 152 /// Set the path associated with the endpoint.
Chris@16 153 void path(const char* p)
Chris@16 154 {
Chris@16 155 impl_.path(p);
Chris@16 156 }
Chris@16 157
Chris@16 158 /// Set the path associated with the endpoint.
Chris@16 159 void path(const std::string& p)
Chris@16 160 {
Chris@16 161 impl_.path(p);
Chris@16 162 }
Chris@16 163
Chris@16 164 /// Compare two endpoints for equality.
Chris@16 165 friend bool operator==(const basic_endpoint<Protocol>& e1,
Chris@16 166 const basic_endpoint<Protocol>& e2)
Chris@16 167 {
Chris@16 168 return e1.impl_ == e2.impl_;
Chris@16 169 }
Chris@16 170
Chris@16 171 /// Compare two endpoints for inequality.
Chris@16 172 friend bool operator!=(const basic_endpoint<Protocol>& e1,
Chris@16 173 const basic_endpoint<Protocol>& e2)
Chris@16 174 {
Chris@16 175 return !(e1.impl_ == e2.impl_);
Chris@16 176 }
Chris@16 177
Chris@16 178 /// Compare endpoints for ordering.
Chris@16 179 friend bool operator<(const basic_endpoint<Protocol>& e1,
Chris@16 180 const basic_endpoint<Protocol>& e2)
Chris@16 181 {
Chris@16 182 return e1.impl_ < e2.impl_;
Chris@16 183 }
Chris@16 184
Chris@16 185 /// Compare endpoints for ordering.
Chris@16 186 friend bool operator>(const basic_endpoint<Protocol>& e1,
Chris@16 187 const basic_endpoint<Protocol>& e2)
Chris@16 188 {
Chris@16 189 return e2.impl_ < e1.impl_;
Chris@16 190 }
Chris@16 191
Chris@16 192 /// Compare endpoints for ordering.
Chris@16 193 friend bool operator<=(const basic_endpoint<Protocol>& e1,
Chris@16 194 const basic_endpoint<Protocol>& e2)
Chris@16 195 {
Chris@16 196 return !(e2 < e1);
Chris@16 197 }
Chris@16 198
Chris@16 199 /// Compare endpoints for ordering.
Chris@16 200 friend bool operator>=(const basic_endpoint<Protocol>& e1,
Chris@16 201 const basic_endpoint<Protocol>& e2)
Chris@16 202 {
Chris@16 203 return !(e1 < e2);
Chris@16 204 }
Chris@16 205
Chris@16 206 private:
Chris@16 207 // The underlying UNIX domain endpoint.
Chris@16 208 boost::asio::local::detail::endpoint impl_;
Chris@16 209 };
Chris@16 210
Chris@16 211 /// Output an endpoint as a string.
Chris@16 212 /**
Chris@16 213 * Used to output a human-readable string for a specified endpoint.
Chris@16 214 *
Chris@16 215 * @param os The output stream to which the string will be written.
Chris@16 216 *
Chris@16 217 * @param endpoint The endpoint to be written.
Chris@16 218 *
Chris@16 219 * @return The output stream.
Chris@16 220 *
Chris@16 221 * @relates boost::asio::local::basic_endpoint
Chris@16 222 */
Chris@16 223 template <typename Elem, typename Traits, typename Protocol>
Chris@16 224 std::basic_ostream<Elem, Traits>& operator<<(
Chris@16 225 std::basic_ostream<Elem, Traits>& os,
Chris@16 226 const basic_endpoint<Protocol>& endpoint)
Chris@16 227 {
Chris@16 228 os << endpoint.path();
Chris@16 229 return os;
Chris@16 230 }
Chris@16 231
Chris@16 232 } // namespace local
Chris@16 233 } // namespace asio
Chris@16 234 } // namespace boost
Chris@16 235
Chris@16 236 #include <boost/asio/detail/pop_options.hpp>
Chris@16 237
Chris@16 238 #endif // defined(BOOST_ASIO_HAS_LOCAL_SOCKETS)
Chris@16 239 // || defined(GENERATING_DOCUMENTATION)
Chris@16 240
Chris@16 241 #endif // BOOST_ASIO_LOCAL_BASIC_ENDPOINT_HPP