xtd - Reference Guide  0.1.0
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
Public Member Functions | List of all members
xtd::io::stream_writer Class Reference

#include <stream_writer.h>

Definition

Represents a writer that can write a sequential series of characters.

Namespace
xtd::io
Library
xtd.core

Public Member Functions

 stream_writer (const xtd::ustring &path)
 Initializes a new instance of the stream_writer class for the specified file name. More...
 
 stream_writer (std::ostream &stream)
 Initializes a new instance of the stream_writer class for the specified stream. More...
 
 stream_writer (const xtd::ustring &path, bool append)
 Initializes a new instance of the System::IO::StreamWriter 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. More...
 
 stream_writer (std::ostream &stream, bool append)
 Initializes a new instance of the stream_writer class for the specified stream. More...
 
bool auto_flush () const
 
void auto_flush (bool auto_flush)
 
std::optional< std::reference_wrapper< std::ostream > > base_stream () const
 Returns the underlying stream. More...
 
void close () override
 Closes the stream_writer object and the underlying stream, and releases any system resources associated with the reader. More...
 
void flush () override
 Clears all buffers for the current writer and causes any buffered data to be written to the underlying device. More...
 
void write (const xtd::ustring &value) override
 Writes the specified string value to the text stream. More...
 
- Public Member Functions inherited from xtd::io::text_writer
const xtd::ustringnew_line () const noexcept
 Gets the line terminator string used by the current text_writer. More...
 
void new_line (const xtd::ustring &new_line) noexcept
 Sets the line terminator string used by the current text_writer. More...
 
void write (bool value)
 Writes the specified bool value to the text stream. More...
 
void write (double value)
 Writes the specified double value to the text stream. More...
 
void write (float value)
 Writes the specified float value to the text stream. More...
 
void write (int8_t value)
 Writes the specified int8_t value to the text stream. More...
 
void write (int16_t value)
 Writes the specified int16_t value to the text stream. More...
 
void write (int32_t value)
 Writes the specified int32_t value to the text stream. More...
 
void write (int64_t value)
 Writes the specified int64_t value to the text stream. More...
 
void write (uint8_t value)
 Writes the specified uint8_t value to the text stream. More...
 
void write (uint16_t value)
 Writes the specified uint16_t value to the text stream. More...
 
void write (uint32_t value)
 Writes the specified uint32_t value to the text stream. More...
 
void write (uint64_t value)
 Writes the specified uint64_t value to the text stream. More...
 
template<typename value_t >
void write (value_t value)
 Writes the specified value_t value to the text stream. More...
 
template<typename ... args_t>
void write (const xtd::ustring &fmt, args_t &&... args) noexcept
 Writes the specified arguments with specified format to the text stream. More...
 
void write_line ()
 Writes new line to the text stream. More...
 
void write_line (const xtd::ustring &value)
 Writes the specified string value and new line to the text stream. More...
 
void write_line (bool value)
 Writes the specified bool value and new line to the text stream. More...
 
void write_line (double value)
 Writes the specified double value and new line to the text stream. More...
 
void write_line (float value)
 Writes the specified float value and new line to the text stream. More...
 
void write_line (int8_t value)
 Writes the specified int8_t value and new line to the text stream. More...
 
void write_line (int16_t value)
 Writes the specified int16_t value and new line to the text stream. More...
 
void write_line (int32_t value)
 Writes the specified int32_t value and new line to the text stream. More...
 
void write_line (int64_t value)
 Writes the specified int64_t value and new line to the text stream. More...
 
void write_line (uint8_t value)
 Writes the specified uint8_t value and new line to the text stream. More...
 
void write_line (uint16_t value)
 Writes the specified uint16_t value and new line to the text stream. More...
 
void write_line (uint32_t value)
 Writes the specified uint32_t value and new line to the text stream. More...
 
void write_line (uint64_t value)
 Writes the specified uint64_t value and new line to the text stream. More...
 
