mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-21 13:09:32 +02:00
* Map dfANY to CSV data, allows to use regular Load/Save methods in TCSVDataset. Check if me can introduce dfCSV
git-svn-id: trunk@30433 -
This commit is contained in:
parent
59e2728940
commit
7ad2f934f5
@ -496,7 +496,6 @@ type
|
||||
function GetRecordUpdateBufferCached(const ABookmark : TBufBookmark; IncludePrior : boolean = false) : boolean;
|
||||
function GetActiveRecordUpdateBuffer : boolean;
|
||||
procedure ParseFilter(const AFilter: string);
|
||||
function GetPacketReader(const Format: TDataPacketFormat; const AStream: TStream): TDataPacketReader;
|
||||
|
||||
function GetIndexDefs : TIndexDefs;
|
||||
function GetIndexFieldNames: String;
|
||||
@ -560,6 +559,7 @@ type
|
||||
function IsReadFromPacket : Boolean;
|
||||
function getnextpacket : integer;
|
||||
procedure ActiveBufferToRecord;
|
||||
function GetPacketReader(const Format: TDataPacketFormat; const AStream: TStream): TDataPacketReader; virtual;
|
||||
// abstracts, must be overidden by descendents
|
||||
function Fetch : boolean; virtual;
|
||||
function LoadField(FieldDef : TFieldDef;buffer : pointer; out CreateBlob : boolean) : boolean; virtual;
|
||||
|
@ -81,7 +81,7 @@ Type
|
||||
function GetCurrentRecord : boolean; override;
|
||||
procedure GotoNextRecord; override;
|
||||
procedure InitLoadRecords; override;
|
||||
procedure RestoreRecord override;
|
||||
procedure RestoreRecord; override;
|
||||
procedure StoreRecord(ARowState : TRowState; AUpdOrder : integer = 0); override;
|
||||
class function RecognizeStream(AStream : TStream) : boolean; override;
|
||||
Property Options : TCSVOptions Read FOptions;
|
||||
@ -95,6 +95,7 @@ Type
|
||||
FCSVOptions: TCSVOptions;
|
||||
procedure SetCSVOptions(AValue: TCSVOptions);
|
||||
Protected
|
||||
function GetPacketReader(const Format: TDataPacketFormat; const AStream: TStream): TDataPacketReader; override;
|
||||
procedure LoadBlobIntoBuffer(FieldDef: TFieldDef;ABlobBuf: PBufBlobField); override;
|
||||
procedure InternalInitFieldDefs; override;
|
||||
Public
|
||||
@ -120,7 +121,7 @@ implementation
|
||||
|
||||
{ TCSVDataPacketReader }
|
||||
|
||||
Procedure TCSVDataPacketReader.ReadNextRow;
|
||||
procedure TCSVDataPacketReader.ReadNextRow;
|
||||
|
||||
|
||||
begin
|
||||
@ -167,7 +168,7 @@ begin
|
||||
FOwnsOptions:=AOptions=Nil;
|
||||
end;
|
||||
|
||||
Destructor TCSVDataPacketReader.Destroy;
|
||||
destructor TCSVDataPacketReader.Destroy;
|
||||
begin
|
||||
If FOwnsOptions then
|
||||
FreeAndNil(FOPtions);
|
||||
@ -302,6 +303,15 @@ begin
|
||||
FCSVOptions.Assign(AValue);
|
||||
end;
|
||||
|
||||
function TCustomCSVDataset.GetPacketReader(const Format: TDataPacketFormat;
|
||||
const AStream: TStream): TDataPacketReader;
|
||||
begin
|
||||
If (Format=dfAny) then
|
||||
Result:=TCSVDataPacketReader.Create(Self,AStream,FCSVOptions)
|
||||
else
|
||||
Result:=Inherited GetPacketReader(Format,AStream);
|
||||
end;
|
||||
|
||||
procedure TCustomCSVDataset.LoadBlobIntoBuffer(FieldDef: TFieldDef;
|
||||
ABlobBuf: PBufBlobField);
|
||||
begin
|
||||
@ -313,13 +323,13 @@ begin
|
||||
// Do nothing
|
||||
end;
|
||||
|
||||
Constructor TCustomCSVDataset.Create(AOwner: TComponent);
|
||||
constructor TCustomCSVDataset.Create(AOwner: TComponent);
|
||||
begin
|
||||
inherited Create(AOwner);
|
||||
FCSVOptions:=TCSVOptions.Create;
|
||||
end;
|
||||
|
||||
Destructor TCustomCSVDataset.Destroy;
|
||||
destructor TCustomCSVDataset.Destroy;
|
||||
begin
|
||||
FreeAndNil(FCSVOptions);
|
||||
inherited Destroy;
|
||||
@ -342,7 +352,7 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomCSVDataset.LoadFromCSVFile(Const AFileName: string);
|
||||
procedure TCustomCSVDataset.LoadFromCSVFile(const AFileName: string);
|
||||
|
||||
Var
|
||||
F : TFileStream;
|
||||
|
Loading…
Reference in New Issue
Block a user