]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/asio/ip/basic_resolver_entry.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / boost / asio / ip / basic_resolver_entry.hpp
1 //
2 // ip/basic_resolver_entry.hpp
3 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 //
5 // Copyright (c) 2003-2017 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 //
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)
9 //
10
11 #ifndef BOOST_ASIO_IP_BASIC_RESOLVER_ENTRY_HPP
12 #define BOOST_ASIO_IP_BASIC_RESOLVER_ENTRY_HPP
13
14 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 # pragma once
16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17
18 #include <boost/asio/detail/config.hpp>
19 #include <string>
20 #include <boost/asio/detail/string_view.hpp>
21
22 #include <boost/asio/detail/push_options.hpp>
23
24 namespace boost {
25 namespace asio {
26 namespace ip {
27
28 /// An entry produced by a resolver.
29 /**
30 * The boost::asio::ip::basic_resolver_entry class template describes an entry
31 * as returned by a resolver.
32 *
33 * @par Thread Safety
34 * @e Distinct @e objects: Safe.@n
35 * @e Shared @e objects: Unsafe.
36 */
37 template <typename InternetProtocol>
38 class basic_resolver_entry
39 {
40 public:
41 /// The protocol type associated with the endpoint entry.
42 typedef InternetProtocol protocol_type;
43
44 /// The endpoint type associated with the endpoint entry.
45 typedef typename InternetProtocol::endpoint endpoint_type;
46
47 /// Default constructor.
48 basic_resolver_entry()
49 {
50 }
51
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)
55 : endpoint_(ep),
56 host_name_(static_cast<std::string>(host)),
57 service_name_(static_cast<std::string>(service))
58 {
59 }
60
61 /// Get the endpoint associated with the entry.
62 endpoint_type endpoint() const
63 {
64 return endpoint_;
65 }
66
67 /// Convert to the endpoint associated with the entry.
68 operator endpoint_type() const
69 {
70 return endpoint_;
71 }
72
73 /// Get the host name associated with the entry.
74 std::string host_name() const
75 {
76 return host_name_;
77 }
78
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
83 {
84 return std::basic_string<char, std::char_traits<char>, Allocator>(
85 host_name_.c_str(), alloc);
86 }
87
88 /// Get the service name associated with the entry.
89 std::string service_name() const
90 {
91 return service_name_;
92 }
93
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
98 {
99 return std::basic_string<char, std::char_traits<char>, Allocator>(
100 service_name_.c_str(), alloc);
101 }
102
103 private:
104 endpoint_type endpoint_;
105 std::string host_name_;
106 std::string service_name_;
107 };
108
109 } // namespace ip
110 } // namespace asio
111 } // namespace boost
112
113 #include <boost/asio/detail/pop_options.hpp>
114
115 #endif // BOOST_ASIO_IP_BASIC_RESOLVER_ENTRY_HPP