Changeset 184 for trunk/UAcronym.pas
- Timestamp:
- Jul 4, 2018, 2:05:48 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UAcronym.pas
r159 r184 17 17 TImportSources = class; 18 18 TImportFormats = class; 19 20 TSearchFlag = (sfCaseInsensitive); 21 TSearchFlags = set of TSearchFlag; 19 22 20 23 { TAcronym } … … 36 39 procedure SaveToNode(Node: TDOMNode); 37 40 procedure LoadFromNode(Node: TDOMNode); 38 function SearchByName(Name: string ): TAcronym;41 function SearchByName(Name: string; Flags: TSearchFlags = []): TAcronym; 39 42 function AddAcronym(Name: string): TAcronym; 40 43 end; … … 65 68 procedure SaveToNode(Node: TDOMNode); 66 69 procedure LoadFromNode(Node: TDOMNode); 67 function SearchByName(Name: string ): TAcronymMeaning;70 function SearchByName(Name: string; Flags: TSearchFlags = []): TAcronymMeaning; 68 71 function AddMeaning(Name: string): TAcronymMeaning; 69 72 end; … … 237 240 function GetMeaningsCount: Integer; 238 241 function AddAcronym(AcronymName, MeaningName: string): TAcronymMeaning; 242 function SearchAcronym(AcronymName, MeaningName: string; Flags: TSearchFlags = []): TAcronymMeaning; 239 243 procedure RemoveMeaning(Meaning: TAcronymMeaning); 240 244 procedure RemoveAcronym(AcronymName, MeaningName: string); … … 1031 1035 end; 1032 1036 1033 function TAcronymMeanings.SearchByName(Name: string): TAcronymMeaning; 1037 function TAcronymMeanings.SearchByName(Name: string; Flags: TSearchFlags 1038 ): TAcronymMeaning; 1034 1039 var 1035 1040 I: Integer; 1036 1041 begin 1037 1042 I := 0; 1038 while (I < Count) and (TAcronymMeaning(Items[I]).Name <> Name) do Inc(I); 1043 if sfCaseInsensitive in Flags then begin 1044 while (I < Count) and (LowerCase(TAcronymMeaning(Items[I]).Name) <> LowerCase(Name)) do Inc(I); 1045 end else begin 1046 while (I < Count) and (TAcronymMeaning(Items[I]).Name <> Name) do Inc(I); 1047 end; 1039 1048 if I < Count then Result := TAcronymMeaning(Items[I]) 1040 1049 else Result := nil; … … 1152 1161 end; 1153 1162 1154 function TAcronyms.SearchByName(Name: string ): TAcronym;1163 function TAcronyms.SearchByName(Name: string; Flags: TSearchFlags = []): TAcronym; 1155 1164 var 1156 1165 I: Integer; 1157 1166 begin 1158 1167 I := 0; 1159 while (I < Count) and (TAcronym(Items[I]).Name <> Name) do Inc(I); 1168 if sfCaseInsensitive in Flags then begin 1169 while (I < Count) and (LowerCase(TAcronym(Items[I]).Name) <> LowerCase(Name)) do Inc(I); 1170 end else begin 1171 while (I < Count) and (TAcronym(Items[I]).Name <> Name) do Inc(I); 1172 end; 1160 1173 if I < Count then Result := TAcronym(Items[I]) 1161 1174 else Result := nil; … … 1684 1697 end; 1685 1698 1699 function TAcronymDb.SearchAcronym(AcronymName, MeaningName: string; 1700 Flags: TSearchFlags = []): TAcronymMeaning; 1701 var 1702 Acronym: TAcronym; 1703 Meaning: TAcronymMeaning; 1704 begin 1705 Result := nil; 1706 Acronym := Acronyms.SearchByName(AcronymName); 1707 if Assigned(Acronym) then begin 1708 Meaning := Acronym.Meanings.SearchByName(MeaningName, Flags); 1709 if Assigned(Meaning) then begin 1710 Result := Meaning; 1711 end; 1712 end; 1713 end; 1714 1686 1715 procedure TAcronymDb.RemoveMeaning(Meaning: TAcronymMeaning); 1687 1716 var
Note:
See TracChangeset
for help on using the changeset viewer.