unit XMLSystem;

interface

Uses Windows;

Type
 TItemType = (itProgram, itVisual, itGeneral, itCMLx, itMisc, itUnknown);
 TItem = Class(Tobject)
 private
    FRequired: boolean;
    FDescription: String;
    FInstallTo: String;
    FName: string;
    FURL: String;
    FItemType: TItemType;
    FElementID: String;
    FStartMenuLocation: string;
    FStartMenuExecute: String;
    fFilename: String;
    FGroupName: String;
    FDirectURL: String;
    FInstallItem: Boolean;
    FItemSize: Integer;
    FLocal: String;
    FInstallFromLocal: Boolean;
    procedure SetDescription(const Value: String);
    procedure SetInstallTo(const Value: String);
    procedure SetItemType(const Value: TItemType);
    procedure SetName(const Value: string);
    procedure SetRequired(const Value: boolean);
    procedure SetURL(const Value: String);
    procedure SetElementID(const Value: String);
    procedure SetStartMenuExecute(const Value: String);
    procedure SetStartMenuLocation(const Value: string);
    procedure SetGroupName(const Value: String);
    procedure SetDirectURL(const Value: String);
    procedure SetInstallItem(const Value: Boolean);
    procedure SetItemSize(const Value: Integer);
    procedure SetLocal(const Value: String);
    procedure SetInstallFromLocal(const Value: Boolean);
 public
    Constructor Create;
    Property Description: String read FDescription write SetDescription;
    Property ElementID: String read FElementID write SetElementID;
    Property Filename: String read fFilename write fFilename;
    Property InstallTo: String read FInstallTo write SetInstallTo;
    Property ItemType: TItemType read FItemType write SetItemType;
    Property Name: string read FName write SetName;
    Property Required: boolean read FRequired write SetRequired;
    Property URL: String read FURL write SetURL;
    Property DirectURL: String read FDirectURL write SetDirectURL;
    Property StartMenuLocation: string read FStartMenuLocation write SetStartMenuLocation;
    Property StartMenuExecute: String read FStartMenuExecute write SetStartMenuExecute;
    Property GroupName: String read FGroupName write SetGroupName;
    Property InstallItem: Boolean read FInstallItem write SetInstallItem;
    Property ItemSize: Integer read FItemSize write SetItemSize;
    Property Local: String read FLocal write SetLocal;
    Property InstallFromLocal: Boolean read FInstallFromLocal write SetInstallFromLocal;
 end;
 TItemList = Class(TObject)
 private
  fList: array of TItem;
    function Get_COUNT: integer;
    function GET_ITEM(Index: Integer): TItem;
    procedure SET_ITEM(Index: Integer; const Value: TItem);
 public
  Function AddItem: TItem;
  Property Count: integer read Get_COUNT;
  Property Item[Index: Integer]: TItem read GET_ITEM write SET_ITEM; default;
 end;
 TItemGroup = Class(Tobject)
  private
    FScreenName: String;
    FDescription: String;
    FName: String;
    FListIndex: Integer;
    FIconFileName: String;
    FTreatAs: String;
    procedure SetDescription(const Value: String);
    procedure SetName(const Value: String);
    procedure SetScreenName(const Value: String);
    procedure SetListIndex(const Value: Integer);
    procedure SetIconFileName(const Value: String);
    procedure SetTreatAs(const Value: String);
 public
  Property Description: String read FDescription write SetDescription;
  Property Name: String read FName write SetName;
  Property ScreenName: String read FScreenName write SetScreenName;
  Property ListIndex: Integer read FListIndex write SetListIndex;
  Property IconFileName: String read FIconFileName write SetIconFileName;
  Property TreatAs: String read FTreatAs write SetTreatAs;
 end;
 TItemGroupList = Class(TObject)
 private
  fList: array of TItemGroup;
    function GET_COUNT: Integer;
    function GetItemGroup(Index: Integer): TItemGroup;
    procedure SetItemGroup(Index: Integer; const Value: TItemGroup);
 public
  Function Add: TItemGroup;
  Property Count: Integer read GET_COUNT;
  Property ItemGroup[Index: Integer]: TItemGroup read GetItemGroup write SetItemGroup; default;
  Function GetByListIndex(Index: Integer): TItemGroup;
  Function GetByScreenname(Screenname: String): TItemGroup;
 end;
 TLink = Class(TObject)
  private
    FIconIndex: Integer;
    FIcon: String;
    FTitle: String;
    FCreateIn: String;
    FExecute: String;
    FParameters: String;
    procedure SetCreateIn(const Value: String);
    procedure SetExecute(const Value: String);
    procedure SetIcon(const Value: String);
    procedure SetIconIndex(const Value: Integer);
    procedure SetTitle(const Value: String);
    procedure SetParameters(const Value: String);
 public
  Property Title: String read FTitle write SetTitle;
  Property Execute: String read FExecute write SetExecute;
  Property CreateIn: String read FCreateIn write SetCreateIn;
  Property IconIndex: Integer read FIconIndex write SetIconIndex;
  Property Icon: String read FIcon write SetIcon;
  Property Parameters: String read FParameters write SetParameters;
 end;
 TLinkList = Class(Tobject)
 private
  fList: Array of TLink;
  function GetLink(Index: Integer): TLink;
  procedure SetLink(Index: Integer; const Value: TLink);
 public
  function Add: TLink;
  Function Count: Integer;
  Property Link[Index: Integer]: TLink read GetLink write SetLink; default;
 End;
 TRegItem = Record
  Name: String;
  Value: String;
 end;
 TRegItemList = Class(TObject)
 private
  fList: array of TRegItem;
    fPath: String;
    fRootKey: HKEY;
    function GETCOUNT: Cardinal;
    function GETITEM(Index: Integer): TRegItem;
    procedure SETITEM(Index: Integer; const Value: TRegItem);
 public
  Constructor Create(RootKey: String; Path: String);
  Property Count: Cardinal read GETCOUNT;
  Procedure Add(Name, Value: String);
  Property RegItem[Index: Integer]: TRegItem read GETITEM write SETITEM; default;
  Property Path: String read fPath write fPath;
  Property RootKey: HKEY read fRootKey write fRootKey;
 end;
 TRegList = Class(TObject)
 private
  fList: array of TRegItemList;
    function GETCOUNT: Cardinal;
    function GETREGITEMLIST(Index: Integer): TRegItemList;
    procedure SETREGITEMLIST(Index: Integer; const Value: TRegItemList);
 public
  Property Count: Cardinal read GETCOUNT;
  Function Add(RootKey, Path: String): Integer;
  Property RegItemList[Index: Integer]: TRegItemList read GETREGITEMLIST write SETREGITEMLIST; default;
 end;
 TRepDownload = record
  Name: String;
  UPD: String;
  DirectURL: String;
  Size: Integer;
  ExtractTo: String;
  ItemType: TItemType;
 end;
 TRepDownloadList = class(TObject)
 private
  fList: Array of TRepDownload;
  function GETCOUNT: Cardinal;
  function GETREPDOWNLOAD(Index: Integer): TRepDownload;
  function GETTOTALSIZE: Cardinal;
  procedure SETREPDOWNLOAD(Index: Integer; const Value: TRepDownload);
 public
  Property Count: Cardinal read GETCOUNT;
  Property RepDownload[Index: Integer]: TRepDownload read GETREPDOWNLOAD Write SETREPDOWNLOAD; default;
  Property TotalSize: Cardinal read GETTOTALSIZE;
  Procedure Add(Name: String; ItemType: TItemType; ExtractTo: String); 
 end;

 Function StrToHKEY(Str: String): HKEY;
 Function HKEYToStr(KEY: HKEY): String;

