xtd 0.2.0
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 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;
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:61
Represents a strongly typed list of objects that can be accessed by index. Provides methods to search...
Definition list.hpp:79
void write(const xtd::array< xtd::byte > &buffer, size offset, size count) override
Writes a block of bytes to the current stream using data read from a buffer.
void set_length(xtd::size value) override
Sets the length of the current stream to the specified value.
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.
void write_to(std::ostream &stream)
Writes the entire contents of this memory stream to another stream.
xtd::size position() const override
Gets the current position within the stream.
xtd::size capacity() const
Gets the number of bytes allocated for this stream.
bool can_write() const noexcept override
Gets a value indicating whether the current stream supports writing.
xtd::size length() const override
Gets the length of the stream in bytes.
bool can_seek() const noexcept override
Gets a value indicating whether the current stream supports seeking.
xtd::size seek(std::streamoff offset, seek_origin loc)
Sets the position within the current stream to the specified value.
xtd::array< xtd::byte > to_array() const
Writes the stream contents to a byte array, regardless of the Position property.
memory_stream()
Initializes a new instance of the MemoryStream class with an expandable capacity initialized to zero.
void flush() override
Overrides the Flush() method so that no action is performed.
xtd::size read(xtd::array< xtd::byte > &buffer, size offset, size count) override
Reads a block of bytes from the current stream and writes the data to a buffer.
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 <value_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.