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