delphidelphi-xe3tstream

What are the underlying Read/Write methods for Streams in Delphi XE3


I have some derived Stream classes for older versions of RADStudio that just reimplement the Read,Write,Seek methods, and the Size and Position properties.

I'm looking to port these to XE3, but I see that there are now (for example) three overloads for Read - the original one, plus two that take TBytes as parameters.

Delphi

function Read(var Buffer; Count: Longint): Longint; overload; virtual;
function Read(Buffer: TBytes; Offset, Count: Longint): Longint; overload; virtual;
function Read(var Buffer: TBytes; Count: Longint): Longint; overload;

C++

virtual int __fastcall Read(void *Buffer, int Count)/* overload */;
virtual int __fastcall Read(System::DynamicArray<System::Byte> Buffer, int Offset, int Count)/* overload */;
int __fastcall Read(System::DynamicArray<System::Byte> &Buffer, int Count)/* overload */;

Do I need to implement all three, or just one? And if just one, which one...?

Normally I'd be able to find this from the VCL source, but I've just got the trial version (no source) at present.


Solution

  • You only need implement the method read and write with these signatures

    function Read(var Buffer; Count: Longint): Longint; overload; virtual;
    function Write(const Buffer; Count: Longint): Longint
    

    because the overloads versions which uses the TBytes (and System::DynamicArray<System::Byte>) as parameter internally calls to the above versions of Read and Write.