17# include <ext/stdio_filebuf.h>
18# include <ext/stdio_sync_filebuf.h>
25#ifdef _MSVC_STL_UPDATE
26# define FMT_MSVC_STL_UPDATE _MSVC_STL_UPDATE
27#elif defined(_MSC_VER) && _MSC_VER < 1912
28# define FMT_MSVC_STL_UPDATE _MSVC_LANG
30# define FMT_MSVC_STL_UPDATE 0
39struct file_access_tag {};
41template <
typename Tag,
typename BufType, FILE* BufType::*FileMemberPtr>
43 friend auto get_file(BufType& obj) -> FILE* {
return obj.*FileMemberPtr; }
46#if FMT_MSVC_STL_UPDATE
47template class file_access<file_access_tag, std::filebuf,
48 &std::filebuf::_Myfile>;
49auto get_file(std::filebuf&) -> FILE*;
54template <
typename Char>
56 const Char* buf_data = buf.
data();
58 unsigned_streamsize size = buf.
size();
61 unsigned_streamsize n = size <= max_size ? size : max_size;
62 os.write(buf_data,
static_cast<std::streamsize
>(n));
74template <
typename Char>
78 template <
typename T,
typename Context>
79 auto format(
const T& value, Context& ctx)
const ->
decltype(ctx.out()) {
82 auto&& output = std::basic_ostream<Char>(&formatbuf);
83 output.imbue(std::locale::classic());
85 output.exceptions(std::ios_base::failbit | std::ios_base::badbit);
87 {buffer.data(), buffer.size()}, ctx);
93template <
typename T,
typename Char>
96 template <
typename Context>
98 ->
decltype(ctx.out()) {
120#if FMT_MSVC_STL_UPDATE && FMT_USE_RTTI
121 if (
auto* buf =
dynamic_cast<std::filebuf*
>(os.rdbuf()))
123#elif defined(_WIN32) && defined(__GLIBCXX__) && FMT_USE_RTTI
124 auto* rdbuf = os.rdbuf();
125 if (
auto* sfbuf =
dynamic_cast<__gnu_cxx::stdio_sync_filebuf<char>*
>(rdbuf))
127 else if (
auto* fbuf =
dynamic_cast<__gnu_cxx::stdio_filebuf<char>*
>(rdbuf))
152 fmt::vargs<T...>
vargs = {{args...}};
161 fmt::print(os,
"{}\n", fmt::format(fmt, std::forward<T>(args)...));
A dynamically growing memory buffer for trivially copyable/constructible types with the first SIZE el...
Definition format.h:790
A contiguous memory buffer with an optional growing ability.
Definition base.h:1698
constexpr auto size() const noexcept -> size_t
Returns the size of this buffer.
Definition base.h:1740
FMT_CONSTEXPR auto data() noexcept -> T *
Returns a pointer to the buffer data (not null-terminated).
Definition base.h:1746
friend auto get_file(BufType &obj) -> FILE *
Definition ostream.h:43
detail namespace with internal helper functions
Definition input_adapters.h:32
FMT_CONSTEXPR void ignore_unused(const T &...)
Definition base.h:348
constexpr auto max_value() -> T
Definition format.h:407
FMT_CONSTEXPR auto to_unsigned(Int value) -> make_unsigned_t< Int >
Definition base.h:422
auto get_file(F *f, int) -> apple_file< F >
Definition format-inl.h:1642
@ use_utf8
Definition base.h:442
FMT_API auto write_console(int fd, string_view text) -> bool
Definition format-inl.h:1694
void write_buffer(std::basic_ostream< Char > &os, buffer< Char > &buf)
Definition ostream.h:55
void vformat_to(buffer< Char > &buf, basic_string_view< Char > fmt, typename vformat_args< Char >::type args, locale_ref loc={})
Definition format.h:3665
FMT_EXPORT void println(std::ostream &os, format_string< T... > fmt, T &&... args)
Definition ostream.h:160
FMT_EXPORT void print(std::ostream &os, format_string< T... > fmt, T &&... args)
Prints formatted data to the stream os.
Definition ostream.h:151
constexpr auto streamed(const T &value) -> detail::streamed_view< T >
Returns a view that formats value via an ostream operator<<.
Definition ostream.h:112
void vprint(std::ostream &os, string_view fmt, format_args args)
Definition ostream.h:116
const T & value
Definition ostream.h:69
typename fstring< T... >::t format_string
Definition base.h:2720
typename std::make_unsigned< T >::type make_unsigned_t
Definition base.h:308
#define FMT_BEGIN_NAMESPACE
Definition base.h:239
#define FMT_END_NAMESPACE
Definition base.h:242
#define FMT_EXPORT
Definition base.h:248