|
@@ -99,6 +99,19 @@ interface
|
|
{ TRelObjInput }
|
|
{ TRelObjInput }
|
|
|
|
|
|
TRelObjInput = class(TObjInput)
|
|
TRelObjInput = class(TObjInput)
|
|
|
|
+ private const
|
|
|
|
+ MaxBufSize=512;
|
|
|
|
+ private
|
|
|
|
+ FBuf: array [0..MaxBufSize-1] of Char;
|
|
|
|
+ FBufSize: Integer;
|
|
|
|
+ FBufPos: Integer;
|
|
|
|
+
|
|
|
|
+ function FillBuf: boolean;
|
|
|
|
+ function AtEndOfBuf: boolean;
|
|
|
|
+ function AtEoF: boolean;
|
|
|
|
+ function ReadChar(out c: char): boolean;
|
|
|
|
+ function PeekChar(out c: char): boolean;
|
|
|
|
+ function ReadLine(out s: string): boolean;
|
|
public
|
|
public
|
|
constructor create;override;
|
|
constructor create;override;
|
|
function ReadObjData(AReader:TObjectreader;out Data:TObjData):boolean;override;
|
|
function ReadObjData(AReader:TObjectreader;out Data:TObjData):boolean;override;
|
|
@@ -537,138 +550,138 @@ implementation
|
|
TRelObjInput
|
|
TRelObjInput
|
|
*****************************************************************************}
|
|
*****************************************************************************}
|
|
|
|
|
|
- constructor TRelObjInput.create;
|
|
|
|
|
|
+ function TRelObjInput.FillBuf: boolean;
|
|
begin
|
|
begin
|
|
- inherited create;
|
|
|
|
- cobjdata:=TRelObjData;
|
|
|
|
|
|
+ FBufPos:=0;
|
|
|
|
+ FBufSize:=min(FReader.size-FReader.Pos,MaxBufSize);
|
|
|
|
+ if FBufSize>0 then
|
|
|
|
+ result:=FReader.read(FBuf,FBufSize)
|
|
|
|
+ else
|
|
|
|
+ result:=true;
|
|
end;
|
|
end;
|
|
|
|
|
|
- function TRelObjInput.ReadObjData(AReader: TObjectreader; out Data: TObjData): boolean;
|
|
|
|
|
|
+ function TRelObjInput.AtEndOfBuf: boolean;
|
|
begin
|
|
begin
|
|
- result:=false;
|
|
|
|
|
|
+ result:=FBufPos=FBufSize;
|
|
end;
|
|
end;
|
|
|
|
|
|
- class function TRelObjInput.CanReadObjData(AReader: TObjectreader): boolean;
|
|
|
|
- const
|
|
|
|
- MaxBufSize=512;
|
|
|
|
- var
|
|
|
|
- Buf: array [0..MaxBufSize-1] of Char;
|
|
|
|
- BufSize: Integer = 0;
|
|
|
|
- BufPos: Integer = 0;
|
|
|
|
|
|
+ function TRelObjInput.AtEoF: boolean;
|
|
|
|
+ begin
|
|
|
|
+ result:=AtEndOfBuf and (FReader.Pos=FReader.size);
|
|
|
|
+ end;
|
|
|
|
|
|
- function FillBuf: boolean;
|
|
|
|
|
|
+ function TRelObjInput.ReadChar(out c: char): boolean;
|
|
|
|
+ begin
|
|
|
|
+ c:=#0;
|
|
|
|
+ if AtEndOfBuf then
|
|
begin
|
|
begin
|
|
- BufPos:=0;
|
|
|
|
- BufSize:=min(AReader.size-AReader.Pos,MaxBufSize);
|
|
|
|
- if BufSize>0 then
|
|
|
|
- result:=AReader.read(Buf,BufSize)
|
|
|
|
- else
|
|
|
|
- result:=true;
|
|
|
|
|
|
+ result:=FillBuf;
|
|
|
|
+ if not result then
|
|
|
|
+ exit;
|
|
end;
|
|
end;
|
|
-
|
|
|
|
- function AtEndOfBuf: boolean;
|
|
|
|
|
|
+ if not AtEndOfBuf then
|
|
begin
|
|
begin
|
|
- result:=BufPos=BufSize;
|
|
|
|
- end;
|
|
|
|
|
|
+ c:=FBuf[FBufPos];
|
|
|
|
+ Inc(FBufPos);
|
|
|
|
+ result:=true;
|
|
|
|
+ end
|
|
|
|
+ else
|
|
|
|
+ result:=false;
|
|
|
|
+ end;
|
|
|
|
|
|
- function AtEoF: boolean;
|
|
|
|
|
|
+ function TRelObjInput.PeekChar(out c: char): boolean;
|
|
|
|
+ begin
|
|
|
|
+ c:=#0;
|
|
|
|
+ if AtEndOfBuf then
|
|
begin
|
|
begin
|
|
- result:=AtEndOfBuf and (AReader.Pos=AReader.size);
|
|
|
|
|
|
+ result:=FillBuf;
|
|
|
|
+ if not result then
|
|
|
|
+ exit;
|
|
end;
|
|
end;
|
|
-
|
|
|
|
- function ReadChar(out c: char): boolean;
|
|
|
|
|
|
+ if not AtEndOfBuf then
|
|
begin
|
|
begin
|
|
- c:=#0;
|
|
|
|
- if AtEndOfBuf then
|
|
|
|
- begin
|
|
|
|
- result:=FillBuf;
|
|
|
|
- if not result then
|
|
|
|
- exit;
|
|
|
|
- end;
|
|
|
|
- if not AtEndOfBuf then
|
|
|
|
- begin
|
|
|
|
- c:=Buf[BufPos];
|
|
|
|
- Inc(BufPos);
|
|
|
|
- result:=true;
|
|
|
|
- end
|
|
|
|
- else
|
|
|
|
- result:=false;
|
|
|
|
- end;
|
|
|
|
|
|
+ c:=FBuf[FBufPos];
|
|
|
|
+ result:=true;
|
|
|
|
+ end
|
|
|
|
+ else
|
|
|
|
+ result:=false;
|
|
|
|
+ end;
|
|
|
|
|
|
- function PeekChar(out c: char): boolean;
|
|
|
|
|
|
+ function TRelObjInput.ReadLine(out s: string): boolean;
|
|
|
|
+ var
|
|
|
|
+ c: Char;
|
|
|
|
+ begin
|
|
|
|
+ s:='';
|
|
|
|
+ if AtEoF then
|
|
begin
|
|
begin
|
|
- c:=#0;
|
|
|
|
- if AtEndOfBuf then
|
|
|
|
- begin
|
|
|
|
- result:=FillBuf;
|
|
|
|
- if not result then
|
|
|
|
- exit;
|
|
|
|
- end;
|
|
|
|
- if not AtEndOfBuf then
|
|
|
|
- begin
|
|
|
|
- c:=Buf[BufPos];
|
|
|
|
- result:=true;
|
|
|
|
- end
|
|
|
|
- else
|
|
|
|
- result:=false;
|
|
|
|
|
|
+ result:=false;
|
|
|
|
+ exit;
|
|
end;
|
|
end;
|
|
-
|
|
|
|
- function ReadLine(out s: string): boolean;
|
|
|
|
- var
|
|
|
|
- c: Char;
|
|
|
|
|
|
+ repeat
|
|
|
|
+ if not AtEoF then
|
|
|
|
+ begin
|
|
|
|
+ if not ReadChar(c) then
|
|
|
|
+ begin
|
|
|
|
+ result:=false;
|
|
|
|
+ exit;
|
|
|
|
+ end;
|
|
|
|
+ if not (c in [#13,#10]) then
|
|
|
|
+ s:=s+c;
|
|
|
|
+ end;
|
|
|
|
+ until (c in [#13,#10]) or AtEoF;
|
|
|
|
+ if (c=#13) and not AtEoF then
|
|
begin
|
|
begin
|
|
- s:='';
|
|
|
|
- if AtEoF then
|
|
|
|
|
|
+ if not PeekChar(c) then
|
|
begin
|
|
begin
|
|
result:=false;
|
|
result:=false;
|
|
exit;
|
|
exit;
|
|
end;
|
|
end;
|
|
- repeat
|
|
|
|
- if not AtEoF then
|
|
|
|
- begin
|
|
|
|
- if not ReadChar(c) then
|
|
|
|
- begin
|
|
|
|
- result:=false;
|
|
|
|
- exit;
|
|
|
|
- end;
|
|
|
|
- if not (c in [#13,#10]) then
|
|
|
|
- s:=s+c;
|
|
|
|
- end;
|
|
|
|
- until (c in [#13,#10]) or AtEoF;
|
|
|
|
- if (c=#13) and not AtEoF then
|
|
|
|
|
|
+ if c=#10 then
|
|
begin
|
|
begin
|
|
- if not PeekChar(c) then
|
|
|
|
|
|
+ if not ReadChar(c) then
|
|
begin
|
|
begin
|
|
result:=false;
|
|
result:=false;
|
|
exit;
|
|
exit;
|
|
end;
|
|
end;
|
|
- if c=#10 then
|
|
|
|
- begin
|
|
|
|
- if not ReadChar(c) then
|
|
|
|
- begin
|
|
|
|
- result:=false;
|
|
|
|
- exit;
|
|
|
|
- end;
|
|
|
|
- end;
|
|
|
|
end;
|
|
end;
|
|
- result:=true;
|
|
|
|
end;
|
|
end;
|
|
|
|
+ result:=true;
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+ constructor TRelObjInput.create;
|
|
|
|
+ begin
|
|
|
|
+ inherited create;
|
|
|
|
+ cobjdata:=TRelObjData;
|
|
|
|
+ FBufSize:=0;
|
|
|
|
+ FBufPos:=0;
|
|
|
|
+ end;
|
|
|
|
|
|
|
|
+ function TRelObjInput.ReadObjData(AReader: TObjectreader; out Data: TObjData): boolean;
|
|
|
|
+ begin
|
|
|
|
+ result:=false;
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+ class function TRelObjInput.CanReadObjData(AReader: TObjectreader): boolean;
|
|
var
|
|
var
|
|
s: string;
|
|
s: string;
|
|
|
|
+ instance: TRelObjInput;
|
|
begin
|
|
begin
|
|
result:=false;
|
|
result:=false;
|
|
- while not AtEoF do
|
|
|
|
- begin
|
|
|
|
- if not ReadLine(s) then
|
|
|
|
- exit;
|
|
|
|
- s:=Trim(s);
|
|
|
|
- if s<>'' then
|
|
|
|
- begin
|
|
|
|
- result:=s='XL2';
|
|
|
|
|
|
+ instance:=TRelObjInput.Create;
|
|
|
|
+ instance.FReader:=AReader;
|
|
|
|
+ with instance do
|
|
|
|
+ while not AtEoF do
|
|
|
|
+ begin
|
|
|
|
+ if not ReadLine(s) then
|
|
exit;
|
|
exit;
|
|
- end;
|
|
|
|
- end;
|
|
|
|
|
|
+ s:=Trim(s);
|
|
|
|
+ if s<>'' then
|
|
|
|
+ begin
|
|
|
|
+ result:=s='XL2';
|
|
|
|
+ break;
|
|
|
|
+ end;
|
|
|
|
+ end;
|
|
|
|
+ instance.Free;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|