fmt
Loading...
Searching...
No Matches
xchar.cppm File Reference
module fmt

Support for character types other than char, chiefly wchar_t. More...

#include "fmt/macros.hpp"
#include <cerrno>
#include <climits>
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <version>
import fmt:ostream;
import std;

Classes

struct  fmt::detail::FormatStringChar< S, typename >
struct  fmt::detail::FormatStringChar< S, void_t< decltype(sizeof(detail::toStringView(std::declval< S >())))> >
struct  fmt::detail::IsCompileStringLike< S, typename >
struct  fmt::detail::IsCompileStringLike< S, decltype(void(sizeof(S)))>
struct  fmt::detail::FormatStringChar< S, enable_if_t< IsCompileStringLike< S >::value > >
struct  fmt::BasicFstring< Char, T >

Typedefs

template<typename T>
using fmt::detail::IsExoticChar = bool_constant<!std::is_same<T, char>::value>
template<typename S>
using fmt::detail::format_string_char_t = typename FormatStringChar<S>::type
using fmt::WstringView = BasicStringView<wchar_t>
using fmt::WformatParseContext = ParseContext<wchar_t>
using fmt::WformatContext = BufferedContext<wchar_t>
using fmt::WformatArgs = BasicFormatArgs<WformatContext>
using fmt::WmemoryBuffer = BasicMemoryBuffer<wchar_t>
template<typename Char, typename... T>
using fmt::BasicFormatString = BasicFstring<Char, T...>
template<typename... T>
using fmt::WformatString = typename BasicFormatString<wchar_t, T...>::t

Functions

