[fpc-devel] Method for write string into TStream

thaddy at thaddy.com thaddy at thaddy.com
Tue Jul 22 12:58:07 CEST 2014

You can always use KOL for that ;)
But anyway: we implemented that at the cost of read-back speed and 
looking for zero termination, which is flawed anyway for object pascal 
strings, since it can contain zero's.
It can be done through RTTI with my usual complaints about that sort of 

A (abstract) stream can not know if the length is stored or 
not...without rtti.

If you accept polymorhism this is not a good idea. I may be wrong (again)

On 21-7-2014 10:27, LacaK wrote:
> Hi,
> When I work with f.e. TFileStream I need often write string into stream.
> Now I use:
>  Stream1.WriteBuffer(s[1], length(s));
> I think, that for convenience it will be useful having something like:
> procedure TStream.WriteString(const s: string);
>  begin
>    WriteBuffer(s[1], length(s)*sizeof(char);
>  end;
> In FPC we now have for user convenience also WriteByte, WriteWord, 
> WriteQWord (which all calls WriteBuffer)
> and Delphi has lot of overloaded WriteData (but none of them takes as 
> parameter string):
> http://docwiki.embarcadero.com/Libraries/XE3/en/System.Classes.TStream.WriteData 
> Do you think, that something similar can be added also in FPC ?
> Thanks
> -Laco.
> _______________________________________________
> fpc-devel maillist  -  fpc-devel at lists.freepascal.org
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

More information about the fpc-devel mailing list