[fpc-devel] Method for write string into TStream

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


Way 1: Introduce new method(s), leave Write/ReadAnsiString as is.
  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: 

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

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


More information about the fpc-devel mailing list