[fpc-devel] Method for write string into TStream
pascaldragon at googlemail.com
Mon Jul 21 11:30:19 CEST 2014
Am 21.07.2014 10:29 schrieb "LacaK" <lacak at zoznam.sk>:
> When I work with f.e. TFileStream I need often write string into stream.
> Now I use:
> Stream1.WriteBuffer(s, length(s));
> I think, that for convenience it will be useful having something like:
> procedure TStream.WriteString(const s: string);
> WriteBuffer(s, length(s)*sizeof(char);
> 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
> Do you think, that something similar can be added also in FPC ?
There is already a WriteAnsiString (
) with the difference that it also writes out the length. Adding an
additional overload (especially with a name like WriteString) would IMHO be
confusing because of this.
Nothing stops you though from writing a class helper that adds a
WriteString method to TStream.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the fpc-devel