From eda6ec6e814e7c9dd06d3e0a0e77b9e6d0e9bc9a Mon Sep 17 00:00:00 2001 From: Basile Burg Date: Tue, 6 Feb 2018 14:09:42 +0100 Subject: [PATCH] add more stringrange functions --- src/ce_stringrange.pas | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/ce_stringrange.pas b/src/ce_stringrange.pas index b3cde56e..33415dd8 100644 --- a/src/ce_stringrange.pas +++ b/src/ce_stringrange.pas @@ -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.