123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- {
- This file is part of the Free Component Library (FCL)
- Copyright (c) 2012 by the Free Pascal development team
- Plain text reader
-
- See the file COPYING.FPC, included in this distribution,
- for details about the copyright.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- **********************************************************************}
- unit IReaderTXT;
- {$mode objfpc}{$H+}
- interface
- uses
- Classes, fpIndexer;
- type
- { TIReaderTXT }
- TIReaderTXT = class(TCustomFileReader)
- private
- protected
- function AllowedToken(token: UTF8String): boolean; override;
- public
- procedure LoadFromStream(FileStream: TStream); override;
- end;
- implementation
- { TIReaderTXT }
- function TIReaderTXT.AllowedToken(token: UTF8String): boolean;
- begin
- Result := inherited AllowedToken(token) and (Length(token) > 1);
- end;
- procedure TIReaderTXT.LoadFromStream(FileStream: TStream);
- var
- token: UTF8String;
- p: TSearchWordData;
- begin
- inherited LoadFromStream(FileStream);
- token := GetToken;
- while token <> '' do
- begin
- if AllowedToken(token) then
- begin
- p.SearchWord := token;
- P.Position:=TokenStartPos;
- p.Context:=GetContext;
- Add(p);
- end;
- token := GetToken;
- end;
- end;
- initialization
- FileHandlers.RegisterFileReader('Text format', 'txt', TIReaderTXT);
- end.
|