summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 8b49757)
raw | patch | inline | side by side (parent: 8b49757)
author | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Sat, 26 Aug 2017 00:54:36 +0000 (03:54 +0300) | ||
committer | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Sat, 26 Aug 2017 05:12:37 +0000 (08:12 +0300) |
src/shared/xdynrec.pas | patch | blob | history | |
src/shared/xparser.pas | patch | blob | history |
diff --git a/src/shared/xdynrec.pas b/src/shared/xdynrec.pas
index f3400d87730d0594b176a233c5d5913558c5be21..0774c1356388d2f16354d0f36208a72c5b623f10 100644 (file)
--- a/src/shared/xdynrec.pas
+++ b/src/shared/xdynrec.pas
interface
uses
- xparser;
+ xparser, Classes;
// ////////////////////////////////////////////////////////////////////////// //
diff --git a/src/shared/xparser.pas b/src/shared/xparser.pas
index 503a9a0017a56be690c88195c420bb339e1b1666..a7b8a51c1bbec667d0f61cc89480186141c3e591 100644 (file)
--- a/src/shared/xparser.pas
+++ b/src/shared/xparser.pas
interface
+uses
+ Classes;
+
// ////////////////////////////////////////////////////////////////////////// //
type
mTokInt: Integer;
protected
- procedure warmup (); virtual; abstract; // called in constructor to warm up the system
+ procedure warmup (); virtual; // called in constructor to warm up the system
procedure loadNextChar (); virtual; abstract; // loads next char into mNextChar; #0 means 'eof'
public
type
TFileTextParser = class(TTextParser)
private
- mFile: File;
+ mFile: TStream;
protected
- procedure warmup (); override; // called in constructor to warm up the system
procedure loadNextChar (); override; // loads next char into mNextChar; #0 means 'eof'
public
mPos: Integer;
protected
- procedure warmup (); override; // called in constructor to warm up the system
procedure loadNextChar (); override; // loads next char into mNextChar; #0 means 'eof'
public
type
TFileTextWriter = class(TTextWriter)
private
- mFile: File;
+ mFile: TStream;
protected
procedure putBuf (constref buf; len: SizeUInt); override;
function TTextParser.isEOF (): Boolean; inline; begin result := (mCurChar = #0); end;
+procedure TTextParser.warmup ();
+begin
+ mNextChar := ' ';
+ loadNextChar();
+ mCurChar := mNextChar;
+ if (mNextChar <> #0) then loadNextChar();
+end;
+
+
function TTextParser.skipChar (): Boolean;
begin
if (mCurChar = #0) then begin result := false; exit; end;
// ////////////////////////////////////////////////////////////////////////// //
constructor TFileTextParser.Create (const fname: AnsiString; loadToken: Boolean=true);
begin
- AssignFile(mFile, fname);
- Reset(mFile, 1);
+ mFile := openDiskFileRO(fname);
inherited Create(loadToken);
end;
destructor TFileTextParser.Destroy ();
begin
- CloseFile(mFile);
+ mFile.Free();
inherited;
end;
-procedure TFileTextParser.warmup ();
-var
- rd: Integer;
-begin
- blockRead(mFile, mCurChar, 1, rd);
- if (rd = 0) then begin mCurChar := #0; exit; end;
- if (mCurChar = #0) then mCurChar := ' ';
- loadNextChar();
-end;
-
-
procedure TFileTextParser.loadNextChar ();
var
rd: Integer;
begin
- blockRead(mFile, mNextChar, 1, rd);
+ rd := mFile.Read(mNextChar, 1);
if (rd = 0) then begin mNextChar := #0; exit; end;
if (mNextChar = #0) then mNextChar := ' ';
end;
end;
-procedure TStrTextParser.warmup ();
-begin
- if (mPos > Length(mStr)) then
- begin
- mCurChar := #0;
- mNextChar := #0;
- exit;
- end;
- mCurChar := mStr[mPos]; Inc(mPos);
- if (mCurChar = #0) then mCurChar := ' ';
- loadNextChar();
-end;
-
-
procedure TStrTextParser.loadNextChar ();
begin
mNextChar := #0;
// ////////////////////////////////////////////////////////////////////////// //
constructor TFileTextWriter.Create (const fname: AnsiString);
begin
- AssignFile(mFile, fname);
- Rewrite(mFile, 1);
+ mFile := createDiskFile(fname);
inherited Create();
end;
destructor TFileTextWriter.Destroy ();
begin
- CloseFile(mFile);
+ mFile.Free();
+ inherited;
end;
procedure TFileTextWriter.putBuf (constref buf; len: SizeUInt);
var
- wr: SizeUInt;
pc: PChar;
begin
if (len > 0) then
begin
pc := @buf;
- BlockWrite(mFile, pc^, len, wr);
- if (wr <> len) then raise Exception.Create('write error');
+ mFile.WriteBuffer(pc^, len);
{
while (len > 0) do
begin