resolver_query_base.hpp 3.7 KB

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