unit dpermareader;

interface

uses
  dstrings;

type
TPermaReader = object
private
  FStream: PStream;
  FBufSize: LongInt;
  FStackBuffer: array[0..1023] of Byte;
  FInitialBuffer: array of Byte;
  FBeginning: PByte;
  FPermaBuffers: array of AnsiString;
public
  procedure Init(Stream: PStream; BufSize: LongInt); inline;
  procedure Done; inline;
  function GetPermaPointer(Size: LongInt): Pointer;
  // With StartPermaString you should save position of string
  // with FinishPermaString you use saved position and got resulting permastring
  function StartPermaString: LongInt;
  function FinishPermaString(Start: LongInt): TAnsiBuf;

  function MatchAndSkip(const S: AnsiString): Boolean;
  function SkipToChar(C: AnsiChar; MaxLen: LongInt = -1): Boolean;
  function SkipToChar(C: AnsiChar; var S: AnsiString; MaxLen: LongInt = -1): Boolean;
end;

implementation

end.
