ELC in dev
ELC-lang
载入中...
搜索中...
未找到
elc::APIs::die 命名空间参考

终止报错相关基础函数 更多...

struct  die_state
 

函数

void Init_die_state (die_state &state) noexcept
 
void ConsoleLog (const die_state &state, string_view_t< char > str) noexcept
 
void ConsoleLog (const die_state &state, string_view_t< wchar_t > str) noexcept
 
void ConsoleLogEnd (const die_state &state) noexcept
 
void die () noexcept
 终止整个程序并可能的触发断点或输出错误信息
 
void die_with (string_view err_msg) noexcept
 同 die() ,但是有详细的错误信息
 

详细描述

终止报错相关基础函数

函数说明

◆ ConsoleLog() [1/2]

void elc::APIs::die::ConsoleLog ( const die_state state,
string_view_t< char str 
)
inlinenoexcept

在文件 all_defs.cpp18284 行定义.

18284 {
18285 #if SYSTEM_TYPE == windows
18286 WriteConsoleA(state.hConsole,str.data(),(DWORD)str.size(),nullptr,nullptr);
18287 #elif SYSTEM_TYPE == linux
18288 fputs(str.data(),stderr);
18289 #endif
18290 }
constexpr size_t size() const noexcept
constexpr const char_T * data() const noexcept
函数调用图:
这是这个函数的调用关系图:

◆ ConsoleLog() [2/2]

void elc::APIs::die::ConsoleLog ( const die_state state,
string_view_t< wchar_t str 
)
inlinenoexcept

在文件 all_defs.cpp18291 行定义.

18291 {
18292 #if SYSTEM_TYPE == windows
18293 WriteConsoleW(state.hConsole,str.data(),(DWORD)str.size(),nullptr,nullptr);
18294 #elif SYSTEM_TYPE == linux
18295 fputws(str.data(),stderr);
18296 #endif
18297 }
函数调用图:

◆ ConsoleLogEnd()

void elc::APIs::die::ConsoleLogEnd ( const die_state state)
inlinenoexcept

在文件 all_defs.cpp18298 行定义.

18298 {
18299 #if SYSTEM_TYPE == windows
18300 FlushFileBuffers(state.hConsole);
18301 //chenge color back
18302 SetConsoleTextAttribute(state.hConsole,state.text_color);
18303 #elif SYSTEM_TYPE == linux
18304 fflush(stderr);
18305 //chenge color back
18306 fputs("\033[0m",stderr);
18307 #endif
18308 }
函数调用图:
这是这个函数的调用关系图:

◆ die()

void elc::APIs::die::die ( )
inlinenoexcept

终止整个程序并可能的触发断点或输出错误信息

在文件 all_defs.cpp18311 行定义.

18311 {
18312 #if SYSTEM_TYPE == windows
18313 if(IsDebuggerPresent())
18314 __debugbreak();
18315 #endif
18316 #if defined(_WINMAIN_)
18317 ::MessageBoxW(NULL,L"\nelc died.",NULL,MB_ICONERROR);
18318 #endif
18319 die_state state;
18320 Init_die_state(state);
18321 ConsoleLog(state,"\nelc died.\n");
18322 ConsoleLogEnd(state);
18323 ::std::abort();
18324 }
void Init_die_state(die_state &state) noexcept
void ConsoleLogEnd(const die_state &state) noexcept
void ConsoleLog(const die_state &state, string_view_t< char > str) noexcept
函数调用图:
这是这个函数的调用关系图:

◆ die_with()

void elc::APIs::die::die_with ( string_view  err_msg)
inlinenoexcept

同 die() ,但是有详细的错误信息

参数
err_msg错误信息

在文件 all_defs.cpp18327 行定义.

18327 {
18328 #if SYSTEM_TYPE == windows
18329 if(IsDebuggerPresent())
18330 __debugbreak();
18331 #endif
18332 if(err_msg){
18333 if constexpr(wchar_t_same_as_char16_t){
18334 push_and_disable_msvc_warning(26494);//未初始化警告diss
18335 wchar_t err_msg_in_wchar[2048];
18337 const auto size=char_set::utf32_to_utf16((char16_t*)err_msg_in_wchar,err_msg).processed_output().size();
18338 err_msg_in_wchar[size]=L'\0';
18339 #if defined(_WINMAIN_)
18340 ::MessageBoxW(NULL,err_msg_in_wchar,NULL,MB_ICONERROR);
18341 #endif
18342 die_state state;
18343 Init_die_state(state);
18344 ConsoleLog(state,L"\nelc died because:\n");
18345 ConsoleLog(state,err_msg_in_wchar);
18346 ConsoleLog(state,L"\n");
18347 ConsoleLogEnd(state);
18348 }
18349 elseif constexpr(wchar_t_same_as_char_t){
18350 const string_view_t<wchar_t> err_msg_in_wchar{(const wchar_t*)err_msg.data(),err_msg.size()};
18351 #if defined(_WINMAIN_)
18352 ::MessageBoxW(NULL,err_msg_in_wchar.data(),NULL,MB_ICONERROR);
18353 #endif
18354 die_state state;
18355 Init_die_state(state);
18356 ConsoleLog(state,L"\nelc died because:\n");
18357 ConsoleLog(state,err_msg_in_wchar);
18358 ConsoleLog(state,L"\n");
18359 ConsoleLogEnd(state);
18360 }
18361 else{
18362 ::std::mbstate_t stat{};
18363 push_and_disable_msvc_warning(26494);//未初始化警告diss
18364 char err_msg_in_char[2048];
18365 char* err_msg_write = err_msg_in_char;
18366 size_t s;
18368 for(auto c:err_msg){
18369 s = ::std::c32rtomb(err_msg_write, c, &stat);
18370 push_and_disable_msvc_warning(26475)//强转警告diss
18371 if(s == npos)
18372 die();
18374 err_msg_write += s;
18375 }
18376 *err_msg_write = '\0';
18377 #if defined(_WINMAIN_)
18378 ::MessageBoxA(NULL,err_msg_in_char,NULL,MB_ICONERROR);
18379 #endif
18380 die_state state;
18381 Init_die_state(state);
18382 ConsoleLog(state,"\nelc died because:\n");
18383 ConsoleLog(state,err_msg_in_char);
18384 ConsoleLog(state,"\n");
18385 ConsoleLogEnd(state);
18386 }
18387 }
18388 else
18389 die();
18390 ::std::abort();
18391 }
#define elseif
Definition all_defs.cpp:650
#define pop_msvc_warning()
Definition all_defs.cpp:478
#define push_and_disable_msvc_warning(...)
Definition all_defs.cpp:479
void die() noexcept
终止整个程序并可能的触发断点或输出错误信息
函数调用图:
这是这个函数的调用关系图:

◆ Init_die_state()

void elc::APIs::die::Init_die_state ( die_state state)
inlinenoexcept

在文件 all_defs.cpp18270 行定义.

18270 {
18271 #if SYSTEM_TYPE == windows
18272 state.hConsole=GetStdHandle(STD_ERROR_HANDLE);
18273 //chenge color to red
18274 CONSOLE_SCREEN_BUFFER_INFO csbi;
18275 GetConsoleScreenBufferInfo(state.hConsole,&csbi);
18276 state.text_color=csbi.wAttributes;
18277 SetConsoleTextAttribute(state.hConsole,FOREGROUND_RED);
18278 #elif SYSTEM_TYPE == linux
18279 //chenge color to red
18280 fputs("\033[31m",stderr);
18281 #endif
18282 }
函数调用图:
这是这个函数的调用关系图: