|
@@ -125,9 +125,6 @@ interface
|
|
uses
|
|
uses
|
|
DB, Classes, SysUtils;
|
|
DB, Classes, SysUtils;
|
|
|
|
|
|
-const
|
|
|
|
- MAXSTRLEN = 250;
|
|
|
|
-
|
|
|
|
type
|
|
type
|
|
//-----------------------------------------------------------------------------
|
|
//-----------------------------------------------------------------------------
|
|
// TRecInfo
|
|
// TRecInfo
|
|
@@ -165,6 +162,7 @@ type
|
|
FRecInfoOfs :Integer;
|
|
FRecInfoOfs :Integer;
|
|
FBookmarkOfs :Integer;
|
|
FBookmarkOfs :Integer;
|
|
FSaveChanges :Boolean;
|
|
FSaveChanges :Boolean;
|
|
|
|
+ FMaxRecordLength :Cardinal;
|
|
protected
|
|
protected
|
|
function AllocRecordBuffer: PChar; override;
|
|
function AllocRecordBuffer: PChar; override;
|
|
procedure FreeRecordBuffer(var Buffer: PChar); override;
|
|
procedure FreeRecordBuffer(var Buffer: PChar); override;
|
|
@@ -199,6 +197,7 @@ type
|
|
function BufToStore(Buffer: PChar): String; virtual;
|
|
function BufToStore(Buffer: PChar): String; virtual;
|
|
function StoreToBuf(Source: String): String; virtual;
|
|
function StoreToBuf(Source: String): String; virtual;
|
|
public
|
|
public
|
|
|
|
+ property MaxRecordLength: Cardinal read FMaxRecordLength write FMaxRecordLength default 250;
|
|
constructor Create(AOwner: TComponent); override;
|
|
constructor Create(AOwner: TComponent); override;
|
|
destructor Destroy; override;
|
|
destructor Destroy; override;
|
|
function GetFieldData(Field: TField; Buffer: Pointer): Boolean; override;
|
|
function GetFieldData(Field: TField; Buffer: Pointer): Boolean; override;
|
|
@@ -274,20 +273,20 @@ implementation
|
|
//-----------------------------------------------------------------------------
|
|
//-----------------------------------------------------------------------------
|
|
constructor TFixedFormatDataSet.Create(AOwner : TComponent);
|
|
constructor TFixedFormatDataSet.Create(AOwner : TComponent);
|
|
begin
|
|
begin
|
|
- FFileMustExist := TRUE;
|
|
|
|
- FLoadfromStream := False;
|
|
|
|
- FRecordSize := 0;
|
|
|
|
- FTrimSpace := TRUE;
|
|
|
|
- FSchema := TStringList.Create;
|
|
|
|
- FData := TStringList.Create; // Load the textfile into a stringlist
|
|
|
|
- inherited Create(AOwner);
|
|
|
|
|
|
+ FFileMustExist := TRUE;
|
|
|
|
+ FLoadfromStream := False;
|
|
|
|
+ FRecordSize := 0;
|
|
|
|
+ FTrimSpace := TRUE;
|
|
|
|
+ FSchema := TStringList.Create;
|
|
|
|
+ FData := TStringList.Create; // Load the textfile into a stringlist
|
|
|
|
+ inherited Create(AOwner);
|
|
end;
|
|
end;
|
|
|
|
|
|
destructor TFixedFormatDataSet.Destroy;
|
|
destructor TFixedFormatDataSet.Destroy;
|
|
begin
|
|
begin
|
|
- inherited Destroy;
|
|
|
|
- FData.Free;
|
|
|
|
- FSchema.Free;
|
|
|
|
|
|
+ inherited Destroy;
|
|
|
|
+ FData.Free;
|
|
|
|
+ FSchema.Free;
|
|
end;
|
|
end;
|
|
|
|
|
|
procedure TFixedFormatDataSet.SetSchema(const Value: TStringList);
|
|
procedure TFixedFormatDataSet.SetSchema(const Value: TStringList);
|
|
@@ -338,7 +337,7 @@ begin
|
|
FData.Objects[i] := TObject(Pointer(i+1)); // Fabricate Bookmarks
|
|
FData.Objects[i] := TObject(Pointer(i+1)); // Fabricate Bookmarks
|
|
end;
|
|
end;
|
|
if (Maxlen = 0) then
|
|
if (Maxlen = 0) then
|
|
- Maxlen := MAXSTRLEN;
|
|
|
|
|
|
+ Maxlen := FMaxRecordLength;
|
|
LstFields := TStringList.Create;
|
|
LstFields := TStringList.Create;
|
|
try
|
|
try
|
|
LoadFieldScheme(LstFields, Maxlen);
|
|
LoadFieldScheme(LstFields, Maxlen);
|
|
@@ -368,13 +367,13 @@ begin
|
|
end;
|
|
end;
|
|
if not FLoadfromStream then
|
|
if not FLoadfromStream then
|
|
FData.LoadFromFile(FileName);
|
|
FData.LoadFromFile(FileName);
|
|
- FRecordSize := MAXSTRLEN;
|
|
|
|
|
|
+ FRecordSize := FMaxRecordLength;
|
|
InternalInitFieldDefs;
|
|
InternalInitFieldDefs;
|
|
if DefaultFields then
|
|
if DefaultFields then
|
|
CreateFields;
|
|
CreateFields;
|
|
BindFields(TRUE);
|
|
BindFields(TRUE);
|
|
if FRecordSize = 0 then
|
|
if FRecordSize = 0 then
|
|
- FRecordSize := MAXSTRLEN;
|
|
|
|
|
|
+ FRecordSize := FMaxRecordLength;
|
|
BookmarkSize := SizeOf(Integer);
|
|
BookmarkSize := SizeOf(Integer);
|
|
FRecInfoOfs := FRecordSize + CalcFieldsSize; // Initialize the offset for TRecInfo in the buffer
|
|
FRecInfoOfs := FRecordSize + CalcFieldsSize; // Initialize the offset for TRecInfo in the buffer
|
|
FBookmarkOfs := FRecInfoOfs + SizeOf(TRecInfo);
|
|
FBookmarkOfs := FRecInfoOfs + SizeOf(TRecInfo);
|