VLink 2.0.0
A high-performance communication middleware
载入中...
搜索中...
未找到
vlink::format 命名空间参考

Lightweight header-only {} placeholder formatter. 更多...

命名空间

namespace  detail

struct  FString
 Compile-time format string wrapper that carries type information about arguments. 更多...
struct  FormatToNResult
 Result type for format_to_n, carrying the output pointer, written size and truncation flag. 更多...
struct  FormatToResult
 Result type for the fixed-array overload of format_to. 更多...

类型定义

template<typename... T>
using format_string = typename FString<T...>::t
 Alias for FString used as the type of format-string parameters.

函数

template<typename... ArgsT>
detail::FormatArgStore< char, detail::RemoveCvref< ArgsT >... > make_format_args (const ArgsT &... args)
 Creates a type-erased argument store from a variadic argument list.
template<typename... ArgsT>
FormatToNResult< char * > format_to_n (char *out, size_t n, format_string< ArgsT... > fmt, const ArgsT &... args)
 Formats arguments into a char* buffer, writing at most n characters.
template<size_t N, typename... ArgsT>
FormatToResult format_to (char(&out)[N], format_string< ArgsT... > fmt, const ArgsT &... args)
 Formats arguments into a fixed-size char array.
template<typename OutputItT, typename... ArgsT, std::enable_if_t< detail::kIsOutputIterator< detail::RemoveCvref< OutputItT > > &&!std::is_array_v< std::remove_reference_t< OutputItT > >, int > = 0>
detail::RemoveCvref< OutputItT > format_to (OutputItT &&out, format_string< ArgsT... > fmt, const ArgsT &... args)
 Formats arguments to an output iterator.

详细描述

Lightweight header-only {} placeholder formatter.

类型定义说明

◆ format_string

template<typename... T>
using vlink::format::format_string = typename FString<T...>::t

Alias for FString used as the type of format-string parameters.

format_string<ArgsT...> is the type of the format argument in format_to_n and format_to. Constructed implicitly from string literals.

模板参数
TExpected argument types (for documentation; not enforced at runtime).

函数说明

◆ format_to() [1/2]

template<size_t N, typename... ArgsT>
FormatToResult vlink::format::format_to ( char(&) out[N],
format_string< ArgsT... > fmt,
const ArgsT &... args )
inline

Formats arguments into a fixed-size char array.

The array size N is deduced automatically. Equivalent to format_to_n(out, N, fmt, args...).

模板参数
NArray size (deduced).
ArgsTArgument types.
参数
outDestination char array.
fmtFormat string.
argsFormat arguments.
返回
FormatToResult with end pointer, total size and truncation flag.
函数调用图:

◆ format_to() [2/2]

template<typename OutputItT, typename... ArgsT, std::enable_if_t< detail::kIsOutputIterator< detail::RemoveCvref< OutputItT > > &&!std::is_array_v< std::remove_reference_t< OutputItT > >, int > = 0>
detail::RemoveCvref< OutputItT > vlink::format::format_to ( OutputItT && out,
format_string< ArgsT... > fmt,
const ArgsT &... args )
inline

Formats arguments to an output iterator.

Writes each character via *out++ = c. The iterator must model the OutputIterator concept (assignable and dereferenceable).

模板参数
OutputItTOutput iterator type.
ArgsTArgument types.
参数
outDestination output iterator.
fmtFormat string with {} placeholders.
argsFormat arguments.
返回
The iterator one past the last written character.
函数调用图:

◆ format_to_n()

template<typename... ArgsT>
FormatToNResult< char * > vlink::format::format_to_n ( char * out,
size_t n,
format_string< ArgsT... > fmt,
const ArgsT &... args )
inline

Formats arguments into a char* buffer, writing at most n characters.

Placeholders ({}) in fmt are replaced in order by the corresponding argument from args. If more characters would be produced than n, output is truncated and the returned truncated flag is set. The caller must null-terminate the output if needed.

模板参数
ArgsTArgument types (deduced).
参数
outDestination buffer. Must have capacity of at least n bytes.
nMaximum number of characters to write (not counting a null terminator).
fmtFormat string with {} placeholders.
argsFormat arguments.
返回
FormatToNResult with the end pointer, total size and truncation flag.
函数调用图:
这是这个函数的调用关系图:

◆ make_format_args()

template<typename... ArgsT>
detail::FormatArgStore< char, detail::RemoveCvref< ArgsT >... > vlink::format::make_format_args ( const ArgsT &... args)
inline

Creates a type-erased argument store from a variadic argument list.

模板参数
ArgsTArgument types.
参数
argsArguments to capture.
返回
FormatArgStore containing the erased argument values.
这是这个函数的调用关系图: