CodePorting.Translator Cs2Cpp
CodePorting.Translator.Cs2Cpp.Framework
buffered_stream.h
1
2#pragma once
3
4#include "system/io/stream.h"
5#include "system/reflection.h"
6
7namespace System { namespace IO {
12 class ASPOSECPP_SHARED_CLASS BufferedStream : public Stream
13 {
14 RTTI_INFO(System::IO::BufferedStream, ::System::BaseTypesInfo<System::IO::Stream>);
15 public:
18 ASPOSECPP_SHARED_API BufferedStream(const SharedPtr<Stream>& stream);
22 ASPOSECPP_SHARED_API BufferedStream(const SharedPtr<Stream>& stream, int bufferSize);
24 virtual ASPOSECPP_SHARED_API ~BufferedStream();
25
26 public: //Stream impl.
29 virtual ASPOSECPP_SHARED_API int ReadByte() override;
32 virtual ASPOSECPP_SHARED_API void WriteByte(uint8_t value) override;
38 virtual ASPOSECPP_SHARED_API int32_t Read(const ArrayPtr<uint8_t>& buffer, int32_t offset, int32_t count) override;
44 virtual ASPOSECPP_SHARED_API int32_t Read(const System::Details::ArrayView<uint8_t>& buffer, int32_t offset, int32_t count) override;
49 virtual ASPOSECPP_SHARED_API void Write(const ArrayPtr<uint8_t>& buffer, int32_t offset, int32_t count) override;
54 virtual ASPOSECPP_SHARED_API void Write(const System::Details::ArrayView<uint8_t>& buffer, int32_t offset, int32_t count) override;
59 virtual ASPOSECPP_SHARED_API int64_t Seek(int64_t offset, SeekOrigin origin) override;
62 virtual ASPOSECPP_SHARED_API void SetLength(int64_t value) override;
64 virtual ASPOSECPP_SHARED_API void Flush() override;
65
66 public: //Stream impl.
69 virtual ASPOSECPP_SHARED_API void set_Position(int64_t value) override;
71 virtual ASPOSECPP_SHARED_API int64_t get_Position() const override;
73 virtual ASPOSECPP_SHARED_API int64_t get_Length() const override;
76 virtual ASPOSECPP_SHARED_API bool get_CanRead() const override;
79 virtual ASPOSECPP_SHARED_API bool get_CanSeek() const override;
82 virtual ASPOSECPP_SHARED_API bool get_CanWrite() const override;
83
84 private:
85
86 template<template<typename T> class ArrT> int32_t _Read(const ArrT<uint8_t> & buffer, int32_t offset, int32_t count);
87 template<template<typename T> class ArrT> void _Write(const ArrT<uint8_t>& buffer, int32_t offset, int32_t count);
88
89 private:
91 SharedPtr<Stream> m_stream;
93 ArrayPtr<uint8_t> m_buffer;
95 int m_buffer_pos;
97 int m_buffer_read_ahead;
99 bool m_buffer_reading;
100 };
101
102}}
Adds a buffering layer on top of another stream. Objects of this class should only be allocated using...
Definition: buffered_stream.h:13
virtual bool get_CanRead() const override
Determines if the stream is readable.
virtual 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 underlying stream.
BufferedStream(const SharedPtr< Stream > &stream)
Constructs an BufferedStream object that wraps the specified stream and uses a 4096 bytes long buffer...
virtual ~BufferedStream()
Destructor.
virtual void set_Position(int64_t value) override
Flushes the buffer to the underlying stream and then sets the stream's position.
virtual void Flush() override
Writes the content of the buffer to the underlying stream.
virtual 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 underlying stream and writes them to the specified byte ...
BufferedStream(const SharedPtr< Stream > &stream, int bufferSize)
Constructs an BufferedStream object that wraps the specified stream and uses a buffer of the specifie...
virtual void WriteByte(uint8_t value) override
Writes the specified unsigned 8-bit integer value to the underlying stream.
virtual bool get_CanWrite() const override
Determines if the stream is writable.
virtual void SetLength(int64_t value) override
Sets the length of the stream represented by the current object.
virtual int64_t get_Position() const override
Returns the current position of the stream.
virtual int ReadByte() override
Reads a single byte from the underlying stream and returns a 32-bit integer value equivalent to the v...
virtual int64_t get_Length() const override
Returns the length of the stream.
virtual bool get_CanSeek() const override
Determines if the stream supports seeking.
virtual 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 underlying stream.
virtual int64_t Seek(int64_t offset, SeekOrigin origin) override
Sets the position of the stream represented by the current object.
virtual int32_t Read(const ArrayPtr< uint8_t > &buffer, int32_t offset, int32_t count) override
Reads the specified number of bytes from the underlying stream and writes them to the specified byte ...
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