template<typename value_t >
void write_line (value_t value)
 Writes the specified value_t value and new line to the text stream. More...
 
template<typename ... args_t>
void write_line (const xtd::ustring &fmt, args_t &&... args) noexcept
 Writes the specified arguments with specified format to the text stream. More...
 
- Public Member Functions inherited from xtd::object
 object ()=default
 Create a new instance of the ultimate base class object. More...
 
virtual bool equals (const object &obj) const noexcept
 Determines whether the specified object is equal to the current object. More...
 
virtual size_t get_hash_code () const noexcept
 Serves as a hash function for a particular type. More...
 
template<typename object_t >
std::unique_ptr< object_t > memberwise_clone () const
 Gets the type of the current instance. More...
 
virtual xtd::ustring to_string () const noexcept
 Returns a std::string that represents the current object. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from xtd::io::text_writer
static null_text_writernull () noexcept
 Provides a text_writer with no backing store that can be written to, but not read from. More...
 
static synchronized_text_writer synchronised (text_writer &writer) noexcept
 Creates a thread-safe (synchronized) wrapper around the specified text_writer object. More...
 
- Static Public Member Functions inherited from xtd::object
static bool equals (const object &object_a, const object &object_b) noexcept
 Determines whether the specified object instances are considered equal. More...
 
static bool reference_equals (const object &object_a, const object &object_b) noexcept
 Determines whether the specified object instances are the same instance. More...
 
- Protected Attributes inherited from xtd::io::text_writer
xtd::ustring new_line_ = "\n"
 
- Protected Member Functions inherited from xtd::io::text_writer
 text_writer ()=default
 Initializes a new instance of the xtd::io::text_writer class. More...
 

Constructor & Destructor Documentation

◆ stream_writer() [1/4]

xtd::io::stream_writer::stream_writer ( const xtd::ustring path)

Initializes a new instance of the stream_writer class for the specified file name.

Parameters
pathThe complete file path to be read.
Exceptions
xtd::argument_exceptionpath contains one or more of the invalid characters -or- The system could not retrieve the absolute path.
xtd::io::io_exceptionthe handle of the specified file cannot be opened

◆ stream_writer() [2/4]

xtd::io::stream_writer::stream_writer ( std::ostream &  stream)

Initializes a new instance of the stream_writer class for the specified stream.

Parameters
streamThe stream to be read.

◆ stream_writer() [3/4]

xtd::io::stream_writer::stream_writer ( const xtd::ustring path,
bool  append 
)

Initializes a new instance of the System::IO::StreamWriter 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.

Parameters
pathThe complete file path to write to.
appendDetermines 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.
Exceptions
xtd::argument_exceptionpath contains one or more of the invalid characters -or- The system could not retrieve the absolute path.
xtd::io::io_exceptionthe handle of the specified file cannot be opened

◆ stream_writer() [4/4]

xtd::io::stream_writer::stream_writer ( std::ostream &  stream,
bool  append 
)

Initializes a new instance of the stream_writer class for the specified stream.

Parameters
streamThe stream to be read.

Member Function Documentation

◆ base_stream()

std::optional<std::reference_wrapper<std::ostream> > xtd::io::stream_writer::base_stream ( ) const

Returns the underlying stream.

Returns
The underlying stream.

◆ close()

void xtd::io::stream_writer::close ( )
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.

◆ flush()

void xtd::io::stream_writer::flush ( )
overridevirtual

Clears all buffers for the current writer and causes any buffered data to be written to the underlying device.

Remarks
This default method does nothing, but derived classes can virtual the method to provide the appropriate functionality

Reimplemented from xtd::io::text_writer.

◆ write()

void xtd::io::stream_writer::write ( const xtd::ustring value)
overridevirtual

Writes the specified string value to the text stream.

Parameters
valueThe value to write
Exceptions
io::io_exceptionAn I/O error occurs.

Reimplemented from xtd::io::text_writer.


The documentation for this class was generated from the following file: