Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:29:00

0001 //
0002 // ip/basic_resolver_entry.hpp
0003 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~
0004 //
0005 // Copyright (c) 2003-2023 Christopher M. Kohlhoff (chris at kohlhoff dot com)
0006 //
0007 // Distributed under the Boost Software License, Version 1.0. (See accompanying
0008 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0009 //
0010 
0011 #ifndef BOOST_ASIO_IP_BASIC_RESOLVER_ENTRY_HPP
0012 #define BOOST_ASIO_IP_BASIC_RESOLVER_ENTRY_HPP
0013 
0014 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
0015 # pragma once
0016 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
0017 
0018 #include <boost/asio/detail/config.hpp>
0019 #include <string>
0020 #include <boost/asio/detail/string_view.hpp>
0021 
0022 #include <boost/asio/detail/push_options.hpp>
0023 
0024 namespace boost {
0025 namespace asio {
0026 namespace ip {
0027 
0028 /// An entry produced by a resolver.
0029 /**
0030  * The boost::asio::ip::basic_resolver_entry class template describes an entry
0031  * as returned by a resolver.
0032  *
0033  * @par Thread Safety
0034  * @e Distinct @e objects: Safe.@n
0035  * @e Shared @e objects: Unsafe.
0036  */
0037 template <typename InternetProtocol>
0038 class basic_resolver_entry
0039 {
0040 public:
0041   /// The protocol type associated with the endpoint entry.
0042   typedef InternetProtocol protocol_type;
0043 
0044   /// The endpoint type associated with the endpoint entry.
0045   typedef typename InternetProtocol::endpoint endpoint_type;
0046 
0047   /// Default constructor.
0048   basic_resolver_entry()
0049   {
0050   }
0051 
0052   /// Construct with specified endpoint, host name and service name.
0053   basic_resolver_entry(const endpoint_type& ep,
0054       BOOST_ASIO_STRING_VIEW_PARAM host, BOOST_ASIO_STRING_VIEW_PARAM service)
0055     : endpoint_(ep),
0056       host_name_(static_cast<std::string>(host)),
0057       service_name_(static_cast<std::string>(service))
0058   {
0059   }
0060 
0061   /// Get the endpoint associated with the entry.
0062   endpoint_type endpoint() const
0063   {
0064     return endpoint_;
0065   }
0066 
0067   /// Convert to the endpoint associated with the entry.
0068   operator endpoint_type() const
0069   {
0070     return endpoint_;
0071   }
0072 
0073   /// Get the host name associated with the entry.
0074   std::string host_name() const
0075   {
0076     return host_name_;
0077   }
0078 
0079   /// Get the host name associated with the entry.
0080   template <class Allocator>
0081   std::basic_string<char, std::char_traits<char>, Allocator> host_name(
0082       const Allocator& alloc = Allocator()) const
0083   {
0084     return std::basic_string<char, std::char_traits<char>, Allocator>(
0085         host_name_.c_str(), alloc);
0086   }
0087 
0088   /// Get the service name associated with the entry.
0089   std::string service_name() const
0090   {
0091     return service_name_;
0092   }
0093 
0094   /// Get the service name associated with the entry.
0095   template <class Allocator>
0096   std::basic_string<char, std::char_traits<char>, Allocator> service_name(
0097       const Allocator& alloc = Allocator()) const
0098   {
0099     return std::basic_string<char, std::char_traits<char>, Allocator>(
0100         service_name_.c_str(), alloc);
0101   }
0102 
0103 private:
0104   endpoint_type endpoint_;
0105   std::string host_name_;
0106   std::string service_name_;
0107 };
0108 
0109 } // namespace ip
0110 } // namespace asio
0111 } // namespace boost
0112 
0113 #include <boost/asio/detail/pop_options.hpp>
0114 
0115 #endif // BOOST_ASIO_IP_BASIC_RESOLVER_ENTRY_HPP