Browse Source

--- Merging r23144 into '.':
U packages/fcl-base/src/contnrs.pp
--- Merging r23361 into '.':
A packages/fcl-base/examples/intl/restest.cs.mo
A packages/fcl-base/examples/intl/restest.cs.po
U packages/fcl-base/examples/intl/Makefile

# revisions: 23144,23361
r23144 | michael | 2012-12-14 15:56:42 +0100 (Fri, 14 Dec 2012) | 1 line
Changed paths:
M /trunk/packages/fcl-base/src/contnrs.pp

* Expose ForeachCall functionality in new Iterate call, but keep backwards compatibiliy
r23361 | hajny | 2013-01-11 00:43:01 +0100 (Fri, 11 Jan 2013) | 1 line
Changed paths:
M /trunk/packages/fcl-base/examples/intl/Makefile
A /trunk/packages/fcl-base/examples/intl/restest.cs.mo
A /trunk/packages/fcl-base/examples/intl/restest.cs.po

+ new language added (cs)

git-svn-id: branches/fixes_2_6@24561 -

marco 12 years ago
parent
commit
2323a02ec2

+ 2 - 0
.gitattributes

@@ -1676,6 +1676,8 @@ packages/fcl-base/examples/fstream.pp svneol=native#text/plain
 packages/fcl-base/examples/htdump.pp svneol=native#text/plain
 packages/fcl-base/examples/intl/Makefile svneol=native#text/plain
 packages/fcl-base/examples/intl/README.txt svneol=native#text/plain
+packages/fcl-base/examples/intl/restest.cs.mo -text
+packages/fcl-base/examples/intl/restest.cs.po svneol=native#text/plain
 packages/fcl-base/examples/intl/restest.de.mo -text
 packages/fcl-base/examples/intl/restest.de.po svneol=native#text/plain
 packages/fcl-base/examples/intl/restest.fr.mo -text

+ 1 - 1
packages/fcl-base/examples/intl/Makefile

@@ -3,7 +3,7 @@
 # Add a 2 letter code when adding a language to DEMOLANGUAGES
 #
 
-DEMOLANGUAGES=fr nl de pb
+DEMOLANGUAGES=fr nl de pb ru cs
 
 #
 # No need to add after this line.

BIN
packages/fcl-base/examples/intl/restest.cs.mo


+ 27 - 0
packages/fcl-base/examples/intl/restest.cs.po

@@ -0,0 +1,27 @@
+msgid ""
+msgstr ""
+"Content-Type: text/plain; charset=UTF-8\n"
+"Project-Id-Version: \n"
+"POT-Creation-Date: \n"
+"PO-Revision-Date: \n"
+"Last-Translator: Václav Valíček <[email protected]>\n"
+"Language-Team: \n"
+"MIME-Version: 1.0\n"
+"Content-Transfer-Encoding: 8bit\n"
+"X-Generator: Poedit 1.5.4\n"
+
+#: testo:testing
+msgid "Testing :"
+msgstr "Zkouška:"
+
+#: testo:first
+msgid "First"
+msgstr "První"
+
+#: testo:second
+msgid "Second"
+msgstr "Druhý"
+
+#: testo:third
+msgid "Third"
+msgstr "Třetí"

+ 51 - 10
packages/fcl-base/src/contnrs.pp

@@ -413,8 +413,9 @@ type
     Procedure AddNode(ANode : THTCustomNode); override;
     procedure SetData(const index: string; const AValue: Pointer); virtual;
     function GetData(const index: string):Pointer; virtual;
+    function ForEachCall(aMethod: TDataIteratorMethod): THTDataNode; virtual;
   Public
-    function ForEachCall(aMethod: TDataIteratorMethod): Pointer; virtual;
+    function Iterate(aMethod: TDataIteratorMethod): Pointer; virtual;
     procedure Add(const aKey: string; AItem: pointer); virtual;
     property Items[const index: string]: Pointer read GetData write SetData; default;
   end;
@@ -434,8 +435,9 @@ type
     Procedure AddNode(ANode : THTCustomNode); override;
     procedure SetData(const Index, AValue: string); virtual;
     function GetData(const index: string): String; virtual;
+    function ForEachCall(aMethod: TStringIteratorMethod): THTStringNode; virtual;
   Public
