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;
46
59 virtual ASPOSECPP_SHARED_API RTaskPtr<int32_t> ReadAsync(const ArrayPtr<uint8_t>& buffer, int32_t offset, int32_t count,
60 const Threading::CancellationToken& cancellationToken);
61
73 ASPOSECPP_SHARED_API RTaskPtr<int32_t> ReadAsync(const ArrayPtr<uint8_t>& buffer, int32_t offset, int32_t count);
74
79 virtual ASPOSECPP_SHARED_API void Write(const ArrayPtr<uint8_t>& buffer, int32_t offset, int32_t count) = 0;
80
89 virtual ASPOSECPP_SHARED_API TaskPtr WriteAsync(const ArrayPtr<uint8_t>& buffer, int32_t offset, int32_t count,
90 const Threading::CancellationToken& cancellationToken);
91
99 ASPOSECPP_SHARED_API TaskPtr WriteAsync(const ArrayPtr<uint8_t>& buffer, int32_t offset, int32_t count);
100
106 virtual ASPOSECPP_SHARED_API int32_t Read(const System::Details::ArrayView<uint8_t>& buffer, int32_t offset, int32_t count);
111 virtual ASPOSECPP_SHARED_API void Write(const System::Details::ArrayView<uint8_t>& buffer, int32_t offset, int32_t count);
118 template<std::size_t N>
119 int32_t Read(const System::Details::StackArray<uint8_t, N>& buffer, int32_t offset, int32_t count)
120 {
121 return Read(static_cast<System::Details::ArrayView<uint8_t>>(buffer), offset, count);
122 }
128 template<std::size_t N>
129 void Write(const System::Details::StackArray<uint8_t, N>& buffer, int32_t offset, int32_t count)
130 {
131 Write(static_cast<System::Details::ArrayView<uint8_t>>(buffer), offset, count);
132 }
133
138 virtual ASPOSECPP_SHARED_API int64_t Seek(int64_t offset, SeekOrigin origin) = 0;
141 virtual ASPOSECPP_SHARED_API void SetLength(int64_t value) = 0;
143 virtual ASPOSECPP_SHARED_API void Flush() = 0;
148 virtual ASPOSECPP_SHARED_API TaskPtr FlushAsync(const Threading::CancellationToken& cancellationToken);
152 ASPOSECPP_SHARED_API TaskPtr FlushAsync();
154 virtual void Close() {}
156 ASPOSECPP_SHARED_API void Dispose() override;
157
177 virtual ASPOSECPP_SHARED_API int EndRead(System::SharedPtr<System::IAsyncResult> asyncResult);
180 virtual ASPOSECPP_SHARED_API void EndWrite(System::SharedPtr<System::IAsyncResult> asyncResult);
181
184 ASPOSECPP_SHARED_API void CopyTo(const SharedPtr<Stream>& destination);
185
189 ASPOSECPP_SHARED_API void CopyTo(const SharedPtr<Stream>& destination, int32_t buffer_size);
190
193 virtual ASPOSECPP_SHARED_API void set_Position(int64_t value) = 0;
196 virtual ASPOSECPP_SHARED_API int64_t get_Position() const = 0;
199 virtual ASPOSECPP_SHARED_API int64_t get_Length() const = 0;
202 virtual ASPOSECPP_SHARED_API bool get_CanRead() const = 0;
205 virtual ASPOSECPP_SHARED_API bool get_CanSeek() const = 0;
208 virtual ASPOSECPP_SHARED_API bool get_CanWrite() const = 0;
209
212 virtual ASPOSECPP_SHARED_API bool get_CanTimeout() const;
214 virtual ASPOSECPP_SHARED_API void set_ReadTimeout(int timeout);
215
218 virtual ASPOSECPP_SHARED_API int get_ReadTimeout() const;
220 virtual ASPOSECPP_SHARED_API void set_WriteTimeout(int timeout);
221
223 virtual ASPOSECPP_SHARED_API int get_WriteTimeout() const;
224
226 static const System::SharedPtr<Stream> ASPOSECPP_SHARED_API Null;
227
228protected:
231 virtual ASPOSECPP_SHARED_API void Dispose(bool disposing);
232};
233
234}} // System::IO
235
236#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:226
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.
TaskPtr WriteAsync(const ArrayPtr< uint8_t > &buffer, int32_t offset, int32_t count)
Asynchronously writes a sequence of bytes to the current stream, advances the current position within...
RTaskPtr< int32_t > ReadAsync(const ArrayPtr< uint8_t > &buffer, int32_t offset, int32_t count)
Asynchronously reads a sequence of bytes from the current stream, advances the position within the st...
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.
TaskPtr FlushAsync()
Asynchronously clears all buffers for this stream, causes any buffered data to be written to the unde...
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 TaskPtr FlushAsync(const Threading::CancellationToken &cancellationToken)
Asynchronously clears all buffers for this stream, causes any buffered data to be written to the unde...
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:129
virtual void Dispose(bool disposing)
Releases all resources used by the current object and closes the stream.
virtual RTaskPtr< int32_t > ReadAsync(const ArrayPtr< uint8_t > &buffer, int32_t offset, int32_t count, const Threading::CancellationToken &cancellationToken)
Asynchronously reads a sequence of bytes from the current stream, advances the position within the st...
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:119
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 TaskPtr WriteAsync(const ArrayPtr< uint8_t > &buffer, int32_t offset, int32_t count, const Threading::CancellationToken &cancellationToken)
Asynchronously writes a sequence of bytes to the current stream, advances the current position within...
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:154
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
Propagates notification that operations should be canceled. This class provides a mechanism for coope...
Definition: cancellation_token.h:43
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