123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189 |
- #ifndef ASIO_GENERIC_BASIC_ENDPOINT_HPP
- #define ASIO_GENERIC_BASIC_ENDPOINT_HPP
- #if defined(_MSC_VER) && (_MSC_VER >= 1200)
- # pragma once
- #endif
- #include "asio/detail/config.hpp"
- #include "asio/generic/detail/endpoint.hpp"
- #include "asio/detail/push_options.hpp"
- namespace asio {
- namespace generic {
- template <typename Protocol>
- class basic_endpoint
- {
- public:
-
- typedef Protocol protocol_type;
-
-
- #if defined(GENERATING_DOCUMENTATION)
- typedef implementation_defined data_type;
- #else
- typedef asio::detail::socket_addr_type data_type;
- #endif
-
- basic_endpoint() noexcept
- {
- }
-
- basic_endpoint(const void* socket_address,
- std::size_t socket_address_size, int socket_protocol = 0)
- : impl_(socket_address, socket_address_size, socket_protocol)
- {
- }
-
- template <typename Endpoint>
- basic_endpoint(const Endpoint& endpoint)
- : impl_(endpoint.data(), endpoint.size(), endpoint.protocol().protocol())
- {
- }
-
- basic_endpoint(const basic_endpoint& other)
- : impl_(other.impl_)
- {
- }
-
- basic_endpoint(basic_endpoint&& other)
- : impl_(other.impl_)
- {
- }
-
- basic_endpoint& operator=(const basic_endpoint& other)
- {
- impl_ = other.impl_;
- return *this;
- }
-
- basic_endpoint& operator=(basic_endpoint&& other)
- {
- impl_ = other.impl_;
- return *this;
- }
-
- protocol_type protocol() const
- {
- return protocol_type(impl_.family(), impl_.protocol());
- }
-
- data_type* data()
- {
- return impl_.data();
- }
-
- const data_type* data() const
- {
- return impl_.data();
- }
-
- std::size_t size() const
- {
- return impl_.size();
- }
-
- void resize(std::size_t new_size)
- {
- impl_.resize(new_size);
- }
-
- std::size_t capacity() const
- {
- return impl_.capacity();
- }
-
- friend bool operator==(const basic_endpoint<Protocol>& e1,
- const basic_endpoint<Protocol>& e2)
- {
- return e1.impl_ == e2.impl_;
- }
-
- friend bool operator!=(const basic_endpoint<Protocol>& e1,
- const basic_endpoint<Protocol>& e2)
- {
- return !(e1.impl_ == e2.impl_);
- }
-
- friend bool operator<(const basic_endpoint<Protocol>& e1,
- const basic_endpoint<Protocol>& e2)
- {
- return e1.impl_ < e2.impl_;
- }
-
- friend bool operator>(const basic_endpoint<Protocol>& e1,
- const basic_endpoint<Protocol>& e2)
- {
- return e2.impl_ < e1.impl_;
- }
-
- friend bool operator<=(const basic_endpoint<Protocol>& e1,
- const basic_endpoint<Protocol>& e2)
- {
- return !(e2 < e1);
- }
-
- friend bool operator>=(const basic_endpoint<Protocol>& e1,
- const basic_endpoint<Protocol>& e2)
- {
- return !(e1 < e2);
- }
- private:
-
- asio::generic::detail::endpoint impl_;
- };
- }
- }
- #include "asio/detail/pop_options.hpp"
- #endif
|