18#if defined __APPLE__ || defined(__FreeBSD__)
25#if FMT_HAS_INCLUDE("winapifamily.h")
26# include <winapifamily.h>
28#if (FMT_HAS_INCLUDE(<fcntl.h>) || defined(__APPLE__) || \
29 defined(__linux__)) && \
30 (!defined(WINAPI_FAMILY) || (WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP))
32# define FMT_USE_FCNTL 1
34# define FMT_USE_FCNTL 0
38# if defined(_WIN32) && !defined(__MINGW32__)
40# define FMT_POSIX(call) _##call
42# define FMT_POSIX(call) call
48# define FMT_POSIX_CALL(call) FMT_SYSTEM(call)
50# define FMT_SYSTEM(call) ::call
53# define FMT_POSIX_CALL(call) ::_##call
55# define FMT_POSIX_CALL(call) ::call
62# define FMT_RETRY_VAL(result, expression, error_result) \
64 (result) = (expression); \
65 } while ((result) == (error_result) && errno == EINTR)
67# define FMT_RETRY_VAL(result, expression, error_result) result = (expression)
70#define FMT_RETRY(result, expression) FMT_RETRY_VAL(result, expression, -1)
123 template <
typename ParseContext>
128 template <
typename FormatContext>
130 ->
decltype(ctx.out()) {
131 auto out = ctx.out();
132 out = detail::write_bytes(out, ec.category().name(),
134 out = detail::write<Char>(out, Char(
':'));
135 out = detail::write<Char>(out, ec.value());
154 size_t size()
const {
return buffer_.size() - 1; }
155 const char* c_str()
const {
return &buffer_[0]; }
199template <
typename... Args>
201 const Args&... args) {
202 return vwindows_error(error_code, message, fmt::make_format_args(args...));
207FMT_API void report_windows_error(
int error_code,
217template <
typename S,
typename... Args,
typename Char =
char_t<S>>
218void say(
const S& format_str, Args&&... args) {
244 other.
file_ =
nullptr;
250 other.file_ =
nullptr;
268 fmt::vprint(
file_, format_str, args);
271 template <
typename... Args>
273 vprint(format_str, fmt::make_format_args(args...));
289 explicit file(
int fd) : fd_(fd) {}
309 file(
const file&) =
delete;
310 void operator=(
const file&) =
delete;
312 file(file&& other)
FMT_NOEXCEPT : fd_(other.fd_) { other.fd_ = -1; }
315 file& operator=(file&& other) {
343 FMT_API static file dup(
int fd);
355 FMT_API static void pipe(file& read_end, file& write_end);
368 buffer_size() =
default;
370 buffer_size operator=(
size_t val)
const {
371 auto bs = buffer_size();
377struct ostream_params {
378 int oflag = file::WRONLY | file::CREATE | file::TRUNC;
379 size_t buffer_size = BUFSIZ > 32768 ? BUFSIZ : 32768;
383 template <
typename...
T>
384 ostream_params(
T... params,
int new_oflag) : ostream_params(params...) {
388 template <
typename...
T>
389 ostream_params(
T... params, detail::buffer_size bs)
390 : ostream_params(params...) {
391 this->buffer_size = bs.value;
397constexpr detail::buffer_size buffer_size;
400class FMT_API ostream final :
private detail::buffer<char> {
405 if (
size() == 0)
return;
410 void grow(
size_t)
override;
412 ostream(
cstring_view path,
const detail::ostream_params& params)
413 : file_(path, params.oflag) {
414 set(
new char[params.buffer_size], params.buffer_size);
418 ostream(ostream&& other)
420 file_(
std::move(other.file_)) {
422 other.set(
nullptr, 0);
429 template <
typename...
T>
443 fmt::make_format_args(args...));
462template <
typename...
T>
464 return {path, detail::ostream_params(params...)};
473 using locale_t = _locale_t;
475 static void freelocale(locale_t loc) { _free_locale(loc); }
477 static double strtod_l(
const char* nptr,
char** endptr, _locale_t loc) {
478 return _strtod_l(nptr, endptr, loc);
485 using type = locale_t;
486 locale(
const locale&) =
delete;
487 void operator=(
const locale&) =
delete;
491 locale_ =
FMT_SYSTEM(newlocale(LC_NUMERIC_MASK,
"C",
nullptr));
493 locale_ = _create_locale(LC_NUMERIC,
"C");
497 ~locale() { freelocale(locale_); }
499 type get()
const {
return locale_; }
503 double strtod(
const char*& str)
const {
505 double result = strtod_l(str, &end, locale_);
basic_cstring_view(const std::basic_string< Char > &s)
basic_cstring_view(const Char *s)
const Char * c_str() const
void vprint(string_view format_str, format_args args)
void operator=(const buffered_file &)=delete
FILE * get() const FMT_NOEXCEPT
FMT_API buffered_file(cstring_view filename, cstring_view mode)
FMT_API int() fileno() const
buffered_file() FMT_NOEXCEPT
buffered_file(const buffered_file &)=delete
FMT_API ~buffered_file() FMT_NOEXCEPT
void print(string_view format_str, const Args &... args)
buffered_file & operator=(buffered_file &&other)
void print(std::FILE *f, const text_style &ts, const S &format_str, const Args &... args)
void vformat_to(buffer< Char > &buf, const text_style &ts, basic_string_view< Char > format_str, basic_format_args< buffer_context< type_identity_t< Char > > > args)
std::basic_string< Char > format(const text_style &ts, const S &format_str, const Args &... args)
typename detail::char_t_impl< S >::type char_t
#define FMT_END_DETAIL_NAMESPACE
#define FMT_MODULE_EXPORT_BEGIN
constexpr auto count() -> size_t
#define FMT_BEGIN_NAMESPACE
#define FMT_BEGIN_DETAIL_NAMESPACE
#define FMT_END_NAMESPACE
#define FMT_MODULE_EXPORT_END
const std::error_category & system_category() FMT_NOEXCEPT
SPDLOG_INLINE std::shared_ptr< logger > get(const std::string &name)
T system_category(T... args)