mirror of https://gitlab.com/basile.b/dexed.git
add more stringrange functions
This commit is contained in:
parent
382ae6c7bd
commit
eda6ec6e81
|
@ -86,6 +86,12 @@ type
|
|||
function startsWith(const value: string): boolean; {$IFNDEF DEBUG}inline;{$ENDIF}
|
||||
// indicates wether the range starts with value.
|
||||
function startsWith(var value: TStringRange): boolean; {$IFNDEF DEBUG}inline;{$ENDIF}
|
||||
// indicates wether the range ends with value.
|
||||
function endsWith(const value: string): boolean; {$IFNDEF DEBUG}inline;{$ENDIF}
|
||||
|
||||
|
||||
// read-only position
|
||||
function position: integer;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
@ -122,6 +128,11 @@ begin
|
|||
len := length(str);
|
||||
end;
|
||||
|
||||
function TStringRange.position: integer;
|
||||
begin
|
||||
Result := pos;
|
||||
end;
|
||||
|
||||
function TStringRange.init(const pchr: PChar; length: integer): PStringRange;
|
||||
begin
|
||||
ptr := pchr;
|
||||
|
@ -320,5 +331,13 @@ begin
|
|||
value.pos := p1;
|
||||
end;
|
||||
|
||||
function TStringRange.endsWith(const value: string): boolean;
|
||||
begin
|
||||
if empty then
|
||||
Result := false
|
||||
else
|
||||
Result := ptr[pos .. length(value)-1] = value;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
|
|
Loading…
Reference in New Issue