VLink  2.0.0
A high-performance communication middleware
vlink::format 命名空间参考

Minimal allocation-free {} placeholder formatter. 更多...

命名空间

 

struct  FString
 Compile-time format-string wrapper carrying the expected argument list. 更多...
 
struct  FormatToNResult
 Return type of format_to_n; carries the end iterator, total size and truncation flag. 更多...
 
struct  FormatToResult
 Return type of the fixed-array format_to overload. 更多...
 

类型定义

template<typename... ArgsT>
using format_string = typename FString< ArgsT... >::t
 Convenience alias used as the formal type of format-string parameters. 更多...
 

函数

template<typename... ArgsT>
detail::FormatArgStore< char, detail::RemoveCvref< ArgsT >... > make_format_args (const ArgsT &... args)
 Public API 更多...
 
template<typename... ArgsT>
FormatToNResult< char * > format_to_n (char *out, size_t n, format_string< ArgsT... > fmt, const ArgsT &... args)
 Formats args into out, writing at most n characters. 更多...
 
template<size_t NumT, typename... ArgsT>
FormatToResult format_to (char(&out)[NumT], format_string< ArgsT... > fmt, const ArgsT &... args)
 Formats args into a fixed-size character array; equivalent to format_to_n. 更多...
 
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 args through an output iterator. 更多...
 

详细描述

Minimal allocation-free {} placeholder formatter.

类型定义说明

◆ format_string

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

Convenience alias used as the formal type of format-string parameters.

模板参数
ArgsTExpected argument types.

函数说明

◆ format_to() [1/2]

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

Formats args into a fixed-size character array; equivalent to format_to_n.

模板参数
NumTArray size (deduced).
ArgsTArgument types.
参数
outDestination array.
fmtFormat string.
argsArguments to substitute.
返回
FormatToResult describing the 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 args through an output iterator.

Writes each character via *out++ = c. The iterator must satisfy the OutputIterator concept; arrays are explicitly excluded so the fixed-array overload wins overload resolution.

模板参数
OutputItTOutput iterator type.
ArgsTArgument types.
参数
outDestination iterator.
fmtFormat string.
argsArguments to substitute.
返回
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 args into out, writing at most n characters.

Placeholders in fmt are substituted with args in order. When the produced text would exceed n the output is truncated and truncated is set to true. The caller is responsible for null termination if needed.

模板参数
ArgsTArgument types (deduced).
参数
outDestination buffer with capacity of at least n bytes.
nMaximum characters to write, not counting a null terminator.
fmtFormat string with {} placeholders.
argsArguments to substitute.
返回
FormatToNResult describing the end iterator, 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

Public API

Builds a type-erased argument store from a parameter pack.

模板参数
ArgsTArgument types.
参数
argsArgument values.
返回
Argument store usable by the format engine.