Autor Beitrag
cbs
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 207
Erhaltene Danke: 1



BeitragVerfasst: Sa 17.01.04 16:10 
hallo zusammen.

ich möchte mir ein neues Stream object mit neuen methoden erstellen was sowohl mit TMemoryStream als auch mit TFileStream zurechtkommt. da is für mich egal ist ob der stream im speicher oder auf platte liegt

ich hab mir das so vorgestellt, das ich ein internes (private) object vom typ TStream speichere und es einfach jeweils mit TMemoryStream oder mit TFileStream erstelle. meine frage ist jetzt ob es probleme beim erstellen oder freigeben dieses objects gibt. ich gebe ja dann beispielsweise kein TMemoryStream object frei sondern ein TStream-Object welches aber als TMemoryStream erstellt wurde.

alle klarheiten beseitigt? :lol:

hier mal ein code schnipsel wie ich mir das vorstelle:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
  TDataFile = class(TObject)
  private
    FStream: TStream;
  protected
  public
    constructor Create; overload;
    constructor Create(const FileName: string; Mode: Word); overload;
    destructor Destroy; override;
  end;

implementation

{ TDataFile }

constructor TDataFile.Create;
begin
  FStream:= TMemoryStream.Create;
end;

constructor TDataFile.Create(const FileName: string; Mode: Word);
begin
  FStream:= TFilestream.Create(FileName, Mode);
end;

destructor TDataFile.Destroy;
begin
  FreeAndNil(FStream);
  inherited;
end;


danke schonmal !
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: Sa 17.01.04 18:01 
Kannst du problemlos so machen...! :)

_________________
gringo pussy cats - eef i see you i will pull your tail out by eets roots!
cbs Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 207
Erhaltene Danke: 1



BeitragVerfasst: Sa 17.01.04 20:33 
oki, super

danke! :D :D

ich hätte jetzt vermutet das evtl speicherlegs entstehen wenn ich das object freigebe, da z.b. TFileStream zwar von TStream abgeleitet ist aber trotzdem unterm strich ne andere struktur hat.