17# include <system_error>
19# if FMT_HAS_INCLUDE(<xlocale.h>)
26# if FMT_HAS_INCLUDE("winapifamily.h")
27# include <winapifamily.h>
29# if (FMT_HAS_INCLUDE(<fcntl.h>) || defined(__APPLE__) || \
30 defined(__linux__)) && \
31 (!defined(WINAPI_FAMILY) || \
32 (WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP)) && \
35# define FMT_USE_FCNTL 1
37# define FMT_USE_FCNTL 0
42# if defined(_WIN32) && !defined(__MINGW32__)
44# define FMT_POSIX(call) _##call
46# define FMT_POSIX(call) call
52# define FMT_HAS_SYSTEM
53# define FMT_POSIX_CALL(call) FMT_SYSTEM(call)
55# define FMT_SYSTEM(call) ::call
58# define FMT_POSIX_CALL(call) ::_##call
60# define FMT_POSIX_CALL(call) ::call
67# define FMT_RETRY_VAL(result, expression, error_result) \
69 (result) = (expression); \
70 } while ((result) == (error_result) && errno == EINTR)
72# define FMT_RETRY_VAL(result, expression, error_result) result = (expression)
75#define FMT_RETRY(result, expression) FMT_RETRY_VAL(result, expression, -1)
108 auto c_str() const -> const Char* {
return data_; }
118FMT_API void format_windows_error(buffer<char>& out,
int error_code,
119 const char* message)
noexcept;
149template <
typename... T>
150auto windows_error(
int error_code,
string_view message,
const T&... args)
151 -> std::system_error {
152 return vwindows_error(error_code, message,
vargs<T...>{{args...}});
157FMT_API void report_windows_error(
int error_code,
const char* message)
noexcept;
160 return std::system_category();
166template <
typename S,
typename... Args,
typename Char = char_t<S>>
167void say(
const S& fmt, Args&&... args) {
168 std::system(
format(
"say \"{}\"",
format(fmt, args...)).c_str());
192 inline buffered_file(buffered_file&& other) noexcept : file_(other.file_) {
193 other.file_ =
nullptr;
196 inline auto operator=(buffered_file&& other) -> buffered_file& {
199 other.file_ =
nullptr;
210 inline auto get() const noexcept -> FILE* {
return file_; }
214 template <typename... T>
216 fmt::vargs<T...>
vargs = {{args...}};
218 : fmt::vprint(file_, fmt,
vargs);
235 explicit file(
int fd) : fd_(fd) {}
251 inline file() noexcept : fd_(-1) {}
258 void operator=(
const file&) =
delete;
260 inline file(
file&& other) noexcept : fd_(other.fd_) { other.fd_ = -1; }
263 inline auto operator=(
file&& other) ->
file& {
274 inline auto descriptor() const noexcept ->
int {
return fd_; }
281 auto size() const ->
long long;
284 auto read(
void* buffer,
size_t count) ->
size_t;
287 auto write(const
void* buffer,
size_t count) ->
size_t;
291 static auto dup(
int fd) ->
file;
299 void dup2(
int fd, std::error_code& ec) noexcept;
303 auto fdopen(const
char* mode) -> buffered_file;
305# if defined(_WIN32) && !defined(__MINGW32__)
322auto getpagesize() -> long;
327 constexpr buffer_size() =
default;
329 FMT_CONSTEXPR auto operator=(
size_t val)
const -> buffer_size {
330 auto bs = buffer_size();
336struct ostream_params {
337 int oflag = file::WRONLY | file::CREATE | file::TRUNC;
338 size_t buffer_size = BUFSIZ > 32768 ? BUFSIZ : 32768;
340 constexpr ostream_params() {}
342 template <
typename... T>
343 ostream_params(T... params,
int new_oflag) : ostream_params(params...) {
347 template <
typename... T>
348 ostream_params(T... params, detail::buffer_size bs)
349 : ostream_params(params...) {
350 this->buffer_size = bs.value;
355# if defined(__INTEL_COMPILER) && __INTEL_COMPILER < 2000
356 ostream_params(
int new_oflag) : oflag(new_oflag) {}
357 ostream_params(detail::buffer_size bs) : buffer_size(bs.value) {}
373 FMT_API static void grow(buffer<char>& buf,
size_t);
376 FMT_API ostream(ostream&& other)
noexcept;
380 detail::buffer<char>& buf = *
this;
384 inline void flush() {
385 if (
size() == 0)
return;
390 template <
typename... T>
391 friend auto output_file(
cstring_view path, T... params) -> ostream;
393 inline void close() {
418template <
typename... T>
419inline auto output_file(
cstring_view path, T... params) -> ostream {
420 return {path, detail::ostream_params(params...)};
#define S(label, offset, message)
Definition Errors.hpp:113
then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file
Definition ThirdPartyNotices.txt:204
#define FMT_END_EXPORT
Definition base.h:267
basic_string_view< char > string_view
Definition base.h:620
detail::format_arg_store< context, sizeof...(T), detail::count_named_args< T... >(), detail::make_descriptor< context, T... >()> vargs
Definition base.h:2832
typename fstring< T... >::t format_string
Definition base.h:2794
basic_appender< char > appender
Definition base.h:623
#define FMT_CONSTEXPR
Definition base.h:113
#define FMT_BEGIN_NAMESPACE
Definition base.h:256
#define FMT_API
Definition base.h:286
#define FMT_BEGIN_EXPORT
Definition base.h:266
basic_format_args< context > format_args
Definition base.h:651
#define FMT_END_NAMESPACE
Definition base.h:259
A reference to a null-terminated string.
Definition os.h:96
basic_cstring_view(const std::basic_string< Char > &s)
Constructs a string reference from an std::string object.
Definition os.h:105
basic_cstring_view(const Char *s)
Constructs a string reference object from a C string.
Definition os.h:102
auto c_str() const -> const char *
Definition os.h:108
void operator=(const buffered_file &)=delete
auto operator=(buffered_file &&other) -> buffered_file &
Definition os.h:196
FMT_API ~buffered_file() noexcept
friend class file
Definition os.h:177
auto get() const noexcept -> FILE *
Definition os.h:210
buffered_file() noexcept
Definition os.h:186
FMT_API auto descriptor() const -> int
void print(string_view fmt, const T &... args)
Definition os.h:215
FMT_API buffered_file(cstring_view filename, cstring_view mode)
buffered_file(const buffered_file &)=delete
A contiguous memory buffer with an optional growing ability.
Definition base.h:1773
constexpr auto size() const noexcept -> size_t
Returns the size of this buffer.
Definition base.h:1815
FMT_CONSTEXPR auto data() noexcept -> T *
Returns a pointer to the buffer data (not null-terminated).
Definition base.h:1821
FMT_CONSTEXPR void clear()
Clears this buffer.
Definition base.h:1825
Converts a string literal into a format string that will be parsed at compile time and converted into...
Definition printf.h:50
FMT_CONSTEXPR auto is_locking() -> bool
Definition base.h:2443
FMT_API void print(FILE *, string_view)
FMT_FUNC void vformat_to(buffer< char > &buf, string_view fmt, format_args args, locale_ref loc)
Definition format-inl.h:1451
Definition StringMap.hpp:773
#define FMT_POSIX(call)
Definition os.h:46
basic_cstring_view< wchar_t > wcstring_view
Definition os.h:112
auto system_category() noexcept -> const std::error_category &
Definition os.h:159
basic_cstring_view< char > cstring_view
Definition os.h:111