implementation

Uses SysUtils;

Function StrToHKEY(Str: String): HKEY;
begin
 Result := HKEY_CURRENT_USER;
 If uppercase(Str) = 'HKEY_CLASSES_ROOT' then Result := HKEY_CLASSES_ROOT;
 If uppercase(Str) = 'HKEY_LOCAL_MACHINE' then Result := HKEY_LOCAL_MACHINE;
 If uppercase(str) = 'HKEY_USERS' then Result := HKEY_USERS;
 If uppercase(str) = 'HKEY_CURRENT_CONFIG' then Result := HKEY_CURRENT_CONFIG;
end;

Function HKEYToStr(KEY: HKEY): String;
Begin
 Result := 'HKEY_CURRENT_USER';
 Case KEY of
  HKEY_CLASSES_ROOT: Result := 'HKEY_CLASSES_ROOT';
  HKEY_LOCAL_MACHINE: Result := 'HKEY_LOCAL_MACHINE';
  HKEY_USERS: Result := 'HKEY_USERS';
  HKEY_CURRENT_CONFIG: Result := 'HKEY_CURRENT_CONFIG';
 end;
end;

{ TItem }

constructor TItem.Create;
begin
  inherited;
  fItemType := itUnknown;
end;

procedure TItem.SetDescription(const Value: String);
begin
  FDescription := Value;
