|
@@ -142,6 +142,9 @@ type
|
|
end;
|
|
end;
|
|
//-----------------------------------------------------------------------------
|
|
//-----------------------------------------------------------------------------
|
|
// TBaseTextDataSet
|
|
// TBaseTextDataSet
|
|
|
|
+
|
|
|
|
+ { TFixedFormatDataSet }
|
|
|
|
+
|
|
TFixedFormatDataSet = class(TDataSet)
|
|
TFixedFormatDataSet = class(TDataSet)
|
|
private
|
|
private
|
|
FSchema :TStringList;
|
|
FSchema :TStringList;
|
|
@@ -159,7 +162,7 @@ type
|
|
procedure RemoveWhiteLines(List : TStrings; IsFileRecord : Boolean);
|
|
procedure RemoveWhiteLines(List : TStrings; IsFileRecord : Boolean);
|
|
procedure LoadFieldScheme(List : TStrings; MaxSize : Integer);
|
|
procedure LoadFieldScheme(List : TStrings; MaxSize : Integer);
|
|
function GetActiveRecBuf(out RecBuf: TRecordBuffer): Boolean;
|
|
function GetActiveRecBuf(out RecBuf: TRecordBuffer): Boolean;
|
|
- procedure SetFieldPos(var Buffer : TRecordBuffer; FieldNo : Integer);
|
|
|
|
|
|
+ procedure SetFieldOfs(var Buffer : TRecordBuffer; FieldNo : Integer);
|
|
protected
|
|
protected
|
|
FData :TStringlist;
|
|
FData :TStringlist;
|
|
FDataOffset :Integer;
|
|
FDataOffset :Integer;
|
|
@@ -364,7 +367,11 @@ begin
|
|
begin
|
|
begin
|
|
Len := StrToIntDef(LstFields.Values[LstFields.Names[i]], MaxLen);
|
|
Len := StrToIntDef(LstFields.Values[LstFields.Names[i]], MaxLen);
|
|
FieldDefs.Add(Trim(LstFields.Names[i]), ftString, Len, False);
|
|
FieldDefs.Add(Trim(LstFields.Names[i]), ftString, Len, False);
|
|
- Inc(FRecordSize, Len+1);
|
|
|
|
|
|
+ Inc(Len);
|
|
|
|
+{$IFDEF FPC_REQUIRES_PROPER_ALIGNMENT}
|
|
|
|
+ Len := Align(Len, SizeOf(PtrInt));
|
|
|
|
+{$ENDIF}
|
|
|
|
+ Inc(FRecordSize, Len);
|
|
end;
|
|
end;
|
|
finally
|
|
finally
|
|
LstFields.Free;
|
|
LstFields.Free;
|
|
@@ -394,6 +401,9 @@ begin
|
|
BindFields(TRUE);
|
|
BindFields(TRUE);
|
|
BookmarkSize := SizeOf(PtrInt);
|
|
BookmarkSize := SizeOf(PtrInt);
|
|
FRecInfoOfs := FRecordSize + CalcFieldsSize; // Initialize the offset for TRecInfo in the buffer
|
|
FRecInfoOfs := FRecordSize + CalcFieldsSize; // Initialize the offset for TRecInfo in the buffer
|
|
|
|
+{$IFDEF FPC_REQUIRES_PROPER_ALIGNMENT}
|
|
|
|
+ FRecInfoOfs := Align(FRecInfoOfs, SizeOf(PtrInt));
|
|
|
|
+{$ENDIF}
|
|
FRecBufSize := FRecInfoOfs + SizeOf(TRecInfo);
|
|
FRecBufSize := FRecInfoOfs + SizeOf(TRecInfo);
|
|
FLastBookmark := FData.Count;
|
|
FLastBookmark := FData.Count;
|
|
FCurRec := FDataOffset - 1;
|
|
FCurRec := FDataOffset - 1;
|
|
@@ -631,7 +641,7 @@ begin
|
|
begin
|
|
begin
|
|
if Field.FieldNo > 0 then
|
|
if Field.FieldNo > 0 then
|
|
begin
|
|
begin
|
|
- SetFieldPos(TRecordBuffer(RecBuf), Field.FieldNo);
|
|
|
|
|
|
+ SetFieldOfs(TRecordBuffer(RecBuf), Field.FieldNo);
|
|
Result := RecBuf < StrEnd(RecBuf); // just ''=Null
|
|
Result := RecBuf < StrEnd(RecBuf); // just ''=Null
|
|
if Result and Assigned(Buffer) then
|
|
if Result and Assigned(Buffer) then
|
|
begin
|
|
begin
|
|
@@ -676,7 +686,7 @@ begin
|
|
Field.Validate(Buffer);
|
|
Field.Validate(Buffer);
|
|
if Assigned(Buffer) and (Field.FieldKind <> fkInternalCalc) then
|
|
if Assigned(Buffer) and (Field.FieldKind <> fkInternalCalc) then
|
|
begin
|
|
begin
|
|
- SetFieldPos(TRecordBuffer(RecBuf), Field.FieldNo);
|
|
|
|
|
|
+ SetFieldOfs(TRecordBuffer(RecBuf), Field.FieldNo);
|
|
Move(Buffer^, RecBuf[0], Field.DataSize);
|
|
Move(Buffer^, RecBuf[0], Field.DataSize);
|
|
end;
|
|
end;
|
|
end
|
|
end
|
|
@@ -691,14 +701,18 @@ begin
|
|
DataEvent(deFieldChange, PtrInt(Field));
|
|
DataEvent(deFieldChange, PtrInt(Field));
|
|
end;
|
|
end;
|
|
|
|
|
|
-procedure TFixedFormatDataSet.SetFieldPos(var Buffer : TRecordBuffer; FieldNo : Integer);
|
|
|
|
|
|
+procedure TFixedFormatDataSet.SetFieldOfs(var Buffer : TRecordBuffer; FieldNo : Integer);
|
|
var
|
|
var
|
|
- i : Integer;
|
|
|
|
|
|
+ i, Len : Integer;
|
|
begin
|
|
begin
|
|
i := 1;
|
|
i := 1;
|
|
while (i < FieldNo) and (i < FieldDefs.Count) do
|
|
while (i < FieldNo) and (i < FieldDefs.Count) do
|
|
begin
|
|
begin
|
|
- Inc(Buffer, FieldDefs.Items[i-1].Size+1);
|
|
|
|
|
|
+ Len := FieldDefs.Items[i-1].Size + 1;
|
|
|
|
+{$IFDEF FPC_REQUIRES_PROPER_ALIGNMENT}
|
|
|
|
+ Len := Align(Len, SizeOf(PtrInt));
|
|
|
|
+{$ENDIF}
|
|
|
|
+ Inc(Buffer, Len);
|
|
Inc(i);
|
|
Inc(i);
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|