unit uRODLLineStream; {----------------------------------------------------------------------------} { RemObjects SDK Library - CodeGen2 } { } { compiler: Delphi 5 and up, Kylix 2 and up } { platform: Win32, Linux } { } { (c)opyright RemObjects Software. all rights reserved. } { } { Using this code requires a valid license of the RemObjects SDK } { which can be obtained at http://www.remobjects.com. } {----------------------------------------------------------------------------} {$IFDEF LINUX} {$I ../RemObjects.inc} {$ELSE} {$I ..\RemObjects.inc} {$ENDIF LINUX} interface uses Classes; type TLineStream = class(TStringStream) private function GetEof: Boolean; public function ReadLine: string; procedure WriteLine(const line: string); procedure Clear; property Eof: Boolean read GetEof; end; implementation { TLineStream } procedure TLineStream.Clear; begin Size := 0; end; function TLineStream.GetEof: Boolean; begin Result := Position = Size; end; function TLineStream.ReadLine: string; var I: Integer; begin I := Position; while (I < Size-1) and (DataString[I+1] <> #13) and (DataString[I+2] <> #10) do Inc(I); if I = Size-1 then begin Result := ReadString(I-Position+1); end else begin Result := ReadString(I-Position); // Do not eat the carriage return Position := Position + 2; end; end; procedure TLineStream.WriteLine(const line: string); begin WriteString(line + #13#10); end; end.