basic_resolver_entry.hpp 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. //
  2. // basic_resolver_entry.hpp
  3. // ~~~~~~~~~~~~~~~~~~~~~~~~
  4. //
  5. // Copyright (c) 2003-2010 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 ASIO_IP_BASIC_RESOLVER_ENTRY_HPP
  11. #define 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 "asio/detail/push_options.hpp"
  16. #include "asio/detail/push_options.hpp"
  17. #include <string>
  18. #include "asio/detail/pop_options.hpp"
  19. namespace asio {
  20. namespace ip {
  21. /// An entry produced by a resolver.
  22. /**
  23. * The 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& endpoint,
  44. const std::string& host_name, const std::string& service_name)
  45. : endpoint_(endpoint),
  46. host_name_(host_name),
  47. service_name_(service_name)
  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. #include "asio/detail/pop_options.hpp"
  78. #endif // ASIO_IP_BASIC_RESOLVER_ENTRY_HPP