Стартовый пул
This commit is contained in:
@@ -0,0 +1,287 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<CONFIG>
|
||||
<ProjectOptions>
|
||||
<Version Value="9"/>
|
||||
<General>
|
||||
<MainUnit Value="0"/>
|
||||
<Title Value="RxViewsPanel demo"/>
|
||||
<UseXPManifest Value="True"/>
|
||||
<Icon Value="0"/>
|
||||
</General>
|
||||
<i18n>
|
||||
<EnableI18N LFM="False"/>
|
||||
</i18n>
|
||||
<BuildModes Count="1">
|
||||
<Item1 Name="default" Default="True"/>
|
||||
</BuildModes>
|
||||
<PublishOptions>
|
||||
<Version Value="2"/>
|
||||
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
|
||||
<ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/>
|
||||
</PublishOptions>
|
||||
<RunParams>
|
||||
<local>
|
||||
<FormatVersion Value="1"/>
|
||||
</local>
|
||||
</RunParams>
|
||||
<RequiredPackages Count="3">
|
||||
<Item1>
|
||||
<PackageName Value="LazControls"/>
|
||||
<MinVersion Valid="True"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<PackageName Value="rxnew"/>
|
||||
<MinVersion Major="2" Minor="1" Release="2" Build="105" Valid="True"/>
|
||||
</Item2>
|
||||
<Item3>
|
||||
<PackageName Value="LCL"/>
|
||||
</Item3>
|
||||
</RequiredPackages>
|
||||
<Units Count="14">
|
||||
<Unit0>
|
||||
<Filename Value="project1.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<CursorPos Y="15"/>
|
||||
<UsageCount Value="23"/>
|
||||
</Unit0>
|
||||
<Unit1>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<ComponentName Value="Form1"/>
|
||||
<HasResources Value="True"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<UnitName Value="Unit1"/>
|
||||
<IsVisibleTab Value="True"/>
|
||||
<TopLine Value="15"/>
|
||||
<CursorPos X="7" Y="34"/>
|
||||
<UsageCount Value="23"/>
|
||||
<Loaded Value="True"/>
|
||||
<LoadedDesigner Value="True"/>
|
||||
</Unit1>
|
||||
<Unit2>
|
||||
<Filename Value="../../rxviewspanel.pas"/>
|
||||
<UnitName Value="RxViewsPanel"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<TopLine Value="167"/>
|
||||
<CursorPos X="36" Y="201"/>
|
||||
<UsageCount Value="11"/>
|
||||
<Bookmarks Count="2">
|
||||
<Item0 Y="295" ID="1"/>
|
||||
<Item1 X="3" Y="330" ID="2"/>
|
||||
</Bookmarks>
|
||||
</Unit2>
|
||||
<Unit3>
|
||||
<Filename Value="../../registerrx.pas"/>
|
||||
<TopLine Value="40"/>
|
||||
<CursorPos X="30" Y="50"/>
|
||||
<UsageCount Value="11"/>
|
||||
</Unit3>
|
||||
<Unit4>
|
||||
<Filename Value="../../rxtoolbar.pas"/>
|
||||
<TopLine Value="1113"/>
|
||||
<CursorPos X="45" Y="1143"/>
|
||||
<UsageCount Value="11"/>
|
||||
</Unit4>
|
||||
<Unit5>
|
||||
<Filename Value="../../rxaboutdialog.pas"/>
|
||||
<UnitName Value="RxAboutDialog"/>
|
||||
<TopLine Value="27"/>
|
||||
<CursorPos X="3" Y="46"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit5>
|
||||
<Unit6>
|
||||
<Filename Value="../../../../lcl/extctrls.pp"/>
|
||||
<UnitName Value="ExtCtrls"/>
|
||||
<TopLine Value="1147"/>
|
||||
<CursorPos X="13" Y="1179"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit6>
|
||||
<Unit7>
|
||||
<Filename Value="../../../../lcl/buttons.pp"/>
|
||||
<UnitName Value="Buttons"/>
|
||||
<TopLine Value="331"/>
|
||||
<CursorPos X="17" Y="350"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit7>
|
||||
<Unit8>
|
||||
<Filename Value="../../../../lcl/stdctrls.pp"/>
|
||||
<UnitName Value="StdCtrls"/>
|
||||
<TopLine Value="1420"/>
|
||||
<CursorPos X="3" Y="1439"/>
|
||||
<UsageCount Value="11"/>
|
||||
</Unit8>
|
||||
<Unit9>
|
||||
<Filename Value="../../../install/fpcsrc/rtl/objpas/classes/classesh.inc"/>
|
||||
<TopLine Value="411"/>
|
||||
<CursorPos X="24" Y="435"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit9>
|
||||
<Unit10>
|
||||
<Filename Value="../../../install/fpcsrc/rtl/objpas/classes/collect.inc"/>
|
||||
<TopLine Value="18"/>
|
||||
<CursorPos X="3" Y="21"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit10>
|
||||
<Unit11>
|
||||
<Filename Value="../../../../lcl/controls.pp"/>
|
||||
<UnitName Value="Controls"/>
|
||||
<TopLine Value="1265"/>
|
||||
<CursorPos X="15" Y="1280"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit11>
|
||||
<Unit12>
|
||||
<Filename Value="../../../../lcl/include/control.inc"/>
|
||||
<TopLine Value="3131"/>
|
||||
<CursorPos Y="3151"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit12>
|
||||
<Unit13>
|
||||
<Filename Value="../../../../lcl/include/untabbednotebook.inc"/>
|
||||
<TopLine Value="176"/>
|
||||
<CursorPos X="17" Y="204"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit13>
|
||||
</Units>
|
||||
<JumpHistory Count="27" HistoryIndex="26">
|
||||
<Position1>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="18" Column="29"/>
|
||||
</Position1>
|
||||
<Position2>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="18" Column="29"/>
|
||||
</Position2>
|
||||
<Position3>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="40" Column="3" TopLine="15"/>
|
||||
</Position3>
|
||||
<Position4>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="41" Column="3" TopLine="15"/>
|
||||
</Position4>
|
||||
<Position5>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="42" Column="3" TopLine="15"/>
|
||||
</Position5>
|
||||
<Position6>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="43" Column="3" TopLine="15"/>
|
||||
</Position6>
|
||||
<Position7>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="42" Column="3" TopLine="15"/>
|
||||
</Position7>
|
||||
<Position8>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="36" Column="3" TopLine="7"/>
|
||||
</Position8>
|
||||
<Position9>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="42" Column="41" TopLine="17"/>
|
||||
</Position9>
|
||||
<Position10>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="43" Column="41" TopLine="17"/>
|
||||
</Position10>
|
||||
<Position11>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="44" Column="41" TopLine="17"/>
|
||||
</Position11>
|
||||
<Position12>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="45" Column="41" TopLine="17"/>
|
||||
</Position12>
|
||||
<Position13>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="46" Column="41" TopLine="17"/>
|
||||
</Position13>
|
||||
<Position14>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="47" Column="41" TopLine="18"/>
|
||||
</Position14>
|
||||
<Position15>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="48" Column="41" TopLine="19"/>
|
||||
</Position15>
|
||||
<Position16>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="49" Column="41" TopLine="20"/>
|
||||
</Position16>
|
||||
<Position17>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="50" Column="41" TopLine="21"/>
|
||||
</Position17>
|
||||
<Position18>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="51" Column="41" TopLine="22"/>
|
||||
</Position18>
|
||||
<Position19>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="52" Column="41" TopLine="27"/>
|
||||
</Position19>
|
||||
<Position20>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="58" Column="29" TopLine="33"/>
|
||||
</Position20>
|
||||
<Position21>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="58" Column="29" TopLine="9"/>
|
||||
</Position21>
|
||||
<Position22>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="53" Column="3" TopLine="50"/>
|
||||
</Position22>
|
||||
<Position23>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="54" Column="3" TopLine="51"/>
|
||||
</Position23>
|
||||
<Position24>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="55" Column="3" TopLine="13"/>
|
||||
</Position24>
|
||||
<Position25>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="56" Column="3" TopLine="24"/>
|
||||
</Position25>
|
||||
<Position26>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="57" Column="3" TopLine="25"/>
|
||||
</Position26>
|
||||
<Position27>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="33" Column="7" TopLine="16"/>
|
||||
</Position27>
|
||||
</JumpHistory>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
<Version Value="11"/>
|
||||
<Target>
|
||||
<Filename Value="project1"/>
|
||||
</Target>
|
||||
<SearchPaths>
|
||||
<IncludeFiles Value="$(ProjOutDir)"/>
|
||||
<UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/>
|
||||
</SearchPaths>
|
||||
<Linking>
|
||||
<Options>
|
||||
<Win32>
|
||||
<GraphicApplication Value="True"/>
|
||||
</Win32>
|
||||
</Options>
|
||||
</Linking>
|
||||
</CompilerOptions>
|
||||
<Debugging>
|
||||
<Exceptions Count="3">
|
||||
<Item1>
|
||||
<Name Value="EAbort"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<Name Value="ECodetoolError"/>
|
||||
</Item2>
|
||||
<Item3>
|
||||
<Name Value="EFOpenError"/>
|
||||
</Item3>
|
||||
</Exceptions>
|
||||
</Debugging>
|
||||
</CONFIG>
|
@@ -0,0 +1,170 @@
|
||||
{ ex_rx_datapacket unit
|
||||
|
||||
Copyright (C) 2005-2017 Lagunov Aleksey alexs75@yandex.ru and Lazarus team
|
||||
original conception from rx library for Delphi (c)
|
||||
|
||||
This library is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU Library General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version with the following modification:
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent modules,and
|
||||
to copy and distribute the resulting executable under terms of your choice,
|
||||
provided that you also meet, for each linked independent module, the terms
|
||||
and conditions of the license of that module. An independent module is a
|
||||
module which is not derived from or based on this library. If you modify
|
||||
this library, you may extend this exception to your version of the library,
|
||||
but you are not obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public License
|
||||
along with this library; if not, write to the Free Software Foundation,
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
}
|
||||
|
||||
unit ex_rx_datapacket;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils,db;
|
||||
|
||||
type
|
||||
TRowStateValue = (rsvOriginal, rsvDeleted, rsvInserted, rsvUpdated, rsvDetailUpdates);
|
||||
TRowState = set of TRowStateValue;
|
||||
|
||||
type
|
||||
TRxDataPacketFormat = (dfBinary,dfXML,dfXMLUTF8,dfAny);
|
||||
|
||||
type
|
||||
|
||||
{ TRxDatapacketReader }
|
||||
|
||||
TRxDatapacketReaderClass = class of TRxDatapacketReader;
|
||||
TRxDatapacketReader = class(TObject)
|
||||
FStream : TStream;
|
||||
protected
|
||||
class function RowStateToByte(const ARowState : TRowState) : byte;
|
||||
class function ByteToRowState(const AByte : Byte) : TRowState;
|
||||
public
|
||||
constructor create(AStream : TStream); virtual;
|
||||
// Load a dataset from stream:
|
||||
// Load the field-definitions from a stream.
|
||||
procedure LoadFieldDefs(AFieldDefs : TFieldDefs); virtual; abstract;
|
||||
// Is called before the records are loaded
|
||||
procedure InitLoadRecords; virtual; abstract;
|
||||
// Return the RowState of the current record, and the order of the update
|
||||
function GetRecordRowState(out AUpdOrder : Integer) : TRowState; virtual; abstract;
|
||||
// Returns if there is at least one more record available in the stream
|
||||
function GetCurrentRecord : boolean; virtual; abstract;
|
||||
// Store a record from stream in the current record-buffer
|
||||
procedure RestoreRecord(ADataset : TDataset); virtual; abstract;
|
||||
// Move the stream to the next record
|
||||
procedure GotoNextRecord; virtual; abstract;
|
||||
|
||||
// Store a dataset to stream:
|
||||
// Save the field-definitions to a stream.
|
||||
procedure StoreFieldDefs(AFieldDefs : TFieldDefs); virtual; abstract;
|
||||
// Save a record from the current record-buffer to the stream
|
||||
procedure StoreRecord(ADataset : TDataset; ARowState : TRowState; AUpdOrder : integer = 0); virtual; abstract;
|
||||
// Is called after all records are stored
|
||||
procedure FinalizeStoreRecords; virtual; abstract;
|
||||
// Checks if the provided stream is of the right format for this class
|
||||
class function RecognizeStream(AStream : TStream) : boolean; virtual; abstract;
|
||||
property Stream: TStream read FStream;
|
||||
end;
|
||||
|
||||
type
|
||||
TRxDatapacketReaderRegistration = record
|
||||
ReaderClass : TRxDatapacketReaderClass;
|
||||
Format : TRxDatapacketFormat;
|
||||
end;
|
||||
|
||||
function GetRegisterDatapacketReader(AStream : TStream; AFormat : TRxDatapacketFormat; var ADataReaderClass : TRxDatapacketReaderRegistration) : boolean;
|
||||
procedure RegisterDatapacketReader(ADatapacketReaderClass : TRxDatapacketReaderClass; AFormat : TRxDatapacketFormat);
|
||||
|
||||
implementation
|
||||
|
||||
var
|
||||
RxRegisteredDatapacketReaders : Array of TRxDatapacketReaderRegistration;
|
||||
|
||||
|
||||
function GetRegisterDatapacketReader(AStream: TStream;
|
||||
AFormat: TRxDatapacketFormat;
|
||||
var ADataReaderClass: TRxDatapacketReaderRegistration): boolean;
|
||||
var i : integer;
|
||||
begin
|
||||
Result := False;
|
||||
for i := 0 to length(RxRegisteredDatapacketReaders)-1 do if ((AFormat=dfAny) or (AFormat=RxRegisteredDatapacketReaders[i].Format)) then
|
||||
begin
|
||||
|
||||
if (AStream <> nil) then
|
||||
AStream.Seek(0,soFromBeginning); // ensure at start of stream to check value
|
||||
|
||||
if (AStream=nil) or (RxRegisteredDatapacketReaders[i].ReaderClass.RecognizeStream(AStream)) then
|
||||
begin
|
||||
ADataReaderClass := RxRegisteredDatapacketReaders[i];
|
||||
Result := True;
|
||||
if (AStream <> nil) then
|
||||
AStream.Seek(0,soFromBeginning);
|
||||
break;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure RegisterDatapacketReader(
|
||||
ADatapacketReaderClass: TRxDatapacketReaderClass; AFormat: TRxDatapacketFormat
|
||||
);
|
||||
begin
|
||||
setlength(RxRegisteredDatapacketReaders,length(RxRegisteredDatapacketReaders)+1);
|
||||
with RxRegisteredDatapacketReaders[length(RxRegisteredDatapacketReaders)-1] do
|
||||
begin
|
||||
Readerclass := ADatapacketReaderClass;
|
||||
Format := AFormat;
|
||||
end;
|
||||
end;
|
||||
|
||||
{ TRxDatapacketReader }
|
||||
|
||||
class function TRxDatapacketReader.RowStateToByte(const ARowState: TRowState
|
||||
): byte;
|
||||
var RowStateInt : Byte;
|
||||
begin
|
||||
RowStateInt:=0;
|
||||
if rsvOriginal in ARowState then RowStateInt := RowStateInt+1;
|
||||
if rsvDeleted in ARowState then RowStateInt := RowStateInt+2;
|
||||
if rsvInserted in ARowState then RowStateInt := RowStateInt+4;
|
||||
if rsvUpdated in ARowState then RowStateInt := RowStateInt+8;
|
||||
Result := RowStateInt;
|
||||
end;
|
||||
|
||||
class function TRxDatapacketReader.ByteToRowState(const AByte: Byte
|
||||
): TRowState;
|
||||
begin
|
||||
result := [];
|
||||
if (AByte and 1)=1 then Result := Result+[rsvOriginal];
|
||||
if (AByte and 2)=2 then Result := Result+[rsvDeleted];
|
||||
if (AByte and 4)=4 then Result := Result+[rsvInserted];
|
||||
if (AByte and 8)=8 then Result := Result+[rsvUpdated];
|
||||
end;
|
||||
|
||||
constructor TRxDatapacketReader.create(AStream: TStream);
|
||||
begin
|
||||
FStream := AStream;
|
||||
end;
|
||||
|
||||
initialization
|
||||
setlength(RxRegisteredDatapacketReaders,0);
|
||||
finalization
|
||||
setlength(RxRegisteredDatapacketReaders,0);
|
||||
end.
|
||||
|
Reference in New Issue
Block a user