• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // ip/resolver_query_base.hpp
3 // ~~~~~~~~~~~~~~~~~~~~~~~~~~
4 //
5 // Copyright (c) 2003-2015 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 //
7 // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 //
10 
11 #ifndef ASIO_IP_RESOLVER_QUERY_BASE_HPP
12 #define ASIO_IP_RESOLVER_QUERY_BASE_HPP
13 
14 
15 #include "asio/detail/config.hpp"
16 #include "asio/detail/socket_types.hpp"
17 
18 #include "asio/detail/push_options.hpp"
19 
20 namespace asio {
21 namespace ip {
22 
23 /// The resolver_query_base class is used as a base for the
24 /// basic_resolver_query class templates to provide a common place to define
25 /// the flag constants.
26 class resolver_query_base
27 {
28 public:
29   enum flags
30   {
31     canonical_name = ASIO_OS_DEF(AI_CANONNAME),
32     passive = ASIO_OS_DEF(AI_PASSIVE),
33     numeric_host = ASIO_OS_DEF(AI_NUMERICHOST),
34     numeric_service = ASIO_OS_DEF(AI_NUMERICSERV),
35     v4_mapped = ASIO_OS_DEF(AI_V4MAPPED),
36     all_matching = ASIO_OS_DEF(AI_ALL),
37     address_configured = ASIO_OS_DEF(AI_ADDRCONFIG)
38   };
39 
40   // Implement bitmask operations as shown in C++ Std [lib.bitmask.types].
41 
operator &(flags x,flags y)42   friend flags operator&(flags x, flags y)
43   {
44     return static_cast<flags>(
45         static_cast<unsigned int>(x) & static_cast<unsigned int>(y));
46   }
47 
operator |(flags x,flags y)48   friend flags operator|(flags x, flags y)
49   {
50     return static_cast<flags>(
51         static_cast<unsigned int>(x) | static_cast<unsigned int>(y));
52   }
53 
operator ^(flags x,flags y)54   friend flags operator^(flags x, flags y)
55   {
56     return static_cast<flags>(
57         static_cast<unsigned int>(x) ^ static_cast<unsigned int>(y));
58   }
59 
operator ~(flags x)60   friend flags operator~(flags x)
61   {
62     return static_cast<flags>(~static_cast<unsigned int>(x));
63   }
64 
operator &=(flags & x,flags y)65   friend flags& operator&=(flags& x, flags y)
66   {
67     x = x & y;
68     return x;
69   }
70 
operator |=(flags & x,flags y)71   friend flags& operator|=(flags& x, flags y)
72   {
73     x = x | y;
74     return x;
75   }
76 
operator ^=(flags & x,flags y)77   friend flags& operator^=(flags& x, flags y)
78   {
79     x = x ^ y;
80     return x;
81   }
82 
83 protected:
84   /// Protected destructor to prevent deletion through this type.
~resolver_query_base()85   ~resolver_query_base()
86   {
87   }
88 };
89 
90 } // namespace ip
91 } // namespace asio
92 
93 #include "asio/detail/pop_options.hpp"
94 
95 #endif // ASIO_IP_RESOLVER_QUERY_BASE_HPP
96