MyGUI 3.2.2

MyGUI_Diagnostic.h
Go to the documentation of this file.
1 /*
2 * This source file is part of MyGUI. For the latest info, see http://mygui.info/
3 * Distributed under the MIT License
4 * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT)
5 */
6
7 #ifndef MYGUI_DIAGNOSTIC_H_
8 #define MYGUI_DIAGNOSTIC_H_
9
10 #include "MyGUI_Prerequest.h"
11 #include "MyGUI_Exception.h"
12 #include "MyGUI_LogManager.h"
13 #include <sstream>
14
15 // for debugging
16 #if MYGUI_COMPILER == MYGUI_COMPILER_MSVC
17 # include <crtdbg.h>
18 #endif
19
20 #define MYGUI_LOG_SECTION "Core"
21 #define MYGUI_LOG_FILENAME "MyGUI.log"
22 #define MYGUI_LOG(level, text) MYGUI_LOGGING(MYGUI_LOG_SECTION, level, text)
23
24 #define MYGUI_BASE_EXCEPT(desc, src) throw MyGUI::Exception(desc, src, __FILE__, __LINE__);
25
26 // MSVC specific: sets the breakpoint
27 #if MYGUI_COMPILER == MYGUI_COMPILER_MSVC
28 # define MYGUI_DBG_BREAK _CrtDbgBreak();
29 #else
30 # define MYGUI_DBG_BREAK
31 #endif
32
33 #define MYGUI_EXCEPT(dest) \
34 { \
35 MYGUI_LOG(Critical, dest); \
36 MYGUI_DBG_BREAK;\
37 std::ostringstream stream; \
38 stream << dest << "\n"; \
39 MYGUI_BASE_EXCEPT(stream.str().c_str(), "MyGUI"); \
40 }
41
42 #define MYGUI_ASSERT(exp, dest) \
43 { \
44 if ( ! (exp) ) \
45 { \
46 MYGUI_LOG(Critical, dest); \
47 MYGUI_DBG_BREAK;\
48 std::ostringstream stream; \
49 stream << dest << "\n"; \
50 MYGUI_BASE_EXCEPT(stream.str().c_str(), "MyGUI"); \
51 } \
52 }
53
54 #define MYGUI_ASSERT_RANGE(index, size, owner) MYGUI_ASSERT(index < size, owner << " : index number " << index << " out of range [" << size << "]");
55 #define MYGUI_ASSERT_RANGE_AND_NONE(index, size, owner) MYGUI_ASSERT(index < size || index == MyGUI::ITEM_NONE, owner << " : index number " << index << " out of range [" << size << "]");
56 #define MYGUI_ASSERT_RANGE_INSERT(index, size, owner) MYGUI_ASSERT((index <= size) || (index == MyGUI::ITEM_NONE), owner << " : insert index number " << index << " out of range [" << size << "] or not ITEM_NONE");
57
58 #if MYGUI_DEBUG_MODE == 1
59 # define MYGUI_REGISTER_VALUE(map, value) \
60 { \
61 MYGUI_LOG(Info, "Register value : '" << #value << "' = " << (int)value); \
62 map[#value] = value; \
63 }
64 # define MYGUI_DEBUG_ASSERT(exp, dest) MYGUI_ASSERT(exp, dest)
65 #else
66 # define MYGUI_REGISTER_VALUE(map, value) map[#value] = value;
67 # define MYGUI_DEBUG_ASSERT(exp, dest) ((void)0)
68 #endif
69
70
71 #if MYGUI_COMPILER == MYGUI_COMPILER_MSVC
72 # if MYGUI_COMP_VER < 1310 // VC++ 7.1
73 # define MYGUI_OBSOLETE_START(text)
74 # define MYGUI_OBSOLETE_END
75 # else
76 # define MYGUI_OBSOLETE_START(text) __declspec(deprecated(text))
77 # define MYGUI_OBSOLETE_END
78 # endif
79
80 #elif MYGUI_COMPILER == MYGUI_COMPILER_GNUC
81 # if MYGUI_PLATFORM == MYGUI_PLATFORM_LINUX && MYGUI_COMP_VER < 310 // gcc 3.1
82 # define MYGUI_OBSOLETE_START(text)
83 # define MYGUI_OBSOLETE_END
84 # else
85 # define MYGUI_OBSOLETE_START(text)
86 # define MYGUI_OBSOLETE_END __attribute__((deprecated))
87 # endif
88
89 #else
90 # define MYGUI_OBSOLETE_START(text)
91 # define MYGUI_OBSOLETE_END
92
93 #endif
94
95 #define MYGUI_OBSOLETE(text) MYGUI_OBSOLETE_START(text)MYGUI_OBSOLETE_END
96
97 #endif // MYGUI_DIAGNOSTIC_H_
MyGUI_Prerequest.h
MyGUI_Exception.h
MyGUI_LogManager.h