-    function ForEachCall(aMethod: TStringIteratorMethod): String; virtual;
+    function Iterate(aMethod: TStringIteratorMethod): String; virtual;
     procedure Add(const aKey,aItem: string); virtual;
     property Items[const index: string]: String read GetData write SetData; default;
   end;
@@ -464,10 +466,11 @@ type
     Procedure AddNode(ANode : THTCustomNode); override;
     procedure SetData(const Index: string; AObject : TObject); virtual;
     function GetData(const index: string): TObject; virtual;
+    function ForEachCall(aMethod: TObjectIteratorMethod): THTObjectNode; virtual;
   Public
     constructor Create(AOwnsObjects : Boolean = True);
     constructor CreateWith(AHashTableSize: Longword; aHashFunc: THashFunction; AOwnsObjects : Boolean = True);
-    function ForEachCall(aMethod: TObjectIteratorMethod): TObject; virtual;
+    function Iterate(aMethod: TObjectIteratorMethod): TObject; virtual;
     procedure Add(const aKey: string; AItem : TObject); virtual;
     property Items[const index: string]: TObject read GetData write SetData; default;
     Property OwnsObjects : Boolean Read FOwnsObjects Write FOwnsObjects;
@@ -2255,7 +2258,20 @@ begin
   Result:=THTDataNode.CreateWith(aKey);
 end;
 
-function TFPDataHashTable.ForEachCall(aMethod: TDataIteratorMethod): Pointer;
+function TFPDataHashTable.Iterate(aMethod: TDataIteratorMethod): Pointer;
+
+Var
+  N : THTDataNode;
+
+begin
+  N:=ForEachCall(AMethod);
+  if Assigned(N) then
+    Result:=N.Data
+  else
+    Result:=Nil;  
+end;
+
+function TFPDataHashTable.ForEachCall(aMethod: TDataIteratorMethod): THTDataNode;
 var
   i, j: Longword;
   continue: boolean;
@@ -2273,7 +2289,7 @@ begin
           aMethod(THTDataNode(Chain(i)[j]).Data, THTDataNode(Chain(i)[j]).Key, continue);
           if not continue then
           begin
-            Result := THTDataNode(Chain(i)[j]).Data;
+            Result := THTDataNode(Chain(i)[j]);
             Exit;
           end;
         end;
@@ -2331,13 +2347,25 @@ begin
   Result:=THTStringNode.CreateWith(aKey);
 end;
 
+function TFPStringHashTable.Iterate(aMethod: TStringIteratorMethod): String;
+
+Var
+  N : THTStringNode;
+
+begin
+  N:=ForEachCall(AMethod);
+  if Assigned(N) then
+    Result:=N.Data
+  else
+    Result:='';  
+end;
 
-function TFPStringHashTable.ForEachCall(aMethod: TStringIteratorMethod): String;
+function TFPStringHashTable.ForEachCall(aMethod: TStringIteratorMethod): THTStringNode;
 var
   i, j: Longword;
   continue: boolean;
 begin
-  Result := '';
+  Result := Nil;
   continue := true;
   if FHashTableSize>0 then
    for i := 0 to FHashTableSize-1 do
@@ -2350,7 +2378,7 @@ begin
           aMethod(THTStringNode(Chain(i)[j]).Data, THTStringNode(Chain(i)[j]).Key, continue);
           if not continue then
           begin
-            Result := THTStringNode(Chain(i)[j]).Data;
+            Result := THTStringNode(Chain(i)[j]);
             Exit;
           end;
         end;
@@ -2405,7 +2433,20 @@ begin
 end;
 
 
-function TFPObjectHashTable.ForEachCall(aMethod: TObjectIteratorMethod): TObject;
+function TFPObjectHashTable.Iterate(aMethod: TObjectIteratorMethod): TObject;
+
+Var
+  N : THTObjectNode;
+
+begin
+  N:=ForEachCall(AMethod);
+  if Assigned(N) then
+    Result:=N.Data
+  else
+    Result:=Nil;  
+end;
+
+function TFPObjectHashTable.ForEachCall(aMethod: TObjectIteratorMethod): THTObjectNode;
 var
   i, j: Longword;
   continue: boolean;
@@ -2423,7 +2464,7 @@ begin
           aMethod(THTObjectNode(Chain(i)[j]).Data, THTObjectNode(Chain(i)[j]).Key, continue);
           if not continue then
           begin
-            Result := THTObjectNode(Chain(i)[j]).Data;
+            Result := THTObjectNode(Chain(i)[j]);
             Exit;
           end;
         end;