Unravel Engine C++ Reference
Loading...
Searching...
No Matches
file_ostream.h
Go to the documentation of this file.
1#pragma once
2
3
4
6
7#include "filesystem.h"
8
9
10
11#include <iosfwd>
12
13#include <memory>
14
15#include <ostream>
16
17
18
19namespace fs
20
21{
22
23
24
26
28
29class file_ostream : public std::ostream
30
31{
32
33public:
34
36
37 explicit file_ostream(const path& file_path,
38
39 std::ios_base::openmode mode = default_file_write_mode);
40
41 explicit file_ostream(const std::string& absolute_path,
42
43 std::ios_base::openmode mode = default_file_write_mode);
44
46
47
48
49 file_ostream(const file_ostream&) = delete;
50
51 auto operator=(const file_ostream&) -> file_ostream& = delete;
52
53 file_ostream(file_ostream&& other) noexcept;
54
55 auto operator=(file_ostream&& other) noexcept -> file_ostream&;
56
57 ~file_ostream() override;
58
59
60
61 void open(const path& file_path, std::ios_base::openmode mode = default_file_write_mode);
62
63 void open(const std::string& absolute_path, std::ios_base::openmode mode = default_file_write_mode);
64
65
66
67 auto is_open() const -> bool;
68
69 auto native_handle() const -> FILE*;
70
71 auto tell() const -> long long;
72
73 auto file_size() const -> long long;
74
75 auto seek(long long offset, int whence = SEEK_SET) -> bool;
76
77 auto flush_file() -> bool;
78
79 void close();
80
81
82
83private:
84
85 struct impl;
86
87 std::unique_ptr<impl> impl_;
88
89};
90
91
92
93} // namespace fs
94
95
stdio-backed output stream. Accepts std::ios open flags (e.g. std::ios::binary | std::ios::app)
file_ostream(const file_ostream &)=delete
auto file_size() const -> long long
~file_ostream() override
auto operator=(const file_ostream &) -> file_ostream &=delete
void open(const path &file_path, std::ios_base::openmode mode=default_file_write_mode)
auto is_open() const -> bool
auto seek(long long offset, int whence=SEEK_SET) -> bool
auto flush_file() -> bool
auto tell() const -> long long
auto native_handle() const -> FILE *
Definition cache.hpp:11
constexpr std::ios_base::openmode default_file_write_mode
file_stream_ownership
Whether a file stream wrapper should fclose its FILE* on destruction.
Hash specialization for batch_key to enable use in std::unordered_map.