end;

procedure TItem.SetDirectURL(const Value: String);
begin
  FDirectURL := Value;
end;

procedure TItem.SetElementID(const Value: String);
begin
  FElementID := Value;
end;

procedure TItem.SetGroupName(const Value: String);
begin
  FGroupName := Value;
end;

procedure TItem.SetInstallFromLocal(const Value: Boolean);
begin
  FInstallFromLocal := Value;
end;

procedure TItem.SetInstallItem(const Value: Boolean);
begin
  FInstallItem := Value;
end;

procedure TItem.SetInstallTo(const Value: String);
begin
  FInstallTo := Value;
end;

procedure TItem.SetItemSize(const Value: Integer);
begin
  FItemSize := Value;
end;

procedure TItem.SetItemType(const Value: TItemType);
begin
  FItemType := Value;
end;

procedure TItem.SetLocal(const Value: String);
begin
  FLocal := Value;
end;

procedure TItem.SetName(const Value: string);
begin
  FName := Value;
end;

procedure TItem.SetRequired(const Value: boolean);
begin
  FRequired := Value;
end;

procedure TItem.SetStartMenuExecute(const Value: String);
begin
  FStartMenuExecute := Value;
end;

procedure TItem.SetStartMenuLocation(const Value: string);
begin
  FStartMenuLocation := Value;
end;

procedure TItem.SetURL(const Value: String);
begin
  FURL := Value;
end;

{ TItemList }

function TItemList.AddItem: TItem;
begin
 setlength(flist, length(flist) + 1);
 fList[length(flist) - 1] := TItem.Create;
 Result := fList[Length(fList) - 1];
end;

function TItemList.Get_COUNT: integer;
begin
 Result := length(fList);
end;

function TItemList.GET_ITEM(Index: Integer): TItem;
begin
 Result := fList[Index];
end;

procedure TItemList.SET_ITEM(Index: Integer; const Value: TItem);
begin
 fList[Index] := Value;
end;

{ TItemGroup }

procedure TItemGroup.SetDescription(const Value: String);
begin
  FDescription := Value;
end;

procedure TItemGroup.SetIconFileName(const Value: String);
begin
  FIconFileName := Value;
end;

procedure TItemGroup.SetListIndex(const Value: Integer);
begin
  FListIndex := Value;
end;

procedure TItemGroup.SetName(const Value: String);
begin
  FName := Value;
end;

procedure TItemGroup.SetScreenName(const Value: String);
begin
  FScreenName := Value;
end;

procedure TItemGroup.SetTreatAs(const Value: String);
begin
  FTreatAs := Value;
end;

{ TItemGroupList }

function TItemGroupList.Add: TItemGroup;
begin
 Setlength(fList, length(flist) + 1);
 fList[Length(fList)-1] := TItemGroup.Create;
 Result := fList[length(fList)-1];
end;

function TItemGroupList.GET_COUNT: Integer;
begin
 Result := length(flist);
end;

function TItemGroupList.GetItemGroup(Index: Integer): TItemGroup;
begin
 Result := fList[Index];
end;

procedure TItemGroupList.SetItemGroup(Index: Integer;
  const Value: TItemGroup);
begin
 fList[Index] := Value;
end;

