mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-03 15:50:26 +02:00
* Small cleanup of TTextReader interface
git-svn-id: trunk@34727 -
This commit is contained in:
parent
9c81e90e08
commit
8c1ebcd4ad
@ -86,13 +86,14 @@ type
|
||||
{ TTextReader }
|
||||
|
||||
TTextReader = class(TObject)
|
||||
Protected
|
||||
function IsEof: Boolean; virtual; abstract;
|
||||
public
|
||||
constructor Create; virtual;
|
||||
procedure Reset; virtual; abstract;
|
||||
procedure Close; virtual; abstract;
|
||||
function IsEof: Boolean; virtual; abstract;
|
||||
procedure ReadLine(out AString: string); virtual; abstract; overload;
|
||||
function ReadLine: string; virtual; abstract; overload;
|
||||
function ReadLine: string; overload;
|
||||
property Eof: Boolean read IsEof;
|
||||
end;
|
||||
|
||||
@ -106,6 +107,8 @@ type
|
||||
FStream: TStream;
|
||||
FBuffer: array of Byte;
|
||||
procedure FillBuffer;
|
||||
Protected
|
||||
function IsEof: Boolean; override;
|
||||
public
|
||||
constructor Create(AStream: TStream; ABufferSize: Integer;
|
||||
AOwnsStream: Boolean); virtual;
|
||||
@ -113,9 +116,7 @@ type
|
||||
destructor Destroy; override;
|
||||
procedure Reset; override;
|
||||
procedure Close; override;
|
||||
function IsEof: Boolean; override;
|
||||
procedure ReadLine(out AString: string); override; overload;
|
||||
function ReadLine: string; override; overload;
|
||||
property BaseStream: TStream read FStream;
|
||||
property OwnsStream: Boolean read FOwnsStream write FOwnsStream;
|
||||
end;
|
||||
@ -125,15 +126,15 @@ type
|
||||
TStringReader = class(TTextReader)
|
||||
private
|
||||
FReader: TTextReader;
|
||||
Protected
|
||||
function IsEof: Boolean; override;
|
||||
public
|
||||
constructor Create(const AString: string; ABufferSize: Integer); virtual;
|
||||
constructor Create(const AString: string); virtual;
|
||||
destructor Destroy; override;
|
||||
procedure Reset; override;
|
||||
procedure Close; override;
|
||||
function IsEof: Boolean; override;
|
||||
procedure ReadLine(out AString: string); override; overload;
|
||||
function ReadLine: string; override; overload;
|
||||
end;
|
||||
|
||||
{ TFileReader }
|
||||
@ -141,6 +142,8 @@ type
|
||||
TFileReader = class(TTextReader)
|
||||
private
|
||||
FReader: TTextReader;
|
||||
Protected
|
||||
function IsEof: Boolean; override;
|
||||
public
|
||||
constructor Create(const AFileName: TFileName; AMode: Word;
|
||||
ARights: Cardinal; ABufferSize: Integer); virtual;
|
||||
@ -151,9 +154,7 @@ type
|
||||
destructor Destroy; override;
|
||||
procedure Reset; override;
|
||||
procedure Close; override;
|
||||
function IsEof: Boolean; override;
|
||||
procedure ReadLine(out AString: string); override; overload;
|
||||
function ReadLine: string; override; overload;
|
||||
end;
|
||||
|
||||
{ allows you to represent just a small window of a bigger stream as a substream.
|
||||
@ -331,6 +332,12 @@ begin
|
||||
inherited Create;
|
||||
end;
|
||||
|
||||
function TTextReader.ReadLine: string;
|
||||
|
||||
begin
|
||||
ReadLine(Result);
|
||||
end;
|
||||
|
||||
{ TStreamReader }
|
||||
|
||||
constructor TStreamReader.Create(AStream: TStream; ABufferSize: Integer;
|
||||
@ -441,10 +448,6 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function TStreamReader.ReadLine: string;
|
||||
begin
|
||||
ReadLine(Result);
|
||||
end;
|
||||
|
||||
{ TStringReader }
|
||||
|
||||
@ -485,11 +488,6 @@ begin
|
||||
FReader.ReadLine(AString);
|
||||
end;
|
||||
|
||||
function TStringReader.ReadLine: string;
|
||||
begin
|
||||
ReadLine(Result);
|
||||
end;
|
||||
|
||||
{ TFileReader }
|
||||
|
||||
constructor TFileReader.Create(const AFileName: TFileName; AMode: Word;
|
||||
@ -542,11 +540,6 @@ begin
|
||||
FReader.ReadLine(AString);
|
||||
end;
|
||||
|
||||
function TFileReader.ReadLine: string;
|
||||
begin
|
||||
ReadLine(Result);
|
||||
end;
|
||||
|
||||
{ TStreamHelper }
|
||||
|
||||
function TStreamHelper.readwordLE:word;
|
||||
|
Loading…
Reference in New Issue
Block a user