#1 2018-01-14 06:30:57

mariomoretti
Member
From: italy
Registered: 2012-01-29
Posts: 88

tRawByteStringStream

Hi AB,

sorry but i don't remember how to open a ticket.

The write methof of this object doesn't work well if one want to write before the end of the buffer, changing the stream position to do it.

function TRawByteStringStream.Write(const Buffer; Count: Integer): Longint;
begin
  if Count<=0 then
    Result := 0 else begin
    Result := Count;
    SetLength(fDataString,(fPosition+Result));
    MoveFast(Buffer,PByteArray(fDataString)[fPosition],Result);
    inc(FPosition,Result);
  end;
end;

I have made this change and now seems to be right.

// before 
SeltLength(fDataString,(fPosition + Result))
//after
 if fPosition+Result > Length(fDataString) then SetLength(fDataString,(fPosition+Result));

Offline

#2 2018-01-27 18:36:20

mariomoretti
Member
From: italy
Registered: 2012-01-29
Posts: 88

Re: tRawByteStringStream

No reply , so i opened a ticket...

Result : rejiected because it could break existing code.
I obviously agree wit this concept.
I don't agree with the fact that as is 'well' documented this stream is only for append. There isn't any line in the SAD saying that tRawByteStringStream may not be used as any other one derived from tstream class.

Offline

#3 2018-01-28 11:08:26

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,661
Website

Re: tRawByteStringStream

This class mimics TStringStream in this respect:

Delphi doc wrote:

Use Write to replace the end of the string from the current position on with the first Count bytes of Buffer. Write will change the Size property to reflect the new length of the DataString.

But the confusion was indeed understandable.
I updated the class description.

Offline

Board footer

Powered by FluxBB