xtd 0.2.0
memory_stream.hpp
Go to the documentation of this file.
1
4#pragma once
5#include "stream.hpp"
6#include "../collections/generic/list.hpp"
7#include "../new_ptr.hpp"
8
10namespace xtd {
12 namespace io {
29 public:
31
45
47
51 bool can_read() const noexcept override;
52
55 bool can_seek() const noexcept override;
56
59 bool can_write() const noexcept override;
60
65 xtd::size capacity() const;
70 void capacity(xtd::size value);
71
74 xtd::size length() const override;
75
78 xtd::size position() const override;
81 void position(xtd::size value) override;
83
85
90 void flush() override;
91
92 using xtd::io::stream::read;
102 xtd::size read(xtd::array<xtd::byte>& buffer, size offset, size count) override;
103
108 xtd::size seek(std::streamoff offset, seek_origin loc);
109
113 void set_length(xtd::size value) override;
114
119 xtd::array<xtd::byte> to_array() const;
120
121 using xtd::io::stream::write;
134 void write(const xtd::array<xtd::byte>& buffer, size offset, size count) override;
135
140 void write_to(std::ostream& stream);
142 private:
143 xtd::byte abstract_read_byte_unchecked();
144 void abstract_write_byte_unchecked(xtd::byte b);
145
146 struct data {
147 xtd::array<byte>* static_buffer = null;
149 xtd::size position = 0;
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:59
Represents a strongly typed list of objects that can be accessed by index. Provides methods to search...
Definition list.hpp:80
Creates a stream whose backing store is memory.
Definition memory_stream.hpp:28
memory_stream(xtd::size capacity)
Initializes a new instance of the MemoryStream class with an expandable capacity initialized as speci...
bool can_read() const noexcept 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.
Provides a generic view of a sequence of bytes. This is an abstract class.
Definition stream.hpp:40
@ io
I/O erreror occurs.
#define core_export_
Define shared library export.
Definition core_export.hpp:13
xtd::sptr< type_t > ptr
The xtd::ptr object is a shared pointer.
Definition ptr.hpp:27
null_ptr null
Represents a null pointer value.
size_t size
Represents a size of any object in bytes.
Definition size.hpp:23
seek_origin
Specifies the position in a stream to use for seeking.
Definition seek_origin.hpp:16
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.hpp:10
Contains xtd::io::stream class.