|
NexusForce 1.0.0
A rigorously engineered full-stack C++ backend library.
|
字符串格式化功能 更多...
类 | |
| struct | neforce::format_options |
| 格式选项 更多... | |
| struct | neforce::formatter< Number, Dummy > |
| 格式化器主模板 更多... | |
| struct | neforce::formatter< T, enable_if_t< is_floating_point_v< T > > > |
| 浮点数类型的格式化器特化 更多... | |
| struct | neforce::formatter< T, enable_if_t< is_standard_integral_v< T > &&is_signed_v< T > > > |
| 有符号整数类型的格式化器特化 更多... | |
| struct | neforce::formatter< T, enable_if_t< is_standard_integral_v< T > &&is_unsigned_v< T > > > |
| 无符号整数类型的格式化器特化 更多... | |
| struct | neforce::formatter< char > |
| 单个字符的格式化器特化 更多... | |
| struct | neforce::formatter< bool > |
| 布尔类型的格式化器特化 更多... | |
| struct | neforce::formatter< string > |
| 字符串类型的格式化器特化 更多... | |
| struct | neforce::formatter< string_view > |
| 字符串视图的格式化器特化 更多... | |
| struct | neforce::formatter< const char * > |
| C风格字符串的格式化器特化 更多... | |
| struct | neforce::formatter< nullptr_t > |
| nullptr_t 格式化器 更多... | |
| struct | neforce::formatter< T *, enable_if_t<!is_cstring_v< T * > > > |
| 指针格式化器 更多... | |
| struct | neforce::formatter< char * > |
| 非const C风格字符串的格式化器特化 更多... | |
| struct | neforce::formatter< datetime > |
| datetime 格式化器特化 更多... | |
枚举 | |
| enum class | neforce::format_align { format_align::DEFAULT , format_align::LEFT , format_align::RIGHT , format_align::CENTER , format_align::NUMERIC } |
| 对齐方式枚举 更多... | |
| enum class | neforce::format_type : uint8_t { format_type::DEFAULT , format_type::DECIMAL , format_type::BINARY , format_type::OCTAL , format_type::HEX , format_type::SCIENTIFIC , format_type::FIXED , format_type::GENERAL , format_type::CHAR } |
| 数值类型格式枚举 更多... | |
函数 | |
| template<typename... Args, enable_if_t<(sizeof...(Args) > 0), int > = 0> | |
| constexpr string | neforce::format (const string_view fmt, Args &&... args) |
| 格式化字符串 | |
| template<size_t N, typename... Args, enable_if_t<(sizeof...(Args) > 0), int > = 0> | |
| constexpr string | neforce::format (const char(&fmt)[N], Args &&... args) |
| 格式化字符串 | |
| constexpr string | neforce::format_named (const string_view fmt, const std::initializer_list< pair< const char *, string_view > > params) |
| 命名参数格式化 | |
| template<typename... Args, enable_if_t<(sizeof...(Args) > 0), int > = 0> | |
| string | neforce::format (const locale &loc, const string_view fmt, Args &&... args) |
| locale 感知的格式化 | |
字符串格式化功能
|
strong |
对齐方式枚举
| 枚举值 | |
|---|---|
| DEFAULT | 默认(数字右对齐,其他左对齐) |
| LEFT | 左对齐 '<' |
| RIGHT | 右对齐 '>' |
| CENTER | 居中 '^' |
| NUMERIC | 符号感知填充 '=' |
在文件 format.hpp 第 27 行定义.
|
strong |
数值类型格式枚举
| 枚举值 | |
|---|---|
| DEFAULT | 默认(由类型决定) |
| DECIMAL | 十进制 'd' / 'f' / 'g' |
| BINARY | 二进制 'b' |
| OCTAL | 八进制 'o' |
| HEX | 十六进制 'x' / 'X' |
| SCIENTIFIC | 科学计数法 'e' / 'E' |
| FIXED | 固定小数 'f' |
| GENERAL | 通用浮点 'g' / 'G' |
| CHAR | 字符 'c' |
在文件 format.hpp 第 39 行定义.
|
nodiscardconstexpr |
格式化字符串
| N | 格式字符串长度 |
| Args | 参数类型 |
| fmt | 格式字符串字面量 |
| args | 要格式化的参数 |
| value_exception | 如果格式错误 |
在编译期验证格式字符串中花括号的平衡性。 用法:format("Hello, {}!", name)
在文件 format.hpp 第 828 行定义.
|
nodiscard |
locale 感知的格式化
| Args | 参数类型 |
| loc | locale 对象 |
| fmt | 格式字符串 |
| args | 要格式化的参数 |
格式选项中的 loc 指针将被设置为 &loc,所有 formatter 特化 均可通过 opts.loc 访问 locale 以进行本地化格式化。
在文件 format.hpp 第 901 行定义.
引用了 format(), forward(), neforce::format_options::loc, neforce::basic_string< CharT, Traits, Alloc >::reserve() , 以及 neforce::basic_string_view< CharT, Traits >::size().
|
nodiscardconstexpr |
格式化字符串
| Args | 参数类型 |
| fmt | 格式字符串 |
| args | 要格式化的参数 |
| value_exception | 如果格式错误 |
支持以下格式:
在文件 format.hpp 第 805 行定义.
引用了 format(), forward(), forward_as_tuple(), neforce::basic_string< CharT, Traits, Alloc >::reserve() , 以及 neforce::basic_string_view< CharT, Traits >::size().
被这些函数引用 neforce::zlib_compressor::compress(), neforce::zlib_compressor::compress(), neforce::zlib_compressor::compress(), neforce::zlib_compressor::decompress(), neforce::zlib_compressor::decompress(), neforce::sys_console::eprintf(), neforce::sys_console::eprintfln(), format(), format(), format(), neforce::sys_console::printcf(), neforce::sys_console::printcfln(), neforce::sys_console::printf(), neforce::sys_console::printfln(), neforce::zlib_compressor::stream_compressor::reset(), neforce::zlib_compressor::stream_decompressor::reset(), neforce::zlib_compressor::stream_compressor::stream_compressor(), neforce::zlib_compressor::stream_decompressor::stream_decompressor(), neforce::datetime::to_offset_string(), neforce::datetime::to_RFC1123(), neforce::color::to_string(), neforce::date::to_string() , 以及 neforce::time::to_string().
|
nodiscardconstexpr |
命名参数格式化
| fmt | 格式字符串,使用 {name} 标记命名占位符 |
| params | 命名参数列表 |
将格式字符串中的 {name} 替换为 params 中的对应值。 不支持格式选项,仅做纯文本替换。 用法:format_named("{greeting}, {name}!", {{"greeting", "Hello"}, {"name", "World"}})
在文件 format.hpp 第 843 行定义.
引用了 format_named(), neforce::basic_string< CharT, Traits, Alloc >::reserve(), neforce::basic_string_view< CharT, Traits >::size() , 以及 neforce::basic_string_view< CharT, Traits >::view().
被这些函数引用 format_named().