123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262 |
- #ifndef BOOST_ASIO_IP_BASIC_RESOLVER_QUERY_HPP
- #define BOOST_ASIO_IP_BASIC_RESOLVER_QUERY_HPP
- #if defined(_MSC_VER) && (_MSC_VER >= 1200)
- # pragma once
- #endif
- #include <boost/asio/detail/config.hpp>
- #include <string>
- #include <boost/asio/detail/socket_ops.hpp>
- #include <boost/asio/ip/resolver_query_base.hpp>
- #include <boost/asio/detail/push_options.hpp>
- namespace boost {
- namespace asio {
- namespace ip {
- template <typename InternetProtocol>
- class basic_resolver_query
- : public resolver_query_base
- {
- public:
-
- typedef InternetProtocol protocol_type;
-
-
- basic_resolver_query(const std::string& service,
- resolver_query_base::flags resolve_flags = passive | address_configured)
- : hints_(),
- host_name_(),
- service_name_(service)
- {
- typename InternetProtocol::endpoint endpoint;
- hints_.ai_flags = static_cast<int>(resolve_flags);
- hints_.ai_family = PF_UNSPEC;
- hints_.ai_socktype = endpoint.protocol().type();
- hints_.ai_protocol = endpoint.protocol().protocol();
- hints_.ai_addrlen = 0;
- hints_.ai_canonname = 0;
- hints_.ai_addr = 0;
- hints_.ai_next = 0;
- }
-
-
- basic_resolver_query(const protocol_type& protocol,
- const std::string& service,
- resolver_query_base::flags resolve_flags = passive | address_configured)
- : hints_(),
- host_name_(),
- service_name_(service)
- {
- hints_.ai_flags = static_cast<int>(resolve_flags);
- hints_.ai_family = protocol.family();
- hints_.ai_socktype = protocol.type();
- hints_.ai_protocol = protocol.protocol();
- hints_.ai_addrlen = 0;
- hints_.ai_canonname = 0;
- hints_.ai_addr = 0;
- hints_.ai_next = 0;
- }
-
-
- basic_resolver_query(const std::string& host, const std::string& service,
- resolver_query_base::flags resolve_flags = address_configured)
- : hints_(),
- host_name_(host),
- service_name_(service)
- {
- typename InternetProtocol::endpoint endpoint;
- hints_.ai_flags = static_cast<int>(resolve_flags);
- hints_.ai_family = BOOST_ASIO_OS_DEF(AF_UNSPEC);
- hints_.ai_socktype = endpoint.protocol().type();
- hints_.ai_protocol = endpoint.protocol().protocol();
- hints_.ai_addrlen = 0;
- hints_.ai_canonname = 0;
- hints_.ai_addr = 0;
- hints_.ai_next = 0;
- }
-
-
- basic_resolver_query(const protocol_type& protocol,
- const std::string& host, const std::string& service,
- resolver_query_base::flags resolve_flags = address_configured)
- : hints_(),
- host_name_(host),
- service_name_(service)
- {
- hints_.ai_flags = static_cast<int>(resolve_flags);
- hints_.ai_family = protocol.family();
- hints_.ai_socktype = protocol.type();
- hints_.ai_protocol = protocol.protocol();
- hints_.ai_addrlen = 0;
- hints_.ai_canonname = 0;
- hints_.ai_addr = 0;
- hints_.ai_next = 0;
- }
-
- basic_resolver_query(const basic_resolver_query& other)
- : hints_(other.hints_),
- host_name_(other.host_name_),
- service_name_(other.service_name_)
- {
- }
-
- basic_resolver_query(basic_resolver_query&& other)
- : hints_(other.hints_),
- host_name_(static_cast<std::string&&>(other.host_name_)),
- service_name_(static_cast<std::string&&>(other.service_name_))
- {
- }
-
- const boost::asio::detail::addrinfo_type& hints() const
- {
- return hints_;
- }
-
- std::string host_name() const
- {
- return host_name_;
- }
-
- std::string service_name() const
- {
- return service_name_;
- }
- private:
- boost::asio::detail::addrinfo_type hints_;
- std::string host_name_;
- std::string service_name_;
- };
- }
- }
- }
- #include <boost/asio/detail/pop_options.hpp>
- #endif
|