11 #ifndef ASIO_IP_BASIC_RESOLVER_ITERATOR_HPP 12 #define ASIO_IP_BASIC_RESOLVER_ITERATOR_HPP 14 #if defined(_MSC_VER) && (_MSC_VER >= 1200) 16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 29 #if defined(ASIO_WINDOWS_RUNTIME) 31 #endif // defined(ASIO_WINDOWS_RUNTIME) 50 template <
typename InternetProtocol>
78 const std::string&
host_name,
const std::string& service_name)
85 if (address_info->ai_canonname)
86 actual_host_name = address_info->ai_canonname;
88 iter.values_.reset(
new values_type);
93 || address_info->ai_family ==
ASIO_OS_DEF(AF_INET6))
96 typename InternetProtocol::endpoint endpoint;
97 endpoint.resize(static_cast<std::size_t>(address_info->ai_addrlen));
98 memcpy(endpoint.data(), address_info->ai_addr,
99 address_info->ai_addrlen);
100 iter.values_->push_back(
102 actual_host_name, service_name));
104 address_info = address_info->ai_next;
112 const typename InternetProtocol::endpoint& endpoint,
113 const std::string&
host_name,
const std::string& service_name)
116 iter.values_.reset(
new values_type);
117 iter.values_->push_back(
119 endpoint, host_name, service_name));
124 template <
typename Endpo
intIterator>
126 EndpointIterator
begin, EndpointIterator
end,
127 const std::string&
host_name,
const std::string& service_name)
132 iter.values_.reset(
new values_type);
133 for (EndpointIterator ep_iter = begin; ep_iter !=
end; ++ep_iter)
135 iter.values_->push_back(
137 *ep_iter, host_name, service_name));
143 #if defined(ASIO_WINDOWS_RUNTIME) 146 Windows::Foundation::Collections::IVectorView<
147 Windows::Networking::EndpointPair^>^ endpoints,
149 const std::string&
host_name,
const std::string& service_name)
154 iter.values_.reset(
new values_type);
155 for (
unsigned int i = 0; i < endpoints->Size; ++i)
157 auto pair = endpoints->GetAt(i);
160 && pair->RemoteHostName->Type
161 != Windows::Networking::HostNameType::Ipv4)
165 && pair->RemoteHostName->Type
166 != Windows::Networking::HostNameType::Ipv6)
169 iter.values_->push_back(
171 typename InternetProtocol::endpoint(
173 asio::detail::winrt_utils::string(
174 pair->RemoteHostName->CanonicalName)),
175 asio::detail::winrt_utils::integer(
176 pair->RemoteServiceName)),
177 host_name, service_name));
182 #endif // defined(ASIO_WINDOWS_RUNTIME) 187 return dereference();
193 return &dereference();
228 if (++index_ == values_->size())
238 if (!values_ && !other.values_)
240 if (values_ != other.values_)
242 return index_ == other.index_;
247 return (*values_)[index_];
250 typedef std::vector<basic_resolver_entry<InternetProtocol> > values_type;
251 asio::detail::shared_ptr<values_type> values_;
260 #endif // ASIO_IP_BASIC_RESOLVER_ITERATOR_HPP static basic_resolver_iterator create(asio::detail::addrinfo_type *address_info, const std::string &host_name, const std::string &service_name)
Create an iterator from an addrinfo list returned by getaddrinfo.
friend bool operator!=(const basic_resolver_iterator &a, const basic_resolver_iterator &b)
Test two iterators for inequality.
static basic_resolver_iterator create(EndpointIterator begin, EndpointIterator end, const std::string &host_name, const std::string &service_name)
Create an iterator from a sequence of endpoints, host and service name.
SocketService Iterator begin
std::forward_iterator_tag iterator_category
The iterator category.
static ASIO_DECL address from_string(const char *str)
asio::basic_streambuf< Allocator > & b
basic_resolver_iterator()
Default constructor creates an end iterator.
const basic_resolver_entry< InternetProtocol > * pointer
The type of the result of applying operator->() to the iterator.
std::ptrdiff_t difference_type
The type used for the distance between two iterators.
basic_resolver_iterator operator++(int)
Increment operator (postfix).
const basic_resolver_entry< InternetProtocol > & reference
The type of the result of applying operator*() to the iterator.
friend bool operator==(const basic_resolver_iterator &a, const basic_resolver_iterator &b)
Test two iterators for equality.
const basic_resolver_entry< InternetProtocol > & operator*() const
Dereference an iterator.
static basic_resolver_iterator create(const typename InternetProtocol::endpoint &endpoint, const std::string &host_name, const std::string &service_name)
Create an iterator from an endpoint, host name and service name.
An iterator over the entries produced by a resolver.
ASIO_DECL std::string host_name()
Get the current host name.
basic_resolver_entry< InternetProtocol > value_type
The type of the value pointed to by the iterator.
SocketService Iterator Iterator end
An entry produced by a resolver.
basic_resolver_iterator & operator++()
Increment operator (prefix).
const basic_resolver_entry< InternetProtocol > * operator->() const
Dereference an iterator.