xtd 0.2.0
Loading...
Searching...
No Matches
stream_writer.h
Go to the documentation of this file.
1
4#pragma once
5#include "text_writer.h"
6#include "../optional.h"
7#include <fstream>
8
10namespace xtd {
12 namespace io {
27 public:
29
38 explicit stream_writer(std::ostream& stream);
44 stream_writer(const xtd::ustring& path, bool append);
47 stream_writer(std::ostream& stream, bool append);
50 stream_writer(const stream_writer&) = delete;
51 stream_writer& operator =(const stream_writer&) = delete;
54
56
64 bool auto_flush() const;
71 void auto_flush(bool auto_flush);
72
75 std::optional<std::reference_wrapper<std::ostream>> base_stream() const;
77
79
82 void close() override;
83
86 void flush() override;
87
88 using text_writer::write;
92 void write(const xtd::ustring& value) override;
94
95 private:
96 std::ostream* stream_ = nullptr;
97 bool auto_flush_ = false;
98 bool delete_when_destroy_ = false;
99 };
100 }
101}
Performs operations on std::basic_string instances that contain file or directory path information....
Definition path.h:34
Implements a xtd::io::text_writer for writing characters to a stream.
Definition stream_writer.h:26
stream_writer(std::ostream &stream)
Initializes a new instance of the stream_writer class for the specified stream.
void flush() override
Clears all buffers for the current writer and causes any buffered data to be written to the underlyin...
stream_writer(const xtd::ustring &path)
Initializes a new instance of the stream_writer class for the specified file name.
std::optional< std::reference_wrapper< std::ostream > > base_stream() const
Returns the underlying stream.
bool auto_flush() const
Gets a value indicating whether the xtd::io::stream_writer will flush its buffer to the underlying st...
void write(const xtd::ustring &value) override
Writes the specified string value to the text stream.
void close() override
Closes the stream_writer object and the underlying stream, and releases any system resources associat...
void auto_flush(bool auto_flush)
Sets a value indicating whether the xtd::io::stream_writer will flush its buffer to the underlying st...
stream_writer(const xtd::ustring &path, bool append)
Initializes a new instance of the xtd::io::stream_writer class for the specified file on the specifie...
stream_writer(std::ostream &stream, bool append)
Initializes a new instance of the stream_writer class for the specified stream.
Represents a writer that can write a sequential series of characters.
Definition text_writer.h:34
Represents text as a sequence of UTF-8 code units.
Definition ustring.h:47
#define core_export_
Define shared library export.
Definition core_export.h:13
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10
Contains xtd::io::text_writer class.