auto fmt::detail::writeLoc (BasicAppender< wchar_t > out, LocValue value, const FormatSpecs &specs, LocaleRef loc) -> bool
template<typename Char>
auto fmt::detail::vformatTo (Buffer< Char > &buf, BasicStringView< Char > fmt, BasicFormatArgs< BufferedContext< Char > > args, LocaleRef loc={}) -> void
auto fmt::runtime (WstringView s) -> RuntimeFormatString< wchar_t >
template<typename... T>
constexpr auto fmt::makeWformatArgs (T &... args) -> decltype(fmt::makeFormatArgs< WformatContext >(args...))
template<typename T>
auto fmt::arg (const wchar_t *name, const T &arg) -> NamedArg< T, wchar_t >
template<typename It, typename Sentinel, typename S, typename Char = typename decltype(detail::toStringView( std::declval<S>()))::value_type>
requires (detail::IsExoticChar<Char>::value)
auto fmt::join (It begin, Sentinel end, S &&sep) -> JoinView< It, Sentinel, Char >
template<typename Range, typename S, typename Char = typename decltype(detail::toStringView( std::declval<S>()))::value_type>
requires (detail::IsExoticChar<Char>::value && !IsTupleLike<Range>::value)
auto fmt::join (Range &&range, S &&sep) -> JoinView< decltype(std::begin(range)), decltype(std::end(range)), Char >
template<typename T>
auto fmt::join (std::initializer_list< T > list, WstringView sep) -> JoinView< const T *, const T *, wchar_t >
template<typename Tuple, typename S, typename Char = typename decltype(detail::toStringView( std::declval<S>()))::value_type>
requires (detail::IsExoticChar<Char>::value && IsTupleLike<Tuple>::value)
auto fmt::join (const Tuple &tuple, S &&sep) -> TupleJoinView< Tuple, Char >
template<typename Char>
requires (!std::is_same<Char, char>::value)
auto fmt::vformat (BasicStringView< Char > fmt, BasicFormatArgs< BufferedContext< Char > > args) -> std::basic_string< Char >
template<typename... T>
auto fmt::format (WformatString< T... > fmt, T &&... args) -> std::wstring
template<typename OutputIt, typename... T>
auto fmt::formatTo (OutputIt out, WformatString< T... > fmt, T &&... args) -> OutputIt
template<typename S, typename... T, typename Char = detail::format_string_char_t<S>>
requires (!std::is_same<Char, char>::value && !std::is_same<Char, wchar_t>::value)
auto fmt::format (const S &fmt, T &&... args) -> std::basic_string< Char >
template<typename S, typename Char = detail::format_string_char_t<S>>
requires (detail::IsExoticChar<Char>::value)
auto fmt::vformat (LocaleRef loc, const S &fmt, BasicFormatArgs< BufferedContext< Char > > args) -> std::basic_string< Char >
template<typename S, typename... T, typename Char = detail::format_string_char_t<S>>
requires (detail::IsExoticChar<Char>::value)
auto fmt::format (LocaleRef loc, const S &fmt, T &&... args) -> std::basic_string< Char >
template<typename OutputIt, typename S, typename Char = detail::format_string_char_t<S>>
requires (detail::IsOutputIterator<OutputIt, Char>::value && detail::IsExoticChar<Char>::value)
auto fmt::vformatTo (OutputIt out, const S &fmt, BasicFormatArgs< BufferedContext< Char > > args) -> OutputIt
template<typename OutputIt, typename S, typename... T, typename Char = detail::format_string_char_t<S>>
requires (detail::IsOutputIterator<OutputIt, Char>::value && !std::is_same<Char, char>::value && !std::is_same<Char, wchar_t>::value)
auto fmt::formatTo (OutputIt out, const S &fmt, T &&... args) -> OutputIt
template<typename S, typename OutputIt, typename... Args, typename Char = detail::format_string_char_t<S>>
requires (detail::IsOutputIterator<OutputIt, Char>::value && detail::IsExoticChar<Char>::value)
auto fmt::vformatTo (OutputIt out, LocaleRef loc, const S &fmt, BasicFormatArgs< BufferedContext< Char > > args) -> OutputIt
template<typename OutputIt, typename S, typename... T, typename Char = detail::format_string_char_t<S>, bool enable = detail::IsOutputIterator<OutputIt, Char>::value && detail::IsExoticChar<Char>::value>
auto fmt::formatTo (OutputIt out, LocaleRef loc, const S &fmt, T &&... args) -> typename std::enable_if< enable, OutputIt >::type
template<typename OutputIt, typename Char, typename... Args>
requires (detail::IsOutputIterator<OutputIt, Char>::value && detail::IsExoticChar<Char>::value)
auto fmt::vformatToN (OutputIt out, size_t n, BasicStringView< Char > fmt, BasicFormatArgs< BufferedContext< Char > > args) -> FormatToNResult< OutputIt >
template<typename OutputIt, typename... T>
requires (detail::IsOutputIterator<OutputIt, wchar_t>::value)
auto fmt::formatToN (OutputIt out, size_t n, WformatString< T... > fmt, T &&... args) -> FormatToNResult< OutputIt >
template<typename OutputIt, typename S, typename... T, typename Char = detail::format_string_char_t<S>>
requires (detail::IsOutputIterator<OutputIt, Char>::value && !std::is_same<Char, char>::value && !std::is_same<Char, wchar_t>::value)
auto fmt::formatToN (OutputIt out, size_t n, const S &fmt, T &&... args) -> FormatToNResult< OutputIt >
template<typename S, typename... T, typename Char = detail::format_string_char_t<S>>
requires (detail::IsExoticChar<Char>::value)
auto fmt::formattedSize (const S &fmt, T &&... args) -> size_t
auto fmt::vprint (std::FILE *f, WstringView fmt, WformatArgs args) -> void
auto fmt::vprint (WstringView fmt, WformatArgs args) -> void
template<typename... T>
auto fmt::print (std::FILE *f, WformatString< T... > fmt, T &&... args) -> void
template<typename... T>
auto fmt::print (WformatString< T... > fmt, T &&... args) -> void
template<typename... T>
auto fmt::println (std::FILE *f, WformatString< T... > fmt, T &&... args) -> void
template<typename... T>
auto fmt::println (WformatString< T... > fmt, T &&... args) -> void
auto fmt::vformat (TextStyle ts, WstringView fmt, WformatArgs args) -> std::wstring
template<typename... T>
auto fmt::format (TextStyle ts, WformatString< T... > fmt, T &&... args) -> std::wstring
auto fmt::vprint (std::wostream &os, WstringView fmt, WformatArgs args) -> void
template<typename... T>
auto fmt::print (std::wostream &os, WformatString< T... > fmt, T &&... args) -> void
template<typename... T>
auto fmt::println (std::wostream &os, WformatString< T... > fmt, T &&... args) -> void
template<typename T>
auto fmt::to_wstring (const T &value) -> std::wstring

Detailed Description

Support for character types other than char, chiefly wchar_t.

Interface partition fmt:xchar.

Typedef Documentation

◆ WformatArgs

using fmt::WformatArgs = BasicFormatArgs<WformatContext>
export

A view of wide formatting arguments, for type-erased functions.

◆ WformatContext

using fmt::WformatContext = BufferedContext<wchar_t>
export

The formatting context for wchar_t.

◆ WformatParseContext

using fmt::WformatParseContext = ParseContext<wchar_t>
export

The format string parsing context for wchar_t.

◆ WformatString

template<typename... T>
using fmt::WformatString = typename BasicFormatString<wchar_t, T...>::t
export

A wide format string, checked against the argument types at compile time.

◆ WmemoryBuffer

