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_DETAIL_ENDPOINT_HPP
0012 #define BOOST_ASIO_GENERIC_DETAIL_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
0020 #include <cstddef>
0021 #include <boost/asio/detail/socket_types.hpp>
0022
0023 #include <boost/asio/detail/push_options.hpp>
0024
0025 namespace boost {
0026 namespace asio {
0027 namespace generic {
0028 namespace detail {
0029
0030
0031 class endpoint
0032 {
0033 public:
0034
0035 BOOST_ASIO_DECL endpoint();
0036
0037
0038 BOOST_ASIO_DECL endpoint(const void* sock_addr,
0039 std::size_t sock_addr_size, int sock_protocol);
0040
0041
0042 endpoint(const endpoint& other)
0043 : data_(other.data_),
0044 size_(other.size_),
0045 protocol_(other.protocol_)
0046 {
0047 }
0048
0049
0050 endpoint& operator=(const endpoint& other)
0051 {
0052 data_ = other.data_;
0053 size_ = other.size_;
0054 protocol_ = other.protocol_;
0055 return *this;
0056 }
0057
0058
0059 int family() const
0060 {
0061 return data_.base.sa_family;
0062 }
0063
0064
0065 int protocol() const
0066 {
0067 return protocol_;
0068 }
0069
0070
0071 boost::asio::detail::socket_addr_type* data()
0072 {
0073 return &data_.base;
0074 }
0075
0076
0077 const boost::asio::detail::socket_addr_type* data() const
0078 {
0079 return &data_.base;
0080 }
0081
0082
0083 std::size_t size() const
0084 {
0085 return size_;
0086 }
0087
0088
0089 BOOST_ASIO_DECL void resize(std::size_t size);
0090
0091
0092 std::size_t capacity() const
0093 {
0094 return sizeof(boost::asio::detail::sockaddr_storage_type);
0095 }
0096
0097
0098 BOOST_ASIO_DECL friend bool operator==(
0099 const endpoint& e1, const endpoint& e2);
0100
0101
0102 BOOST_ASIO_DECL friend bool operator<(
0103 const endpoint& e1, const endpoint& e2);
0104
0105 private:
0106
0107 union data_union
0108 {
0109 boost::asio::detail::socket_addr_type base;
0110 boost::asio::detail::sockaddr_storage_type generic;
0111 } data_;
0112
0113
0114 std::size_t size_;
0115
0116
0117 int protocol_;
0118
0119
0120 BOOST_ASIO_DECL void init(const void* sock_addr,
0121 std::size_t sock_addr_size, int sock_protocol);
0122 };
0123
0124 }
0125 }
0126 }
0127 }
0128
0129 #include <boost/asio/detail/pop_options.hpp>
0130
0131 #if defined(BOOST_ASIO_HEADER_ONLY)
0132 # include <boost/asio/generic/detail/impl/endpoint.ipp>
0133 #endif
0134
0135 #endif