mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-17 02:19:27 +02:00
* Add TReader.ReadStr for Delphi compatibility
This commit is contained in:
parent
d51a0c6b3c
commit
689fae7dd9
@ -1682,6 +1682,7 @@ type
|
|||||||
Procedure FlushBuffer; virtual;
|
Procedure FlushBuffer; virtual;
|
||||||
function NextValue: TValueType; virtual; abstract;
|
function NextValue: TValueType; virtual; abstract;
|
||||||
function ReadValue: TValueType; virtual; abstract;
|
function ReadValue: TValueType; virtual; abstract;
|
||||||
|
function CurrentValue : TValueType; virtual; abstract;
|
||||||
procedure BeginRootComponent; virtual; abstract;
|
procedure BeginRootComponent; virtual; abstract;
|
||||||
procedure BeginComponent(var Flags: TFilerFlags; var AChildPos: Integer;
|
procedure BeginComponent(var Flags: TFilerFlags; var AChildPos: Integer;
|
||||||
var CompClassName, CompName: String); virtual; abstract; overload;
|
var CompClassName, CompName: String); virtual; abstract; overload;
|
||||||
@ -1735,7 +1736,8 @@ type
|
|||||||
FBufPos: Integer;
|
FBufPos: Integer;
|
||||||
FBufEnd: Integer;
|
FBufEnd: Integer;
|
||||||
FVersion: TBOVersion;
|
FVersion: TBOVersion;
|
||||||
|
FCurrentValue : TValueType;
|
||||||
|
Function CurrentValue : TValueType; override;
|
||||||
function ReadWord : word; {$ifdef CLASSESINLINE}inline;{$endif CLASSESINLINE}
|
function ReadWord : word; {$ifdef CLASSESINLINE}inline;{$endif CLASSESINLINE}
|
||||||
function ReadDWord : longword; {$ifdef CLASSESINLINE}inline;{$endif CLASSESINLINE}
|
function ReadDWord : longword; {$ifdef CLASSESINLINE}inline;{$endif CLASSESINLINE}
|
||||||
function ReadQWord : qword; {$ifdef CLASSESINLINE}inline;{$endif CLASSESINLINE}
|
function ReadQWord : qword; {$ifdef CLASSESINLINE}inline;{$endif CLASSESINLINE}
|
||||||
@ -1847,6 +1849,7 @@ type
|
|||||||
procedure ReadPropValue(Instance: TPersistent; PropInfo: Pointer);
|
procedure ReadPropValue(Instance: TPersistent; PropInfo: Pointer);
|
||||||
procedure PropertyError;
|
procedure PropertyError;
|
||||||
procedure ReadData(Instance: TComponent);
|
procedure ReadData(Instance: TComponent);
|
||||||
|
function DoReadString(aType : TValueType): rawbytestring;
|
||||||
procedure SetName(aComponent: TComponent; aName : string); virtual;
|
procedure SetName(aComponent: TComponent; aName : string); virtual;
|
||||||
property PropName: rawbytestring read FPropName;
|
property PropName: rawbytestring read FPropName;
|
||||||
property CanHandleExceptions: Boolean read FCanHandleExcepts;
|
property CanHandleExceptions: Boolean read FCanHandleExcepts;
|
||||||
@ -1897,6 +1900,8 @@ type
|
|||||||
function ReadComponentDeltaRes(Instance: TComponent; const DeltaCandidates: array of Ansistring; const Proc: TGetStreamProc): TComponent;
|
function ReadComponentDeltaRes(Instance: TComponent; const DeltaCandidates: array of Ansistring; const Proc: TGetStreamProc): TComponent;
|
||||||
function ReadVariant: Variant;
|
function ReadVariant: Variant;
|
||||||
procedure ReadSignature;
|
procedure ReadSignature;
|
||||||
|
// Readstr assumes that valuetype has aleady been read and will raise an error if it was not a string type
|
||||||
|
function ReadStr : RawByteString;
|
||||||
function ReadString: RawBytestring;
|
function ReadString: RawBytestring;
|
||||||
function ReadWideString: WideString;
|
function ReadWideString: WideString;
|
||||||
function ReadUnicodeString: UnicodeString;
|
function ReadUnicodeString: UnicodeString;
|
||||||
|
@ -142,12 +142,24 @@ var
|
|||||||
b: byte;
|
b: byte;
|
||||||
begin
|
begin
|
||||||
Read(b, 1);
|
Read(b, 1);
|
||||||
Result := TValueType(b);
|
FCurrentValue:=TValueType(b);
|
||||||
|
Result := FCurrentValue;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TBinaryObjectReader.CurrentValue: TValueType;
|
||||||
|
|
||||||
|
begin
|
||||||
|
Result:=FCurrentValue;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TBinaryObjectReader.NextValue: TValueType;
|
function TBinaryObjectReader.NextValue: TValueType;
|
||||||
|
|
||||||
|
var
|
||||||
|
b: byte;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Result := ReadValue;
|
Read(b,1);
|
||||||
|
Result:=TValueType(b);
|
||||||
{ We only 'peek' at the next value, so seek back to unget the read value: }
|
{ We only 'peek' at the next value, so seek back to unget the read value: }
|
||||||
Dec(FBufPos);
|
Dec(FBufPos);
|
||||||
end;
|
end;
|
||||||
@ -377,6 +389,7 @@ begin
|
|||||||
Read(Pointer(@Result[1])^, i);
|
Read(Pointer(@Result[1])^, i);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
function TBinaryObjectReader.ReadString(StringType: TValueType): RawByteString;
|
function TBinaryObjectReader.ReadString(StringType: TValueType): RawByteString;
|
||||||
var
|
var
|
||||||
b: Byte;
|
b: Byte;
|
||||||
@ -1688,24 +1701,35 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
function TReader.ReadString: rawbytestring;
|
function TReader.ReadStr : rawbytestring;
|
||||||
|
|
||||||
var
|
|
||||||
StringType: TValueType;
|
|
||||||
begin
|
begin
|
||||||
StringType := FDriver.ReadValue;
|
Result:=DoReadString(Driver.CurrentValue)
|
||||||
if StringType in [vaString, vaLString,vaUTF8String] then
|
end;
|
||||||
begin
|
|
||||||
Result := FDriver.ReadString(StringType);
|
function TReader.DoReadString(aType : TValueType): rawbytestring;
|
||||||
if (StringType=vaUTF8String) then
|
|
||||||
|
begin
|
||||||
|
Case aType of
|
||||||
|
vaString, vaLString,vaUTF8String:
|
||||||
|
begin
|
||||||
|
Result := FDriver.ReadString(aType);
|
||||||
|
if (aType=vaUTF8String) then
|
||||||
Result:=rawbytestring(utf8Decode(Result));
|
Result:=rawbytestring(utf8Decode(Result));
|
||||||
end
|
end;
|
||||||
else if StringType in [vaWString] then
|
vaWString:
|
||||||
Result:= rawbytestring(FDriver.ReadWidestring)
|
Result:= rawbytestring(FDriver.ReadWidestring);
|
||||||
else if StringType in [vaUString] then
|
vaUString:
|
||||||
Result:= rawbytestring(FDriver.ReadUnicodeString)
|
Result:= rawbytestring(FDriver.ReadUnicodeString);
|
||||||
else
|
else
|
||||||
raise EReadError.Create(SInvalidPropertyValue);
|
raise EReadError.Create(SInvalidPropertyValue);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TReader.ReadString: rawbytestring;
|
||||||
|
|
||||||
|
begin
|
||||||
|
DoReadString(FDriver.ReadValue);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user