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}
|
function startsWith(const value: string): boolean; {$IFNDEF DEBUG}inline;{$ENDIF}
|
||||||
// indicates wether the range starts with value.
|
// indicates wether the range starts with value.
|
||||||
function startsWith(var value: TStringRange): boolean; {$IFNDEF DEBUG}inline;{$ENDIF}
|
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;
|
end;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
@ -122,6 +128,11 @@ begin
|
||||||
len := length(str);
|
len := length(str);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TStringRange.position: integer;
|
||||||
|
begin
|
||||||
|
Result := pos;
|
||||||
|
end;
|
||||||
|
|
||||||
function TStringRange.init(const pchr: PChar; length: integer): PStringRange;
|
function TStringRange.init(const pchr: PChar; length: integer): PStringRange;
|
||||||
begin
|
begin
|
||||||
ptr := pchr;
|
ptr := pchr;
|
||||||
|
@ -320,5 +331,13 @@ begin
|
||||||
value.pos := p1;
|
value.pos := p1;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TStringRange.endsWith(const value: string): boolean;
|
||||||
|
begin
|
||||||
|
if empty then
|
||||||
|
Result := false
|
||||||
|
else
|
||||||
|
Result := ptr[pos .. length(value)-1] = value;
|
||||||
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue