Creates a stream whose backing store is memory.
Public constructors | |
| memory_stream () | |
| Initializes a new instance of the MemoryStream class with an expandable capacity initialized to zero. | |
| memory_stream (xtd::usize capacity) | |
| Initializes a new instance of the MemoryStream class with an expandable capacity initialized as specified. | |
Public Properties | |
| auto | can_read () const noexcept -> bool override |
| Gets a value indicating whether the current stream supports reading. | |
| auto | can_seek () const noexcept -> bool override |
| Gets a value indicating whether the current stream supports seeking. | |
| auto | can_write () const noexcept -> bool override |
| Gets a value indicating whether the current stream supports writing. | |
| auto | capacity () const -> xtd::usize |
| Gets the number of bytes allocated for this stream. | |
| auto | capacity (xtd::usize value) -> void |
| Sets the number of bytes allocated for this stream. | |
| auto | length () const -> xtd::usize override |
| Gets the length of the stream in bytes. | |
| auto | position () const -> xtd::usize override |
| Gets the current position within the stream. | |
| auto | position (xtd::usize value) -> void override |
| Sets the current position within the stream. | |
Public Methods | |
| auto | flush () -> void override |
| Overrides the Flush() method so that no action is performed. | |
| auto | read (xtd::array< xtd::byte > &buffer, usize offset, usize count) -> xtd::usize override |
| Reads a block of bytes from the current stream and writes the data to a buffer. | |
| auto | seek (std::streamoff offset, seek_origin loc) -> xtd::usize |
| Sets the position within the current stream to the specified value. | |
| auto | set_length (xtd::usize value) -> void override |
| Sets the length of the current stream to the specified value. | |
| auto | to_array () const -> xtd::array< xtd::byte > |
| Writes the stream contents to a byte array, regardless of the Position property. | |
| auto | write (const xtd::array< xtd::byte > &buffer, usize offset, usize count) -> void override |
| Writes a block of bytes to the current stream using data read from a buffer. | |
| auto | write_to (std::ostream &stream) -> void |
| Writes the entire contents of this memory stream to another stream. | |
| virtual auto | read (xtd::span< xtd::byte > &buffer) -> xtd::usize |
| 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 auto | write (xtd::span< const xtd::byte > buffer) -> void |
Additional Inherited Members | |
| static xtd::io::null_stream | null_stream |
| A Stream with no backing store. | |
| static constexpr xtd::int32 | eof |
| Represnets an eof value. | |
| virtual auto | can_timeout () const noexcept -> bool |
| Gets a value that determines whether the current stream can time out. | |
| virtual auto | is_closed () const noexcept -> bool |
| Indicates if the stream is closed. | |
| virtual auto | read_timeout () const -> xtd::int32 |
| Gets a value, in milliseconds, that determines how long the stream will attempt to read before timing out. | |
| virtual auto | read_timeout (xtd::int32 value) -> void |
| Sets a value, in milliseconds, that determines how long the stream will attempt to read before timing out. | |
| virtual auto | write_timeout () const -> xtd::int32 |
| Gets a value, in milliseconds, that determines how long the stream will attempt to write before timing out. | |
| virtual auto | write_timeout (xtd::int32 value) -> void |
| Sets a value, in milliseconds, that determines how long the stream will attempt to write before timing out. | |
| auto | copy_to (std::ostream &destination) -> void |
| Reads the bytes from the current memory stream and writes them to another stream. | |
| auto | copy_to (std::ostream &destination, xtd::usize buffer_size) -> void |
| Reads the bytes from the current memory stream and writes them to another stream, using a specified buffer size. | |
| auto | read_at_least (xtd::array< xtd::byte > &buffer, xtd::usize minimum_bytes, bool throw_on_end_of_stream=true) -> xtd::usize |
| 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 auto | read_byte () -> xtd::int32 |
| auto | read_exactly (xtd::array< xtd::byte > &buffer) -> void |
| Reads bytes from the current stream and advances the position within the stream until the buffer is filled. | |
| auto | read_exactly (xtd::array< xtd::byte > &buffer, xtd::usize offset, xtd::usize count) -> void |
| Reads count number of bytes from the current stream and advances the position within the stream. | |
| virtual auto | write_byte (xtd::byte value) -> void |
| object ()=default | |
| Create a new instance of the ultimate base class object. | |
| virtual auto | equals (const object &obj) const noexcept -> bool |
| Determines whether the specified object is equal to the current object. | |
| virtual auto | get_hash_code () const noexcept -> xtd::usize |
| Serves as a hash function for a particular type. | |
| virtual auto | get_type () const noexcept -> type_object |
| Gets the type of the current instance. | |
| template<typename object_t> | |
| auto | memberwise_clone () const -> xtd::unique_ptr_object< object_t > |
| Creates a shallow copy of the current object. | |
| virtual auto | to_string () const -> xtd::string |
| Returns a xtd::string that represents the current object. | |
| template<typename object_a_t, typename object_b_t> | |
| static auto | equals (const object_a_t &object_a, const object_b_t &object_b) noexcept -> bool |
| Determines whether the specified object instances are considered equal. | |
| template<typename object_a_t, typename object_b_t> | |
| static auto | reference_equals (const object_a_t &object_a, const object_b_t &object_b) noexcept -> bool |
| Determines whether the specified object instances are the same instance. | |
| stream () | |
| Initializes a new instance of the xtd::io::stream class. | |
| abstract_object ()=default | |
| Initializes a new instance of the xtd::abstract_object class. | |
| xtd::io::memory_stream::memory_stream | ( | ) |
Initializes a new instance of the MemoryStream class with an expandable capacity initialized to zero.
| xtd::io::memory_stream::memory_stream | ( | xtd::usize | capacity | ) |
Initializes a new instance of the MemoryStream class with an expandable capacity initialized as specified.
| capacity | The initial size of the internal array in bytes. |
|
nodiscardoverridevirtualnoexcept |
Gets a value indicating whether the current stream supports reading.
Implements xtd::io::stream.
|
nodiscardoverridevirtualnoexcept |
Gets a value indicating whether the current stream supports seeking.
Implements xtd::io::stream.
|
nodiscardoverridevirtualnoexcept |
Gets a value indicating whether the current stream supports writing.
Implements xtd::io::stream.
|
nodiscard |
Gets the number of bytes allocated for this stream.
| xtd::argument_out_of_range_exception | A capacity is less than the current length of the stream. |
| auto xtd::io::memory_stream::capacity | ( | xtd::usize | value | ) | -> void |
Sets the number of bytes allocated for this stream.
| value | The length of the usable portion of the buffer for the stream. |
| xtd::argument_out_of_range_exception | A capacity is less than the current length of the stream. |
|
nodiscardoverridevirtual |
Gets the length of the stream in bytes.
Implements xtd::io::stream.
|
nodiscardoverridevirtual |
Gets the current position within the stream.
Implements xtd::io::stream.
|
overridevirtual |
Sets the current position within the stream.
| value | The current position within the stream. |
Implements xtd::io::stream.
|
overridevirtual |
Overrides the Flush() method so that no action is performed.
Implements xtd::io::stream.
|
overridevirtual |
Reads a block of bytes from the current stream and writes the data to a buffer.
| buffer | When this method returns, contains the specified byte array with the values between offset and (offset + count - 1) replaced by the characters read from the current stream. |
| offset | The zero-based byte offset in buffer at which to begin storing data from the current stream. |
| count | The maximum number of bytes to read. |
Implements xtd::io::stream.
| auto xtd::io::memory_stream::seek | ( | std::streamoff | offset, |
| seek_origin | loc ) -> xtd::usize |
Sets the position within the current stream to the specified value.
| offset | The new position within the stream. This is relative to the loc parameter, and can be positive or negative. |
| loc | A value of type xtd::io::seek_origin, which acts as the seek reference point. |
|
overridevirtual |
Sets the length of the current stream to the specified value.
| value | The value at which to set the length. |
Implements xtd::io::stream.
|
nodiscard |
Writes the stream contents to a byte array, regardless of the Position property.
|
overridevirtual |
Writes a block of bytes to the current stream using data read from a buffer.
| buffer | The buffer to write data from. |
| offset | The zero-based byte offset in buffer at which to begin copying bytes to the current stream. |
| count | The maximum number of bytes to write. |
Implements xtd::io::stream.
| auto xtd::io::memory_stream::write_to | ( | std::ostream & | stream | ) | -> void |
Writes the entire contents of this memory stream to another stream.
| stream | The stream to write this memory stream to. |
| xtd::bject_closed_exception | The current or target stream is closed. |
|
virtual |
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. |
Reimplemented from xtd::io::stream.
Reimplemented from xtd::io::stream.