2 // ip/basic_resolver_entry.hpp
3 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~
5 // Copyright (c) 2003-2017 Christopher M. Kohlhoff (chris at kohlhoff dot com)
7 // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
11 #ifndef BOOST_ASIO_IP_BASIC_RESOLVER_ENTRY_HPP
12 #define BOOST_ASIO_IP_BASIC_RESOLVER_ENTRY_HPP
14 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
18 #include <boost/asio/detail/config.hpp>
20 #include <boost/asio/detail/string_view.hpp>
22 #include <boost/asio/detail/push_options.hpp>
28 /// An entry produced by a resolver.
30 * The boost::asio::ip::basic_resolver_entry class template describes an entry
31 * as returned by a resolver.
34 * @e Distinct @e objects: Safe.@n
35 * @e Shared @e objects: Unsafe.
37 template <typename InternetProtocol>
38 class basic_resolver_entry
41 /// The protocol type associated with the endpoint entry.
42 typedef InternetProtocol protocol_type;
44 /// The endpoint type associated with the endpoint entry.
45 typedef typename InternetProtocol::endpoint endpoint_type;
47 /// Default constructor.
48 basic_resolver_entry()
52 /// Construct with specified endpoint, host name and service name.
53 basic_resolver_entry(const endpoint_type& ep,
54 BOOST_ASIO_STRING_VIEW_PARAM host, BOOST_ASIO_STRING_VIEW_PARAM service)
56 host_name_(static_cast<std::string>(host)),
57 service_name_(static_cast<std::string>(service))
61 /// Get the endpoint associated with the entry.
62 endpoint_type endpoint() const
67 /// Convert to the endpoint associated with the entry.
68 operator endpoint_type() const
73 /// Get the host name associated with the entry.
74 std::string host_name() const
79 /// Get the host name associated with the entry.
80 template <class Allocator>
81 std::basic_string<char, std::char_traits<char>, Allocator> host_name(
82 const Allocator& alloc = Allocator()) const
84 return std::basic_string<char, std::char_traits<char>, Allocator>(
85 host_name_.c_str(), alloc);
88 /// Get the service name associated with the entry.
89 std::string service_name() const
94 /// Get the service name associated with the entry.
95 template <class Allocator>
96 std::basic_string<char, std::char_traits<char>, Allocator> service_name(
97 const Allocator& alloc = Allocator()) const
99 return std::basic_string<char, std::char_traits<char>, Allocator>(
100 service_name_.c_str(), alloc);
104 endpoint_type endpoint_;
105 std::string host_name_;
106 std::string service_name_;
113 #include <boost/asio/detail/pop_options.hpp>
115 #endif // BOOST_ASIO_IP_BASIC_RESOLVER_ENTRY_HPP