[fpc-devel] Method for write string into TStreamt

Dmitry Boyarintsev skalogryz.lists at gmail.com
Tue Jul 22 14:37:30 CEST 2014

On Tue, Jul 22, 2014 at 6:46 AM, thaddy at thaddy.com <thaddy at thaddy.com>

> A case for ternary computing is not really a bad idea ;)
> On 21-7-2014 21:42, Hans-Peter Diettrich wrote:
>> Dmitry Boyarintsev schrieb:
>>  How about introducing a default parameter?
>>> The parameter keeps the method backward compatible, allowing write a
>>> string without the prefix.
>>> public procedure TStream.WriteAnsiString(
>>>   const S: string;
>>>   withLength: Boolean = true;
>> How should a string without a length be read back?
>> DoDi
>> I didn't see DoDi's email anywhere in the thread, though it seems like
there're two threads anyway:
"Re: [fpc-devel] Method for write string into TStream" and "[fpc-devel]
Method for write string into TStream"

Anyways, answering DoDi's question.
It definitely won't be able to read a string without a size, but it doesn't
mean that the string size should immediately precede the string content.
So maybe a modification like this could help

procedure TStream.ReadAnsiString(knownsize: Integer=-1)
   if knownsize<0 then
     TheSize := ...readsize
     TheSize := knownsize

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20140722/9d75f96e/attachment.html>

More information about the fpc-devel mailing list