28#if defined(_MSC_VER) && _MSC_VER < 1935
29#define format_string _Fmt_string
33 FILE *pfOutputInfo = NULL;
34 FILE *pfOutputWarn = NULL;
35 FILE *pfOutputErr = NULL;
49 NBT_Print(FILE *_pfOutputInfo = stdout, FILE *_pfOutputWarn = stderr, FILE *_pfOutputErr = stderr)
50 : pfOutputInfo(_pfOutputInfo)
51 , pfOutputWarn(_pfOutputWarn)
52 , pfOutputErr(_pfOutputErr)
66 template<
typename... Args>
67 void operator()(
Level lvl,
const std::format_string<Args...> fmt, Args&&... args)
noexcept
69 FILE *pfOutput = NULL;
73 pfOutput = pfOutputInfo;
76 pfOutput = pfOutputWarn;
79 pfOutput = pfOutputErr;
93 auto tmp = std::format(std::move(fmt), std::forward<Args>(args)...);
94 fwrite(tmp.data(),
sizeof(tmp.data()[0]), tmp.size(), pfOutput);
96 catch (
const std::exception &e)
98 fprintf(stderr,
"ErrInfo Exception: \"%s\"\n", e.what());
102 fprintf(stderr,
"ErrInfo Exception: \"Unknown Error\"\n");
113 template<
typename... Args>
114 void operator()(
const std::format_string<Args...> fmt, Args&&... args)
noexcept
116 return operator()(Level::Info, std::move(fmt), std::forward<Args>(args)...);
141 template<
typename... Args>
142 void operator()(
Level lvl,
const std::format_string<Args...> fmt, Args&&... args)
const noexcept
151 template<
typename... Args>
152 void operator()(
const std::format_string<Args...> fmt, Args&&... args)
const noexcept
NBT_Print_Level
用于指示信息打印等级的枚举
定义 NBT_Print.hpp:11
@ Info
普通信息
定义 NBT_Print.hpp:12
@ Warn
警告信息
定义 NBT_Print.hpp:13
@ Err
错误信息
定义 NBT_Print.hpp:14
NBT_Print_Level Level
信息等级,直接映射NBT_Print_Level
定义 NBT_Print.hpp:125
~NBT_NoPrint(void) noexcept
默认析构函数
定义 NBT_Print.hpp:133
void operator()(Level lvl, const std::format_string< Args... > fmt, Args &&... args) const noexcept
仿函数调用,接受打印等级和格式化字符串,忽略所有参数。
定义 NBT_Print.hpp:142
void operator()(const std::format_string< Args... > fmt, Args &&... args) const noexcept
仿函数调用,默认 Info 等级,忽略所有参数。
定义 NBT_Print.hpp:152
NBT_NoPrint(void) noexcept
默认构造函数
定义 NBT_Print.hpp:129
~NBT_Print(void)=default
默认析构
void operator()(const std::format_string< Args... > fmt, Args &&... args) noexcept
函数调用运算符重载,用于将类作为仿函数调用,默认使用Info等级输出信息
定义 NBT_Print.hpp:114
void operator()(Level lvl, const std::format_string< Args... > fmt, Args &&... args) noexcept
函数调用运算符重载,用于将类作为仿函数调用,通过使用指定等级输出信息
定义 NBT_Print.hpp:67
NBT_Print(FILE *_pfOutputInfo=stdout, FILE *_pfOutputWarn=stderr, FILE *_pfOutputErr=stderr)
通过c文件对象构造
定义 NBT_Print.hpp:49
NBT_Print_Level Level
信息等级,直接映射NBT_Print_Level
定义 NBT_Print.hpp:38