annotate DEPENDENCIES/generic/include/boost/asio/ip/basic_resolver_query.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/basic_resolver_query.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_BASIC_RESOLVER_QUERY_HPP
Chris@16 12 #define BOOST_ASIO_IP_BASIC_RESOLVER_QUERY_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 <string>
Chris@16 20 #include <boost/asio/detail/socket_ops.hpp>
Chris@16 21 #include <boost/asio/ip/resolver_query_base.hpp>
Chris@16 22
Chris@16 23 #include <boost/asio/detail/push_options.hpp>
Chris@16 24
Chris@16 25 namespace boost {
Chris@16 26 namespace asio {
Chris@16 27 namespace ip {
Chris@16 28
Chris@16 29 /// An query to be passed to a resolver.
Chris@16 30 /**
Chris@16 31 * The boost::asio::ip::basic_resolver_query class template describes a query
Chris@16 32 * that can be passed to a resolver.
Chris@16 33 *
Chris@16 34 * @par Thread Safety
Chris@16 35 * @e Distinct @e objects: Safe.@n
Chris@16 36 * @e Shared @e objects: Unsafe.
Chris@16 37 */
Chris@16 38 template <typename InternetProtocol>
Chris@16 39 class basic_resolver_query
Chris@16 40 : public resolver_query_base
Chris@16 41 {
Chris@16 42 public:
Chris@16 43 /// The protocol type associated with the endpoint query.
Chris@16 44 typedef InternetProtocol protocol_type;
Chris@16 45
Chris@16 46 /// Construct with specified service name for any protocol.
Chris@16 47 /**
Chris@16 48 * This constructor is typically used to perform name resolution for local
Chris@16 49 * service binding.
Chris@16 50 *
Chris@16 51 * @param service A string identifying the requested service. This may be a
Chris@16 52 * descriptive name or a numeric string corresponding to a port number.
Chris@16 53 *
Chris@16 54 * @param resolve_flags A set of flags that determine how name resolution
Chris@16 55 * should be performed. The default flags are suitable for local service
Chris@16 56 * binding.
Chris@16 57 *
Chris@16 58 * @note On POSIX systems, service names are typically defined in the file
Chris@16 59 * <tt>/etc/services</tt>. On Windows, service names may be found in the file
Chris@16 60 * <tt>c:\\windows\\system32\\drivers\\etc\\services</tt>. Operating systems
Chris@16 61 * may use additional locations when resolving service names.
Chris@16 62 */
Chris@16 63 basic_resolver_query(const std::string& service,
Chris@16 64 resolver_query_base::flags resolve_flags = passive | address_configured)
Chris@16 65 : hints_(),
Chris@16 66 host_name_(),
Chris@16 67 service_name_(service)
Chris@16 68 {
Chris@16 69 typename InternetProtocol::endpoint endpoint;
Chris@16 70 hints_.ai_flags = static_cast<int>(resolve_flags);
Chris@16 71 hints_.ai_family = PF_UNSPEC;
Chris@16 72 hints_.ai_socktype = endpoint.protocol().type();
Chris@16 73 hints_.ai_protocol = endpoint.protocol().protocol();
Chris@16 74 hints_.ai_addrlen = 0;
Chris@16 75 hints_.ai_canonname = 0;
Chris@16 76 hints_.ai_addr = 0;
Chris@16 77 hints_.ai_next = 0;
Chris@16 78 }
Chris@16 79
Chris@16 80 /// Construct with specified service name for a given protocol.
Chris@16 81 /**
Chris@16 82 * This constructor is typically used to perform name resolution for local
Chris@16 83 * service binding with a specific protocol version.
Chris@16 84 *
Chris@16 85 * @param protocol A protocol object, normally representing either the IPv4 or
Chris@16 86 * IPv6 version of an internet protocol.
Chris@16 87 *
Chris@16 88 * @param service A string identifying the requested service. This may be a
Chris@16 89 * descriptive name or a numeric string corresponding to a port number.
Chris@16 90 *
Chris@16 91 * @param resolve_flags A set of flags that determine how name resolution
Chris@16 92 * should be performed. The default flags are suitable for local service
Chris@16 93 * binding.
Chris@16 94 *
Chris@16 95 * @note On POSIX systems, service names are typically defined in the file
Chris@16 96 * <tt>/etc/services</tt>. On Windows, service names may be found in the file
Chris@16 97 * <tt>c:\\windows\\system32\\drivers\\etc\\services</tt>. Operating systems
Chris@16 98 * may use additional locations when resolving service names.
Chris@16 99 */
Chris@16 100 basic_resolver_query(const protocol_type& protocol,
Chris@16 101 const std::string& service,
Chris@16 102 resolver_query_base::flags resolve_flags = passive | address_configured)
Chris@16 103 : hints_(),
Chris@16 104 host_name_(),
Chris@16 105 service_name_(service)
Chris@16 106 {
Chris@16 107 hints_.ai_flags = static_cast<int>(resolve_flags);
Chris@16 108 hints_.ai_family = protocol.family();
Chris@16 109 hints_.ai_socktype = protocol.type();
Chris@16 110 hints_.ai_protocol = protocol.protocol();
Chris@16 111 hints_.ai_addrlen = 0;
Chris@16 112 hints_.ai_canonname = 0;
Chris@16 113 hints_.ai_addr = 0;
Chris@16 114 hints_.ai_next = 0;
Chris@16 115 }
Chris@16 116
Chris@16 117 /// Construct with specified host name and service name for any protocol.
Chris@16 118 /**
Chris@16 119 * This constructor is typically used to perform name resolution for
Chris@16 120 * communication with remote hosts.
Chris@16 121 *
Chris@16 122 * @param host A string identifying a location. May be a descriptive name or
Chris@16 123 * a numeric address string. If an empty string and the passive flag has been
Chris@16 124 * specified, the resolved endpoints are suitable for local service binding.
Chris@16 125 * If an empty string and passive is not specified, the resolved endpoints
Chris@16 126 * will use the loopback address.
Chris@16 127 *
Chris@16 128 * @param service A string identifying the requested service. This may be a
Chris@16 129 * descriptive name or a numeric string corresponding to a port number. May
Chris@16 130 * be an empty string, in which case all resolved endpoints will have a port
Chris@16 131 * number of 0.
Chris@16 132 *
Chris@16 133 * @param resolve_flags A set of flags that determine how name resolution
Chris@16 134 * should be performed. The default flags are suitable for communication with
Chris@16 135 * remote hosts.
Chris@16 136 *
Chris@16 137 * @note On POSIX systems, host names may be locally defined in the file
Chris@16 138 * <tt>/etc/hosts</tt>. On Windows, host names may be defined in the file
Chris@16 139 * <tt>c:\\windows\\system32\\drivers\\etc\\hosts</tt>. Remote host name
Chris@16 140 * resolution is performed using DNS. Operating systems may use additional
Chris@16 141 * locations when resolving host names (such as NETBIOS names on Windows).
Chris@16 142 *
Chris@16 143 * On POSIX systems, service names are typically defined in the file
Chris@16 144 * <tt>/etc/services</tt>. On Windows, service names may be found in the file
Chris@16 145 * <tt>c:\\windows\\system32\\drivers\\etc\\services</tt>. Operating systems
Chris@16 146 * may use additional locations when resolving service names.
Chris@16 147 */
Chris@16 148 basic_resolver_query(const std::string& host, const std::string& service,
Chris@16 149 resolver_query_base::flags resolve_flags = address_configured)
Chris@16 150 : hints_(),
Chris@16 151 host_name_(host),
Chris@16 152 service_name_(service)
Chris@16 153 {
Chris@16 154 typename InternetProtocol::endpoint endpoint;
Chris@16 155 hints_.ai_flags = static_cast<int>(resolve_flags);
Chris@16 156 hints_.ai_family = BOOST_ASIO_OS_DEF(AF_UNSPEC);
Chris@16 157 hints_.ai_socktype = endpoint.protocol().type();
Chris@16 158 hints_.ai_protocol = endpoint.protocol().protocol();
Chris@16 159 hints_.ai_addrlen = 0;
Chris@16 160 hints_.ai_canonname = 0;
Chris@16 161 hints_.ai_addr = 0;
Chris@16 162 hints_.ai_next = 0;
Chris@16 163 }
Chris@16 164
Chris@16 165 /// Construct with specified host name and service name for a given protocol.
Chris@16 166 /**
Chris@16 167 * This constructor is typically used to perform name resolution for
Chris@16 168 * communication with remote hosts.
Chris@16 169 *
Chris@16 170 * @param protocol A protocol object, normally representing either the IPv4 or
Chris@16 171 * IPv6 version of an internet protocol.
Chris@16 172 *
Chris@16 173 * @param host A string identifying a location. May be a descriptive name or
Chris@16 174 * a numeric address string. If an empty string and the passive flag has been
Chris@16 175 * specified, the resolved endpoints are suitable for local service binding.
Chris@16 176 * If an empty string and passive is not specified, the resolved endpoints
Chris@16 177 * will use the loopback address.
Chris@16 178 *
Chris@16 179 * @param service A string identifying the requested service. This may be a
Chris@16 180 * descriptive name or a numeric string corresponding to a port number. May
Chris@16 181 * be an empty string, in which case all resolved endpoints will have a port
Chris@16 182 * number of 0.
Chris@16 183 *
Chris@16 184 * @param resolve_flags A set of flags that determine how name resolution
Chris@16 185 * should be performed. The default flags are suitable for communication with
Chris@16 186 * remote hosts.
Chris@16 187 *
Chris@16 188 * @note On POSIX systems, host names may be locally defined in the file
Chris@16 189 * <tt>/etc/hosts</tt>. On Windows, host names may be defined in the file
Chris@16 190 * <tt>c:\\windows\\system32\\drivers\\etc\\hosts</tt>. Remote host name
Chris@16 191 * resolution is performed using DNS. Operating systems may use additional
Chris@16 192 * locations when resolving host names (such as NETBIOS names on Windows).
Chris@16 193 *
Chris@16 194 * On POSIX systems, service names are typically defined in the file
Chris@16 195 * <tt>/etc/services</tt>. On Windows, service names may be found in the file
Chris@16 196 * <tt>c:\\windows\\system32\\drivers\\etc\\services</tt>. Operating systems
Chris@16 197 * may use additional locations when resolving service names.
Chris@16 198 */
Chris@16 199 basic_resolver_query(const protocol_type& protocol,
Chris@16 200 const std::string& host, const std::string& service,
Chris@16 201 resolver_query_base::flags resolve_flags = address_configured)
Chris@16 202 : hints_(),
Chris@16 203 host_name_(host),
Chris@16 204 service_name_(service)
Chris@16 205 {
Chris@16 206 hints_.ai_flags = static_cast<int>(resolve_flags);
Chris@16 207 hints_.ai_family = protocol.family();
Chris@16 208 hints_.ai_socktype = protocol.type();
Chris@16 209 hints_.ai_protocol = protocol.protocol();
Chris@16 210 hints_.ai_addrlen = 0;
Chris@16 211 hints_.ai_canonname = 0;
Chris@16 212 hints_.ai_addr = 0;
Chris@16 213 hints_.ai_next = 0;
Chris@16 214 }
Chris@16 215
Chris@16 216 /// Get the hints associated with the query.
Chris@16 217 const boost::asio::detail::addrinfo_type& hints() const
Chris@16 218 {
Chris@16 219 return hints_;
Chris@16 220 }
Chris@16 221
Chris@16 222 /// Get the host name associated with the query.
Chris@16 223 std::string host_name() const
Chris@16 224 {
Chris@16 225 return host_name_;
Chris@16 226 }
Chris@16 227
Chris@16 228 /// Get the service name associated with the query.
Chris@16 229 std::string service_name() const
Chris@16 230 {
Chris@16 231 return service_name_;
Chris@16 232 }
Chris@16 233
Chris@16 234 private:
Chris@16 235 boost::asio::detail::addrinfo_type hints_;
Chris@16 236 std::string host_name_;
Chris@16 237 std::string service_name_;
Chris@16 238 };
Chris@16 239
Chris@16 240 } // namespace ip
Chris@16 241 } // namespace asio
Chris@16 242 } // namespace boost
Chris@16 243
Chris@16 244 #include <boost/asio/detail/pop_options.hpp>
Chris@16 245
Chris@16 246 #endif // BOOST_ASIO_IP_BASIC_RESOLVER_QUERY_HPP