is_debugger_present.hpp 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /*
  2. * Copyright Andrey Semashev 2007 - 2015.
  3. * Distributed under the Boost Software License, Version 1.0.
  4. * (See accompanying file LICENSE_1_0.txt or copy at
  5. * http://www.boost.org/LICENSE_1_0.txt)
  6. */
  7. /*!
  8. * \file is_debugger_present.hpp
  9. * \author Andrey Semashev
  10. * \date 05.12.2012
  11. *
  12. * The header contains implementation of the \c is_debugger_present predicate in template expressions.
  13. */
  14. #ifndef BOOST_LOG_EXPRESSIONS_PREDICATES_IS_DEBUGGER_PRESENT_HPP_INCLUDED_
  15. #define BOOST_LOG_EXPRESSIONS_PREDICATES_IS_DEBUGGER_PRESENT_HPP_INCLUDED_
  16. #include <boost/log/detail/config.hpp>
  17. #ifdef BOOST_HAS_PRAGMA_ONCE
  18. #pragma once
  19. #endif
  20. #if defined(BOOST_WINDOWS)
  21. #include <boost/phoenix/core/terminal.hpp> // this is needed to be able to include this header alone, Boost.Phoenix blows up without it
  22. #include <boost/phoenix/function/adapt_callable.hpp>
  23. #include <boost/log/detail/header.hpp>
  24. #if defined(BOOST_USE_WINDOWS_H)
  25. #ifndef _WIN32_WINNT
  26. #define _WIN32_WINNT 0x0500
  27. #endif
  28. #include <windows.h>
  29. #else // defined(BOOST_USE_WINDOWS_H)
  30. namespace boost {
  31. BOOST_LOG_OPEN_NAMESPACE
  32. namespace expressions {
  33. namespace aux {
  34. extern "C" {
  35. __declspec(dllimport) int __stdcall IsDebuggerPresent();
  36. } // extern "C"
  37. } // namespace aux
  38. } // namespace expressions
  39. BOOST_LOG_CLOSE_NAMESPACE // namespace log
  40. } // namespace boost
  41. #endif // BOOST_USE_WINDOWS_H
  42. namespace boost {
  43. BOOST_LOG_OPEN_NAMESPACE
  44. namespace expressions {
  45. namespace aux {
  46. struct is_debugger_present
  47. {
  48. typedef bool result_type;
  49. result_type operator() () const
  50. {
  51. return IsDebuggerPresent() != 0;
  52. }
  53. };
  54. } // namespace aux
  55. #ifndef BOOST_LOG_DOXYGEN_PASS
  56. BOOST_PHOENIX_ADAPT_CALLABLE_NULLARY(is_debugger_present, aux::is_debugger_present)
  57. #else
  58. /*!
  59. * The function generates a filter that will check whether the logger is attached to the process
  60. */
  61. unspecified is_debugger_present();
  62. #endif
  63. } // namespace expressions
  64. BOOST_LOG_CLOSE_NAMESPACE // namespace log
  65. } // namespace boost
  66. #include <boost/log/detail/footer.hpp>
  67. #endif // BOOST_WINDOWS
  68. #endif // BOOST_LOG_EXPRESSIONS_PREDICATES_IS_DEBUGGER_PRESENT_HPP_INCLUDED_