Chris@16
|
1 //
|
Chris@16
|
2 // ip/resolver_query_base.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_RESOLVER_QUERY_BASE_HPP
|
Chris@16
|
12 #define BOOST_ASIO_IP_RESOLVER_QUERY_BASE_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 <boost/asio/detail/socket_types.hpp>
|
Chris@16
|
20
|
Chris@16
|
21 #include <boost/asio/detail/push_options.hpp>
|
Chris@16
|
22
|
Chris@16
|
23 namespace boost {
|
Chris@16
|
24 namespace asio {
|
Chris@16
|
25 namespace ip {
|
Chris@16
|
26
|
Chris@16
|
27 /// The resolver_query_base class is used as a base for the
|
Chris@16
|
28 /// basic_resolver_query class templates to provide a common place to define
|
Chris@16
|
29 /// the flag constants.
|
Chris@16
|
30 class resolver_query_base
|
Chris@16
|
31 {
|
Chris@16
|
32 public:
|
Chris@16
|
33 #if defined(GENERATING_DOCUMENTATION)
|
Chris@16
|
34 /// A bitmask type (C++ Std [lib.bitmask.types]).
|
Chris@16
|
35 typedef unspecified flags;
|
Chris@16
|
36
|
Chris@16
|
37 /// Determine the canonical name of the host specified in the query.
|
Chris@16
|
38 static const flags canonical_name = implementation_defined;
|
Chris@16
|
39
|
Chris@16
|
40 /// Indicate that returned endpoint is intended for use as a locally bound
|
Chris@16
|
41 /// socket endpoint.
|
Chris@16
|
42 static const flags passive = implementation_defined;
|
Chris@16
|
43
|
Chris@16
|
44 /// Host name should be treated as a numeric string defining an IPv4 or IPv6
|
Chris@16
|
45 /// address and no name resolution should be attempted.
|
Chris@16
|
46 static const flags numeric_host = implementation_defined;
|
Chris@16
|
47
|
Chris@16
|
48 /// Service name should be treated as a numeric string defining a port number
|
Chris@16
|
49 /// and no name resolution should be attempted.
|
Chris@16
|
50 static const flags numeric_service = implementation_defined;
|
Chris@16
|
51
|
Chris@16
|
52 /// If the query protocol family is specified as IPv6, return IPv4-mapped
|
Chris@16
|
53 /// IPv6 addresses on finding no IPv6 addresses.
|
Chris@16
|
54 static const flags v4_mapped = implementation_defined;
|
Chris@16
|
55
|
Chris@16
|
56 /// If used with v4_mapped, return all matching IPv6 and IPv4 addresses.
|
Chris@16
|
57 static const flags all_matching = implementation_defined;
|
Chris@16
|
58
|
Chris@16
|
59 /// Only return IPv4 addresses if a non-loopback IPv4 address is configured
|
Chris@16
|
60 /// for the system. Only return IPv6 addresses if a non-loopback IPv6 address
|
Chris@16
|
61 /// is configured for the system.
|
Chris@16
|
62 static const flags address_configured = implementation_defined;
|
Chris@16
|
63 #else
|
Chris@16
|
64 enum flags
|
Chris@16
|
65 {
|
Chris@16
|
66 canonical_name = BOOST_ASIO_OS_DEF(AI_CANONNAME),
|
Chris@16
|
67 passive = BOOST_ASIO_OS_DEF(AI_PASSIVE),
|
Chris@16
|
68 numeric_host = BOOST_ASIO_OS_DEF(AI_NUMERICHOST),
|
Chris@16
|
69 numeric_service = BOOST_ASIO_OS_DEF(AI_NUMERICSERV),
|
Chris@16
|
70 v4_mapped = BOOST_ASIO_OS_DEF(AI_V4MAPPED),
|
Chris@16
|
71 all_matching = BOOST_ASIO_OS_DEF(AI_ALL),
|
Chris@16
|
72 address_configured = BOOST_ASIO_OS_DEF(AI_ADDRCONFIG)
|
Chris@16
|
73 };
|
Chris@16
|
74
|
Chris@16
|
75 // Implement bitmask operations as shown in C++ Std [lib.bitmask.types].
|
Chris@16
|
76
|
Chris@16
|
77 friend flags operator&(flags x, flags y)
|
Chris@16
|
78 {
|
Chris@16
|
79 return static_cast<flags>(
|
Chris@16
|
80 static_cast<unsigned int>(x) & static_cast<unsigned int>(y));
|
Chris@16
|
81 }
|
Chris@16
|
82
|
Chris@16
|
83 friend flags operator|(flags x, flags y)
|
Chris@16
|
84 {
|
Chris@16
|
85 return static_cast<flags>(
|
Chris@16
|
86 static_cast<unsigned int>(x) | static_cast<unsigned int>(y));
|
Chris@16
|
87 }
|
Chris@16
|
88
|
Chris@16
|
89 friend flags operator^(flags x, flags y)
|
Chris@16
|
90 {
|
Chris@16
|
91 return static_cast<flags>(
|
Chris@16
|
92 static_cast<unsigned int>(x) ^ static_cast<unsigned int>(y));
|
Chris@16
|
93 }
|
Chris@16
|
94
|
Chris@16
|
95 friend flags operator~(flags x)
|
Chris@16
|
96 {
|
Chris@101
|
97 return static_cast<flags>(~static_cast<unsigned int>(x));
|
Chris@16
|
98 }
|
Chris@16
|
99
|
Chris@16
|
100 friend flags& operator&=(flags& x, flags y)
|
Chris@16
|
101 {
|
Chris@16
|
102 x = x & y;
|
Chris@16
|
103 return x;
|
Chris@16
|
104 }
|
Chris@16
|
105
|
Chris@16
|
106 friend flags& operator|=(flags& x, flags y)
|
Chris@16
|
107 {
|
Chris@16
|
108 x = x | y;
|
Chris@16
|
109 return x;
|
Chris@16
|
110 }
|
Chris@16
|
111
|
Chris@16
|
112 friend flags& operator^=(flags& x, flags y)
|
Chris@16
|
113 {
|
Chris@16
|
114 x = x ^ y;
|
Chris@16
|
115 return x;
|
Chris@16
|
116 }
|
Chris@16
|
117 #endif
|
Chris@16
|
118
|
Chris@16
|
119 protected:
|
Chris@16
|
120 /// Protected destructor to prevent deletion through this type.
|
Chris@16
|
121 ~resolver_query_base()
|
Chris@16
|
122 {
|
Chris@16
|
123 }
|
Chris@16
|
124 };
|
Chris@16
|
125
|
Chris@16
|
126 } // namespace ip
|
Chris@16
|
127 } // namespace asio
|
Chris@16
|
128 } // namespace boost
|
Chris@16
|
129
|
Chris@16
|
130 #include <boost/asio/detail/pop_options.hpp>
|
Chris@16
|
131
|
Chris@16
|
132 #endif // BOOST_ASIO_IP_RESOLVER_QUERY_BASE_HPP
|