Type
Tlargefile_reader_base =
Class(TInterfacedObject, Ilargefileimporter)
Private
Private
Content: Tbytes;
Fendianess: Tendianess;
Fchunksize: Tfilereadchunksize;
Private
//..
end;
//..
Procedure Tlargefile_reader_base.Loadstream(Stream: Tstream;
Endianess: Tendianess = Bigendian);
Begin
Setlength(Content, Stream.Size);
Stream.Position := 0;
If Endianess = Bigendian
Then
Stream.ReadBuffer(Content, Stream.Size)
// standard little endian
Else
Raise Exception.Create('
Loading Little-Endian coded files not implemented');
Fendianess := Endianess;
End;
Procedure Tlargefile_reader_base.Setastext(Atext:
String);
Var
P: Pchar;
C: PByte;
Max: Pchar;
Begin
Setlength(Content, Length(Atext));
Max := @Atext[Length(Atext)];
// last element
P := @Atext[1];
C := @Content[0];
While P <> Max
Do
Begin
C^ := Ord(P^);
Inc(C);
Inc(P);
End;
// last element
C^ := Ord(P^);
// Inc(C);
// Inc(P);
End;
Function Tlargefile_reader_base.Getastext:
String;
Var
C: PByte;
P: Pchar;
Max: PByte;
Begin
// Result := Utils.Bytestostr(content);
Max := @Content[High(Content)];
// last element
Setlength(Result, Length(Content));
P := @Result[1];
C := @Content[0];
// for c in self.content do
While C <> Max
Do
Begin
P^ := Char(C^);
Inc(P);
Inc(C, Bytesize);
End;
// last element
P^ := Char(C^);
End;