|
@@ -169,11 +169,14 @@ type
|
|
OnFoundTag: TOnFoundTag;
|
|
OnFoundTag: TOnFoundTag;
|
|
OnFoundText: TOnFoundText;
|
|
OnFoundText: TOnFoundText;
|
|
Raw: Pchar;
|
|
Raw: Pchar;
|
|
|
|
+ FCurrent : PChar;
|
|
constructor Create(sRaw: string);overload;
|
|
constructor Create(sRaw: string);overload;
|
|
constructor Create(pRaw: PChar);overload;
|
|
constructor Create(pRaw: PChar);overload;
|
|
procedure Exec;
|
|
procedure Exec;
|
|
procedure NilOnFoundTag(NoCaseTag, ActualTag: string);
|
|
procedure NilOnFoundTag(NoCaseTag, ActualTag: string);
|
|
procedure NilOnFoundText(Text: string);
|
|
procedure NilOnFoundText(Text: string);
|
|
|
|
+ Public
|
|
|
|
+ Function CurrentPos : Integer;
|
|
property Done: Boolean read FDone write FDone;
|
|
property Done: Boolean read FDone write FDone;
|
|
end;
|
|
end;
|
|
|
|
|
|
@@ -187,12 +190,9 @@ begin
|
|
end;
|
|
end;
|
|
|
|
|
|
function CopyBuffer(StartIndex: PChar; Length: Integer): string;
|
|
function CopyBuffer(StartIndex: PChar; Length: Integer): string;
|
|
-var
|
|
|
|
- S: string;
|
|
|
|
begin
|
|
begin
|
|
- SetLength(S, Length);
|
|
|
|
- StrLCopy(@S[1], StartIndex, Length);
|
|
|
|
- Result:= S;
|
|
|
|
|
|
+ SetLength(Result, Length);
|
|
|
|
+ StrLCopy(@Result[1], StartIndex, Length);
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
@@ -221,6 +221,14 @@ procedure THTMLParser.NilOnFoundText(Text: string);
|
|
begin
|
|
begin
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+function THTMLParser.CurrentPos: Integer;
|
|
|
|
+begin
|
|
|
|
+ if Assigned(Raw) and Assigned(FCurrent) then
|
|
|
|
+ Result:=FCurrent-Raw
|
|
|
|
+ else
|
|
|
|
+ Result:=0;
|
|
|
|
+end;
|
|
|
|
+
|
|
procedure THTMLParser.Exec;
|
|
procedure THTMLParser.Exec;
|
|
var
|
|
var
|
|
L: Integer;
|
|
L: Integer;
|
|
@@ -264,6 +272,7 @@ begin
|
|
begin
|
|
begin
|
|
L:= P - TextStart;
|
|
L:= P - TextStart;
|
|
{ Yes, copy to buffer }
|
|
{ Yes, copy to buffer }
|
|
|
|
+ FCurrent:=P;
|
|
OnFoundText( CopyBuffer(TextStart, L) );
|
|
OnFoundText( CopyBuffer(TextStart, L) );
|
|
end else
|
|
end else
|
|
begin
|
|
begin
|
|
@@ -299,6 +308,7 @@ begin
|
|
{ Copy this tag to buffer }
|
|
{ Copy this tag to buffer }
|
|
L:= P - TagStart + 1;
|
|
L:= P - TagStart + 1;
|
|
|
|
|
|
|
|
+ FCurrent:=P;
|
|
OnFoundTag( uppercase(CopyBuffer(TagStart, L )), CopyBuffer(TagStart, L ) ); //L505: added uppercase
|
|
OnFoundTag( uppercase(CopyBuffer(TagStart, L )), CopyBuffer(TagStart, L ) ); //L505: added uppercase
|
|
Inc(P); Inc(I);
|
|
Inc(P); Inc(I);
|
|
if I >= TL then Break;
|
|
if I >= TL then Break;
|