xtd 0.2.0
Loading...
Searching...
No Matches
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 auto operator =(const stream_writer&) -> stream_writer& = delete;
56
58
66 [[nodiscard]] auto auto_flush() const -> bool;
73 auto auto_flush(bool auto_flush) -> void;
74
77 [[nodiscard]] auto base_stream() const -> std::optional<xtd::ref<std::ostream>>;
79
81
84 auto close() -> void override;
85
88 auto flush() -> void override;
89
90 using text_writer::write;
94 auto write(const xtd::string& value) -> void 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
auto flush() -> void override
Clears all buffers for the current writer and causes any buffered data to be written to the underlyin...
stream_writer(std::ostream &stream)
Initializes a new instance of the stream_writer class for the specified stream.
auto auto_flush() const -> bool
Gets a value indicating whether the xtd::io::stream_writer will flush its buffer to the underlying st...
stream_writer(const xtd::string &path)
Initializes a new instance of the stream_writer class for the specified file name.
auto write(const xtd::string &value) -> void override
Writes the specified string value to the text stream.
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...
auto close() -> void override
Closes the stream_writer object and the underlying stream, and releases any system resources associat...
auto base_stream() const -> std::optional< xtd::ref< std::ostream > >
Returns the underlying stream.
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
text_writer()=default
Initializes a new instance of the xtd::io::text_writer class.
#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
xtd::reference_wrapper_object< type_t > ref
The xtd::ref object is a reference wrapper.
Definition ref.hpp:25
std::optional< type_t > optional
Represents the optional alias on std::optional.
Definition optional.hpp:26
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.