From cebd916053c0b424b0e69102585ab2fc66d3565f Mon Sep 17 00:00:00 2001 From: michael Date: Mon, 22 Mar 2021 20:09:55 +0000 Subject: [PATCH] * Add ExtractStrings --- packages/rtl/classes.pas | 68 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/packages/rtl/classes.pas b/packages/rtl/classes.pas index 27d01a4..2114317 100644 --- a/packages/rtl/classes.pas +++ b/packages/rtl/classes.pas @@ -1424,6 +1424,7 @@ Function FindNestedComponent(Root : TComponent; APath : String; CStyle : Boolean procedure RedirectFixupReferences(Root: TComponent; const OldRootName, NewRootName: string); procedure RemoveFixupReferences(Root: TComponent; const RootName: string); procedure RegisterIntegerConsts(IntegerType: Pointer; IdentToIntFn: TIdentToInt; IntToIdentFn: TIntToIdent); +function ExtractStrings(Separators, WhiteSpace: TSysCharSet; Content: String; Strings: TStrings; AddEmptyStrings : Boolean = False): Integer; function IdentToInt(const Ident: string; out Int: Longint; const Map: array of TIdentMapEntry): Boolean; function IntToIdent(Int: Longint; var Ident: string; const Map: array of TIdentMapEntry): Boolean; function FindIntToIdent(AIntegerType: Pointer): TIntToIdent; @@ -1587,6 +1588,73 @@ begin IntConstList.Add(TIntConst.Create(IntegerType, IdentToIntFn, IntToIdentFn)); end; +function ExtractStrings(Separators, WhiteSpace: TSysCharSet; Content: String; Strings: TStrings; AddEmptyStrings : Boolean = False): Integer; +var + b,c : integer; + + procedure SkipWhitespace; + begin + while (Content[c] in Whitespace) do + inc (C); + end; + + procedure AddString; + var + l : integer; + + begin + l := c-b; + if (l > 0) or AddEmptyStrings then + begin + if assigned(Strings) then + begin + if l>0 then + Strings.Add (Copy(Content,B,L)) + else + Strings.Add(''); + end; + inc (result); + end; + end; + +var + cc,quoted : char; + i,aLen : Integer; +begin + result := 0; + c := 1; + Quoted := #0; + Separators := Separators + [#13, #10] - ['''','"']; + SkipWhitespace; + b := c; + aLen:=Length(Content); + while C<=aLen do + begin + CC:=Content[c]; + if (CC = Quoted) then + begin + if (C b) then + AddString; +end; + + function FindIntToIdent(AIntegerType: Pointer): TIntToIdent; var