Console Library 8.0.0
A header-only library that makes C++ simple
Loading...
Searching...
No Matches
console::details Namespace Reference

Classes

struct  BasicFormatSpec
 格式说明符结构。 More...

Functions

template<class CharT = char>
void parse_format_spec (const std::basic_string< CharT > &specStr, BasicFormatSpec< CharT > &spec)
 解析格式说明符。
template<class CharT = char>
void apply_format (std::basic_ostream< CharT > &os, const BasicFormatSpec< CharT > &spec)
 将格式说明符应用到输出流。
template<class CharT, class T>
static std::enable_if< std::is_arithmetic< T >::value, void >::type apply_space_if_nonneg (std::basic_ostream< CharT > &os, const T &value)
template<class CharT, class T>
static std::enable_if<!std::is_arithmetic< T >::value, void >::type apply_space_if_nonneg (std::basic_ostream< CharT > &, const T &)
template<typename CharT = char, typename T>
void format_value (std::basic_ostream< CharT > &os, const T &value, const BasicFormatSpec< CharT > &spec)
 格式化单个值。
template<class CharT = char>
void format_impl (std::basic_ostream< CharT > &os, const std::basic_string< CharT > &fmt, size_t &pos, size_t)
 格式化实现(无参数版本,递归终止)。
template<class CharT = char, typename T, typename... Args>
void format_impl (std::basic_ostream< CharT > &os, const std::basic_string< CharT > &fmt, size_t &pos, size_t argIndex, const T &first, const Args &...rest)
 格式化实现(有参数版本)。

Function Documentation

◆ apply_format()

template<class CharT = char>
void console::details::apply_format ( std::basic_ostream< CharT > & os,
const BasicFormatSpec< CharT > & spec )

将格式说明符应用到输出流。

Template Parameters
CharT字符类型。
Parameters
os输出流。
spec格式说明符。

◆ apply_space_if_nonneg() [1/2]

template<class CharT, class T>
std::enable_if<!std::is_arithmetic< T >::value, void >::type console::details::apply_space_if_nonneg ( std::basic_ostream< CharT > & ,
const T &  )
static

◆ apply_space_if_nonneg() [2/2]

template<class CharT, class T>
std::enable_if< std::is_arithmetic< T >::value, void >::type console::details::apply_space_if_nonneg ( std::basic_ostream< CharT > & os,
const T & value )
static

◆ format_impl() [1/2]

template<class CharT = char, typename T, typename... Args>
void console::details::format_impl ( std::basic_ostream< CharT > & os,
const std::basic_string< CharT > & fmt,
size_t & pos,
size_t argIndex,
const T & first,
const Args &... rest )

格式化实现(有参数版本)。

Template Parameters
CharT字符类型。
T第一个参数类型。
Args剩余参数类型。
Parameters
os输出流。
fmt格式字符串。
pos当前解析位置。
argIndex参数索引。
first第一个参数。
rest剩余参数。

◆ format_impl() [2/2]

template<class CharT = char>
void console::details::format_impl ( std::basic_ostream< CharT > & os,
const std::basic_string< CharT > & fmt,
size_t & pos,
size_t  )

格式化实现(无参数版本,递归终止)。

Template Parameters
CharT字符类型。
Parameters
os输出流。
fmt格式字符串。
pos当前解析位置。
argIndex参数索引。

◆ format_value()

template<typename CharT = char, typename T>
void console::details::format_value ( std::basic_ostream< CharT > & os,
const T & value,
const BasicFormatSpec< CharT > & spec )

格式化单个值。

Template Parameters
CharT字符类型。
T值类型。
Parameters
os输出流。
value要格式化的值。
spec格式说明符。

◆ parse_format_spec()

template<class CharT = char>
void console::details::parse_format_spec ( const std::basic_string< CharT > & specStr,
BasicFormatSpec< CharT > & spec )

解析格式说明符。

支持的语法:[[填充]对齐][宽度][:[标志][.精度][类型]]

Parameters
specStr格式字符串(不含花括号和前导冒号)。
spec输出的格式说明符。
Exceptions
BadFormat格式非法时抛出。