📄 dsintf.pas
字号:
{ *************************************************************************** }
{ }
{ Kylix and Delphi Cross-Platform Visual Component Library }
{ }
{ Copyright (c) 1997, 2001 Borland Software Corporation }
{ }
{ *************************************************************************** }
unit DSIntf;
{$MINENUMSIZE 4}
{$T-,H+,X+}
interface
{$IFDEF MSWINDOWS}
uses Windows, VarUtils, Variants, ActiveX, DB, DBCommon;
{$ENDIF}
{$IFDEF LINUX}
uses Libc, VarUtils, Variants, DB, DBCommon;
{$ENDIF}
const
{ Record attributes }
dsRecUnmodified = $0000; { Unmodified record }
dsRecOrg = $0001; { Original record (was changed) }
dsRecDeleted = $0002; { Record was deleted }
dsRecNew = $0004; { Record was inserted }
dsRecModified = $0008; { Record was changed }
dsUnused = $0020; { Record not used anymore (hole) }
dsDetUpd = $0040; { Detail modification Ins/Del/Mod. }
{ Can be combined with other status. }
dsIsNotVisible = dsRecDeleted or dsRecOrg or dsUnused;
dsIsVisible = not (dsRecDeleted or dsRecOrg or dsUnused);
{ Field attributes }
fldAttrHIDDEN = $0001; { Field is hidden }
fldAttrREADONLY = $0002; { Field is readonly }
fldAttrREQUIRED = $0004; { Field value required }
fldAttrLINK = $0008; { Linking field }
BLANK_NULL = 1; { 'real' NULL }
BLANK_NOTCHANGED = 2; { Not changed , compared to original value }
MAXKEYFIELDS = 16;
{ Master Detail Semantics DSBase.SetProp(dspropMD_SEMANTICS, Value) }
mdCASCADEDEL = $0004;
mdCASCADEMOD = $0008; { Allow master link field to be changed (cascade change to details) }
mdALLOWLINKCHANGE = $0010; { Allow detail linkfields to be changed (fly-away) }
type
PLongBool = ^LongBool;
DBResult = Word; { Function result }
DBSearchCond = ( { Search condition for keys }
keySEARCHEQ, { = }
keySEARCHGT, { > }
keySEARCHGEQ { >= }
);
MIDASNAME = packed array [0..31] of Char; { holds a name }
MIDASPATH = packed array [0..260] of Char; { holds a DOS path }
{ Native Types }
{$IFDEF LINUX}
PSafeArray = PVarArray;
{$ENDIF}
TDataPacket = PSafeArray;
pDSAttr = ^DSAttr;
DSAttr = type Byte;
phDSFilter = ^hDSFilter;
hDSFilter = type Pointer;
GROUPSTATE = (
grSTATEMIDDLE, { Record is neither the first or the last in the group }
grSTATEFIRST, { Record is the first in the group }
grSTATELAST, { Record is the last in the group }
grSTATEFIRSTLAST
);
phDSAggregate = ^hDSAggregate;
hDSAggregate = type Integer;
AGGSTATE = (
aggSTATEUNDEF, { State is undefined. Needs recalc. }
aggSTATEOK,
aggSTATEBLANK, { This is a blank value }
aggSTATEERROR { An error occurred previously }
);
AGGVALUE = packed record
iCnt : Integer; { Count of records in each }
eAggState : AGGSTATE; { State of value }
Value : record end; { First byte of value }
end;
pDSBOOKMRK = ^DSBOOKMRK;
DSBOOKMRK = packed record
iPos : Integer; { Position in given order }
iState : Integer; { State of cursor }
iRecNo : Integer; { Record number }
iSeqNo : Integer; { Version number of order }
iOrderID : Integer; { Defines Order }
end;
pSAVEPOINT = ^SAVEPOINT;
SAVEPOINT = type Integer;
DSKEY = packed array[0..MAXKEYFIELDS-1] of Integer;
DSKEYBOOL = packed array[0..MAXKEYFIELDS-1] of LongBool;
{ Dataset and Cursor Properties }
DSProp = (
dspropLOGCHANGES, { rw LongBool, Log changes for undo/delta }
dspropREADONLY, { rw LongBool, Disable dataset updates }
dspropNOOFCHANGES, { r UINT32, Number of changes }
dspropCONSTRAINTS_DISABLED, { rw LongBool, Disable constraints }
dspropDSISPARTIAL, { rw LongBool, Dataset is parital }
dspropRECORDSINDS, { r UINT32, Records in dataset }
dspropAUTOINC_DISABLED, { rw LongBool, Autoinc disabled }
dspropISDELTA, { r LongBool, Dataset is a delta }
dspropDONTINCLMETADATA, { rw LongBool, Exclude metadata in StreamDS }
dspropINCLBLOBSINDELTA, { rw UINT32, include blobs with lengths <= than }
{ this value in delta for 'original' record }
dspropGETSAVEPOINT, { r SAVEPOINT, return savepoint for current update state. }
dspropCOMPRESSARRAYS, { rw LongBool(TRUE), if true expands fielddescriptors for arrays }
dspropMD_SEMANTICS, { rw UINT32(0), Master/detail semantics }
dspropFIELD_FULLNAME, { r in: UINT32 (FieldID), out: zstring (full name) }
dspropFIELDID_FORNAME, { r in: zstring(full name), out:UINT32 (fieldid) }
dspropFIELDID_FORPARENT, { r in: UINT32 (FieldID), out: UINT32 (FieldID) }
dspropCHANGEINDEX_VIEW, { rw DSAttr (UINT32) (update attributes), any combination, 0->show all }
dspropGETUNIQUEINDEX, { r DSIDX, internal use, returns first unique index, if any }
dspropREMOTE_UPDATEMODE, { rw UINT32, 0: where key, 1: where all, 3: where ch }
dspropXML_STREAMMODE,
dspropDISABLEDELETES, { unused }
dspropDISABLEINSERTS, { unused }
dspropDISABLEEDITS, { unused }
dspropDISABLESTRINGTRIM, { rw LongBool: disable automatic trimming of strings }
dspropDATAHASCHANGED
);
CURProp = (
curpropCONSTRAINT_ERROR_MESSAGE,{ r pCHAR, Constraint Error Message }
curpropDSBASE, { r pDSBASE, Underlying DSBASE) }
curpropSETCRACK, { w Sets crack-value to supplied value (DBERR_NOCURRREC) }
curpropGETORG_RECBUF { r returns recordbuffer for original record, error if none }
);
pDSProps = ^DSProps;
{$IFDEF MSWINDOWS}
DSProps = packed record
szName : MIDASPATH; { Name, if any }
iFields : Integer; { Number of columns }
iRecBufSize : Integer; { Size of record buffer }
iBookMarkSize : Integer; { Size of bookmark }
bReadOnly : LongBool; { Dataset is not updateable }
iIndexes : Integer; { Number of indexes on dataset }
iOptParams : Integer; { Number of optional parameters }
bDelta : LongBool; { This is a delta dataset }
iLCID : Integer; { Language used }
iUnused : packed array[0..7] of Integer; { Reserved }
end;
{$ENDIF}
{$IFDEF LINUX}
DSProps = packed record
iFields : Integer; { Number of columns }
iRecBufSize : Integer; { Size of record buffer }
iBookMarkSize : Integer; { Size of bookmark }
iIndexes : Integer; { Number of indexes on dataset }
iOptParams : Integer; { Number of optional parameters }
iLCID : Integer; { Language used }
iUnused : packed array[0..7] of Integer; { Reserved }
bDelta : LongBool; { This is a delta dataset }
bReadOnly : LongBool; { Dataset is not updateable }
szName : MIDASPATH;
szMorePad : packed array[0..2] of Char; { GCC pads this struct to 4 byte boundary }
end;
{$ENDIF}
{ Field Descriptor }
pDSFLDDesc = ^DSFLDDesc;
DSFLDDesc = packed record
szName : MIDASNAME; { Field name }
iFldType : Integer; { Field type }
iFldSubType : Integer; { Field subtype (if applicable) }
iUnits1 : Integer; { Number of Chars, precision etc }
iUnits2 : Integer; { Decimal places etc. }
iFldLen : Integer; { Length in bytes (computed) }
iFldOffsInRec : Integer; { Offset to field in record buffer }
iNullOffsInRec : Integer; { Offset to null flag (1byte) in record buffer }
iFieldID : Word; { FieldID of this field }
iFieldIDParent : Word; { FieldID of parent, if any (part of ADT or ARRAY) }
bCalculated : LongBool; { Field is Calculated }
iFldAttr : Integer; { Field attributes }
iOptParameters : Integer; { Number of optional parameters for field }
end;
{ Index descriptor }
pDSIDXDesc = ^DSIDXDesc;
DSIDXDesc = packed record
szName : MIDASNAME; { IndexName }
iFields : Integer; { Number of fields in order (0 -> base order) }
iKeyFields: DSKEY; { FieldNumbers }
iKeyLen : Integer; { Total length of key (computed) }
bUnique : LongBool;
bDescending : DSKEYBOOL; { TRUE ->Descending }
bCaseInsensitive : DSKEYBOOL;
end;
{ Callbacks }
pfCHANGECallBack = procedure( { Change Notification callback }
iClientData : Integer { Client data }
); stdcall;
pfDSFilter = function( { Filter callback }
iClientData : Integer; { Client data }
pRecBuf : Pointer { Record buffer }
): LongBool; stdcall;
pfDSCalcField = function( { Calculated field callback }
iClientData : Integer; { Client data }
pRecBuf : Pointer { Current record-buffer }
): DBResult; stdcall;
dsCBRType = Integer; { Return value for reconcile callback }
pdsCBRType = ^dsCBRType;
pfDSReconcile = function( { Reconcile callback }
iClientData : Integer; { Client data }
iRslt : Integer; { Result of previous callback }
iAction : DSAttr; { Update request Insert/Modify/Delete }
iResponse : dsCBRType; { Resolver response }
iErrCode : Integer; { Native error-code }
pErrMessage : PChar; { Native errormessage if any }
pErrContext : PChar; { 1-level error context, if any }
pRecUpd : Pointer; { Record that failed update }
pRecOrg : Pointer; { Original record, if any }
pRecConflict : Pointer { Conflicting record, if any }
): dsCBRType; stdcall;
pfDSReconcile_MD = function(
iClientData : Integer;
iRslt : Integer; { Result of previous callback. If set, the previuos parameters are repeated. }
iAction : DSAttr; { Update request Insert/Modify/Delete }
iErrResponse : dsCBRType; { Resolver response }
iErrCode : Integer; { Native error-code, (BDE or ..) }
pErrMessage : PChar; { Native errormessage, if any (otherwise NULL) }
pErrContext : PChar; { 1-level error context, if any (otherwise NULL) }
pRecUpd : PByte; { Record that failed update }
pRecOrg : PByte; { Original record, if any }
pRecConflict : PByte; { Conflicting error, if any }
iLevels : Integer; { Number of levels to error0level }
piFieldIDs : PInteger { Array of fieldIDS to navigate to error-dataset }
): dsCBRType;
pfFLDComp = function( { Field compare callback }
iClientData : Integer; { Client callback data }
pVal1 : Pointer; { Fieldvalue 1 (NULL if blank) }
pVal2 : Pointer { Fieldvalue 2 (NULL if blank) }
): Integer; { returns -1 if pVal1 < pVal2, }
{ 0 if equal, +1 if pVal1 > pVal2 }
{ Resolver & Reconcile callback return values }
const
dscbrSKIP = 1; { Skip this operation (resolver : report error) }
dscbrABORT = 2; { Abort the callback session (reconcile or resolve) }
{ (resolver : undo all changes). }
dscbrMERGE = 3; { Merge the changes (resolver : 'simple' merge) }
{ (reconcile : update original. Keep change). }
{ Resolving only }
dscbrAPPLY = 4; { Overwrite the current record with new values. }
dscbrIGNORE = 5; { Ignore the update request. Don't report error. }
{ Reconcile only }
dscbrCORRECT = 4; { Overwrite change with new values. }
dscbrCANCEL = 5; { Cancel change (remove from delta). }
dscbrREFRESH = 6; { Update original record. Cancel change. }
{ Defines for SetXmlMode/GetXmlMode }
xmlUNTYPED = 1; { Forces XML Data }
xmlXMLDATATYPED = 2; { Not used }
xmlXMLSCHEMA = 4; { Get XML Meta Data }
xmlXMLUTF8 = 8; { Encode data using UTF8 }
xmlON = xmlXMLSCHEMA or xmlUNTYPED;
xmlUTF8 = xmlON or xmlXMLUTF8;
xmlOFF = 0;
{ Packet Creation }
type
TPcktAttrArea = (fldAttrArea, pcktAttrArea);
TPcktFldStatus = (fldIsChanged, fldIsNull, fldIsUnChanged);
PDSDataPacketFldDesc = ^TDSDataPacketFldDesc;
TDSDataPacketFldDesc = packed record
szFieldName: MIDASNAME; { Column Name }
iFieldType: Integer; { Column Type }
iAttributes: Word; { Column attributes }
end;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -