MyGUI: MyGUI_Diagnostic.h Source File

MyGUI 3.4.3

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#define MYGUI_LOG_SECTION "Core"
16#define MYGUI_LOG_FILENAME "MyGUI.log"
17#define MYGUI_LOG(level, text) MYGUI_LOGGING(MYGUI_LOG_SECTION, level, text)
18
19#define MYGUI_BASE_EXCEPT(desc, src) throw MyGUI::Exception(desc, src, __FILE__, __LINE__)
20
21#define MYGUI_EXCEPT(dest) \
22 do \
23 { \
24 MYGUI_LOG(Critical, dest); \
25 std::ostringstream stream; \
26 stream << dest << "\n"; \
27 MYGUI_BASE_EXCEPT(stream.str().c_str(), "MyGUI"); \
28 } while (false)
29
30// NOLINTBEGIN(readability-simplify-boolean-expr)
31#define MYGUI_ASSERT(exp, dest) \
32 do \
33 { \
34 if (!(exp)) \
35 { \
36 MYGUI_LOG(Critical, dest); \
37 std::ostringstream stream; \
38 stream << dest << "\n"; \
39 MYGUI_BASE_EXCEPT(stream.str().c_str(), "MyGUI"); \
40 } \
41 } while (false)
42// NOLINTEND(readability-simplify-boolean-expr)
43
44#define MYGUI_ASSERT_RANGE(index, size, owner) \
45 MYGUI_ASSERT(index < size, owner << " : index number " << index << " out of range [" << size << "]")
46#define MYGUI_ASSERT_RANGE_AND_NONE(index, size, owner) \
47 MYGUI_ASSERT( \
48 index < size || index == MyGUI::ITEM_NONE, \
49 owner << " : index number " << index << " out of range [" << size << "]")
50#define MYGUI_ASSERT_RANGE_INSERT(index, size, owner) \
51 MYGUI_ASSERT( \
52 (index <= size) || (index == MyGUI::ITEM_NONE), \
53 owner << " : insert index number " << index << " out of range [" << size << "] or not ITEM_NONE")
54
55#if MYGUI_DEBUG_MODE == 1
56 #define MYGUI_REGISTER_VALUE(map, value) \
57 do \
58 { \
59 MYGUI_LOG(Info, "Register value : '" << #value << "' = " << (int)value); \
60 map[#value] = value; \
61 } while (false)
62 #define MYGUI_DEBUG_ASSERT(exp, dest) MYGUI_ASSERT(exp, dest)
63#else
64 #define MYGUI_REGISTER_VALUE(map, value) map[#value] = value
65 #define MYGUI_DEBUG_ASSERT(exp, dest) ((void)0)
66#endif
67
68#define MYGUI_OBSOLETE(text) [[deprecated(text)]]
69
70#endif // MYGUI_DIAGNOSTIC_H_
MyGUI_Exception.h
MyGUI_LogManager.h
MyGUI_Prerequest.h