Implements a xtd::io::text_writer for writing characters to a stream.
Public Constructors | |
stream_writer (const xtd::string &path) | |
Initializes a new instance of the stream_writer class for the specified file name. | |
stream_writer (std::ostream &stream) | |
Initializes a new instance of the stream_writer class for the specified 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 specified path, using the default encoding and buffer size. If the file exists, it can be either overwritten or appended to. If the file does not exist, this constructor creates a new file. | |
stream_writer (std::ostream &stream, bool append) | |
Initializes a new instance of the stream_writer class for the specified stream. | |
Public Properties | |
bool | auto_flush () const |
Gets a value indicating whether the xtd::io::stream_writer will flush its buffer to the underlying stream after every call to xtd::io::text_writer::write(char). | |
void | auto_flush (bool auto_flush) |
Sets a value indicating whether the xtd::io::stream_writer will flush its buffer to the underlying stream after every call to xtd::io::text_writer::write(char). | |
std::optional< std::reference_wrapper< std::ostream > > | base_stream () const |
Returns the underlying stream. | |
Public Methods | |
void | close () override |
Closes the stream_writer object and the underlying stream, and releases any system resources associated with the reader. | |
void | flush () override |
Clears all buffers for the current writer and causes any buffered data to be written to the underlying device. | |
void | write (const xtd::string &value) override |
Writes the specified string value to the text stream. | |
virtual void | write (const xtd::string &value) |
Writes the specified string value to the text stream. | |
void | write (bool value) |
Writes the specified bool value to the text stream. | |
void | write (double value) |
Writes the specified double value to the text stream. | |
void | write (float value) |
Writes the specified float value to the text stream. | |
void | write (sbyte value) |
Writes the specified sbyte value to the text stream. | |
void | write (int16 value) |
Writes the specified int16 value to the text stream. | |
void | write (int32 value) |
Writes the specified int32 value to the text stream. | |
void | write (int64 value) |
Writes the specified int64 value to the text stream. | |
void | write (xtd::byte value) |
Writes the specified xtd::byte value to the text stream. | |
void | write (uint16 value) |
Writes the specified uint16 value to the text stream. | |
void | write (uint32 value) |
Writes the specified uint32 value to the text stream. | |
void | write (uint64 value) |
Writes the specified uint64 value to the text stream. | |
template<class value_t > | |
void | write (value_t value) |
Writes the specified value_t value to the text stream. | |
template<class ... args_t> | |
void | write (const xtd::string &fmt, args_t &&... args) noexcept |
Writes the specified arguments with specified format to the text stream. | |
Additional Inherited Members | |
![]() | |
const xtd::string & | new_line () const noexcept |
Gets the line terminator string used by the current text_writer. | |
void | new_line (const xtd::string &new_line) noexcept |
Sets the line terminator string used by the current text_writer. | |
void | write (bool value) |
Writes the specified bool value to the text stream. | |
void | write (double value) |
Writes the specified double value to the text stream. | |
void | write (float value) |
Writes the specified float value to the text stream. | |
void | write (sbyte value) |
Writes the specified sbyte value to the text stream. | |
void | write (int16 value) |
Writes the specified int16 value to the text stream. | |
void | write (int32 value) |
Writes the specified int32 value to the text stream. | |
void | write (int64 value) |
Writes the specified int64 value to the text stream. | |
void | write (xtd::byte value) |
Writes the specified xtd::byte value to the text stream. | |
void | write (uint16 value) |
Writes the specified uint16 value to the text stream. | |
void | write (uint32 value) |
Writes the specified uint32 value to the text stream. | |
void | write (uint64 value) |
Writes the specified uint64 value to the text stream. | |
template<class value_t > | |
void | write (value_t value) |
Writes the specified value_t value to the text stream. | |
template<class ... args_t> | |
void | write (const xtd::string &fmt, args_t &&... args) noexcept |
Writes the specified arguments with specified format to the text stream. | |
void | write_line () |
Writes new line to the text stream. | |
void | write_line (const xtd::string &value) |
Writes the specified string value and new line to the text stream. | |
void | write_line (bool value) |
Writes the specified bool value and new line to the text stream. | |
void | write_line (double value) |
Writes the specified double value and new line to the text stream. | |
void | write_line (float value) |
Writes the specified float value and new line to the text stream. | |
void | write_line (sbyte value) |
Writes the specified sbyte value and new line to the text stream. | |
void | write_line (int16 value) |
Writes the specified int16 value and new line to the text stream. | |
void | write_line (int32 value) |
Writes the specified int32 value and new line to the text stream. | |
void | write_line (int64 value) |
Writes the specified int64 value and new line to the text stream. | |
void | write_line (xtd::byte value) |
Writes the specified xtd::byte value and new line to the text stream. | |
void | write_line (uint16 value) |
Writes the specified uint16 value and new line to the text stream. | |
void | write_line (uint32 value) |
Writes the specified uint32 value and new line to the text stream. | |
void | write_line (uint64 value) |
Writes the specified uint64 value and new line to the text stream. | |
template<class value_t > | |
void | write_line (value_t value) |
Writes the specified value_t value and new line to the text stream. | |
template<class ... args_t> | |
void | write_line (const xtd::string &fmt, args_t &&... args) noexcept |
Writes the specified arguments with specified format to the text stream. | |
![]() | |
object ()=default | |
Create a new instance of the ultimate base class object. | |
virtual bool | equals (const object &obj) const noexcept |
Determines whether the specified object is equal to the current object. | |
virtual xtd::size | get_hash_code () const noexcept |
Serves as a hash function for a particular type. | |
virtual type_object | get_type () const noexcept |
Gets the type of the current instance. | |
template<class object_t > | |
xtd::uptr< object_t > | memberwise_clone () const |
Creates a shallow copy of the current object. | |
virtual xtd::string | to_string () const noexcept |
Returns a xtd::string that represents the current object. | |
![]() | |
static null_text_writer & | null () noexcept |
Provides a text_writer with no backing store that can be written to, but not read from. | |
static synchronized_text_writer | synchronised (text_writer &writer) noexcept |
Creates a thread-safe (synchronized) wrapper around the specified text_writer object. | |
![]() | |
template<class object_a_t , class object_b_t > | |
static bool | equals (const object_a_t &object_a, const object_b_t &object_b) noexcept |
Determines whether the specified object instances are considered equal. | |
template<class object_a_t , class object_b_t > | |
static bool | reference_equals (const object_a_t &object_a, const object_b_t &object_b) noexcept |
Determines whether the specified object instances are the same instance. | |
![]() | |
text_writer ()=default | |
Initializes a new instance of the xtd::io::text_writer class. | |
|
explicit |
Initializes a new instance of the stream_writer class for the specified file name.
path | The complete file path to be read. |
xtd::argument_exception | path contains one or more of the invalid characters -or- The system could not retrieve the absolute path. |
xtd::io::io_exception | the handle of the specified file cannot be opened |
|
explicit |
Initializes a new instance of the stream_writer class for the specified stream.
stream | The stream to be read. |
xtd::io::stream_writer::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 specified path, using the default encoding and buffer size. If the file exists, it can be either overwritten or appended to. If the file does not exist, this constructor creates a new file.
path | The complete file path to write to. |
append | Determines whether data is to be appended to the file. If the file exists and append is false , the file is overwritten. If the file exists and append is true the data is appended to the file. Otherwise, a new file is created. |
xtd::argument_exception | path contains one or more of the invalid characters -or- The system could not retrieve the absolute path. |
xtd::io::io_exception | the handle of the specified file cannot be opened |
xtd::io::stream_writer::stream_writer | ( | std::ostream & | stream, |
bool | append | ||
) |
Initializes a new instance of the stream_writer class for the specified stream.
stream | The stream to be read. |
bool xtd::io::stream_writer::auto_flush | ( | ) | const |
Gets a value indicating whether the xtd::io::stream_writer will flush its buffer to the underlying stream after every call to xtd::io::text_writer::write(char).
true
to force xtd::io::stream_writer to flush its buffer; otherwise, false
. true
means that data will be flushed from the buffer to the stream after each write operation, but the encoder state will not be flushed. false
, xtd::io::stream_writer will do a limited amount of buffering, both internally and potentially in the encoder from the encoding you passed in. You can get better performance by setting AutoFlush to false
, assuming that you always call xtd::io::stream_writer::close (or at least Flush) when you're done writing with a xtd::io::stream_writer. true
when you are writing to a device where the user expects immediate feedback. xtd::console::out is one of these cases: The xtd::io::stream_writer used internally for writing to xtd::console flushes all its internal state except the encoder state after every call to xtd::io::stream_writer::write. void xtd::io::stream_writer::auto_flush | ( | bool | auto_flush | ) |
Sets a value indicating whether the xtd::io::stream_writer will flush its buffer to the underlying stream after every call to xtd::io::text_writer::write(char).
auto_flush | true to force xtd::io::stream_writer to flush its buffer; otherwise, false . |
true
means that data will be flushed from the buffer to the stream after each write operation, but the encoder state will not be flushed. false
, xtd::io::stream_writer will do a limited amount of buffering, both internally and potentially in the encoder from the encoding you passed in. You can get better performance by setting AutoFlush to false
, assuming that you always call xtd::io::stream_writer::close (or at least Flush) when you're done writing with a xtd::io::stream_writer. true
when you are writing to a device where the user expects immediate feedback. xtd::console::out is one of these cases: The xtd::io::stream_writer used internally for writing to xtd::console flushes all its internal state except the encoder state after every call to xtd::io::stream_writer::write. std::optional< std::reference_wrapper< std::ostream > > xtd::io::stream_writer::base_stream | ( | ) | const |
Returns the underlying stream.
|
overridevirtual |
Closes the stream_writer object and the underlying stream, and releases any system resources associated with the reader.
Reimplemented from xtd::io::text_writer.
|
overridevirtual |
Clears all buffers for the current writer and causes any buffered data to be written to the underlying device.
Reimplemented from xtd::io::text_writer.
|
overridevirtual |
Writes the specified string value to the text stream.
value | The value to write |
io::io_exception | An I/O error occurs. |
Reimplemented from xtd::io::text_writer.
|
virtual |
Writes the specified string value to the text stream.
value | The value to write. |
io::io_exception | An I/O error occurs. |
Reimplemented from xtd::io::text_writer.
void xtd::io::text_writer::write | ( | bool | value | ) |
Writes the specified bool value to the text stream.
value | The value to write. |
io::io_exception | An I/O error occurs. |
void xtd::io::text_writer::write | ( | double | value | ) |
Writes the specified double value to the text stream.
value | The value to write. |
io::io_exception | An I/O error occurs. |
void xtd::io::text_writer::write | ( | float | value | ) |
Writes the specified float value to the text stream.
value | The value to write. |
io::io_exception | An I/O error occurs. |
void xtd::io::text_writer::write | ( | sbyte | value | ) |
Writes the specified sbyte value to the text stream.
value | The value to write. |
io::io_exception | An I/O error occurs. |
void xtd::io::text_writer::write | ( | int16 | value | ) |
Writes the specified int16 value to the text stream.
value | The value to write. |
io::io_exception | An I/O error occurs. |
void xtd::io::text_writer::write | ( | int32 | value | ) |
Writes the specified int32 value to the text stream.
value | The value to write. |
io::io_exception | An I/O error occurs. |
void xtd::io::text_writer::write | ( | int64 | value | ) |
Writes the specified int64 value to the text stream.
value | The value to write. |
io::io_exception | An I/O error occurs. |
void xtd::io::text_writer::write | ( | xtd::byte | value | ) |
Writes the specified xtd::byte value to the text stream.
value | The value to write. |
io::io_exception | An I/O error occurs. |
void xtd::io::text_writer::write | ( | uint16 | value | ) |
Writes the specified uint16 value to the text stream.
value | The value to write. |
io::io_exception | An I/O error occurs. |
void xtd::io::text_writer::write | ( | uint32 | value | ) |
Writes the specified uint32 value to the text stream.
value | The value to write. |
io::io_exception | An I/O error occurs. |
void xtd::io::text_writer::write | ( | uint64 | value | ) |
Writes the specified uint64 value to the text stream.
value | The value to write. |
io::io_exception | An I/O error occurs. |
|
inline |
Writes the specified value_t value to the text stream.
value_t | The type of value to write. |
value | The value to write. |
io::io_exception | An I/O error occurs. |
|
inlinenoexcept |
Writes the specified arguments with specified format to the text stream.
format | The arguments format to write. |
args | The arguments to write with format |
io::io_exception | An I/O error occurs. |