⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cidclass.pas

📁 siMail, siMail, siMail, siMail
💻 PAS
字号:
(*
# (C) Copyright 2003
# Miha Vrhovnik, miha.vrhovnik@guest.arnes.si
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA 02111-1307 USA
#
# The Initial Developer of the Original Code is Miha Vrhovnik (Slovenia).
# Portions created by Miha Vrhovnik are Copyright (c)2000-2003.
# All Rights Reserved.
#==============================================================================
# Contributor(s):
#==============================================================================
# History: see whats new.txt from distribution package
#==============================================================================
*)

unit cidClass;

interface

uses Classes, mimepart;

//content-id to file name map class
type TcidToFN = class
  private
    Fcid: TStringList; //content-id
    Ffn: TStringList; //file name
    Fmime: TList;
  public
    function Add(cid, fileName: String; mime: TMimePart): Integer;
    function FindCid(fileName: String): Integer;
    function FindFileName(cid: String): Integer;
    function Cid(Index: Integer): String;
    function FileName(Index: Integer): String;
    function Replace(Index: Integer; cid, fileName: String): Integer;
    function Mime(Index: Integer): TMimePart;
    procedure Delete(Index: Integer);
    function Count: Integer;
    procedure Clear;
    constructor Create;
    destructor Destroy; override;
  published
  end;

implementation



{ TcidToFN }

function TcidToFN.Add(cid, fileName: String; mime: TMimePart): Integer;
begin
  Result := Fcid.Add(cid);
  Ffn.Add(fileName);
  Fmime.Add(mime);
end;

function TcidToFN.Cid(Index: Integer): String;
begin
  if Index < 0 then
    Result := ''
  else
    Result := Fcid.Strings[Index];
end;

procedure TcidToFN.Clear;
begin
  Fcid.Clear;
  Ffn.Clear;
  Fmime.Clear;
end;

function TcidToFN.Count: Integer;
begin
  Result := Fcid.Count;
end;

constructor TcidToFN.Create;
begin
  Fcid := TStringList.Create;
  Ffn := TStringList.Create;
  Fmime := TList.Create;
end;

procedure TcidToFN.Delete(Index: Integer);
begin
  Fcid.Delete(Index);
  Ffn.Delete(Index);
end;

destructor TcidToFN.Destroy;
begin
  Fcid.Free;
  Ffn.Free;
  Fmime.Free;
  inherited;
end;

function TcidToFN.FileName(Index: Integer): String;
begin
  if Index < 0 then
    Result := ''
  else
    Result := Ffn.Strings[Index];
end;

function TcidToFN.FindCid(fileName: String): Integer;
begin
  Result := Ffn.IndexOf(fileName);
end;

function TcidToFN.FindFileName(cid: String): Integer;
begin
  Result := Fcid.IndexOf(cid);
end;

function TcidToFN.Mime(Index: Integer): TMimePart;
begin
  if Index < 0 then
    Result := nil
  else
    Result := Fmime.Items[Index];
end;

function TcidToFN.Replace(Index: Integer; cid, fileName: String): Integer;
begin
  Ffn.Strings[Index] := fileName;
  Fcid.Strings[Index] := cid;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -