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 {
29 public:
31
37 explicit stream_writer(const xtd::string& path);
40 explicit stream_writer(std::ostream& stream);
46 stream_writer(const xtd::string& path, bool append);
49 stream_writer(std::ostream& stream, bool append);
52 stream_writer(const stream_writer&) = delete;
53 stream_writer& operator =(const stream_writer&) = delete;
56
58
66 bool auto_flush() const;
73 void auto_flush(bool auto_flush);
74
77 std::optional<std::reference_wrapper<std::ostream>> base_stream() const;
79
81
84 void close() override;
85
88 void flush() override;
89
90 using text_writer::write;
94 void write(const xtd::string& value) override;
96
97 private:
98 std::ostream* stream_ = nullptr;
99 bool auto_flush_ = false;
100 bool delete_when_destroy_ = false;
101 };
102 }
103}
Represents text as a sequence of character units.
Definition basic_string.h:79
Performs operations on std::basic_string instances that contain file or directory path information....
Definition path.h:36
Implements a xtd::io::text_writer for writing characters to a stream.
Definition stream_writer.h:28
stream_writer(std::ostream &stream)
Initializes a new instance of the stream_writer class for the specified stream.
stream_writer(const xtd::string &path)
Initializes a new instance of the stream_writer class for the specified file name.
void flush() override
Clears all buffers for the current writer and causes any buffered data to be written to the underlyin...
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::string &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::string &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:36
#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.