mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-12 16:09:25 +02:00
+ Implement TSAXReader.Abort method, which can be used to end the parsing prematurely (Mantis #16703)
git-svn-id: trunk@15414 -
This commit is contained in:
parent
87555e084a
commit
73bafe0444
@ -177,6 +177,7 @@ type
|
|||||||
protected
|
protected
|
||||||
FCurColumnNumber, FCurLineNumber: Integer;
|
FCurColumnNumber, FCurLineNumber: Integer;
|
||||||
FCurPublicID, FCurSystemID: SAXString;
|
FCurPublicID, FCurSystemID: SAXString;
|
||||||
|
FStopFlag: Boolean;
|
||||||
|
|
||||||
function GetFeature(const Name: String): Boolean; virtual;
|
function GetFeature(const Name: String): Boolean; virtual;
|
||||||
function GetProperty(const Name: String): TObject; virtual;
|
function GetProperty(const Name: String): TObject; virtual;
|
||||||
@ -213,6 +214,7 @@ type
|
|||||||
procedure Parse(AInput: TSAXInputSource); virtual; abstract; overload;
|
procedure Parse(AInput: TSAXInputSource); virtual; abstract; overload;
|
||||||
procedure Parse(const SystemID: SAXString); virtual; overload;
|
procedure Parse(const SystemID: SAXString); virtual; overload;
|
||||||
procedure ParseStream(AStream: TStream);
|
procedure ParseStream(AStream: TStream);
|
||||||
|
procedure Abort;
|
||||||
|
|
||||||
// Current location
|
// Current location
|
||||||
property CurColumnNumber: Integer read FCurColumnNumber;
|
property CurColumnNumber: Integer read FCurColumnNumber;
|
||||||
@ -653,6 +655,11 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TSAXReader.Abort;
|
||||||
|
begin
|
||||||
|
FStopFlag := True;
|
||||||
|
end;
|
||||||
|
|
||||||
function TSAXReader.DoResolveEntity(const PublicID,
|
function TSAXReader.DoResolveEntity(const PublicID,
|
||||||
SystemID: SAXString): TSAXInputSource;
|
SystemID: SAXString): TSAXInputSource;
|
||||||
begin
|
begin
|
||||||
|
@ -150,7 +150,8 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
FEndOfStream := False;
|
FEndOfStream := False;
|
||||||
while True do
|
FStopFlag := False;
|
||||||
|
while not FStopFlag do
|
||||||
begin
|
begin
|
||||||
// Read data into the input buffer
|
// Read data into the input buffer
|
||||||
BufferSize := AInput.Stream.Read(Buffer, MaxBufferSize);
|
BufferSize := AInput.Stream.Read(Buffer, MaxBufferSize);
|
||||||
@ -161,7 +162,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
BufferPos := 0;
|
BufferPos := 0;
|
||||||
while BufferPos < BufferSize do
|
while (BufferPos < BufferSize) and not FStopFlag do
|
||||||
case ScannerContext of
|
case ScannerContext of
|
||||||
scUnknown:
|
scUnknown:
|
||||||
case Buffer[BufferPos] of
|
case Buffer[BufferPos] of
|
||||||
|
@ -141,7 +141,8 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
FEndOfStream := False;
|
FEndOfStream := False;
|
||||||
while True do
|
FStopFlag := False;
|
||||||
|
while not FStopFlag do
|
||||||
begin
|
begin
|
||||||
// Read data into the input buffer
|
// Read data into the input buffer
|
||||||
BufferSize := AInput.Stream.Read(Buffer, MaxBufferSize);
|
BufferSize := AInput.Stream.Read(Buffer, MaxBufferSize);
|
||||||
@ -152,7 +153,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
BufferPos := 0;
|
BufferPos := 0;
|
||||||
while BufferPos < BufferSize do
|
while (BufferPos < BufferSize) and not FStopFlag do
|
||||||
case ScannerContext of
|
case ScannerContext of
|
||||||
scUnknown:
|
scUnknown:
|
||||||
case Buffer[BufferPos] of
|
case Buffer[BufferPos] of
|
||||||
@ -337,9 +338,7 @@ procedure TSAXXMLReader.EnterNewScannerContext(NewContext: TXMLScannerContext);
|
|||||||
var
|
var
|
||||||
Attr: TSAXAttributes;
|
Attr: TSAXAttributes;
|
||||||
TagName: String;
|
TagName: String;
|
||||||
Found: Boolean;
|
|
||||||
Ent: SAXChar;
|
Ent: SAXChar;
|
||||||
i: Integer;
|
|
||||||
begin
|
begin
|
||||||
case ScannerContext of
|
case ScannerContext of
|
||||||
scWhitespace:
|
scWhitespace:
|
||||||
|
Loading…
Reference in New Issue
Block a user