[fpc-devel] Method for write string into TStream

LacaK lacak at zoznam.sk
Tue Jul 22 10:16:38 CEST 2014


Recap:

Way 1: Introduce new method(s), leave Write/ReadAnsiString as is.
1.1
  procedure WriteRawString(const s: string);
  function ReadRawString(Len: integer)

1.2 (ready for future when string will be UnicodeString)
  procedure WriteString(const s: string);
  function ReadString(Len: integer)

1.3 (create superior of Write/ReadAnsiString)
  type TStringLengthPrefix = (lenNone, lenWord, lenDWord);
  procedure WriteString(const s: string; WriteLength: 
TStringLengthPrefix = lenNone);
  function ReadString(ReadLength: TStringLengthPrefix=lenNone; Len: 
integer=0);

Way 2: Extend existing Write/ReadAnsiString (keeping backward compatibility)
2.1
  type TStringLengthPrefix = (lenNone, lenWord, lenDWord);
  procedure WriteAnsiString(const s: string; WriteLength: 
TStringLengthPrefix = lenDWord);
  function ReadAnsiString(ReadLength: TStringLengthPrefix=lenDWord; Len: 
integer=0);
(but IMO in future, when string becomes unicodestring, then "Ansi" in 
name will sound strange if parameter does not change from "string" to 
"ansistring")

Way 3: Do nothing ;-)
If nobody else consider it as useful. ;-)

-Laco.




More information about the fpc-devel mailing list