annotate DEPENDENCIES/generic/include/boost/asio/ip/resolver_service.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents c530137014c0
children
rev   line source
Chris@16 1 //
Chris@16 2 // ip/resolver_service.hpp
Chris@16 3 // ~~~~~~~~~~~~~~~~~~~~~~~
Chris@16 4 //
Chris@101 5 // Copyright (c) 2003-2015 Christopher M. Kohlhoff (chris at kohlhoff dot com)
Chris@16 6 //
Chris@16 7 // Distributed under the Boost Software License, Version 1.0. (See accompanying
Chris@16 8 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Chris@16 9 //
Chris@16 10
Chris@16 11 #ifndef BOOST_ASIO_IP_RESOLVER_SERVICE_HPP
Chris@16 12 #define BOOST_ASIO_IP_RESOLVER_SERVICE_HPP
Chris@16 13
Chris@16 14 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
Chris@16 15 # pragma once
Chris@16 16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
Chris@16 17
Chris@16 18 #include <boost/asio/detail/config.hpp>
Chris@16 19 #include <boost/asio/async_result.hpp>
Chris@16 20 #include <boost/system/error_code.hpp>
Chris@16 21 #include <boost/asio/io_service.hpp>
Chris@16 22 #include <boost/asio/ip/basic_resolver_iterator.hpp>
Chris@16 23 #include <boost/asio/ip/basic_resolver_query.hpp>
Chris@16 24
Chris@16 25 #if defined(BOOST_ASIO_WINDOWS_RUNTIME)
Chris@16 26 # include <boost/asio/detail/winrt_resolver_service.hpp>
Chris@16 27 #else
Chris@16 28 # include <boost/asio/detail/resolver_service.hpp>
Chris@16 29 #endif
Chris@16 30
Chris@16 31 #include <boost/asio/detail/push_options.hpp>
Chris@16 32
Chris@16 33 namespace boost {
Chris@16 34 namespace asio {
Chris@16 35 namespace ip {
Chris@16 36
Chris@16 37 /// Default service implementation for a resolver.
Chris@16 38 template <typename InternetProtocol>
Chris@16 39 class resolver_service
Chris@16 40 #if defined(GENERATING_DOCUMENTATION)
Chris@16 41 : public boost::asio::io_service::service
Chris@16 42 #else
Chris@16 43 : public boost::asio::detail::service_base<
Chris@16 44 resolver_service<InternetProtocol> >
Chris@16 45 #endif
Chris@16 46 {
Chris@16 47 public:
Chris@16 48 #if defined(GENERATING_DOCUMENTATION)
Chris@16 49 /// The unique service identifier.
Chris@16 50 static boost::asio::io_service::id id;
Chris@16 51 #endif
Chris@16 52
Chris@16 53 /// The protocol type.
Chris@16 54 typedef InternetProtocol protocol_type;
Chris@16 55
Chris@16 56 /// The endpoint type.
Chris@16 57 typedef typename InternetProtocol::endpoint endpoint_type;
Chris@16 58
Chris@16 59 /// The query type.
Chris@16 60 typedef basic_resolver_query<InternetProtocol> query_type;
Chris@16 61
Chris@16 62 /// The iterator type.
Chris@16 63 typedef basic_resolver_iterator<InternetProtocol> iterator_type;
Chris@16 64
Chris@16 65 private:
Chris@16 66 // The type of the platform-specific implementation.
Chris@16 67 #if defined(BOOST_ASIO_WINDOWS_RUNTIME)
Chris@16 68 typedef boost::asio::detail::winrt_resolver_service<InternetProtocol>
Chris@16 69 service_impl_type;
Chris@16 70 #else
Chris@16 71 typedef boost::asio::detail::resolver_service<InternetProtocol>
Chris@16 72 service_impl_type;
Chris@16 73 #endif
Chris@16 74
Chris@16 75 public:
Chris@16 76 /// The type of a resolver implementation.
Chris@16 77 #if defined(GENERATING_DOCUMENTATION)
Chris@16 78 typedef implementation_defined implementation_type;
Chris@16 79 #else
Chris@16 80 typedef typename service_impl_type::implementation_type implementation_type;
Chris@16 81 #endif
Chris@16 82
Chris@16 83 /// Construct a new resolver service for the specified io_service.
Chris@16 84 explicit resolver_service(boost::asio::io_service& io_service)
Chris@16 85 : boost::asio::detail::service_base<
Chris@16 86 resolver_service<InternetProtocol> >(io_service),
Chris@16 87 service_impl_(io_service)
Chris@16 88 {
Chris@16 89 }
Chris@16 90
Chris@16 91 /// Construct a new resolver implementation.
Chris@16 92 void construct(implementation_type& impl)
Chris@16 93 {
Chris@16 94 service_impl_.construct(impl);
Chris@16 95 }
Chris@16 96
Chris@16 97 /// Destroy a resolver implementation.
Chris@16 98 void destroy(implementation_type& impl)
Chris@16 99 {
Chris@16 100 service_impl_.destroy(impl);
Chris@16 101 }
Chris@16 102
Chris@16 103 /// Cancel pending asynchronous operations.
Chris@16 104 void cancel(implementation_type& impl)
Chris@16 105 {
Chris@16 106 service_impl_.cancel(impl);
Chris@16 107 }
Chris@16 108
Chris@16 109 /// Resolve a query to a list of entries.
Chris@16 110 iterator_type resolve(implementation_type& impl, const query_type& query,
Chris@16 111 boost::system::error_code& ec)
Chris@16 112 {
Chris@16 113 return service_impl_.resolve(impl, query, ec);
Chris@16 114 }
Chris@16 115
Chris@16 116 /// Asynchronously resolve a query to a list of entries.
Chris@16 117 template <typename ResolveHandler>
Chris@16 118 BOOST_ASIO_INITFN_RESULT_TYPE(ResolveHandler,
Chris@16 119 void (boost::system::error_code, iterator_type))
Chris@16 120 async_resolve(implementation_type& impl, const query_type& query,
Chris@16 121 BOOST_ASIO_MOVE_ARG(ResolveHandler) handler)
Chris@16 122 {
Chris@16 123 boost::asio::detail::async_result_init<
Chris@16 124 ResolveHandler, void (boost::system::error_code, iterator_type)> init(
Chris@16 125 BOOST_ASIO_MOVE_CAST(ResolveHandler)(handler));
Chris@16 126
Chris@16 127 service_impl_.async_resolve(impl, query, init.handler);
Chris@16 128
Chris@16 129 return init.result.get();
Chris@16 130 }
Chris@16 131
Chris@16 132 /// Resolve an endpoint to a list of entries.
Chris@16 133 iterator_type resolve(implementation_type& impl,
Chris@16 134 const endpoint_type& endpoint, boost::system::error_code& ec)
Chris@16 135 {
Chris@16 136 return service_impl_.resolve(impl, endpoint, ec);
Chris@16 137 }
Chris@16 138
Chris@16 139 /// Asynchronously resolve an endpoint to a list of entries.
Chris@16 140 template <typename ResolveHandler>
Chris@16 141 BOOST_ASIO_INITFN_RESULT_TYPE(ResolveHandler,
Chris@16 142 void (boost::system::error_code, iterator_type))
Chris@16 143 async_resolve(implementation_type& impl, const endpoint_type& endpoint,
Chris@16 144 BOOST_ASIO_MOVE_ARG(ResolveHandler) handler)
Chris@16 145 {
Chris@16 146 boost::asio::detail::async_result_init<
Chris@16 147 ResolveHandler, void (boost::system::error_code, iterator_type)> init(
Chris@16 148 BOOST_ASIO_MOVE_CAST(ResolveHandler)(handler));
Chris@16 149
Chris@16 150 service_impl_.async_resolve(impl, endpoint, init.handler);
Chris@16 151
Chris@16 152 return init.result.get();
Chris@16 153 }
Chris@16 154
Chris@16 155 private:
Chris@16 156 // Destroy all user-defined handler objects owned by the service.
Chris@16 157 void shutdown_service()
Chris@16 158 {
Chris@16 159 service_impl_.shutdown_service();
Chris@16 160 }
Chris@16 161
Chris@16 162 // Perform any fork-related housekeeping.
Chris@16 163 void fork_service(boost::asio::io_service::fork_event event)
Chris@16 164 {
Chris@16 165 service_impl_.fork_service(event);
Chris@16 166 }
Chris@16 167
Chris@16 168 // The platform-specific implementation.
Chris@16 169 service_impl_type service_impl_;
Chris@16 170 };
Chris@16 171
Chris@16 172 } // namespace ip
Chris@16 173 } // namespace asio
Chris@16 174 } // namespace boost
Chris@16 175
Chris@16 176 #include <boost/asio/detail/pop_options.hpp>
Chris@16 177
Chris@16 178 #endif // BOOST_ASIO_IP_RESOLVER_SERVICE_HPP