|
@@ -17,6 +17,7 @@ unit wasm.regexp.objects;
|
|
|
|
|
|
{$mode ObjFPC}{$H+}
|
|
{$mode ObjFPC}{$H+}
|
|
{$modeswitch typehelpers}
|
|
{$modeswitch typehelpers}
|
|
|
|
+{$modeswitch advancedrecords}
|
|
|
|
|
|
interface
|
|
interface
|
|
|
|
|
|
@@ -57,9 +58,12 @@ Type
|
|
Property AsFlags : Longint Read ToFlags Write SetAsFlags;
|
|
Property AsFlags : Longint Read ToFlags Write SetAsFlags;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+ { TRegExpMatch }
|
|
|
|
+
|
|
TRegExpMatch = record
|
|
TRegExpMatch = record
|
|
Value : UTF8String;
|
|
Value : UTF8String;
|
|
StartIndex, StopIndex : Integer;
|
|
StartIndex, StopIndex : Integer;
|
|
|
|
+ function MatchPos(aStartIndex, aStopIndex : Integer) : Boolean;
|
|
end;
|
|
end;
|
|
TRegExpMatchArray = array of TRegExpMatch;
|
|
TRegExpMatchArray = array of TRegExpMatch;
|
|
|
|
|
|
@@ -86,6 +90,7 @@ Type
|
|
function GetGroups(aCount: Integer): TRegExpGroupArray;
|
|
function GetGroups(aCount: Integer): TRegExpGroupArray;
|
|
function GetLastIndex: Longint;
|
|
function GetLastIndex: Longint;
|
|
function GetMatches(aCount: Integer): TRegExpMatchArray;
|
|
function GetMatches(aCount: Integer): TRegExpMatchArray;
|
|
|
|
+ procedure SetLastIndex(AValue: Longint);
|
|
protected
|
|
protected
|
|
function CheckRegExpResult(Res : TWasmRegexpResult; const aOperation : String; aRaise : Boolean = true) : Boolean;
|
|
function CheckRegExpResult(Res : TWasmRegexpResult; const aOperation : String; aRaise : Boolean = true) : Boolean;
|
|
Public
|
|
Public
|
|
@@ -95,7 +100,8 @@ Type
|
|
destructor Destroy; override;
|
|
destructor Destroy; override;
|
|
Function Exec(const aString : String) : TRegExpResult;
|
|
Function Exec(const aString : String) : TRegExpResult;
|
|
Function Test(const aString : String) : Boolean;
|
|
Function Test(const aString : String) : Boolean;
|
|
- Property LastIndex : Longint Read GetLastIndex;
|
|
|
|
|
|
+ // 0 - based !
|
|
|
|
+ Property LastIndex : Longint Read GetLastIndex Write SetLastIndex;
|
|
Property RegexpID : TWasmRegExpID Read FRegexpID;
|
|
Property RegexpID : TWasmRegExpID Read FRegexpID;
|
|
Property FlagsAsInteger : Integer Read FFlags;
|
|
Property FlagsAsInteger : Integer Read FFlags;
|
|
Property Flags : TRegexpFlags Read GetFlags;
|
|
Property Flags : TRegexpFlags Read GetFlags;
|
|
@@ -166,6 +172,13 @@ begin
|
|
Result.AsFlags:=aFlags;
|
|
Result.AsFlags:=aFlags;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+{ TRegExpMatch }
|
|
|
|
+
|
|
|
|
+function TRegExpMatch.MatchPos(aStartIndex, aStopIndex: Integer): Boolean;
|
|
|
|
+begin
|
|
|
|
+ Result:=(aStartIndex=StartIndex) and (aStopIndex=StopIndex);
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
|
|
{ TWasmRegExp }
|
|
{ TWasmRegExp }
|
|
|
|
|
|
@@ -244,6 +257,11 @@ begin
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+procedure TWasmRegExp.SetLastIndex(AValue: Longint);
|
|
|
|
+begin
|
|
|
|
+ CheckRegExpResult(__wasm_regexp_set_last_index(FRegexpID,AValue),'set_last_index');
|
|
|
|
+end;
|
|
|
|
+
|
|
function TWasmRegExp.GetGroups(aCount: Integer): TRegExpGroupArray;
|
|
function TWasmRegExp.GetGroups(aCount: Integer): TRegExpGroupArray;
|
|
|
|
|
|
var
|
|
var
|