xtd - Reference Guide  0.2.0
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
Go to the documentation of this file.
1 #pragma once
6 #include <fstream>
7 #include <optional>
8 #include "text_writer.h"
11 namespace xtd {
13  namespace io {
21  public:
29  stream_writer(std::ostream& stream);
35  stream_writer(const xtd::ustring& path, bool append);
38  stream_writer(std::ostream& stream, bool append);
40  ~stream_writer();
43  bool auto_flush() const;
44  void auto_flush(bool auto_flush);
48  std::optional<std::reference_wrapper<std::ostream>> base_stream() const;
51  void close() override;
55  void flush() override;
57  using text_writer::write;
61  void write(const xtd::ustring& value) override;
63  private:
64  std::ostream* stream_ = nullptr;
65  bool auto_flush_ = false;
66  bool delete_when_destroy_ = false;
67  };
68  }
69 }
stream_writer(const xtd::ustring &path)
Initializes a new instance of the stream_writer class for the specified file name.
The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
Definition: system_report.h:17
void write(const xtd::ustring &value) override
Writes the specified string value to the text stream.
Represents text as a sequence of UTF-8 code units.
Definition: ustring.h:48
Represents a writer that can write a sequential series of characters.
Definition: text_writer.h:29
Performs operations on std::basic_string instances that contain file or directory path information...
Definition: path.h:29
void close() override
Closes the stream_writer object and the underlying stream, and releases any system resources associat...
Implements a xtd::io::text_writer for writing characters to a stream.
Definition: stream_writer.h:20
virtual void write(const xtd::ustring &value)
Writes the specified string value to the text stream.
std::optional< std::reference_wrapper< std::ostream > > base_stream() const
Returns the underlying stream.
void flush() override
Clears all buffers for the current writer and causes any buffered data to be written to the underlyin...
Contains xtd::io::text_writer class.