libxr 1.0
Want to be the best embedded framework
Loading...
Searching...
No Matches
libxr_assert.hpp
1#pragma once
2
3#include <cstddef>
4#include <cstdint>
5#include <cstring>
6#include <optional>
7
8#include "libxr_cb.hpp"
9#include "libxr_def.hpp"
10
25void libxr_fatal_error(const char *file, uint32_t line, bool in_isr);
26
27namespace LibXR
28{
39class Assert
40{
41 public:
55
70
71#ifdef LIBXR_DEBUG_BUILD
90 template <SizeLimitMode mode>
91 static void SizeLimitCheck(size_t limit, size_t size)
92 {
93 if constexpr (mode == SizeLimitMode::EQUAL)
94 {
95 ASSERT(limit == size);
96 }
97 else if constexpr (mode == SizeLimitMode::MORE)
98 {
99 ASSERT(limit <= size);
100 }
101 else if constexpr (mode == SizeLimitMode::LESS)
102 {
103 ASSERT(limit >= size);
104 }
105 }
106#else
118 template <SizeLimitMode mode>
119 static void SizeLimitCheck(size_t limit, size_t size)
120 {
121 UNUSED(limit);
122 UNUSED(size);
123 }
124#endif
125
133 static inline std::optional<LibXR::Callback<const char *, uint32_t>>
135};
136} // namespace LibXR
运行时错误检查的断言工具类。 Provides assertion mechanisms for runtime error checking.
static void SizeLimitCheck(size_t limit, size_t size)
在非调试模式下的占位大小检查函数(无实际作用)。 Dummy size limit check for non-debug builds.
static void RegisterFatalErrorCB(LibXR::Callback< const char *, uint32_t > &&cb)
通过移动语义注册致命错误的回调函数。 Registers a fatal error callback with move semantics.
static std::optional< LibXR::Callback< const char *, uint32_t > > libxr_fatal_error_callback_
存储已注册的致命错误回调函数。 Stores the registered fatal error callback.
static void RegisterFatalErrorCB(const LibXR::Callback< const char *, uint32_t > &cb)
注册致命错误的回调函数。 Registers a fatal error callback.
提供一个通用的回调包装,支持动态参数传递。 Provides a generic callback wrapper, supporting dynamic argument passing.
Definition libxr_cb.hpp:124
LibXR Color Control Library / LibXR终端颜色控制库
constexpr auto min(T1 a, T2 b) -> typename std::common_type< T1, T2 >::type
计算两个数的最小值