2 // local/detail/endpoint.hpp
3 // ~~~~~~~~~~~~~~~~~~~~~~~~~
5 // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 // Derived from a public domain implementation written by Daniel Casimiro.
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)
12 #ifndef BOOST_ASIO_LOCAL_DETAIL_ENDPOINT_HPP
13 #define BOOST_ASIO_LOCAL_DETAIL_ENDPOINT_HPP
15 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
17 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
19 #include <boost/asio/detail/config.hpp>
21 #if defined(BOOST_ASIO_HAS_LOCAL_SOCKETS)
25 #include <boost/asio/detail/socket_types.hpp>
27 #include <boost/asio/detail/push_options.hpp>
34 // Helper class for implementing a UNIX domain endpoint.
38 // Default constructor.
39 BOOST_ASIO_DECL endpoint();
41 // Construct an endpoint using the specified path name.
42 BOOST_ASIO_DECL endpoint(const char* path_name);
44 // Construct an endpoint using the specified path name.
45 BOOST_ASIO_DECL endpoint(const std::string& path_name);
48 endpoint(const endpoint& other)
50 path_length_(other.path_length_)
54 // Assign from another endpoint.
55 endpoint& operator=(const endpoint& other)
58 path_length_ = other.path_length_;
62 // Get the underlying endpoint in the native type.
63 boost::asio::detail::socket_addr_type* data()
68 // Get the underlying endpoint in the native type.
69 const boost::asio::detail::socket_addr_type* data() const
74 // Get the underlying size of the endpoint in the native type.
75 std::size_t size() const
78 + offsetof(boost::asio::detail::sockaddr_un_type, sun_path);
81 // Set the underlying size of the endpoint in the native type.
82 BOOST_ASIO_DECL void resize(std::size_t size);
84 // Get the capacity of the endpoint in the native type.
85 std::size_t capacity() const
87 return sizeof(boost::asio::detail::sockaddr_un_type);
90 // Get the path associated with the endpoint.
91 BOOST_ASIO_DECL std::string path() const;
93 // Set the path associated with the endpoint.
94 BOOST_ASIO_DECL void path(const char* p);
96 // Set the path associated with the endpoint.
97 BOOST_ASIO_DECL void path(const std::string& p);
99 // Compare two endpoints for equality.
100 BOOST_ASIO_DECL friend bool operator==(
101 const endpoint& e1, const endpoint& e2);
103 // Compare endpoints for ordering.
104 BOOST_ASIO_DECL friend bool operator<(
105 const endpoint& e1, const endpoint& e2);
108 // The underlying UNIX socket address.
111 boost::asio::detail::socket_addr_type base;
112 boost::asio::detail::sockaddr_un_type local;
115 // The length of the path associated with the endpoint.
116 std::size_t path_length_;
118 // Initialise with a specified path.
119 BOOST_ASIO_DECL void init(const char* path, std::size_t path_length);
122 } // namespace detail
127 #include <boost/asio/detail/pop_options.hpp>
129 #if defined(BOOST_ASIO_HEADER_ONLY)
130 # include <boost/asio/local/detail/impl/endpoint.ipp>
131 #endif // defined(BOOST_ASIO_HEADER_ONLY)
133 #endif // defined(BOOST_ASIO_HAS_LOCAL_SOCKETS)
135 #endif // BOOST_ASIO_LOCAL_DETAIL_ENDPOINT_HPP