xtd 0.2.0
stream_writer.hpp
Go to the documentation of this file.
1
4#pragma once
5#include "text_writer.hpp"
6#include "../optional.hpp"
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;
74
77 std::optional<xtd::ref<std::ostream>> base_stream() const;
79
81
84 void close() override;
85
88 void flush() override;
89
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}
Performs operations on std::basic_string instances that contain file or directory path information....
Definition path.hpp:37
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...
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.
std::optional< xtd::ref< std::ostream > > base_stream() const
Returns the underlying 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.
Provides a generic view of a sequence of bytes. This is an abstract class.
Definition stream.hpp:40
Represents a writer that can write a sequential series of characters.
Definition text_writer.hpp:36
virtual void write(const xtd::string &value)
Writes the specified string value to the text stream.
#define core_export_
Define shared library export.
Definition core_export.hpp:13
xtd::basic_string< char > string
Represents text as a sequence of UTF-8 code units.
Definition __string_definitions.hpp:43
The xtd::io namespace contains types that allow reading and writing to files and data streams,...
Definition binary_reader.hpp:17
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8
Contains xtd::optional type.
Contains xtd::io::text_writer class.