1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
| unit classParser;
interface
uses classes,SysUtils,Dialogs,
UnitException,unitTextFileReader,UnitChaine;
type TLigne = record
code : string[18] ;
timespan : Cardinal ;
message : shortstring ;
end;
type TParser = class
private
_file : TTextFileReader ;
_currentline : Cardinal ;
_path : string ;
procedure traiterligne(pligne : string);
public
constructor Create(path : string);
destructor Destroy;override;
procedure MAJ ;
procedure lire ;
protected
end;
var bPause : boolean ;
implementation
{ lecteur }
constructor TParser.Create(path : string);
begin
_currentline := 0 ;
if FileExists(path) then begin
_path := path;
_file := TTextFileReader.Create(path);
_file.BuildLinesIndexes ;
end
else
raise EFichierIntrouvable.createRes(@sFichierIntrouvable) ;
end;
destructor TParser.Destroy;
begin
_file.Free ;
end;
procedure TParser.lire;
var ligne : String ;
begin
while (ligne<>'') do
begin
ligne := _file.ReadLine(_currentline);
traiterligne(ligne);
inc(_currentline);
end;
showmessage(inttostr(_currentline));
end;
procedure TParser.traiterligne(pligne : string);
var indexDebutMessage : Byte ;
code : string[18] ;
ligne : TLigne ;
begin
ligne.code := copy(pligne,3,18);
ligne.timespan :=0;//strtointdef(copy(Mot(pligne,'",',3),0,10) ,0);
indexDebutMessage := Pos(']',pligne)+1;
ligne.message := copy(pligne,indexDebutMessage,length(pligne)-indexDebutMessage+1);
end;
end. |
Partager