Registriert seit: 12. Dez 2004
Ort: Wien, Österriech
893 Beiträge
Delphi 6 Enterprise
|
Re: Stream-Problem
13. Mai 2006, 18:23
IMO, ist das, das Beste lösung:
Delphi-Quellcode:
type
TmyFileStream = class(TFileStream)
procedure WriteString( myString:string );
procedure WriteInteger( myInteger:Integer );
procedure WriteSingle( mySingle:Single );
procedure WriteDouble( myDouble:Double);
function ReadSingle():Single;
function ReadDouble():Double;
function ReadString():string;
function ReadInteger():Integer;
end;
implementation
{ TmyFileStream }
function TmyFileStream.ReadDouble: Double;
begin
Read( Result, SizeOf( Double ) );
end;
function TmyFileStream.ReadInteger: Integer;
begin
Read( Result, SizeOf( Integer ) );
end;
function TmyFileStream.ReadSingle: Single;
begin
Read( Result, SizeOf( Single ) );
end;
function TmyFileStream.ReadString: string;
var
len:Integer;
begin
Read( len, SizeOf(len) );
SetLength( Result, len );
Read( Result[1], len );
end;
procedure TmyFileStream.WriteDouble(myDouble: Double);
begin
Write( myDouble, SizeOf(myDouble) );
end;
procedure TmyFileStream.WriteInteger(myInteger: Integer);
begin
Write( myInteger, SizeOf(myInteger) );
end;
procedure TmyFileStream.WriteSingle(mySingle: Single);
begin
Write( mySingle, SizeOf(mySingle) );
end;
procedure TmyFileStream.WriteString(myString: string);
var
len:Integer;
begin
len := Length( myString );
Write( len, SizeOf(len) );
Write( myString[1], Len );
end;
Katura Haris Es (ein gutes Wort) ist wie ein guter Baum, dessen Wurzel fest ist und dessen Zweige in den Himmel reichen.
|
|
Zitat
|