Browse Source

* Added AddReplacesExisting

git-svn-id: trunk@26728 -
michael 11 years ago
parent
commit
4490a61981
1 changed files with 4 additions and 1 deletions
  1. 4 1
      packages/fcl-base/src/inifiles.pp

+ 4 - 1
packages/fcl-base/src/inifiles.pp

@@ -61,6 +61,7 @@ type
 
   TStringHash  = class
   private
+    FAddReplacesExisting: Boolean;
     FHashList : TFPDataHashTable;
   public
     constructor Create(ACapacity : Cardinal = 256);
@@ -70,6 +71,7 @@ type
     function Modify(const Key: string; Value: Integer): Boolean;
     procedure Remove(const Key: string);
     function ValueOf(const Key: string): Integer;
+    Property AddReplacesExisting : Boolean Read FAddReplacesExisting Write FAddReplacesExisting;
   end;
 
   { THashedStringList }
@@ -262,7 +264,8 @@ end;
 
 procedure TStringHash.Add(const Key: string; Value: Integer);
 begin
-  FHashList.Add(Key, Pointer(Value));
+  if Not (AddReplacesExisting and Modify(Key,Value)) then
+    FHashList.Add(Key, Pointer(Value));
 end;
 
 procedure TStringHash.Clear;