type
TBasicCollection=class;
//Grundlegende abstrakte Klasse für einen Knoten (egal welcher)
TBasicCollectionItem=class(TCollectionItem)
Destructor Destroy;
override;
private
FChildCollection:TBasicCollection;
//Für Kindknoten oder nil wenn keine Kinder
public
function GetVSTBezeichner:
string;
virtual;
abstract;
//Text für VST (wird je nach Ableitung anders implementiert)
property ChildCollection:TBasicCollection
read FChildCollection;
procedure Init(
const Param:
string);
virtual;
abstract;
//Param bekommt einen Teilstring von CSettingsTree
end;
TBasicCollection=class(TCollection)
private
function GetBasicCollectionItem(
index:Integer): TBasicCollectionItem;
public
property BasicCollectionItem[
index:Integer]:TBasicCollectionItem
read GetBasicCollectionItem;
procedure Init(
const Param:
string);
end;
//CollectionItem für die Knoten (Verzeichnisse und Benutzerhinweise)
TCollectionItemA=class(TBasicCollectionItem)
private
FName:
string;
//hier nur Name merken
procedure SetName(
const Value:
string);
public
function getVSTBezeichner:
string;
override;
//result:=FName;
property Name:
string read FName
write SetName;
procedure Init(
const Param:
string);
override;
end;
//CollectionItem für die anderen Knoten
TCollectionItemB=class(TBasicCollectionItem)
private
FAuthReq: Integer;
FxID: Integer;
FText:
string;
procedure SetAuthReq(
const Value: Integer);
procedure SetText(
const Value:
string);
procedure SetxID(
const Value: Integer);
public
function getVSTBezeichner:
string;
override;
//result:=Ftext;
property xID:Integer
read FxID
write SetxID;
property AuthReq:Integer
read FAuthReq
write SetAuthReq;
property Text:
string read FText
write SetText;
procedure Init(
const Param:
string);
override;
end;
implementation
{$R *.dfm}
//gibt den Pos-ten Teilstring in den spitzen Klammern zurück (ohne Beachtung von inneren Klammern)
function GetStringPart(
const Str:
string;
Pos: Integer):
String;
var aPos,ePos:Integer;
len:Integer;
countopen:Integer;
begin
len:=length(str);
aPos:=0;
countopen:=0;
while Pos>0
do
begin
inc(aPos);
while (aPos<=len)
and((Str[aPos]<>'
<')
or(countopen>0))
do
begin
case Str[aPos]
of
'
<': inc(countopen);
'
>':
dec(countopen);
end;
inc(aPos);
end;
inc(countopen);
dec(Pos);
end;
ePos:=aPos+1;
countopen:=0;
while (ePos<=len)
and((Str[ePos]<>'
>')
or(countopen>0))
do
begin
case Str[ePos]
of
'
<': inc(countopen);
'
>':
dec(countopen);
end;
inc(ePos);
end;
result:=copy(str,aPos+1,ePos-aPos-1);
end;
{ TBasicCollection }
function TBasicCollection.GetBasicCollectionItem(
index:Integer): TBasicCollectionItem;
begin
result:=items[
index]
as TBasicCollectionItem;
end;
procedure TBasicCollection.Init(
const Param:
string);
var i:Integer;
Part:
string;
BasicCollectionItem:TBasicCollectionItem;
begin
i:=1;
Part:=GetStringPart(Param,i);
while Part<>'
'
do
begin
BasicCollectionItem:=Add
as TBasicCollectionItem;
BasicCollectionItem.Init(Part);
inc(i);
Part:=GetStringPart(Param,i);
end;
end;
{ TBasicCollectionItem }
destructor TBasicCollectionItem.Destroy;
begin
FChildCollection.Free;
inherited;
end;
{ TCollectionItemA }
function TCollectionItemA.getVSTBezeichner:
string;
begin
result:=FName;
end;
procedure TCollectionItemA.Init(
const Param:
string);
begin
Name:=GetStringPart(Param,1);
FChildCollection:=TBasicCollection.Create(TCollectionItemB);
FChildCollection.Init(GetStringPart(Param,2));
end;
procedure TCollectionItemA.SetName(
const Value:
string);
begin
FName := Value;
end;
{ TCollectionItemB }
function TCollectionItemB.getVSTBezeichner:
string;
begin
result:=FText;
end;
procedure TCollectionItemB.Init(
const Param:
string);
begin
xID:=StrToInt(GetStringPart(Param,1));
AuthReq:=StrToInt(GetStringPart(Param,2));
Text:=GetStringPart(Param,3);
end;
procedure TCollectionItemB.SetAuthReq(
const Value: Integer);
begin
FAuthReq := Value;
end;
procedure TCollectionItemB.SetText(
const Value:
string);
begin
FText := Value;
end;
procedure TCollectionItemB.SetxID(
const Value: Integer);
begin
FxID := Value;
end;