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