1//
2// ip/basic_resolver_entry.hpp
3// ~~~~~~~~~~~~~~~~~~~~~~~~~~~
4//
5// Copyright (c) 2003-2015 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
21#include <boost/asio/detail/push_options.hpp>
22
23namespace boost {
24namespace asio {
25namespace ip {
26
27/// An entry produced by a resolver.
28/**
29 * The boost::asio::ip::basic_resolver_entry class template describes an entry
30 * as returned by a resolver.
31 *
32 * @par Thread Safety
33 * @e Distinct @e objects: Safe.@n
34 * @e Shared @e objects: Unsafe.
35 */
36template <typename InternetProtocol>
37class basic_resolver_entry
38{
39public:
40 /// The protocol type associated with the endpoint entry.
41 typedef InternetProtocol protocol_type;
42
43 /// The endpoint type associated with the endpoint entry.
44 typedef typename InternetProtocol::endpoint endpoint_type;
45
46 /// Default constructor.
47 basic_resolver_entry()
48 {
49 }
50
51 /// Construct with specified endpoint, host name and service name.
52 basic_resolver_entry(const endpoint_type& ep,
53 const std::string& host, const std::string& service)
54 : endpoint_(ep),
55 host_name_(host),
56 service_name_(service)
57 {
58 }
59
60 /// Get the endpoint associated with the entry.
61 endpoint_type endpoint() const
62 {
63 return endpoint_;
64 }
65
66 /// Convert to the endpoint associated with the entry.
67 operator endpoint_type() const
68 {
69 return endpoint_;
70 }
71
72 /// Get the host name associated with the entry.
73 std::string host_name() const
74 {
75 return host_name_;
76 }
77
78 /// Get the service name associated with the entry.
79 std::string service_name() const
80 {
81 return service_name_;
82 }
83
84private:
85 endpoint_type endpoint_;
86 std::string host_name_;
87 std::string service_name_;
88};
89
90} // namespace ip
91} // namespace asio
92} // namespace boost
93
94#include <boost/asio/detail/pop_options.hpp>
95
96#endif // BOOST_ASIO_IP_BASIC_RESOLVER_ENTRY_HPP
97

source code of boost/boost/asio/ip/basic_resolver_entry.hpp