using fmt::WmemoryBuffer = BasicMemoryBuffer<wchar_t>
export

A growable wide-character buffer with storage.

◆ WstringView

using fmt::WstringView = BasicStringView<wchar_t>
export

A non-owning view of a wide string.

Function Documentation

◆ arg()

template<typename T>
auto fmt::arg ( const wchar_t * name,
const T & arg ) -> NamedArg< T, wchar_t >
export

Creates a named argument with a wide name, for {name} in a wide format string.

Parameters
namethe argument name. It must outlive the formatting call.
argthe value.
Returns
the named argument, to pass to a formatting function.

◆ format() [1/2]

template<typename... T>
auto fmt::format ( TextStyle ts,
WformatString< T... > fmt,
T &&... args ) -> std::wstring
export

Formats args with the given style and returns the result as a wide string.

Parameters
tsthe style to apply.
fmta wide format string, checked at compile time.
argsthe arguments to format.
Returns
the formatted string, wrapped in ANSI escape sequences.

◆ format() [2/2]

template<typename... T>
auto fmt::format ( WformatString< T... > fmt,
T &&... args ) -> std::wstring
export

Formats args and returns the result as a std::wstring.

Parameters
fmta wide format string, checked at compile time.
argsthe arguments to format.
Returns
the formatted string.

Example:

auto s = fmt::format(L"{} {}", L"wide", 42);

◆ formatTo()

template<typename OutputIt, typename... T>
auto fmt::formatTo ( OutputIt out,
WformatString< T... > fmt,
T &&... args ) -> OutputIt
export

Formats args and writes the result to out.

Parameters
outan output iterator over wchar_t.
fmta wide format string, checked at compile time.
argsthe arguments to format.
Returns
an iterator past the end of the output.

◆ makeWformatArgs()

template<typename... T>
auto fmt::makeWformatArgs ( T &... args) -> decltype(fmt::makeFormatArgs< WformatContext >(args...))
constexprexport

Bundles args into a wformat_args for a type-erased wide formatting function.

Parameters
argsthe arguments to bundle.
Returns
a view of the arguments, which must outlive it.

◆ print() [1/2]

template<typename... T>
auto fmt::print ( std::FILE * f,
WformatString< T... > fmt,
T &&... args ) -> void
export

Formats args and prints the result to the stream f.

The output is written with std::fputws, so the stream must be in wide orientation.

Parameters
fthe stream to write to.
fmta wide format string, checked at compile time.
argsthe arguments to format.
Exceptions
std::system_errorif writing to the stream fails.

◆ print() [2/2]

template<typename... T>
auto fmt::print ( std::wostream & os,
WformatString< T... > fmt,
T &&... args ) -> void
export

Formats args and writes the result to the wide stream os.

Parameters
osthe stream to write to.
fmta wide format string, checked at compile time.
argsthe arguments to format.

◆ println() [1/2]

template<typename... T>
auto fmt::println ( std::FILE * f,
WformatString< T... > fmt,
T &&... args ) -> void
export

Formats args and prints the result to f, followed by a newline.

Parameters
fthe stream to write to.
fmta wide format string, checked at compile time.
argsthe arguments to format.

◆ println() [2/2]

template<typename... T>
auto fmt::println ( std::wostream & os,
WformatString< T... > fmt,
T &&... args ) -> void
export

Formats args and writes the result to the wide stream os, followed by a newline.

Parameters
osthe stream to write to.
fmta wide format string, checked at compile time.
argsthe arguments to format.

◆ runtime()

auto fmt::runtime ( WstringView s) -> RuntimeFormatString< wchar_t >
export

Marks a wide format string as known only at run time, disabling the compile-time check.

Parameters
sthe format string.
Returns
an opaque wrapper accepted where a wformat_string is expected.
Exceptions
fmt::format_errorat run time if the string is invalid.

◆ to_wstring()

template<typename T>
auto fmt::to_wstring ( const T & value) -> std::wstring
export

Converts value to a std::wstring using its default format.

Parameters
valuethe value to convert.
Returns
the formatted value.

◆ vformat() [1/2]

template<typename Char>
requires (!std::is_same<Char, char>::value)
auto fmt::vformat ( BasicStringView< Char > fmt,
BasicFormatArgs< BufferedContext< Char > > args ) -> std::basic_string< Char >
export

Type-erased form of format for a non-char character type.

◆ vformat() [2/2]

auto fmt::vformat ( TextStyle ts,
WstringView fmt,
WformatArgs args ) -> std::wstring
export

Type-erased form of the styled wide format.

◆ vprint()

auto fmt::vprint ( std::wostream & os,
WstringView fmt,
WformatArgs args ) -> void
export

Type-erased form of print for a wide stream.