$search
00001 // 00002 // basic_resolver.hpp 00003 // ~~~~~~~~~~~~~~~~~~ 00004 // 00005 // Copyright (c) 2003-2008 Christopher M. Kohlhoff (chris at kohlhoff dot com) 00006 // 00007 // Distributed under the Boost Software License, Version 1.0. (See accompanying 00008 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 00009 // 00010 00011 #ifndef ASIO_IP_BASIC_RESOLVER_HPP 00012 #define ASIO_IP_BASIC_RESOLVER_HPP 00013 00014 #if defined(_MSC_VER) && (_MSC_VER >= 1200) 00015 # pragma once 00016 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 00017 00018 #include "asio/detail/push_options.hpp" 00019 00020 #include "asio/basic_io_object.hpp" 00021 #include "asio/error.hpp" 00022 #include "asio/ip/resolver_service.hpp" 00023 #include "asio/detail/throw_error.hpp" 00024 00025 namespace asio { 00026 namespace ip { 00027 00029 00037 template <typename InternetProtocol, 00038 typename ResolverService = resolver_service<InternetProtocol> > 00039 class basic_resolver 00040 : public basic_io_object<ResolverService> 00041 { 00042 public: 00044 typedef InternetProtocol protocol_type; 00045 00047 typedef typename InternetProtocol::endpoint endpoint_type; 00048 00050 typedef typename InternetProtocol::resolver_query query; 00051 00053 typedef typename InternetProtocol::resolver_iterator iterator; 00054 00056 00062 explicit basic_resolver(asio::io_service& io_service) 00063 : basic_io_object<ResolverService>(io_service) 00064 { 00065 } 00066 00068 00073 void cancel() 00074 { 00075 return this->service.cancel(this->implementation); 00076 } 00077 00079 00094 iterator resolve(const query& q) 00095 { 00096 asio::error_code ec; 00097 iterator i = this->service.resolve(this->implementation, q, ec); 00098 asio::detail::throw_error(ec); 00099 return i; 00100 } 00101 00103 00119 iterator resolve(const query& q, asio::error_code& ec) 00120 { 00121 return this->service.resolve(this->implementation, q, ec); 00122 } 00123 00125 00150 template <typename ResolveHandler> 00151 void async_resolve(const query& q, ResolveHandler handler) 00152 { 00153 return this->service.async_resolve(this->implementation, q, handler); 00154 } 00155 00157 00174 iterator resolve(const endpoint_type& e) 00175 { 00176 asio::error_code ec; 00177 iterator i = this->service.resolve(this->implementation, e, ec); 00178 asio::detail::throw_error(ec); 00179 return i; 00180 } 00181 00183 00201 iterator resolve(const endpoint_type& e, asio::error_code& ec) 00202 { 00203 return this->service.resolve(this->implementation, e, ec); 00204 } 00205 00207 00233 template <typename ResolveHandler> 00234 void async_resolve(const endpoint_type& e, ResolveHandler handler) 00235 { 00236 return this->service.async_resolve(this->implementation, e, handler); 00237 } 00238 }; 00239 00240 } // namespace ip 00241 } // namespace asio 00242 00243 #include "asio/detail/pop_options.hpp" 00244 00245 #endif // ASIO_IP_BASIC_RESOLVER_HPP