basic_resolver_entry.hpp 2.2 KB

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