X
xzh2000
Unregistered / Unconfirmed
GUEST, unregistred user!
大家帮我看看为什么TextStream属性与FTextStream的实现
代码,为什么这么难理解哦?
unit decorator;
interface
uses
SysUtils, Windows, Messages, Classes, Graphics, Controls,
Forms, Dialogs;
type
TTextStream = class (TObject)
private
function GetEndOfText: Boolean
virtual
abstract;
public
function ReadLine: string
virtual
abstract;
procedure WriteLine(const Value: String)
virtual
abstract;
property EndOfText: Boolean read GetEndOfText;
end;
TTextFilter = class (TTextStream)
private
FOwnsTextStream: Boolean;
FTextStream: TTextStream
{注意这个。。。。。。}
function GetTextStream: TTextStream;
procedure SetTextStream(Value: TTextStream);
public
constructor Create(ATextStream: TTextStream
AOwnsTextStream: Boolean);
destructor Destroy
override;
property OwnsTextStream: Boolean read FOwnsTextStream write FOwnsTextStream;
property TextStream: TTextStream read GetTextStream write SetTextStream;
{注意这个。。。。。。}
end;
implementation
{
********************************* TTextFilter **********************************
}
constructor TTextFilter.Create(ATextStream: TTextStream
AOwnsTextStream:
Boolean);
begin
inherited Create;
TextStream := ATextStream
{注意这个。。。。。。}
OwnsTextStream := AOwnsTextStream;
end;
destructor TTextFilter.Destroy;
begin
TextStream := nil;
inherited Destroy;
end;
function TTextFilter.GetTextStream: TTextStream;
begin
Result := FTextStream;
end;
procedure TTextFilter.SetTextStream(Value: TTextStream);
begin
if Value <> FTextStream then
begin
if OwnsTextStream then FTextStream.Free;
FTextStream := Value
{注意这个。。。。。。}
end;
end;
end.
为什么TextStream与FTextStream一点关系都没有哦?
代码,为什么这么难理解哦?
unit decorator;
interface
uses
SysUtils, Windows, Messages, Classes, Graphics, Controls,
Forms, Dialogs;
type
TTextStream = class (TObject)
private
function GetEndOfText: Boolean
virtual
abstract;
public
function ReadLine: string
virtual
abstract;
procedure WriteLine(const Value: String)
virtual
abstract;
property EndOfText: Boolean read GetEndOfText;
end;
TTextFilter = class (TTextStream)
private
FOwnsTextStream: Boolean;
FTextStream: TTextStream
{注意这个。。。。。。}
function GetTextStream: TTextStream;
procedure SetTextStream(Value: TTextStream);
public
constructor Create(ATextStream: TTextStream
AOwnsTextStream: Boolean);
destructor Destroy
override;
property OwnsTextStream: Boolean read FOwnsTextStream write FOwnsTextStream;
property TextStream: TTextStream read GetTextStream write SetTextStream;
{注意这个。。。。。。}
end;
implementation
{
********************************* TTextFilter **********************************
}
constructor TTextFilter.Create(ATextStream: TTextStream
AOwnsTextStream:
Boolean);
begin
inherited Create;
TextStream := ATextStream
{注意这个。。。。。。}
OwnsTextStream := AOwnsTextStream;
end;
destructor TTextFilter.Destroy;
begin
TextStream := nil;
inherited Destroy;
end;
function TTextFilter.GetTextStream: TTextStream;
begin
Result := FTextStream;
end;
procedure TTextFilter.SetTextStream(Value: TTextStream);
begin
if Value <> FTextStream then
begin
if OwnsTextStream then FTextStream.Free;
FTextStream := Value
{注意这个。。。。。。}
end;
end;
end.
为什么TextStream与FTextStream一点关系都没有哦?