Provides a generic view of a sequence of bytes. This is an abstract class.
Public Fields | |
static xtd::io::null_stream | null_stream |
A Stream with no backing store. | |
static constexpr int32 | eof |
Represnets an eof value. | |
Public Properties | |
virtual bool | can_read () const noexcept=0 |
When overridden in a derived class, gets a value indicating whether the current stream supports reading. | |
virtual bool | can_seek () const noexcept=0 |
When overridden in a derived class, gets a value indicating whether the current stream supports seeking. | |
virtual bool | can_timeout () const noexcept |
Gets a value that determines whether the current stream can time out. | |
virtual bool | can_write () const noexcept=0 |
Gets a value indicating whether the current stream supports writing. | |
virtual bool | is_closed () const noexcept |
Indicates if the stream is closed. | |
virtual xtd::size | length () const =0 |
When overridden in a derived class, gets the length in bytes of the stream. | |
virtual xtd::size | position () const =0 |
When overridden in a derived class, gets the position within the current stream. | |
virtual void | position (xtd::size value)=0 |
When overridden in a derived class, sets the position within the current stream. | |
virtual int32 | read_timeout () const |
Gets a value, in milliseconds, that determines how long the stream will attempt to read before timing out. | |
virtual void | read_timeout (int32 value) |
Sets a value, in milliseconds, that determines how long the stream will attempt to read before timing out. | |
virtual int32 | write_timeout () const |
Gets a value, in milliseconds, that determines how long the stream will attempt to write before timing out. | |
virtual void | write_timeout (int32 value) |
Sets a value, in milliseconds, that determines how long the stream will attempt to write before timing out. | |
Public Methods | |
void | copy_to (std::ostream &destination) |
Reads the bytes from the current memory stream and writes them to another stream. | |
void | copy_to (std::ostream &destination, xtd::size buffer_size) |
Reads the bytes from the current memory stream and writes them to another stream, using a specified buffer size. | |
virtual void | flush ()=0 |
When overridden in a derived class, clears all buffers for this stream and causes any buffered data to be written to the underlying device. exception xtd::io::io_exception An I/O error occurs. | |
virtual xtd::size | read (xtd::span< xtd::byte > &buffer) |
When overridden in a derived class, reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read. | |
virtual xtd::size | read (xtd::array< xtd::byte > &buffer, xtd::size offset, xtd::size count)=0 |
xtd::size | read_at_least (xtd::array< xtd::byte > &buffer, xtd::size minimum_bytes, bool throw_on_end_of_stream=true) |
Reads at least a minimum number of bytes from the current stream and advances the position within the stream by the number of bytes read. | |
virtual int32 | read_byte () |
void | read_exactly (xtd::array< xtd::byte > &buffer) |
Reads bytes from the current stream and advances the position within the stream until the buffer is filled. | |
void | read_exactly (xtd::array< xtd::byte > &buffer, xtd::size offset, xtd::size count) |
Reads count number of bytes from the current stream and advances the position within the stream. | |
virtual void | set_length (xtd::size value)=0 |
virtual void | write (xtd::span< const xtd::byte > buffer) |
virtual void | write (const xtd::array< xtd::byte > &buffer, xtd::size offset, xtd::size count)=0 |
virtual void | write_byte (xtd::byte value) |
Protected constructors | |
stream () | |
Initializes a new instance of the xtd::io::stream class. | |
Additional Inherited Members | |
![]() | |
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. | |
![]() | |
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. | |
![]() | |
abstract_object ()=default | |
Initializes a new instance of the xtd::abstract_object class. | |
|
protected |
Initializes a new instance of the xtd::io::stream class.
|
pure virtualnoexcept |
When overridden in a derived class, gets a value indicating whether the current stream supports reading.
true
if the stream supports reading; otherwise, false
. Implemented in xtd::io::memory_stream, and xtd::net::sockets::network_stream.
|
pure virtualnoexcept |
When overridden in a derived class, gets a value indicating whether the current stream supports seeking.
true
if the stream supports seeking; otherwise, false
. Implemented in xtd::io::memory_stream, and xtd::net::sockets::network_stream.
|
virtualnoexcept |
Gets a value that determines whether the current stream can time out.
false
. Some stream implementations require different behavior, such as xtd::net::sockets::network_stream, which times out if network connectivity is interrupted or lost. If you are implementing a stream that must be able to time out, this property should be overridden to return true
. Reimplemented in xtd::net::sockets::network_stream.
|
pure virtualnoexcept |
Gets a value indicating whether the current stream supports writing.
true
if the stream supports writing; otherwise, false
. Implemented in xtd::io::memory_stream, and xtd::net::sockets::network_stream.
|
virtualnoexcept |
Indicates if the stream is closed.
true
if the stream is closed, false
otherwise
|
pure virtual |
When overridden in a derived class, gets the length in bytes of the stream.
xtd::not_supported_exception | A class derived from xtd::io::stream does not support seeking and the length is unknown. |
Implemented in xtd::io::memory_stream, and xtd::net::sockets::network_stream.
|
pure virtual |
When overridden in a derived class, gets the position within the current stream.
xtd::not_supported_exception | The stream does not support seeking. |
Implemented in xtd::io::memory_stream, and xtd::net::sockets::network_stream.
|
pure virtual |
When overridden in a derived class, sets the position within the current stream.
value | The current position within the stream. |
xtd::not_supported_exception | The stream does not support seeking. |
Implemented in xtd::io::memory_stream, and xtd::net::sockets::network_stream.
|
virtual |
Gets a value, in milliseconds, that determines how long the stream will attempt to read before timing out.
xtd::invalid_operation_exception | The xtd::io::stream::read_timeout method always throws an xtd::invalid_operation_exception. |
Reimplemented in xtd::net::sockets::network_stream.
|
virtual |
Sets a value, in milliseconds, that determines how long the stream will attempt to read before timing out.
value | A value, in milliseconds, that determines how long the stream will attempt to read before timing out. |
xtd::invalid_operation_exception | The xtd::io::stream::read_timeout method always throws an xtd::invalid_operation_exception. |
Reimplemented in xtd::net::sockets::network_stream.
|
virtual |
Gets a value, in milliseconds, that determines how long the stream will attempt to write before timing out.
xtd::invalid_operation_exception | The xtd::io::stream::write_timeout method always throws an xtd::invalid_operation_exception. |
Reimplemented in xtd::net::sockets::network_stream.
|
virtual |
Sets a value, in milliseconds, that determines how long the stream will attempt to write before timing out.
value | A value, in milliseconds, that determines how long the stream will attempt to write before timing out. |
xtd::invalid_operation_exception | The xtd::io::stream::write_timeout method always throws an xtd::invalid_operation_exception. |
Reimplemented in xtd::net::sockets::network_stream.
void xtd::io::stream::copy_to | ( | std::ostream & | destination | ) |
Reads the bytes from the current memory stream and writes them to another stream.
destination | The stream to which the contents of the current memory stream will be copied. |
void xtd::io::stream::copy_to | ( | std::ostream & | destination, |
xtd::size | buffer_size | ||
) |
Reads the bytes from the current memory stream and writes them to another stream, using a specified buffer size.
destination | The stream to which the contents of the current memory stream will be copied. |
buffer_size | The size of the buffer. This value must be greater than zero. The default size is 81920. |
|
pure virtual |
When overridden in a derived class, clears all buffers for this stream and causes any buffered data to be written to the underlying device. exception xtd::io::io_exception An I/O error occurs.
Implemented in xtd::io::memory_stream, and xtd::net::sockets::network_stream.
When overridden in a derived class, reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.
buffer | A region of memory. When this method returns, the contents of this region are replaced by the bytes read from the current source. |
|
pure virtual |
Implemented in xtd::io::memory_stream, and xtd::net::sockets::network_stream.
xtd::size xtd::io::stream::read_at_least | ( | xtd::array< xtd::byte > & | buffer, |
xtd::size | minimum_bytes, | ||
bool | throw_on_end_of_stream = true |
||
) |
Reads at least a minimum number of bytes from the current stream and advances the position within the stream by the number of bytes read.
buffer | A region of memory. When this method returns, the contents of this region are replaced by the bytes read from the current stream. |
minimum_bytes | The minimum number of bytes to read into the buffer. |
throw_on_end_of_stream | true to throw an exception if the end of the stream is reached before reading minimumBytes of bytes; false to return less than minimum_bytes when the end of the stream is reached. The default is true . |
minimum_bytes
when throw_on_end_of_stream
is true
. This will be less than minimum_bytes
when the end of the stream is reached and throw_on_end_of_stream
is false
. This can be less than the number of bytes allocated in the buffer if that many bytes are not currently available. xtd::argument_out_of_range_exception | `minimum_bytes` is greater than the length of `buffer`. |
xtd::io::end_of_stream_exception | `throw_on_end_of_stream` is `true` and the end of the stream is reached before reading `minimum_bytes` bytes of data. |
minimum_bytes
is 0 (zero), this read operation will be completed without waiting for available data in the stream. void xtd::io::stream::read_exactly | ( | xtd::array< xtd::byte > & | buffer | ) |
Reads bytes from the current stream and advances the position within the stream until the buffer is filled.
buffer | A region of memory. When this method returns, the contents of this region are replaced by the bytes read from the current stream |
xtd::end_of_stream_exception | The end of the stream is reached before filling the buffer. |
buffer
is empty, this read operation will be completed without waiting for available data in the stream. void xtd::io::stream::read_exactly | ( | xtd::array< xtd::byte > & | buffer, |
xtd::size | offset, | ||
xtd::size | count | ||
) |
Reads count
number of bytes from the current stream and advances the position within the stream.
buffer | An array of bytes. When this method returns, the buffer contains the specified byte array with the values between offset and (offset + count - 1) replaced by the bytes read from the current stream. |
offset | The byte offset in buffer at which to begin storing the data read from the current stream. |
count | The number of bytes to be read from the current stream. |
xtd::argument_out_of_range_exception | offset is outside the bounds of buffer. -or- The range specified by the combination of offset and count exceeds the length of buffer. |
xtd::io::end_of_stream_exception | `throw_on_end_of_stream` is `true` and the end of the stream is reached before reading `minimum_bytes` bytes of data. |
count
is 0 (zero), this read operation will be completed without waiting for available data in the stream.
|
pure virtual |
Implemented in xtd::io::memory_stream, and xtd::net::sockets::network_stream.
|
pure virtual |
Implemented in xtd::io::memory_stream, and xtd::net::sockets::network_stream.
|
static |
A Stream with no backing store.
|
inlinestaticconstexpr |
Represnets an eof value.