home *** CD-ROM | disk | FTP | other *** search
/ Chip 2000 February / Chip_2000-02_cd.bin / zkuste / Delphi / navody / tt / objvm.exe / UNITS / NamedValuesList.pas < prev    next >
Pascal/Delphi Source File  |  1998-03-13  |  2KB  |  63 lines

  1. unit NamedValuesList;
  2.  
  3. interface
  4. uses
  5.      LangValue,ObjStr;
  6. type TNamedValuesList=class
  7.      protected
  8.         fItems:TObjectStrings;
  9.         function rdItems(No:integer):ILangValue;
  10.         function rdNames(No:Integer):string;
  11.      public
  12.         constructor Create;
  13.         destructor Destroy;override;
  14.         property   Items[No:integer]:ILangValue read rdItems;default;
  15.         property   Names[No:integer]:string read rdNames;
  16.         function   Count:integer;
  17.         function   ValByName(const a:string):ILangValue;
  18.         procedure  Add(const Name:string;a:ILangValue);
  19.         procedure  DeleteValue(a:ILangValue);
  20.      end;
  21. implementation
  22. function    TNamedValuesList.rdItems;
  23.             begin
  24.               Result:=fItems.Objects[No] as ILangValue;
  25.             end;
  26. function    TNamedValuesList.rdNames;
  27.             begin
  28.               Result:=fItems[No];
  29.             end;
  30. constructor TNamedValuesList.Create;
  31.             begin
  32.               Inherited Create;
  33.               fItems:=TObjectStrings.Create;
  34.             end;
  35. destructor  TNamedValuesList.Destroy;
  36.             begin
  37.               fItems.Free;
  38.               Inherited Destroy;
  39.             end;
  40. function    TNamedValuesList.Count;
  41.             begin
  42.               Result:=fItems.Count;
  43.             end;
  44. function    TNamedValuesList.ValByName;
  45.             Var i:Integer;
  46.             begin
  47.               i:=fItems.IndexOf(a);
  48.               if i=-1 then
  49.                 Result:=nil
  50.               else
  51.                 Result:=fItems.Objects[i] as ILangValue;
  52.             end;
  53. procedure   TNamedValuesList.Add;
  54.             begin
  55.               fItems.AddObject(Name,a);
  56.             end;
  57. procedure   TNamedValuesList.DeleteValue(a:ILangValue);
  58.             begin
  59.               fItems.Remove(fItems.IndexOfObject(a));
  60.             end;
  61.  
  62. end.
  63.