function TItemGroupList.GetByListIndex(Index: Integer): TItemGroup;
Var
 I: Integer;
begin
 Result := nil;
 For I := 0 to count - 1 do begin
  if flist[I].ListIndex = Index then begin
   result := fList[I];
   exit;
  end;
 end;
end;

function TItemGroupList.GetByScreenname(Screenname: String): TItemGroup;
Var
 I: Integer;
begin
 Result := nil;
 For I := 0 to count - 1 do begin
  if flist[I].ScreenName = screenname then begin
   result := fList[I];
   exit;
  end;
 end;
end;

{ TLink }

procedure TLink.SetCreateIn(const Value: String);
begin
  FCreateIn := Value;
end;

procedure TLink.SetExecute(const Value: String);
begin
  FExecute := Value;
end;

procedure TLink.SetIcon(const Value: String);
begin
  FIcon := Value;
end;

procedure TLink.SetIconIndex(const Value: Integer);
begin
  FIconIndex := Value;
end;

procedure TLink.SetParameters(const Value: String);
begin
  FParameters := Value;
end;

procedure TLink.SetTitle(const Value: String);
begin
  FTitle := Value;
end;

{ TLinkList }

function TLinkList.Add: TLink;
begin
 Setlength(fList, length(fList) + 1);
 fList[Length(fList)-1] := TLink.Create;
 Result := fList[Length(fList)-1];
end;

function TLinkList.Count: Integer;
begin
 Result := length(fList);
end;

function TLinkList.GetLink(Index: Integer): TLink;
begin
 Result := fList[Index];
end;

procedure TLinkList.SetLink(Index: Integer; const Value: TLink);
begin
 fList[Index] := Value;
end;

{ TRegItemList }

procedure TRegItemList.Add(Name, Value: String);
begin
 SetLength(fList, count + 1);
 fList[Count-1].Name := Name;
 fList[Count-1].Value := Value;
end;

constructor TRegItemList.Create(RootKey, Path: String);
begin
 fRootKey := StrToHKEY(RootKey);
 fPath := Path;
end;

function TRegItemList.GETCOUNT: Cardinal;
begin
 Result := length(fList);
end;

function TRegItemList.GETITEM(Index: Integer): TRegItem;
begin
 Result := fList[Index];
end;

procedure TRegItemList.SETITEM(Index: Integer; const Value: TRegItem);
begin
 fList[Index] := Value;
end;

{ TRegList }

function TRegList.Add(RootKey, Path: String): Integer;
begin
 SetLength(fList, count + 1);
 fList[Count-1] := TRegItemList.Create(RootKey, Path);
 Result := Count - 1; 
end;

function TRegList.GETCOUNT: Cardinal;
begin
 Result := Length(fList);
end;

function TRegList.GETREGITEMLIST(Index: Integer): TRegItemList;
begin
 Result := fList[Index];
end;

procedure TRegList.SETREGITEMLIST(Index: Integer;
  const Value: TRegItemList);
begin
 fList[Index] := Value;
end;

{ TRepDownloadList }

procedure TRepDownloadList.Add(Name: String; ItemType: TItemType; ExtractTo: String);
begin
 Setlength(fList, count + 1);
 fList[Count-1].Name := Name;
 fList[Count-1].ItemType := ItemType;
 fList[Count-1].ExtractTo := ExtractTo;
 fList[Count-1].UPD := '';
 fList[Count-1].DirectURL := '';
 fList[Count-1].Size := 0;

end;

function TRepDownloadList.GETCOUNT: Cardinal;
begin
 Result := length(fList);
end;

function TRepDownloadList.GETREPDOWNLOAD(Index: Integer): TRepDownload;
begin
 Result := fList[Index];
end;

function TRepDownloadList.GETTOTALSIZE: Cardinal;
Var
 I: Integer;
begin
 Result := 0;
 For I := 0 to count - 1 do begin
  inc(Result, fList[I].Size);
 end;
end;

procedure TRepDownloadList.SETREPDOWNLOAD(Index: Integer;
  const Value: TRepDownload);
begin
 fList[Index] := Value;
end;

end.
