xtd 0.2.0
Loading...
Searching...
No Matches
memory_stream.hpp
Go to the documentation of this file.
1
4#pragma once
5#include "stream.hpp"
7#include "../new_ptr.hpp"
8
10namespace xtd {
12 namespace io {
29 public:
31
45
47
51 [[nodiscard]] auto can_read() const noexcept -> bool override;
52
55 [[nodiscard]] auto can_seek() const noexcept -> bool override;
56
59 [[nodiscard]] auto can_write() const noexcept -> bool override;
60
65 [[nodiscard]] auto capacity() const -> xtd::size;
70 auto capacity(xtd::size value) -> void;
71
74 [[nodiscard]] auto length() const -> xtd::size override;
75
78 [[nodiscard]] auto position() const -> xtd::size override;
81 auto position(xtd::size value) -> void override;
83
85
90 auto flush() -> void override;
91
92 using xtd::io::stream::read;
102 auto read(xtd::array<xtd::byte>& buffer, size offset, size count) -> xtd::size override;
103
108 auto seek(std::streamoff offset, seek_origin loc) -> xtd::size;
109
113 auto set_length(xtd::size value) -> void override;
114
119 [[nodiscard]] auto to_array() const -> xtd::array<xtd::byte>;
120
121 using xtd::io::stream::write;
134 auto write(const xtd::array<xtd::byte>& buffer, size offset, size count) -> void override;
135
140 auto write_to(std::ostream& stream) -> void;
142 private:
143 [[nodiscard]] auto abstract_read_byte_unchecked() -> xtd::byte;
144 auto abstract_write_byte_unchecked(xtd::byte b) -> void;
145
146 struct data {
147 xtd::array<byte>* static_buffer = null;
150 bool writable = true;
151 };
152 ptr<data> data_ = new_ptr<data>();
153 };
154 }
155}
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
Definition array.hpp:64
Represents a strongly typed list of objects that can be accessed by index. Provides methods to search...
Definition list.hpp:80
memory_stream(xtd::size capacity)
Initializes a new instance of the MemoryStream class with an expandable capacity initialized as speci...
auto capacity() const -> xtd::size
Gets the number of bytes allocated for this stream.
auto length() const -> xtd::size override
Gets the length of the stream in bytes.
auto can_write() const noexcept -> bool override
Gets a value indicating whether the current stream supports writing.
auto write(const xtd::array< xtd::byte > &buffer, size offset, size count) -> void override
Writes a block of bytes to the current stream using data read from a buffer.
auto set_length(xtd::size value) -> void override
Sets the length of the current stream to the specified value.
auto write_to(std::ostream &stream) -> void
Writes the entire contents of this memory stream to another stream.
auto flush() -> void override
Overrides the Flush() method so that no action is performed.
auto seek(std::streamoff offset, seek_origin loc) -> xtd::size
Sets the position within the current stream to the specified value.
auto can_read() const noexcept -> bool override
Gets a value indicating whether the current stream supports reading.
memory_stream()
Initializes a new instance of the MemoryStream class with an expandable capacity initialized to zero.
auto to_array() const -> xtd::array< xtd::byte >
Writes the stream contents to a byte array, regardless of the Position property.
auto read(xtd::array< xtd::byte > &buffer, size offset, size count) -> xtd::size override
Reads a block of bytes from the current stream and writes the data to a buffer.
auto can_seek() const noexcept -> bool override
Gets a value indicating whether the current stream supports seeking.
auto position() const -> xtd::size override
Gets the current position within the stream.
Provides a generic view of a sequence of bytes. This is an abstract class.
Definition stream.hpp:40
stream()
Initializes a new instance of the xtd::io::stream class.
#define core_export_
Define shared library export.
Definition core_export.hpp:13
size_t size
Represents a size of any object in bytes.
Definition size.hpp:23
null_ptr null
Represents a null pointer value.
xtd::sptr< type_t > ptr
The xtd::ptr object is a shared pointer.
Definition ptr.hpp:27
ptr< type_t > new_ptr(args_t &&... args)
The xtd::new_ptr operator creates a xtd::ptr object.
Definition new_ptr.hpp:24
seek_origin
Specifies the position in a stream to use for seeking.
Definition seek_origin.hpp:16
@ b
The B key.
Definition console_key.hpp:90
Contains xtd::collections::generic::list <type_t> class.
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::new_ptr method.
Contains xtd::io::stream class.