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))
34# define FMT_USE_FCNTL 1
36# define FMT_USE_FCNTL 0
41# if defined(_WIN32) && !defined(__MINGW32__)
43# define FMT_POSIX(call) _##call
45# define FMT_POSIX(call) call
51# define FMT_HAS_SYSTEM
52# define FMT_POSIX_CALL(call) FMT_SYSTEM(call)
54# define FMT_SYSTEM(call) ::call
57# define FMT_POSIX_CALL(call) ::_##call
59# define FMT_POSIX_CALL(call) ::call
66# define FMT_RETRY_VAL(result, expression, error_result) \
68 (result) = (expression); \
69 } while ((result) == (error_result) && errno == EINTR)
71# define FMT_RETRY_VAL(result, expression, error_result) result = (expression)
74#define FMT_RETRY(result, expression) FMT_RETRY_VAL(result, expression, -1)
107 auto c_str() const -> const Char* {
return data_; }
117FMT_API void format_windows_error(buffer<char>& out,
int error_code,
118 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());
193 other.file_ =
nullptr;
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) {}
257 file(
const file&) =
delete;
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;
305# if defined(_WIN32) && !defined(__MINGW32__)
308 static file open_windows_file(
wcstring_view path,
int oflag);
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) {}
371 ostream(
cstring_view path,
const detail::ostream_params& params);
373 static void grow(buffer<char>& buf,
size_t);
376 ostream(ostream&& other)
noexcept;
384 inline void flush() {
385 if (size() == 0)
return;
386 file_.write(data(), size() *
sizeof(data()[0]));
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...)};
then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file
Definition ThirdPartyNotices.txt:205
A reference to a null-terminated string.
Definition os.h:95
basic_cstring_view(const std::basic_string< Char > &s)
Constructs a string reference from an std::string object.
Definition os.h:104
basic_cstring_view(const Char *s)
Constructs a string reference object from a C string.
Definition os.h:101
auto c_str() const -> const Char *
Returns the pointer to a C string.
Definition os.h:107
void operator=(const buffered_file &)=delete
auto operator=(buffered_file &&other) -> buffered_file &
Definition os.h:196
FMT_API ~buffered_file() noexcept
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:1698
detail namespace with internal helper functions
Definition input_adapters.h:32
FMT_CONSTEXPR auto is_locking() -> bool
Definition base.h:2367
@ value
the parser finished reading a JSON value
Implement std::hash so that hash_code can be used in STL containers.
Definition PointerIntPair.h:280
#define FMT_POSIX(call)
Definition os.h:45
auto system_category() noexcept -> const std::error_category &
Definition os.h:159
#define S(label, offset, message)
Definition Errors.h:113
#define FMT_END_EXPORT
Definition base.h:250
typename fstring< T... >::t format_string
Definition base.h:2720
basic_appender< char > appender
Definition base.h:619
#define FMT_CONSTEXPR
Definition base.h:113
#define FMT_BEGIN_NAMESPACE
Definition base.h:239
#define FMT_API
Definition base.h:269
#define FMT_BEGIN_EXPORT
Definition base.h:249
#define FMT_END_NAMESPACE
Definition base.h:242
void print(FILE *f, const text_style &ts, format_string< T... > fmt, T &&... args)
Formats a string and prints it to the specified file stream using ANSI escape sequences to specify te...
Definition color.h:485