basic_resolver_entry.hpp 2.3 KB

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