libxr 1.0
Want to be the best embedded framework
Loading...
Searching...
No Matches
LibXR::Assert Class Reference

运行时错误检查的断言工具类。 Provides assertion mechanisms for runtime error checking. More...

#include <libxr_assert.hpp>

Static Public Member Functions

static void RegisterFatalErrorCB (const LibXR::Callback< const char *, uint32_t > &cb)
 注册致命错误的回调函数。 Registers a fatal error callback.
 
static void RegisterFatalErrorCB (LibXR::Callback< const char *, uint32_t > &&cb)
 通过移动语义注册致命错误的回调函数。 Registers a fatal error callback with move semantics.
 
template<SizeLimitMode mode>
static void SizeLimitCheck (size_t limit, size_t size)
 在非调试模式下的占位大小检查函数(无实际作用)。 Dummy size limit check for non-debug builds.
 

Static Public Attributes

static std::optional< LibXR::Callback< const char *, uint32_t > > libxr_fatal_error_callback_
 存储已注册的致命错误回调函数。 Stores the registered fatal error callback.
 

Detailed Description

运行时错误检查的断言工具类。 Provides assertion mechanisms for runtime error checking.

Assert 类提供了注册和处理致命错误的机制,支持回调函数,并可执行 运行时的大小限制检查(仅在调试模式下启用)。 The Assert class is designed to register and handle fatal errors through callback functions and provides size limit verification.

Definition at line 39 of file libxr_assert.hpp.

Member Function Documentation

◆ RegisterFatalErrorCB() [1/2]

static void LibXR::Assert::RegisterFatalErrorCB ( const LibXR::Callback< const char *, uint32_t > &  cb)
inlinestatic

注册致命错误的回调函数。 Registers a fatal error callback.

该回调函数会在发生致命错误时被触发,用于执行相应的错误处理逻辑。 This callback will be triggered when a fatal error occurs.

Parameters
cb要注册的回调函数。 The callback function to be registered.

Definition at line 51 of file libxr_assert.hpp.

52 {
54 }
static std::optional< LibXR::Callback< const char *, uint32_t > > libxr_fatal_error_callback_
存储已注册的致命错误回调函数。 Stores the registered fatal error callback.

◆ RegisterFatalErrorCB() [2/2]

static void LibXR::Assert::RegisterFatalErrorCB ( LibXR::Callback< const char *, uint32_t > &&  cb)
inlinestatic

通过移动语义注册致命错误的回调函数。 Registers a fatal error callback with move semantics.

该重载版本允许通过移动回调对象,提高回调函数注册的效率。 This overload allows for efficient callback assignment by moving the callback object.

Parameters
cb要注册的回调函数(通过移动语义传递)。 The callback function to be registered.

Definition at line 66 of file libxr_assert.hpp.

67 {
68 libxr_fatal_error_callback_ = std::move(cb);
69 }

◆ SizeLimitCheck()

template<SizeLimitMode mode>
static void LibXR::Assert::SizeLimitCheck ( size_t  limit,
size_t  size 
)
inlinestatic

在非调试模式下的占位大小检查函数(无实际作用)。 Dummy size limit check for non-debug builds.

在发布模式下,该函数不会执行任何操作,以避免不必要的开销。 In release mode, this function does nothing to avoid unnecessary checks.

Template Parameters
mode大小检查模式(EQUAL, MORE, LESS)。 The size constraint mode.
Parameters
limit参考限制值。 The reference limit value.
size要检查的实际大小。 The actual size to be checked.

Definition at line 119 of file libxr_assert.hpp.

120 {
121 UNUSED(limit);
122 UNUSED(size);
123 }
constexpr auto min(T1 a, T2 b) -> typename std::common_type< T1, T2 >::type
计算两个数的最小值

Field Documentation

◆ libxr_fatal_error_callback_

std::optional<LibXR::Callback<const char *, uint32_t> > LibXR::Assert::libxr_fatal_error_callback_
inlinestatic

存储已注册的致命错误回调函数。 Stores the registered fatal error callback.

该可选回调函数用于处理致命错误,如果未注册,则为空。 This optional callback is used to handle fatal errors if registered.

Definition at line 134 of file libxr_assert.hpp.


The documentation for this class was generated from the following file: