CodePorting.Translator Cs2Cpp
CodePorting.Translator.Cs2Cpp.Framework
stream.h
1
2#ifndef _aspose_system_io_stream_h_
3#define _aspose_system_io_stream_h_
4
5#include "system/array.h"
6#include "system/idisposable.h"
7#include "system/io/seekorigin.h"
8#include "system/async_callback.h"
9
10#include "system/details/array_view.h"
11
12#include "system/exceptions.h"
13
14namespace System {
15 class IAsyncResult;
16};
17
18namespace System { namespace IO {
23class ASPOSECPP_SHARED_CLASS Stream : public System::IDisposable
24{
25 RTTI_INFO(System::IO::Stream, ::System::BaseTypesInfo<System::IDisposable>)
26
27public:
30
31 // There no need to define an empty virtual dtor, virtual dtor for inheritance already defined in the Object class
32 // virtual ~Stream() {}
35 virtual ASPOSECPP_SHARED_API int ReadByte();
38 virtual ASPOSECPP_SHARED_API void WriteByte(uint8_t value);
39
45 virtual ASPOSECPP_SHARED_API int32_t Read(const ArrayPtr<uint8_t>& buffer, int32_t offset, int32_t count) = 0;
50 virtual ASPOSECPP_SHARED_API void Write(const ArrayPtr<uint8_t>& buffer, int32_t offset, int32_t count) = 0;
51
57 virtual ASPOSECPP_SHARED_API int32_t Read(const System::Details::ArrayView<uint8_t>& buffer, int32_t offset, int32_t count);
62 virtual ASPOSECPP_SHARED_API void Write(const System::Details::ArrayView<uint8_t>& buffer, int32_t offset, int32_t count);
69 template<std::size_t N>
70 int32_t Read(const System::Details::StackArray<uint8_t, N>& buffer, int32_t offset, int32_t count)
71 {
72 return Read(static_cast<System::Details::ArrayView<uint8_t>>(buffer), offset, count);
73 }
79 template<std::size_t N>
80 void Write(const System::Details::StackArray<uint8_t, N>& buffer, int32_t offset, int32_t count)
81 {
82 Write(static_cast<System::Details::ArrayView<uint8_t>>(buffer), offset, count);
83 }
84
89 virtual ASPOSECPP_SHARED_API int64_t Seek(int64_t offset, SeekOrigin origin) = 0;
92 virtual ASPOSECPP_SHARED_API void SetLength(int64_t value) = 0;
94 virtual ASPOSECPP_SHARED_API void Flush() = 0;
96 virtual void Close() {}
98 ASPOSECPP_SHARED_API void Dispose() override;
99
119 virtual ASPOSECPP_SHARED_API int EndRead(System::SharedPtr<System::IAsyncResult> asyncResult);
122 virtual ASPOSECPP_SHARED_API void EndWrite(System::SharedPtr<System::IAsyncResult> asyncResult);
123
126 ASPOSECPP_SHARED_API void CopyTo(const SharedPtr<Stream>& destination);
127
131 ASPOSECPP_SHARED_API void CopyTo(const SharedPtr<Stream>& destination, int32_t buffer_size);
132
135 virtual ASPOSECPP_SHARED_API void set_Position(int64_t value) = 0;
138 virtual ASPOSECPP_SHARED_API int64_t get_Position() const = 0;
141 virtual ASPOSECPP_SHARED_API int64_t get_Length() const = 0;
144 virtual ASPOSECPP_SHARED_API bool get_CanRead() const = 0;
147 virtual ASPOSECPP_SHARED_API bool get_CanSeek() const = 0;
150 virtual ASPOSECPP_SHARED_API bool get_CanWrite() const = 0;
151
154 virtual ASPOSECPP_SHARED_API bool get_CanTimeout() const;
156 virtual ASPOSECPP_SHARED_API void set_ReadTimeout(int timeout);
157
160 virtual ASPOSECPP_SHARED_API int get_ReadTimeout() const;
162 virtual ASPOSECPP_SHARED_API void set_WriteTimeout(int timeout);
163
165 virtual ASPOSECPP_SHARED_API int get_WriteTimeout() const;
166
168 static const System::SharedPtr<Stream> ASPOSECPP_SHARED_API Null;
169
170protected:
173 virtual ASPOSECPP_SHARED_API void Dispose(bool disposing);
174};
175
176}} // System::IO
177
178#endif // _aspose_system_io_stream_h_
Defines method that releases resources owned by the current object. Objects of this class should only...
Definition: idisposable.h:30
A base class for a variety of stream implementations. Objects of this class should only be allocated ...
Definition: stream.h:24
virtual void EndWrite(System::SharedPtr< System::IAsyncResult > asyncResult)
Ends an asynchronous write operation. Waits until the specified asynchronous write operation complete...
virtual int64_t get_Length() const =0
Returns the length of the stream in bytes.
static const System::SharedPtr< Stream > Null
A stream with no underlying storage.
Definition: stream.h:168
virtual int32_t Read(const ArrayPtr< uint8_t > &buffer, int32_t offset, int32_t count)=0
Reads the specified number of bytes from the stream and writes them to the specified byte array.
virtual void set_WriteTimeout(int timeout)
Sets a value, in milliseconds, that determines how long the stream will attempt to read before timing...
void CopyTo(const SharedPtr< Stream > &destination, int32_t buffer_size)
Copies bytes to the specified stream, using the specified buffer size.
virtual System::SharedPtr< System::IAsyncResult > BeginWrite(System::ArrayPtr< uint8_t > buffer, int offset, int count, System::AsyncCallback callback, System::SharedPtr< System::Object > state)
Initiates an asynchronous write operation.
virtual int EndRead(System::SharedPtr< System::IAsyncResult > asyncResult)
Waits until the specified asynchronous read operation completes.
virtual void Write(const ArrayPtr< uint8_t > &buffer, int32_t offset, int32_t count)=0
Writes the specified subrange of bytes from the specified byte array to the stream.
virtual bool get_CanTimeout() const
Gets a value that determines whether the current stream can time out.
virtual int64_t get_Position() const =0
Returns the current position of the stream.
void Dispose() override
Releases all resources used by the current object and closes the stream.
SharedPtr< Stream > Ptr
An alias for a shared pointer to this class.
Definition: stream.h:29
virtual bool get_CanWrite() const =0
Determines if the stream is writable.
virtual int get_WriteTimeout() const
Gets a value, in milliseconds, that determines how long the stream will attempt to write before timin...
void Write(const System::Details::StackArray< uint8_t, N > &buffer, int32_t offset, int32_t count)
Writes the specified subrange of bytes from the specified byte array to the stream.
Definition: stream.h:80
virtual void Dispose(bool disposing)
Releases all resources used by the current object and closes the stream.
virtual bool get_CanSeek() const =0
Determines if the stream supports seeking.
virtual void Flush()=0
Clears this stream's buffers and writes all buffered data to the underlying storage.
virtual void WriteByte(uint8_t value)
Writes the specified unsigned 8-bit integer value to the stream.
int32_t Read(const System::Details::StackArray< uint8_t, N > &buffer, int32_t offset, int32_t count)
Reads the specified number of bytes from the stream and writes them to the specified byte array.
Definition: stream.h:70
virtual void SetLength(int64_t value)=0
Sets the length of the stream represented by the current object.
virtual System::SharedPtr< System::IAsyncResult > BeginRead(System::ArrayPtr< uint8_t > buffer, int offset, int count, System::AsyncCallback callback, System::SharedPtr< System::Object > state)
Initiates an asynchronous read operation.
virtual bool get_CanRead() const =0
Determines if the stream is readable.
virtual int get_ReadTimeout() const
Gets a value, in milliseconds, that determines how long the stream will attempt to read before timing...
virtual void set_ReadTimeout(int timeout)
Sets a value that determines whether the current stream can time out.
virtual void Write(const System::Details::ArrayView< uint8_t > &buffer, int32_t offset, int32_t count)
Writes the specified subrange of bytes from the specified byte array to the stream.
virtual void Close()
Closes the stream.
Definition: stream.h:96
virtual int32_t Read(const System::Details::ArrayView< uint8_t > &buffer, int32_t offset, int32_t count)
Reads the specified number of bytes from the stream and writes them to the specified byte array.
virtual int ReadByte()
Reads a single byte from the stream and returns a 32-bit integer value equivalent to the value of the...
virtual void set_Position(int64_t value)=0
Sets the stream's position.
void CopyTo(const SharedPtr< Stream > &destination)
Copies bytes to the specified stream.
virtual int64_t Seek(int64_t offset, SeekOrigin origin)=0
Sets the position of the stream represented by the current object.
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
System::MulticastDelegate< void(SharedPtr< IAsyncResult >)> AsyncCallback
A delegate type that represents a method to be called when asynchronous operation completes.
Definition: async_callback.h:13