Browse Source

* Merging revisions 42021,42040,42041,42042 from trunk:
------------------------------------------------------------------------
r42021 | michael | 2019-05-07 17:40:00 +0200 (Tue, 07 May 2019) | 1 line

* GetPrimaryIndexFields is now a public class method, needed in designer
------------------------------------------------------------------------
r42040 | michael | 2019-05-12 09:51:38 +0200 (Sun, 12 May 2019) | 1 line

* Patch from Ondrej Pokorny to fix bug ID #35544 (accept short timezones)
------------------------------------------------------------------------
r42041 | michael | 2019-05-12 09:54:02 +0200 (Sun, 12 May 2019) | 1 line

* Add largeint (int64) parameter supportby Silvio Clecio (bug ID 35554)
------------------------------------------------------------------------
r42042 | michael | 2019-05-12 12:09:16 +0200 (Sun, 12 May 2019) | 1 line

* Add Read/Write(Buffer) TBytes, ReadData/WriteData, ReadBufferData/WriteBufferData to be Delphi compatible
------------------------------------------------------------------------

git-svn-id: branches/fixes_3_2@42424 -

michael 6 years ago
parent
commit
8c43258e68

+ 2 - 1
packages/fcl-db/src/sqldb/oracle/oracleconnection.pp

@@ -1,7 +1,7 @@
 unit oracleconnection;
 
 {
-    Copyright (c) 2006-2014 by Joost van der Sluis, FPC contributors
+    Copyright (c) 2006-2019 by Joost van der Sluis, FPC contributors
 
     Oracle RDBMS connector using the OCI protocol
 
@@ -358,6 +358,7 @@ begin
 
       case DataType of
         ftInteger         : AsInteger := PInteger(ParamBuffers[i].buffer)^;
+        ftLargeint        : AsLargeInt := PInt64(ParamBuffers[i].buffer)^;
         ftFloat           : AsFloat := PDouble(ParamBuffers[i].buffer)^;
         ftString          : begin
                             SetLength(s,ParamBuffers[i].Len);

+ 2 - 2
packages/fcl-web/src/restbridge/sqldbrestschema.pp

@@ -256,7 +256,6 @@ Type
     procedure SetResources(AValue: TSQLDBRestResourceList);
   Protected
     function CreateResourceList: TSQLDBRestResourceList; virtual;
-    function GetPrimaryIndexFields(Q: TSQLQuery): TStringArray; virtual;
     function ProcessIdentifier(const S: UTF8String): UTF8String; virtual;
     Function AttachProcessor(aProcessor : TSQLDBRestCustomBusinessProcessor) : Boolean; Virtual;
     Function DetachProcessor(aProcessor : TSQLDBRestCustomBusinessProcessor) : Boolean; Virtual;
@@ -273,6 +272,7 @@ Type
     Procedure LoadFromFile(Const aFileName : UTF8String);
     Procedure LoadFromStream(Const aStream : TStream);
     Procedure FromJSON(aData: TJSONData;const aPropName: UTF8String='');
+    Class function GetPrimaryIndexFields(Q: TSQLQuery): TStringArray; virtual;
     procedure PopulateResourceFields(aConn: TSQLConnection; aRes: TSQLDBRestResource; aMinFieldOpts : TRestFieldOptions = []); virtual;
     procedure PopulateResources(aConn: TSQLConnection; aTables: array of string; aMinFieldOpts: TRestFieldOptions= []);
     Procedure PopulateResources(aConn : TSQLConnection; aTables : TStrings = Nil; aMinFieldOpts : TRestFieldOptions = []);
@@ -627,7 +627,7 @@ begin
 end;
 
 
-function TSQLDBRestSchema.GetPrimaryIndexFields(Q: TSQLQuery): TStringArray;
+class function TSQLDBRestSchema.GetPrimaryIndexFields(Q: TSQLQuery): TStringArray;
 
 Var
   C,I : Integer;

+ 22 - 3
packages/rtl-objpas/src/inc/dateutil.inc

@@ -448,7 +448,7 @@ function TryISOStrToTime(const aString: string; Out outTime: TDateTime): Boolean
 // Combination of previous
 function TryISOStrToDateTime(const aString: string; out outDateTime: TDateTime): Boolean;
 // Z +hh:nn -hh:nn
-Function TryISOTZStrToTZOffset(TZ : String; Out TZOffset : Integer) : boolean;
+Function TryISOTZStrToTZOffset(const TZ : String; Out TZOffset : Integer) : boolean;
 
 // ISO 8601 Date/Time formatting
 
@@ -2857,7 +2857,7 @@ begin
     outDateTime := 0;
 end;
 
-Function TryISOTZStrToTZOffset(TZ : String; Out TZOffset : Integer) : boolean;
+Function TryISOTZStrToTZOffset(const TZ : String; Out TZOffset : Integer) : boolean;
 
 Var
   H,M : LongInt;
@@ -2871,7 +2871,16 @@ begin
     Result:=TZ[1] in ['+','-'];
     if Not Result then
       Exit;
-    Result:=TryStrToInt(Copy(TZ,2,2),H) and TryStrToInt(Copy(TZ,5,2),M);
+    case Length(TZ) of
+      3: begin
+        Result:=TryStrToInt(Copy(TZ,2,2),H);
+        M := 0;
+      end;
+      5: Result:=TryStrToInt(Copy(TZ,2,2),H) and TryStrToInt(Copy(TZ,4,2),M);
+      6: Result:=TryStrToInt(Copy(TZ,2,2),H) and TryStrToInt(Copy(TZ,5,2),M);
+    else
+      Result := False;
+    end;
     if not Result then
       exit;
     TZOffset:=H*60+M;
@@ -2904,6 +2913,16 @@ begin
     TZ:='Z';
     S:=Copy(S,1,L-1);
     end
+  else If (L>2) and (S[L-2] in ['+','-']) then
+    begin
+    TZ:=Copy(S,L-2,3);
+    S:=Copy(S,1,L-3);
+    end
+  else If (L>4) and (S[L-4] in ['+','-']) then
+    begin
+    TZ:=Copy(S,L-4,5);
+    S:=Copy(S,1,L-5);
+    end
   else If (L>5) and (S[L-5] in ['+','-']) then
     begin
     TZ:=Copy(S,L-5,6);

+ 147 - 0
rtl/objpas/classes/classesh.inc

@@ -887,13 +887,158 @@ type
     procedure SetSize(const NewSize: Int64); virtual;overload;
     procedure ReadNotImplemented;
     procedure WriteNotImplemented;
+    function ReadMaxSizeData(Var Buffer; aSize,aCount : NativeInt) : NativeInt;
+    Procedure ReadExactSizeData(Var Buffer; aSize,aCount : NativeInt);
+    function WriteMaxSizeData(Const Buffer; aSize,aCount : NativeInt) : NativeInt;
+    Procedure WriteExactSizeData(Const Buffer; aSize,aCount : NativeInt);
   public
     function Read(var Buffer; Count: Longint): Longint; virtual;
+    function Read(Buffer: TBytes; Count: Longint): Longint; overload;
+    function Read(Buffer : TBytes; aOffset, Count: Longint): Longint; overload;
+
+    function Write(const Buffer: TBytes; Offset, Count: Longint): Longint; overload;
+    function Write(const Buffer: TBytes; Count: Longint): Longint; overload;
     function Write(const Buffer; Count: Longint): Longint; virtual;
+
     function Seek(Offset: Longint; Origin: Word): Longint; virtual; overload;
     function Seek(const Offset: Int64; Origin: TSeekOrigin): Int64; virtual; overload;
+
+    function ReadData(Buffer: Pointer; Count: NativeInt): NativeInt; overload;
+    function ReadData(const Buffer: TBytes; Count: NativeInt): NativeInt; overload;
+    function ReadData(var Buffer: Boolean): NativeInt; overload;
+    function ReadData(var Buffer: Boolean; Count: NativeInt): NativeInt; overload;
+    function ReadData(var Buffer: AnsiChar): NativeInt; overload;
+    function ReadData(var Buffer: AnsiChar; Count: NativeInt): NativeInt; overload;
+    function ReadData(var Buffer: WideChar): NativeInt; overload;
+    function ReadData(var Buffer: WideChar; Count: NativeInt): NativeInt; overload;
+    function ReadData(var Buffer: Int8): NativeInt; overload;
+    function ReadData(var Buffer: Int8; Count: NativeInt): NativeInt; overload;
+    function ReadData(var Buffer: UInt8): NativeInt; overload;
+    function ReadData(var Buffer: UInt8; Count: NativeInt): NativeInt; overload;
+    function ReadData(var Buffer: Int16): NativeInt; overload;
+    function ReadData(var Buffer: Int16; Count: NativeInt): NativeInt; overload;
+    function ReadData(var Buffer: UInt16): NativeInt; overload;
+    function ReadData(var Buffer: UInt16; Count: NativeInt): NativeInt; overload;
+    function ReadData(var Buffer: Int32): NativeInt; overload;
+    function ReadData(var Buffer: Int32; Count: NativeInt): NativeInt; overload;
+    function ReadData(var Buffer: UInt32): NativeInt; overload;
+    function ReadData(var Buffer: UInt32; Count: NativeInt): NativeInt; overload;
+    function ReadData(var Buffer: Int64): NativeInt; overload;
+    function ReadData(var Buffer: Int64; Count: NativeInt): NativeInt; overload;
+    function ReadData(var Buffer: UInt64): NativeInt; overload;
+    function ReadData(var Buffer: UInt64; Count: NativeInt): NativeInt; overload;
+    function ReadData(var Buffer: Single): NativeInt; overload;
+    function ReadData(var Buffer: Single; Count: NativeInt): NativeInt; overload;
+    function ReadData(var Buffer: Double): NativeInt; overload;
+    function ReadData(var Buffer: Double; Count: NativeInt): NativeInt; overload;
+    function ReadData(var Buffer: Extended): NativeInt; overload;
+    function ReadData(var Buffer: Extended; Count: NativeInt): NativeInt; overload;
+    function ReadData(var Buffer: TExtended80Rec): NativeInt; overload;
+    function ReadData(var Buffer: TExtended80Rec; Count: NativeInt): NativeInt; overload;
+
     procedure ReadBuffer(var Buffer; Count: Longint);
+    procedure ReadBuffer(var Buffer: TBytes; Count: NativeInt); overload;
+    procedure ReadBuffer(var Buffer: TBytes; Offset, Count: NativeInt); overload;
+
+    procedure ReadBufferData(var Buffer: Boolean); overload;
+    procedure ReadBufferData(var Buffer: Boolean; Count: NativeInt); overload;
+    procedure ReadBufferData(var Buffer: AnsiChar); overload;
+    procedure ReadBufferData(var Buffer: AnsiChar; Count: NativeInt); overload;
+    procedure ReadBufferData(var Buffer: WideChar); overload;
+    procedure ReadBufferData(var Buffer: WideChar; Count: NativeInt); overload;
+    procedure ReadBufferData(var Buffer: Int8); overload;
+    procedure ReadBufferData(var Buffer: Int8; Count: NativeInt); overload;
+    procedure ReadBufferData(var Buffer: UInt8); overload;
+    procedure ReadBufferData(var Buffer: UInt8; Count: NativeInt); overload;
+    procedure ReadBufferData(var Buffer: Int16); overload;
+    procedure ReadBufferData(var Buffer: Int16; Count: NativeInt); overload;
+    procedure ReadBufferData(var Buffer: UInt16); overload;
+    procedure ReadBufferData(var Buffer: UInt16; Count: NativeInt); overload;
+    procedure ReadBufferData(var Buffer: Int32); overload;
+    procedure ReadBufferData(var Buffer: Int32; Count: NativeInt); overload;
+    procedure ReadBufferData(var Buffer: UInt32); overload;
+    procedure ReadBufferData(var Buffer: UInt32; Count: NativeInt); overload;
+    procedure ReadBufferData(var Buffer: Int64); overload;
+    procedure ReadBufferData(var Buffer: Int64; Count: NativeInt); overload;
+    procedure ReadBufferData(var Buffer: UInt64); overload;
+    procedure ReadBufferData(var Buffer: UInt64; Count: NativeInt); overload;
+    procedure ReadBufferData(var Buffer: Single); overload;
+    procedure ReadBufferData(var Buffer: Single; Count: NativeInt); overload;
+    procedure ReadBufferData(var Buffer: Double); overload;
+    procedure ReadBufferData(var Buffer: Double; Count: NativeInt); overload;
+    procedure ReadBufferData(var Buffer: Extended); overload;
+    procedure ReadBufferData(var Buffer: Extended; Count: NativeInt); overload;
+    procedure ReadBufferData(var Buffer: TExtended80Rec); overload;
+    procedure ReadBufferData(var Buffer: TExtended80Rec; Count: NativeInt); overload;
+
     procedure WriteBuffer(const Buffer; Count: Longint);
+    procedure WriteBuffer(const Buffer: TBytes; Count: NativeInt); overload;
+    procedure WriteBuffer(const Buffer: TBytes; Offset, Count: NativeInt); overload;
+
+    function WriteData(const Buffer: TBytes; Count: NativeInt): NativeInt; overload;
+    function WriteData(const Buffer: Pointer; Count: NativeInt): NativeInt; overload;
+    function WriteData(const Buffer: Boolean): NativeInt; overload;
+    function WriteData(const Buffer: Boolean; Count: NativeInt): NativeInt; overload;
+    function WriteData(const Buffer: AnsiChar): NativeInt; overload;
+    function WriteData(const Buffer: AnsiChar; Count: NativeInt): NativeInt; overload;
+    function WriteData(const Buffer: WideChar): NativeInt; overload;
+    function WriteData(const Buffer: WideChar; Count: NativeInt): NativeInt; overload;
+    function WriteData(const Buffer: Int8): NativeInt; overload;
+    function WriteData(const Buffer: Int8; Count: NativeInt): NativeInt; overload;
+    function WriteData(const Buffer: UInt8): NativeInt; overload;
+    function WriteData(const Buffer: UInt8; Count: NativeInt): NativeInt; overload;
+    function WriteData(const Buffer: Int16): NativeInt; overload;
+    function WriteData(const Buffer: Int16; Count: NativeInt): NativeInt; overload;
+    function WriteData(const Buffer: UInt16): NativeInt; overload;
+    function WriteData(const Buffer: UInt16; Count: NativeInt): NativeInt; overload;
+    function WriteData(const Buffer: Int32): NativeInt; overload;
+    function WriteData(const Buffer: Int32; Count: NativeInt): NativeInt; overload;
+    function WriteData(const Buffer: UInt32): NativeInt; overload;
+    function WriteData(const Buffer: UInt32; Count: NativeInt): NativeInt; overload;
+    function WriteData(const Buffer: Int64): NativeInt; overload;
+    function WriteData(const Buffer: Int64; Count: NativeInt): NativeInt; overload;
+    function WriteData(const Buffer: UInt64): NativeInt; overload;
+    function WriteData(const Buffer: UInt64; Count: NativeInt): NativeInt; overload;
+    function WriteData(const Buffer: Single): NativeInt; overload;
+    function WriteData(const Buffer: Single; Count: NativeInt): NativeInt; overload;
+    function WriteData(const Buffer: Double): NativeInt; overload;
+    function WriteData(const Buffer: Double; Count: NativeInt): NativeInt; overload;
+    function WriteData(const Buffer: Extended): NativeInt; overload;
+    function WriteData(const Buffer: Extended; Count: NativeInt): NativeInt; overload;
+    function WriteData(const Buffer: TExtended80Rec): NativeInt; overload;
+    function WriteData(const Buffer: TExtended80Rec; Count: NativeInt): NativeInt; overload;
+
+    procedure WriteBufferData(Buffer: Integer); overload;
+    procedure WriteBufferData(Buffer: Integer; Count: NativeInt); overload;
+    procedure WriteBufferData(Buffer: Boolean); overload;
+    procedure WriteBufferData(Buffer: Boolean; Count: NativeInt); overload;
+    procedure WriteBufferData(Buffer: AnsiChar); overload;
+    procedure WriteBufferData(Buffer: AnsiChar; Count: NativeInt); overload;
+    procedure WriteBufferData(Buffer: WideChar); overload;
+    procedure WriteBufferData(Buffer: WideChar; Count: NativeInt); overload;
+    procedure WriteBufferData(Buffer: Int8); overload;
+    procedure WriteBufferData(Buffer: Int8; Count: NativeInt); overload;
+    procedure WriteBufferData(Buffer: UInt8); overload;
+    procedure WriteBufferData(Buffer: UInt8; Count: NativeInt); overload;
+    procedure WriteBufferData(Buffer: Int16); overload;
+    procedure WriteBufferData(Buffer: Int16; Count: NativeInt); overload;
+    procedure WriteBufferData(Buffer: UInt16); overload;
+    procedure WriteBufferData(Buffer: UInt16; Count: NativeInt); overload;
+    procedure WriteBufferData(Buffer: UInt32); overload;
+    procedure WriteBufferData(Buffer: UInt32; Count: NativeInt); overload;
+    procedure WriteBufferData(Buffer: Int64); overload;
+    procedure WriteBufferData(Buffer: Int64; Count: NativeInt); overload;
+    procedure WriteBufferData(Buffer: UInt64); overload;
+    procedure WriteBufferData(Buffer: UInt64; Count: NativeInt); overload;
+    procedure WriteBufferData(Buffer: Single); overload;
+    procedure WriteBufferData(Buffer: Single; Count: NativeInt); overload;
+    procedure WriteBufferData(Buffer: Double); overload;
+    procedure WriteBufferData(Buffer: Double; Count: NativeInt); overload;
+    procedure WriteBufferData(Buffer: Extended); overload;
+    procedure WriteBufferData(Buffer: Extended; Count: NativeInt); overload;
+    procedure WriteBufferData(Buffer: TExtended80Rec); overload;
+    procedure WriteBufferData(Buffer: TExtended80Rec; Count: NativeInt); overload;
+
     function CopyFrom(Source: TStream; Count: Int64): Int64;
     function ReadComponent(Instance: TComponent): TComponent;
     function ReadComponentRes(Instance: TComponent): TComponent;
@@ -983,6 +1128,7 @@ type
   private
     FMemory: Pointer;
     FSize, FPosition: PtrInt;
+    FSizeBoundsSeek : Boolean;
   protected
     Function GetSize : Int64; Override;
     function GetPosition: Int64; Override;
@@ -993,6 +1139,7 @@ type
     procedure SaveToStream(Stream: TStream);
     procedure SaveToFile(const FileName: string);
     property Memory: Pointer read FMemory;
+    Property SizeBoundsSeek : Boolean Read FSizeBoundsSeek Write FSizeBoundsSeek;
   end;
 
 { TMemoryStream }

+ 728 - 21
rtl/objpas/classes/streams.inc

@@ -30,6 +30,26 @@ begin
   Result := 0;
 end;
 
+function TStream.Read(Buffer: TBytes; Count: Longint): Longint;
+begin
+  Result:=Read(Buffer,0,Count);
+end;
+
+function TStream.Read(Buffer: TBytes; aOffset, Count: Longint): Longint;
+begin
+  Result:=Read(Buffer[aOffset],Count);
+end;
+
+function TStream.Write(const Buffer: TBytes; Offset, Count: Longint): Longint;
+begin
+  Result:=Write(Buffer[Offset],Count);
+end;
+
+function TStream.Write(const Buffer: TBytes; Count: Longint): Longint;
+begin
+  Result:=Write(Buffer,0,Count);
+end;
+
 function TStream.Write(const Buffer; Count: Longint): Longint;
 begin
   WriteNotImplemented;
@@ -178,35 +198,719 @@ end;
       Result:=Seek(longint(Offset),ord(Origin));
     end;
 
-  procedure TStream.ReadBuffer(var Buffer; Count: Longint);
+ function TStream.ReadData(Buffer: Pointer; Count: NativeInt): NativeInt;
+ begin
+   Result:=Read(Buffer^,Count);
+ end;
 
-  Var
-    r,t : longint;
+ function TStream.ReadData(const Buffer: TBytes; Count: NativeInt): NativeInt;
+ begin
+   Result:=Read(Buffer,0,Count);
+ end;
+
+ function TStream.ReadData(var Buffer: Boolean): NativeInt;
+ begin
+   Result:=Read(Buffer,sizeOf(Buffer));
+ end;
+
+function TStream.ReadMaxSizeData(Var Buffer; aSize,aCount : NativeInt) : NativeInt;
+
+Var
+  CP : Int64;
+
+begin
+  if aCount<=aSize then
+    Result:=read(Buffer,aCount)
+  else
+    begin
+    Result:=Read(Buffer,aSize);
+    CP:=Position;
+    Result:=Result+Seek(aCount-aSize,soCurrent)-CP;
+    end
+end;
+
+function TStream.WriteMaxSizeData(Const Buffer; aSize,aCount : NativeInt) : NativeInt;
+Var
+  CP : Int64;
+
+begin
+  if aCount<=aSize then
+    Result:=Write(Buffer,aCount)
+  else
+    begin
+    Result:=Write(Buffer,aSize);
+    CP:=Position;
+    Result:=Result+Seek(aCount-aSize,soCurrent)-CP;
+    end
+end;
+
+procedure TStream.WriteExactSizeData(const Buffer; aSize, aCount: NativeInt);
+begin
+  // Embarcadero docs mentions no exception. Does not seem very logical
+  WriteMaxSizeData(Buffer,aSize,ACount);
+end;
+
+procedure TStream.ReadExactSizeData(var Buffer; aSize, aCount: NativeInt);
+begin
+  if ReadMaxSizeData(Buffer,aSize,ACount)<>aCount then
+     Raise EReadError.Create(SReadError);
+end;
+
+
+function TStream.ReadData(var Buffer: Boolean; Count: NativeInt): NativeInt;
+begin
+  Result:=ReadMaxSizeData(Buffer,SizeOf(Buffer),Count);
+end;
+
+function TStream.ReadData(var Buffer: AnsiChar): NativeInt;
+begin
+  Result:=Read(Buffer,sizeOf(Buffer));
+end;
+
+function TStream.ReadData(var Buffer: AnsiChar; Count: NativeInt): NativeInt;
+begin
+  Result:=ReadMaxSizeData(Buffer,SizeOf(Buffer),Count);
+end;
+
+function TStream.ReadData(var Buffer: WideChar): NativeInt;
+begin
+ Result:=Read(Buffer,sizeOf(Buffer));
+end;
+
+function TStream.ReadData(var Buffer: WideChar; Count: NativeInt): NativeInt;
+begin
+  Result:=ReadMaxSizeData(Buffer,SizeOf(Buffer),Count);
+end;
+
+function TStream.ReadData(var Buffer: Int8): NativeInt;
+begin
+ Result:=Read(Buffer,sizeOf(Buffer));
+end;
+
+function TStream.ReadData(var Buffer: Int8; Count: NativeInt): NativeInt;
+begin
+  Result:=ReadMaxSizeData(Buffer,SizeOf(Buffer),Count);
+end;
+
+function TStream.ReadData(var Buffer: UInt8): NativeInt;
+begin
+  Result:=Read(Buffer,sizeOf(Buffer));
+end;
+
+function TStream.ReadData(var Buffer: UInt8; Count: NativeInt): NativeInt;
+begin
+  Result:=ReadMaxSizeData(Buffer,SizeOf(Buffer),Count);
+end;
+
+function TStream.ReadData(var Buffer: Int16): NativeInt;
+begin
+  Result:=Read(Buffer,sizeOf(Buffer));
+end;
+
+function TStream.ReadData(var Buffer: Int16; Count: NativeInt): NativeInt;
+begin
+  Result:=ReadMaxSizeData(Buffer,SizeOf(Buffer),Count);
+end;
+
+function TStream.ReadData(var Buffer: UInt16): NativeInt;
+begin
+  Result:=Read(Buffer,sizeOf(Buffer));
+end;
+
+function TStream.ReadData(var Buffer: UInt16; Count: NativeInt): NativeInt;
+begin
+  Result:=ReadMaxSizeData(Buffer,SizeOf(Buffer),Count);
+end;
+
+function TStream.ReadData(var Buffer: Int32): NativeInt;
+begin
+  Result:=Read(Buffer,sizeOf(Buffer));
+end;
+
+function TStream.ReadData(var Buffer: Int32; Count: NativeInt): NativeInt;
+begin
+  Result:=ReadMaxSizeData(Buffer,SizeOf(Buffer),Count);
+end;
+
+function TStream.ReadData(var Buffer: UInt32): NativeInt;
+begin
+  Result:=Read(Buffer,sizeOf(Buffer));
+end;
+
+function TStream.ReadData(var Buffer: UInt32; Count: NativeInt): NativeInt;
+begin
+  Result:=ReadMaxSizeData(Buffer,SizeOf(Buffer),Count);
+end;
+
+function TStream.ReadData(var Buffer: Int64): NativeInt;
+begin
+  Result:=Read(Buffer,sizeOf(Buffer));
+end;
+
+function TStream.ReadData(var Buffer: Int64; Count: NativeInt): NativeInt;
+begin
+  Result:=ReadMaxSizeData(Buffer,SizeOf(Buffer),Count);
+end;
+
+function TStream.ReadData(var Buffer: UInt64): NativeInt;
+begin
+ Result:=Read(Buffer,sizeOf(Buffer));
+end;
+
+function TStream.ReadData(var Buffer: UInt64; Count: NativeInt): NativeInt;
+begin
+  Result:=ReadMaxSizeData(Buffer,SizeOf(Buffer),Count);
+end;
+
+function TStream.ReadData(var Buffer: Single): NativeInt;
+begin
+  Result:=Read(Buffer,sizeOf(Buffer));
+end;
+
+function TStream.ReadData(var Buffer: Single; Count: NativeInt): NativeInt;
+begin
+  Result:=ReadMaxSizeData(Buffer,SizeOf(Buffer),Count);
+end;
+
+function TStream.ReadData(var Buffer: Double): NativeInt;
+begin
+  Result:=Read(Buffer,sizeOf(Buffer));
+end;
+
+function TStream.ReadData(var Buffer: Double; Count: NativeInt): NativeInt;
+begin
+  Result:=ReadMaxSizeData(Buffer,SizeOf(Buffer),Count);
+end;
+
+function TStream.ReadData(var Buffer: Extended): NativeInt;
+begin
+  Result:=Read(Buffer,sizeOf(Buffer));
+end;
+
+function TStream.ReadData(var Buffer: Extended; Count: NativeInt): NativeInt;
+begin
+  Result:=ReadMaxSizeData(Buffer,SizeOf(Buffer),Count);
+end;
+
+function TStream.ReadData(var Buffer: TExtended80Rec): NativeInt;
+begin
+  Result:=Read(Buffer,sizeOf(Buffer));
+end;
+
+function TStream.ReadData(var Buffer: TExtended80Rec; Count: NativeInt): NativeInt;
+begin
+  Result:=ReadMaxSizeData(Buffer,SizeOf(Buffer),Count);
+end;
+
+procedure TStream.ReadBuffer(var Buffer; Count: Longint);
+
+Var
+  r,t : longint;
+
+begin
+  t:=0;
+  repeat
+    r:=Read(PByte(@Buffer)[t],Count-t);
+    inc(t,r);
+  until (t=Count) or (r<=0);
+  if (t<Count) then
+    Raise EReadError.Create(SReadError);
+end;
+
+procedure TStream.ReadBuffer(var Buffer: TBytes; Count: NativeInt);
+begin
+  ReadBuffer(Buffer,0,Count);
+end;
+
+procedure TStream.ReadBuffer(var Buffer: TBytes; Offset, Count: NativeInt);
+begin
+  ReadBuffer(Buffer[OffSet],Count);
+end;
+
+procedure TStream.ReadBufferData(var Buffer: Boolean);
+begin
+  ReadBuffer(Buffer,SizeOf(Buffer));
+end;
+
+procedure TStream.ReadBufferData(var Buffer: Boolean; Count: NativeInt);
+begin
+  ReadExactSizeData(Buffer,SizeOf(Buffer),Count);
+end;
+
+procedure TStream.ReadBufferData(var Buffer: AnsiChar);
+begin
+  ReadBuffer(Buffer,SizeOf(Buffer));
+end;
+
+procedure TStream.ReadBufferData(var Buffer: AnsiChar; Count: NativeInt);
+begin
+  ReadExactSizeData(Buffer,SizeOf(Buffer),Count);
+end;
+
+procedure TStream.ReadBufferData(var Buffer: WideChar);
+begin
+  ReadBuffer(Buffer,SizeOf(Buffer));
+end;
+
+procedure TStream.ReadBufferData(var Buffer: WideChar; Count: NativeInt);
+begin
+  ReadExactSizeData(Buffer,SizeOf(Buffer),Count);
+end;
+
+procedure TStream.ReadBufferData(var Buffer: Int8);
+begin
+  ReadBuffer(Buffer,SizeOf(Buffer));
+end;
+
+procedure TStream.ReadBufferData(var Buffer: Int8; Count: NativeInt);
+begin
+  ReadExactSizeData(Buffer,SizeOf(Buffer),Count);
+end;
+
+procedure TStream.ReadBufferData(var Buffer: UInt8);
+begin
+  ReadBuffer(Buffer,SizeOf(Buffer));
+end;
+
+procedure TStream.ReadBufferData(var Buffer: UInt8; Count: NativeInt);
+begin
+  ReadExactSizeData(Buffer,SizeOf(Buffer),Count);
+end;
+
+procedure TStream.ReadBufferData(var Buffer: Int16);
+begin
+  ReadBuffer(Buffer,SizeOf(Buffer));
+end;
+
+procedure TStream.ReadBufferData(var Buffer: Int16; Count: NativeInt);
+begin
+  ReadExactSizeData(Buffer,SizeOf(Buffer),Count);
+end;
+
+procedure TStream.ReadBufferData(var Buffer: UInt16);
+begin
+  ReadBuffer(Buffer,SizeOf(Buffer));
+end;
+
+procedure TStream.ReadBufferData(var Buffer: UInt16; Count: NativeInt);
+begin
+  ReadExactSizeData(Buffer,SizeOf(Buffer),Count);
+end;
+
+procedure TStream.ReadBufferData(var Buffer: Int32);
+begin
+  ReadBuffer(Buffer,SizeOf(Buffer));
+end;
+
+procedure TStream.ReadBufferData(var Buffer: Int32; Count: NativeInt);
+begin
+  ReadExactSizeData(Buffer,SizeOf(Buffer),Count);
+end;
+
+procedure TStream.ReadBufferData(var Buffer: UInt32);
+begin
+  ReadBuffer(Buffer,SizeOf(Buffer));
+end;
+
+procedure TStream.ReadBufferData(var Buffer: UInt32; Count: NativeInt);
+begin
+  ReadExactSizeData(Buffer,SizeOf(Buffer),Count);
+end;
+
+procedure TStream.ReadBufferData(var Buffer: Int64);
+begin
+  ReadBuffer(Buffer,SizeOf(Buffer));
+end;
+
+procedure TStream.ReadBufferData(var Buffer: Int64; Count: NativeInt);
+begin
+  ReadExactSizeData(Buffer,SizeOf(Buffer),Count);
+end;
+
+procedure TStream.ReadBufferData(var Buffer: UInt64);
+begin
+  ReadBuffer(Buffer,SizeOf(Buffer));
+end;
+
+procedure TStream.ReadBufferData(var Buffer: UInt64; Count: NativeInt);
+begin
+  ReadExactSizeData(Buffer,SizeOf(Buffer),Count);
+end;
+
+procedure TStream.ReadBufferData(var Buffer: Single);
+begin
+  ReadBuffer(Buffer,SizeOf(Buffer));
+end;
+
+procedure TStream.ReadBufferData(var Buffer: Single; Count: NativeInt);
+begin
+  ReadExactSizeData(Buffer,SizeOf(Buffer),Count);
+end;
+
+procedure TStream.ReadBufferData(var Buffer: Double);
+begin
+  ReadBuffer(Buffer,SizeOf(Buffer));
+end;
+
+procedure TStream.ReadBufferData(var Buffer: Double; Count: NativeInt);
+begin
+  ReadExactSizeData(Buffer,SizeOf(Buffer),Count);
+end;
+
+procedure TStream.ReadBufferData(var Buffer: Extended);
+begin
+  ReadBuffer(Buffer,SizeOf(Buffer));
+end;
+
+procedure TStream.ReadBufferData(var Buffer: Extended; Count: NativeInt);
+begin
+  ReadExactSizeData(Buffer,SizeOf(Buffer),Count);
+end;
+
+procedure TStream.ReadBufferData(var Buffer: TExtended80Rec);
+begin
+  ReadBuffer(Buffer,SizeOf(Buffer));
+end;
+
+procedure TStream.ReadBufferData(var Buffer: TExtended80Rec; Count: NativeInt);
+begin
+  ReadExactSizeData(Buffer,SizeOf(Buffer),Count);
+end;
+
+procedure TStream.WriteBuffer(const Buffer; Count: Longint);
+
+var
+  r,t : Longint;
 
   begin
-    t:=0;
-    repeat
-      r:=Read(PByte(@Buffer)[t],Count-t);
-      inc(t,r);
-    until (t=Count) or (r<=0);
+    T:=0;
+    Repeat
+       r:=Write(PByte(@Buffer)[t],Count-t);
+       inc(t,r);
+    Until (t=count) or (r<=0);
     if (t<Count) then
-      Raise EReadError.Create(SReadError);
+       Raise EWriteError.Create(SWriteError);
   end;
 
-  procedure TStream.WriteBuffer(const Buffer; Count: Longint);
+procedure TStream.WriteBuffer(const Buffer: TBytes; Count: NativeInt);
+begin
+  WriteBuffer(Buffer,0,Count);
+end;
 
-  var
-    r,t : Longint;
+procedure TStream.WriteBuffer(const Buffer: TBytes; Offset, Count: NativeInt);
+begin
+  WriteBuffer(Buffer[Offset],Count);
+end;
 
-    begin
-      T:=0;
-      Repeat
-         r:=Write(PByte(@Buffer)[t],Count-t);
-         inc(t,r);
-      Until (t=count) or (r<=0);
-      if (t<Count) then
-         Raise EWriteError.Create(SWriteError);
-    end;
+function TStream.WriteData(const Buffer: TBytes; Count: NativeInt): NativeInt;
+begin
+  Result:=Write(Buffer, 0, Count);
+end;
+
+function TStream.WriteData(const Buffer: Pointer; Count: NativeInt): NativeInt;
+begin
+  Result:=Write(Buffer^, Count);
+end;
+
+function TStream.WriteData(const Buffer: Boolean): NativeInt;
+begin
+  Result:=Write(Buffer,SizeOf(Buffer));
+end;
+
+function TStream.WriteData(const Buffer: Boolean; Count: NativeInt): NativeInt;
+begin
+  Result:=WriteMaxSizeData(Buffer,SizeOf(Buffer),Count);
+end;
+
+function TStream.WriteData(const Buffer: AnsiChar): NativeInt;
+begin
+  Result:=Write(Buffer,SizeOf(Buffer));
+end;
+
+function TStream.WriteData(const Buffer: AnsiChar; Count: NativeInt): NativeInt;
+begin
+  Result:=WriteMaxSizeData(Buffer,SizeOf(Buffer),Count);
+end;
+
+function TStream.WriteData(const Buffer: WideChar): NativeInt;
+begin
+  Result:=Write(Buffer,SizeOf(Buffer));
+end;
+
+function TStream.WriteData(const Buffer: WideChar; Count: NativeInt): NativeInt;
+begin
+  Result:=WriteMaxSizeData(Buffer,SizeOf(Buffer),Count);
+end;
+
+function TStream.WriteData(const Buffer: Int8): NativeInt;
+begin
+  Result:=Write(Buffer,SizeOf(Buffer));
+end;
+
+function TStream.WriteData(const Buffer: Int8; Count: NativeInt): NativeInt;
+begin
+  Result:=WriteMaxSizeData(Buffer,SizeOf(Buffer),Count);
+end;
+
+function TStream.WriteData(const Buffer: UInt8): NativeInt;
+begin
+  Result:=Write(Buffer,SizeOf(Buffer));
+end;
+
+function TStream.WriteData(const Buffer: UInt8; Count: NativeInt): NativeInt;
+begin
+  Result:=WriteMaxSizeData(Buffer,SizeOf(Buffer),Count);
+end;
+
+function TStream.WriteData(const Buffer: Int16): NativeInt;
+begin
+  Result:=Write(Buffer,SizeOf(Buffer));
+end;
+
+function TStream.WriteData(const Buffer: Int16; Count: NativeInt): NativeInt;
+begin
+  Result:=WriteMaxSizeData(Buffer,SizeOf(Buffer),Count);
+end;
+
+function TStream.WriteData(const Buffer: UInt16): NativeInt;
+begin
+  Result:=Write(Buffer,SizeOf(Buffer));
+end;
+
+function TStream.WriteData(const Buffer: UInt16; Count: NativeInt): NativeInt;
+begin
+  Result:=WriteMaxSizeData(Buffer,SizeOf(Buffer),Count);
+end;
+
+function TStream.WriteData(const Buffer: Int32): NativeInt;
+begin
+  Result:=Write(Buffer,SizeOf(Buffer));
+end;
+
+function TStream.WriteData(const Buffer: Int32; Count: NativeInt): NativeInt;
+begin
+  Result:=WriteMaxSizeData(Buffer,SizeOf(Buffer),Count);
+end;
+
+function TStream.WriteData(const Buffer: UInt32): NativeInt;
+begin
+  Result:=Write(Buffer,SizeOf(Buffer));
+end;
+
+function TStream.WriteData(const Buffer: UInt32; Count: NativeInt): NativeInt;
+begin
+  Result:=WriteMaxSizeData(Buffer,SizeOf(Buffer),Count);
+end;
+
+function TStream.WriteData(const Buffer: Int64): NativeInt;
+begin
+  Result:=Write(Buffer,SizeOf(Buffer));
+end;
+
+function TStream.WriteData(const Buffer: Int64; Count: NativeInt): NativeInt;
+begin
+  Result:=WriteMaxSizeData(Buffer,SizeOf(Buffer),Count);
+end;
+
+function TStream.WriteData(const Buffer: UInt64): NativeInt;
+begin
+  Result:=Write(Buffer,SizeOf(Buffer));
+end;
+
+function TStream.WriteData(const Buffer: UInt64; Count: NativeInt): NativeInt;
+begin
+  Result:=WriteMaxSizeData(Buffer,SizeOf(Buffer),Count);
+end;
+
+function TStream.WriteData(const Buffer: Single): NativeInt;
+begin
+  Result:=Write(Buffer,SizeOf(Buffer));
+end;
+
+function TStream.WriteData(const Buffer: Single; Count: NativeInt): NativeInt;
+begin
+  Result:=WriteMaxSizeData(Buffer,SizeOf(Buffer),Count);
+end;
+
+function TStream.WriteData(const Buffer: Double): NativeInt;
+begin
+  Result:=Write(Buffer,SizeOf(Buffer));
+end;
+
+function TStream.WriteData(const Buffer: Double; Count: NativeInt): NativeInt;
+begin
+  Result:=WriteMaxSizeData(Buffer,SizeOf(Buffer),Count);
+end;
+
+function TStream.WriteData(const Buffer: Extended): NativeInt;
+begin
+  Result:=Write(Buffer,SizeOf(Buffer));
+end;
+
+function TStream.WriteData(const Buffer: Extended; Count: NativeInt): NativeInt;
+begin
+  Result:=WriteMaxSizeData(Buffer,SizeOf(Buffer),Count);
+end;
+
+function TStream.WriteData(const Buffer: TExtended80Rec): NativeInt;
+begin
+  Result:=Write(Buffer,SizeOf(Buffer));
+end;
+
+function TStream.WriteData(const Buffer: TExtended80Rec; Count: NativeInt): NativeInt;
+begin
+  Result:=WriteMaxSizeData(Buffer,SizeOf(Buffer),Count);
+end;
+
+procedure TStream.WriteBufferData(Buffer: Integer);
+begin
+  WriteBuffer(Buffer,SizeOf(Buffer));
+end;
+
+procedure TStream.WriteBufferData(Buffer: Integer; Count: NativeInt);
+begin
+  WriteMaxSizeData(Buffer,SizeOf(Buffer),Count);
+end;
+
+procedure TStream.WriteBufferData(Buffer: Boolean);
+begin
+  WriteBuffer(Buffer,SizeOf(Buffer));
+end;
+
+procedure TStream.WriteBufferData(Buffer: Boolean; Count: NativeInt);
+begin
+  WriteExactSizeData(Buffer,SizeOf(Buffer),Count);
+end;
+
+procedure TStream.WriteBufferData(Buffer: AnsiChar);
+begin
+  WriteBuffer(Buffer,SizeOf(Buffer));
+end;
+
+procedure TStream.WriteBufferData(Buffer: AnsiChar; Count: NativeInt);
+begin
+  WriteExactSizeData(Buffer,SizeOf(Buffer),Count);
+end;
+
+procedure TStream.WriteBufferData(Buffer: WideChar);
+begin
+  WriteBuffer(Buffer,SizeOf(Buffer));
+end;
+
+procedure TStream.WriteBufferData(Buffer: WideChar; Count: NativeInt);
+begin
+  WriteExactSizeData(Buffer,SizeOf(Buffer),Count);
+end;
+
+procedure TStream.WriteBufferData(Buffer: Int8);
+begin
+  WriteBuffer(Buffer,SizeOf(Buffer));
+end;
+
+procedure TStream.WriteBufferData(Buffer: Int8; Count: NativeInt);
+begin
+  WriteExactSizeData(Buffer,SizeOf(Buffer),Count);
+end;
+
+procedure TStream.WriteBufferData(Buffer: UInt8);
+begin
+  WriteBuffer(Buffer,SizeOf(Buffer));
+end;
+
+procedure TStream.WriteBufferData(Buffer: UInt8; Count: NativeInt);
+begin
+  WriteExactSizeData(Buffer,SizeOf(Buffer),Count);
+end;
+
+procedure TStream.WriteBufferData(Buffer: Int16);
+begin
+  WriteBuffer(Buffer,SizeOf(Buffer));
+end;
+
+procedure TStream.WriteBufferData(Buffer: Int16; Count: NativeInt);
+begin
+  WriteExactSizeData(Buffer,SizeOf(Buffer),Count);
+end;
+
+procedure TStream.WriteBufferData(Buffer: UInt16);
+begin
+  WriteBuffer(Buffer,SizeOf(Buffer));
+end;
+
+procedure TStream.WriteBufferData(Buffer: UInt16; Count: NativeInt);
+begin
+  WriteExactSizeData(Buffer,SizeOf(Buffer),Count);
+end;
+
+procedure TStream.WriteBufferData(Buffer: UInt32);
+begin
+  WriteBuffer(Buffer,SizeOf(Buffer));
+end;
+
+procedure TStream.WriteBufferData(Buffer: UInt32; Count: NativeInt);
+begin
+  WriteExactSizeData(Buffer,SizeOf(Buffer),Count);
+end;
+
+procedure TStream.WriteBufferData(Buffer: Int64);
+begin
+  WriteBuffer(Buffer,SizeOf(Buffer));
+end;
+
+procedure TStream.WriteBufferData(Buffer: Int64; Count: NativeInt);
+begin
+  WriteExactSizeData(Buffer,SizeOf(Buffer),Count);
+end;
+
+procedure TStream.WriteBufferData(Buffer: UInt64);
+begin
+  WriteBuffer(Buffer,SizeOf(Buffer));
+end;
+
+procedure TStream.WriteBufferData(Buffer: UInt64; Count: NativeInt);
+begin
+  WriteExactSizeData(Buffer,SizeOf(Buffer),Count);
+end;
+
+procedure TStream.WriteBufferData(Buffer: Single);
+begin
+  WriteBuffer(Buffer,SizeOf(Buffer));
+end;
+
+procedure TStream.WriteBufferData(Buffer: Single; Count: NativeInt);
+begin
+  WriteExactSizeData(Buffer,SizeOf(Buffer),Count);
+end;
+
+procedure TStream.WriteBufferData(Buffer: Double);
+begin
+  WriteBuffer(Buffer,SizeOf(Buffer));
+end;
+
+procedure TStream.WriteBufferData(Buffer: Double; Count: NativeInt);
+begin
+  WriteExactSizeData(Buffer,SizeOf(Buffer),Count);
+end;
+
+procedure TStream.WriteBufferData(Buffer: Extended);
+begin
+  WriteBuffer(Buffer,SizeOf(Buffer));
+end;
+
+procedure TStream.WriteBufferData(Buffer: Extended; Count: NativeInt);
+begin
+  WriteExactSizeData(Buffer,SizeOf(Buffer),Count);
+end;
+
+procedure TStream.WriteBufferData(Buffer: TExtended80Rec);
+begin
+  WriteBuffer(Buffer,SizeOf(Buffer));
+end;
+
+procedure TStream.WriteBufferData(Buffer: TExtended80Rec; Count: NativeInt);
+begin
+  WriteExactSizeData(Buffer,SizeOf(Buffer),Count);
+end;
 
   function TStream.CopyFrom(Source: TStream; Count: Int64): Int64;
 
@@ -447,6 +1151,7 @@ end;
     TheSize : Longint;
     P : PByte ;
   begin
+    Result:='';
     ReadBuffer (TheSize,SizeOf(TheSize));
     SetLength(Result,TheSize);
     // Illegal typecast if no AnsiStrings defined.
@@ -621,6 +1326,8 @@ begin
     soFromEnd       : FPosition:=FSize+Offset;
     soFromCurrent   : FPosition:=FPosition+Offset;
   end;
+  if SizeBoundsSeek and (FPosition>FSize) then
+    FPosition:=FSize;
   Result:=FPosition;
   {$IFDEF DEBUG}
   if Result < 0 then