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 15 #ifndef BOOST_LOG_EXPRESSIONS_PREDICATES_IS_DEBUGGER_PRESENT_HPP_INCLUDED_ 16 #define BOOST_LOG_EXPRESSIONS_PREDICATES_IS_DEBUGGER_PRESENT_HPP_INCLUDED_ 17 18 #include <boost/log/detail/config.hpp> 19 20 #ifdef BOOST_HAS_PRAGMA_ONCE 21 #pragma once 22 #endif 23 24 #if defined(BOOST_WINDOWS) 25 26 #include <boost/phoenix/core/terminal.hpp> // this is needed to be able to include this header alone, Boost.Phoenix blows up without it 27 #include <boost/phoenix/function/adapt_callable.hpp> 28 #include <boost/log/detail/header.hpp> 29 30 #if defined(BOOST_USE_WINDOWS_H) 31 32 #ifndef _WIN32_WINNT 33 #define _WIN32_WINNT 0x0500 34 #endif 35 36 #include <windows.h> 37 38 #else // defined(BOOST_USE_WINDOWS_H) 39 40 namespace boost { 41 42 BOOST_LOG_OPEN_NAMESPACE 43 44 namespace expressions { 45 46 namespace aux { 47 48 extern "C" { 49 50 __declspec(dllimport) int __stdcall IsDebuggerPresent(); 51 52 } // extern "C" 53 54 } // namespace aux 55 56 } // namespace expressions 57 58 BOOST_LOG_CLOSE_NAMESPACE // namespace log 59 60 } // namespace boost 61 62 #endif // BOOST_USE_WINDOWS_H 63 64 namespace boost { 65 66 BOOST_LOG_OPEN_NAMESPACE 67 68 namespace expressions { 69 70 namespace aux { 71 72 struct is_debugger_present 73 { 74 typedef bool result_type; 75 operator ()boost::expressions::aux::is_debugger_present76 result_type operator() () const 77 { 78 return IsDebuggerPresent() != 0; 79 } 80 }; 81 82 } // namespace aux 83 84 #ifndef BOOST_LOG_DOXYGEN_PASS 85 86 BOOST_PHOENIX_ADAPT_CALLABLE_NULLARY(is_debugger_present, aux::is_debugger_present) 87 88 #else 89 90 /*! 91 * The function generates a filter that will check whether the logger is attached to the process 92 */ 93 unspecified is_debugger_present(); 94 95 #endif 96 97 } // namespace expressions 98 99 BOOST_LOG_CLOSE_NAMESPACE // namespace log 100 101 } // namespace boost 102 103 #include <boost/log/detail/footer.hpp> 104 105 #endif // BOOST_WINDOWS 106 107 #endif // BOOST_LOG_EXPRESSIONS_PREDICATES_IS_DEBUGGER_PRESENT_HPP_INCLUDED_ 108