File indexing completed on 2025-01-18 09:28:53
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_ASIO_GENERIC_BASIC_ENDPOINT_HPP
0012 #define BOOST_ASIO_GENERIC_BASIC_ENDPOINT_HPP
0013
0014 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
0015 # pragma once
0016 #endif
0017
0018 #include <boost/asio/detail/config.hpp>
0019 #include <boost/asio/generic/detail/endpoint.hpp>
0020
0021 #include <boost/asio/detail/push_options.hpp>
0022
0023 namespace boost {
0024 namespace asio {
0025 namespace generic {
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042 template <typename Protocol>
0043 class basic_endpoint
0044 {
0045 public:
0046
0047 typedef Protocol protocol_type;
0048
0049
0050
0051 #if defined(GENERATING_DOCUMENTATION)
0052 typedef implementation_defined data_type;
0053 #else
0054 typedef boost::asio::detail::socket_addr_type data_type;
0055 #endif
0056
0057
0058 basic_endpoint() noexcept
0059 {
0060 }
0061
0062
0063 basic_endpoint(const void* socket_address,
0064 std::size_t socket_address_size, int socket_protocol = 0)
0065 : impl_(socket_address, socket_address_size, socket_protocol)
0066 {
0067 }
0068
0069
0070 template <typename Endpoint>
0071 basic_endpoint(const Endpoint& endpoint)
0072 : impl_(endpoint.data(), endpoint.size(), endpoint.protocol().protocol())
0073 {
0074 }
0075
0076
0077 basic_endpoint(const basic_endpoint& other)
0078 : impl_(other.impl_)
0079 {
0080 }
0081
0082
0083 basic_endpoint(basic_endpoint&& other)
0084 : impl_(other.impl_)
0085 {
0086 }
0087
0088
0089 basic_endpoint& operator=(const basic_endpoint& other)
0090 {
0091 impl_ = other.impl_;
0092 return *this;
0093 }
0094
0095
0096 basic_endpoint& operator=(basic_endpoint&& other)
0097 {
0098 impl_ = other.impl_;
0099 return *this;
0100 }
0101
0102
0103 protocol_type protocol() const
0104 {
0105 return protocol_type(impl_.family(), impl_.protocol());
0106 }
0107
0108
0109 data_type* data()
0110 {
0111 return impl_.data();
0112 }
0113
0114
0115 const data_type* data() const
0116 {
0117 return impl_.data();
0118 }
0119
0120
0121 std::size_t size() const
0122 {
0123 return impl_.size();
0124 }
0125
0126
0127 void resize(std::size_t new_size)
0128 {
0129 impl_.resize(new_size);
0130 }
0131
0132
0133 std::size_t capacity() const
0134 {
0135 return impl_.capacity();
0136 }
0137
0138
0139 friend bool operator==(const basic_endpoint<Protocol>& e1,
0140 const basic_endpoint<Protocol>& e2)
0141 {
0142 return e1.impl_ == e2.impl_;
0143 }
0144
0145
0146 friend bool operator!=(const basic_endpoint<Protocol>& e1,
0147 const basic_endpoint<Protocol>& e2)
0148 {
0149 return !(e1.impl_ == e2.impl_);
0150 }
0151
0152
0153 friend bool operator<(const basic_endpoint<Protocol>& e1,
0154 const basic_endpoint<Protocol>& e2)
0155 {
0156 return e1.impl_ < e2.impl_;
0157 }
0158
0159
0160 friend bool operator>(const basic_endpoint<Protocol>& e1,
0161 const basic_endpoint<Protocol>& e2)
0162 {
0163 return e2.impl_ < e1.impl_;
0164 }
0165
0166
0167 friend bool operator<=(const basic_endpoint<Protocol>& e1,
0168 const basic_endpoint<Protocol>& e2)
0169 {
0170 return !(e2 < e1);
0171 }
0172
0173
0174 friend bool operator>=(const basic_endpoint<Protocol>& e1,
0175 const basic_endpoint<Protocol>& e2)
0176 {
0177 return !(e1 < e2);
0178 }
0179
0180 private:
0181
0182 boost::asio::generic::detail::endpoint impl_;
0183 };
0184
0185 }
0186 }
0187 }
0188
0189 #include <boost/asio/detail/pop_options.hpp>
0190
0191 #endif