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