11 #ifndef ASIO_IP_BASIC_RESOLVER_RESULTS_HPP 12 #define ASIO_IP_BASIC_RESOLVER_RESULTS_HPP 14 #if defined(_MSC_VER) && (_MSC_VER >= 1200) 16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 18 #include "asio/detail/config.hpp" 21 #include "asio/detail/socket_ops.hpp" 22 #include "asio/detail/socket_types.hpp" 23 #include "asio/ip/basic_resolver_iterator.hpp" 25 #if defined(ASIO_WINDOWS_RUNTIME) 26 # include "asio/detail/winrt_utils.hpp" 27 #endif // defined(ASIO_WINDOWS_RUNTIME) 29 #include "asio/detail/push_options.hpp" 49 template <
typename InternetProtocol>
51 #if !defined(ASIO_NO_DEPRECATED)
53 #else // !defined(ASIO_NO_DEPRECATED) 55 #endif // !defined(ASIO_NO_DEPRECATED) 96 #if defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) 103 #endif // defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) 112 #if defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) 120 #endif // defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION) 122 #if !defined(GENERATING_DOCUMENTATION) 125 asio::detail::addrinfo_type* address_info,
126 const std::string& host_name,
const std::string& service_name)
132 std::string actual_host_name = host_name;
133 if (address_info->ai_canonname)
134 actual_host_name = address_info->ai_canonname;
136 results.values_.reset(
new values_type);
140 if (address_info->ai_family == ASIO_OS_DEF(AF_INET)
141 || address_info->ai_family == ASIO_OS_DEF(AF_INET6))
144 typename InternetProtocol::endpoint endpoint;
145 endpoint.resize(static_cast<std::size_t>(address_info->ai_addrlen));
146 memcpy(endpoint.data(), address_info->ai_addr,
147 address_info->ai_addrlen);
148 results.values_->push_back(
150 actual_host_name, service_name));
152 address_info = address_info->ai_next;
160 const std::string& host_name,
const std::string& service_name)
163 results.values_.reset(
new values_type);
164 results.values_->push_back(
166 endpoint, host_name, service_name));
171 template <
typename Endpo
intIterator>
173 EndpointIterator
begin, EndpointIterator end,
174 const std::string& host_name,
const std::string& service_name)
179 results.values_.reset(
new values_type);
180 for (EndpointIterator ep_iter = begin; ep_iter !=
end; ++ep_iter)
182 results.values_->push_back(
184 *ep_iter, host_name, service_name));
190 # if defined(ASIO_WINDOWS_RUNTIME) 193 Windows::Foundation::Collections::IVectorView<
194 Windows::Networking::EndpointPair^>^ endpoints,
195 const asio::detail::addrinfo_type& hints,
196 const std::string& host_name,
const std::string& service_name)
201 results.values_.reset(
new values_type);
202 for (
unsigned int i = 0; i < endpoints->Size; ++i)
204 auto pair = endpoints->GetAt(i);
206 if (hints.ai_family == ASIO_OS_DEF(AF_INET)
207 && pair->RemoteHostName->Type
208 != Windows::Networking::HostNameType::Ipv4)
211 if (hints.ai_family == ASIO_OS_DEF(AF_INET6)
212 && pair->RemoteHostName->Type
213 != Windows::Networking::HostNameType::Ipv6)
216 results.values_->push_back(
218 typename InternetProtocol::endpoint(
220 asio::detail::winrt_utils::string(
221 pair->RemoteHostName->CanonicalName)),
222 asio::detail::winrt_utils::integer(
223 pair->RemoteServiceName)),
224 host_name, service_name));
229 # endif // defined(ASIO_WINDOWS_RUNTIME) 230 #endif // !defined(GENERATING_DOCUMENTATION) 233 size_type
size() const ASIO_NOEXCEPT
235 return this->values_ ? this->values_->size() : 0;
241 return this->values_ ? this->values_->max_size() : values_type().max_size();
247 return this->values_ ? this->values_->empty() :
true;
259 const_iterator
end()
const 281 this->values_.swap(that.values_);
282 std::size_t index = this->index_;
283 this->index_ = that.index_;
303 typedef std::vector<basic_resolver_entry<InternetProtocol> > values_type;
309 #include "asio/detail/pop_options.hpp" 311 #endif // ASIO_IP_BASIC_RESOLVER_RESULTS_HPP const_iterator begin() const
Obtain a begin iterator for the results range.
Definition: basic_resolver_results.hpp:251
const_iterator cbegin() const
Obtain a begin iterator for the results range.
Definition: basic_resolver_results.hpp:265
const_iterator iterator
The type of an iterator into the range.
Definition: basic_resolver_results.hpp:77
const_iterator end() const
Obtain an end iterator for the results range.
Definition: basic_resolver_results.hpp:259
basic_resolver_iterator & operator=(const basic_resolver_iterator &other)
Assignment operator.
Definition: basic_resolver_iterator.hpp:93
void swap(basic_resolver_results &that) ASIO_NOEXCEPT
Swap the results range with another.
Definition: basic_resolver_results.hpp:277
std::size_t size_type
Type used to represent a count of the elements in the range.
Definition: basic_resolver_results.hpp:83
Definition: awaitable.hpp:421
size_type max_size() const ASIO_NOEXCEPT
Get the maximum number of entries permitted in a results range.
Definition: basic_resolver_results.hpp:239
basic_resolver_entry< protocol_type > value_type
The type of a value in the results range.
Definition: basic_resolver_results.hpp:65
size_type size() const ASIO_NOEXCEPT
Get the number of entries in the results range.
Definition: basic_resolver_results.hpp:233
basic_resolver_iterator< protocol_type > const_iterator
The type of an iterator into the range.
Definition: basic_resolver_results.hpp:74
bool empty() const ASIO_NOEXCEPT
Determine whether the results range is empty.
Definition: basic_resolver_results.hpp:245
const value_type & const_reference
The type of a const reference to a value in the range.
Definition: basic_resolver_results.hpp:68
basic_resolver_results(const basic_resolver_results &other)
Copy constructor.
Definition: basic_resolver_results.hpp:91
A range of entries produced by a resolver.
Definition: basic_resolver_results.hpp:50
const_iterator cend() const
Obtain an end iterator for the results range.
Definition: basic_resolver_results.hpp:271
std::ptrdiff_t difference_type
Type used to represent the distance between two iterators in the range.
Definition: basic_resolver_results.hpp:80
friend bool operator!=(const basic_resolver_results &a, const basic_resolver_results &b)
Test two iterators for inequality.
Definition: basic_resolver_results.hpp:296
basic_resolver_results()
Default constructor creates an empty range.
Definition: basic_resolver_results.hpp:86
protocol_type::endpoint endpoint_type
The endpoint type associated with the results.
Definition: basic_resolver_results.hpp:62
An iterator over the entries produced by a resolver.
Definition: basic_resolver_iterator.hpp:51
InternetProtocol protocol_type
The protocol type associated with the results.
Definition: basic_resolver_results.hpp:59
value_type & reference
The type of a non-const reference to a value in the range.
Definition: basic_resolver_results.hpp:71
An entry produced by a resolver.
Definition: basic_resolver_entry.hpp:37
basic_resolver_results & operator=(const basic_resolver_results &other)
Assignment operator.
Definition: basic_resolver_results.hpp:106
friend bool operator==(const basic_resolver_results &a, const basic_resolver_results &b)
Test two iterators for equality.
Definition: basic_resolver_results.hpp:289
Definition: any_io_executor.hpp:28