CodePorting.Translator Cs2Cpp
CodePorting.Translator.Cs2Cpp.Framework
memory_stream.h
1
2#ifndef _aspose_system_io_memory_stream_h_
3#define _aspose_system_io_memory_stream_h_
4
5#include "system/io/stream.h"
6#include "system/array.h"
7#include "system/array_segment.h"
8#include "system/reflection.h"
9
10#include "fwd.h"
11
12namespace System { namespace IO {
13 class BinaryReader;
18 class ASPOSECPP_SHARED_CLASS MemoryStream : public Stream
19 {
20 RTTI_INFO(System::IO::MemoryStream, ::System::BaseTypesInfo<System::IO::Stream>);
21 public:
27
29 ASPOSECPP_SHARED_API MemoryStream();
32 ASPOSECPP_SHARED_API MemoryStream(int capacity_);
36 ASPOSECPP_SHARED_API MemoryStream(const ArrayPtr<uint8_t>& content, bool writable = true);
44 ASPOSECPP_SHARED_API MemoryStream(const ArrayPtr<uint8_t>& content, int index, int count, bool writable = true, bool publiclyVisible = false);
45
46
47
50 ASPOSECPP_SHARED_API void set_Capacity(int value);
52 ASPOSECPP_SHARED_API int get_Capacity();
53
55 virtual ASPOSECPP_SHARED_API ArrayPtr<uint8_t> ToArray();
56
57 // Stream impl.
60 ASPOSECPP_SHARED_API int ReadByte() override;
63 ASPOSECPP_SHARED_API void WriteByte(uint8_t value) override;
69 ASPOSECPP_SHARED_API int32_t Read(const ArrayPtr<uint8_t>& buffer, int32_t offset, int32_t count) override;
74 ASPOSECPP_SHARED_API void Write(const ArrayPtr<uint8_t>& buffer, int32_t offset, int32_t count) override;
80 ASPOSECPP_SHARED_API int32_t Read(const System::Details::ArrayView<uint8_t>& buffer, int32_t offset, int32_t count) override;
85 ASPOSECPP_SHARED_API void Write(const System::Details::ArrayView<uint8_t>& buffer, int32_t offset, int32_t count) override;
86
91 ASPOSECPP_SHARED_API int64_t Seek(int64_t offset, SeekOrigin origin) override;
92
93 ASPOSECPP_SHARED_API void SetLength(int64_t value) override;
95 ASPOSECPP_SHARED_API void Flush() override;
96
99 virtual ASPOSECPP_SHARED_API void WriteTo(SharedPtr<Stream> stream);
101 virtual ASPOSECPP_SHARED_API ArrayPtr<uint8_t> GetBuffer();
109 ASPOSECPP_SHARED_API void set_Position(int64_t value) override;
111 ASPOSECPP_SHARED_API int64_t get_Position() const override;
113 ASPOSECPP_SHARED_API int64_t get_Length() const override;
116 ASPOSECPP_SHARED_API bool get_CanRead() const override;
119 ASPOSECPP_SHARED_API bool get_CanSeek() const override;
122 ASPOSECPP_SHARED_API bool get_CanWrite() const override;
124 virtual ASPOSECPP_SHARED_API void Close() override;
125
126 private:
128 void CheckIfClosedThrowDisposed() const;
131 void Expand (int newSize);
135 int CalculateNewCapacity (int minimum);
136
137 // PERF: Internal functions for fast direct access of MemoryStream buffer (cf. BinaryReader for usage)
139 System::ArrayPtr<uint8_t> InternalGetBuffer();
141 int32_t InternalGetPosition() const;
147 int32_t InternalEmulateRead(int32_t count);
148
150 ArrayPtr<uint8_t> internalBuffer;
152 uint8_t* pCurrentPosition = nullptr;
154 bool expandable;
156 bool m_readable = true;
158 bool m_seekable = true;
160 bool m_writable;
162 int capacity;
164 int position;
166 int length;
168 int initialIndex;
170 int dirty_bytes;
172 bool _publiclyVisible;
173 bool _exposable;
174
175 protected:
176#ifdef ASPOSE_GET_SHARED_MEMBERS
178 virtual ASPOSECPP_SHARED_API void GetSharedMembers(System::Object::shared_members_type& result) const override;
179#endif
180
181#ifdef __DBG_FOR_EACH_MEMBER
182 public:
183 void DBG_for_each_member(DBG::for_each_member_visitor &visitor) const override
184 {
185 visitor.add_self(this);
186 }
187
188 const char* DBG_class_name() const override { return "MemoryStream"; }
189#endif
190 };
191
192}}
193
194#endif // _aspose_system_io_memory_stream_h_
Represents a segment of the one-dimensional array. Objects of this class should only be allocated usi...
Definition: array_segment.h:63
Represents a reader that reads primitive data types as binary data in particular encoding....
Definition: binary_reader.h:26
Represents a stream that reads from and writes to memory. Objects of this class should only be alloca...
Definition: memory_stream.h:19
MemoryStream(const ArrayPtr< uint8_t > &content, int index, int count, bool writable=true, bool publiclyVisible=false)
Constructs a new instance of the MemoryStream class that represents a memory stream which is connecte...
int get_Capacity()
Returns the current capacity of the underlying memory buffer.
bool TryGetBuffer(ArraySegment< uint8_t > &buffer)
Returns the array of unsigned bytes from which this stream was created.
int32_t Read(const System::Details::ArrayView< uint8_t > &buffer, int32_t offset, int32_t count) override
Reads the specified number of bytes from the stream and writes them to the specified byte array.
void SetLength(int64_t value) override
Sets the length of the stream represented by the current object.
bool get_CanSeek() const override
Determines if the stream supports seeking.
MemoryStream(int capacity_)
Constructs a new instance of the MemoryStream class that represents a stream based on a memory buffer...
bool get_CanWrite() const override
Determines if the stream is writable.
virtual void Close() override
Closes the stream.
void Write(const System::Details::ArrayView< uint8_t > &buffer, int32_t offset, int32_t count) override
Writes the specified subrange of bytes from the specified byte array to the stream.
System::SharedPtr< System::IO::MemoryStream > Ptr
An alias for a shared pointer to the self.
Definition: memory_stream.h:26
int64_t get_Length() const override
Returns the length of the stream in bytes.
int ReadByte() override
Reads a single byte from the stream and returns a 32-bit integer value equivalent to the value of the...
void Write(const ArrayPtr< uint8_t > &buffer, int32_t offset, int32_t count) override
Writes the specified subrange of bytes from the specified byte array to the stream.
virtual ArrayPtr< uint8_t > ToArray()
Returns a copy of underlying memory buffer as an array of bytes.
MemoryStream()
Constructs a new instance of the MemoryStream class with initial capacity equal to 0.
virtual void WriteTo(SharedPtr< Stream > stream)
Writes the content of the underlying buffer to the specified stream.
void Flush() override
Does nothing.
void WriteByte(uint8_t value) override
Writes the specified unsigned 8-bit integer value to the stream.
void set_Position(int64_t value) override
Sets the stream's position.
int64_t get_Position() const override
Returns the current position of the stream.
void set_Capacity(int value)
Sets the capacity of the underlying memory buffer.
MemoryStream(const ArrayPtr< uint8_t > &content, bool writable=true)
Constructs a new instance of the MemoryStream class that represents a memory stream which is connecte...
int32_t Read(const ArrayPtr< uint8_t > &buffer, int32_t offset, int32_t count) override
Reads the specified number of bytes from the stream and writes them to the specified byte array.
bool get_CanRead() const override
Determines if the stream is readable.
int64_t Seek(int64_t offset, SeekOrigin origin) override
Sets the position of the stream represented by the current object.
virtual ArrayPtr< uint8_t > GetBuffer()
Returns a pointer to the underlying buffer.
A base class for a variety of stream implementations. Objects of this class should only be allocated ...
Definition: stream.h:24
Pointer class to wrap types being allocated on heap. Use it to manage memory for classes inheriting O...
Definition: smart_ptr.h:180
SeekOrigin
Specifies the reference position in the stream relative to which the position to seek to is specified...
Definition: seekorigin.h:11
Definition: db_command.h:9