⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 abstypes.pas

📁 Absolute Database 是来替代BDE[Borland数据库引擎]的用于Delphi 和 C++ Builder 开发用的数据库引擎. 它小巧, 高速, 健壮, 易于使用. 它能直接编译进
💻 PAS
📖 第 1 页 / 共 5 页
字号:
unit ABSTypes;

interface

{$I ABSVer.inc}

uses
     SysUtils, Classes, Windows,

// AbsoluteDatabase units
     {$IFDEF DEBUG_LOG}
     ABSDebug,
     {$ENDIF}
     ABSSecurity,
     ABSMemory,
     ABSConst,
     ABSExcept;


type

//------------------------------------------------------------------------------
// general types
//------------------------------------------------------------------------------


 TABSErrorCode = Integer;
 TABSPageNo = Integer;
 PABSPageNo = ^TABSPageNo;
 TABSPageBuffer = PChar;
 TABSGetRecordMode = (grmCurrent, grmNext, grmPrior);
 TABSGetRecordResult = (grrOK, grrBOF, grrEOF, grrError);
 TABSBLOBOpenMode = (bomWrite, bomRead, bomReadWrite);
 TABSRecordBuffer = PChar;
 TABSState = Integer;
 TABSObjectID = Integer;
 TABSTableID = TABSObjectID;
 TABSObjectName = ShortString;
 TABSSessionID = Integer;
 TABSRecordNo = Int64;
 TABSPageItemID = packed record
  PageNo:        TABSPageNo; // page number or record number (disk engine or memory, temporary engine)
  PageItemNo:    Word;
 end;
 PABSPageItemID = ^TABSPageItemID;
 TABSRecordID = TABSPageItemID;
 PABSRecordID = ^TABSRecordID;

{ Paradox graphic BLOB header }
type
  TGraphicHeader = record
    Count: Word;                { Fixed at 1 }
    HType: Word;                { Fixed at $0100 }
    Size: Longint;              { Size not including header }
  end;

//------------------------------------------------------------------------------
// disk types
//------------------------------------------------------------------------------


 TABSPageRecordCount = Word;
 PABSPageRecordCount = ^TABSPageRecordCount;
 TABSDBFileType = (dbftUnknown,dbftTablesList,dbftActiveSessionsList);
 TABSLockType = (ltIS,ltS,ltSIRW,ltXIRW,ltRW,ltU,ltX); // U - record lock
 const LocksCompatible: array [ltIS..ltX, ltIS..ltX] of Boolean =
       (
       //IS    S      SIRW   XIRW   RW     U      X
{IS}   (True,  True,  True,  True,  True,  True,  False),
{S}    (True,  True,  True,  True,  False, True,  False),
{SIRW} (True,  True,  True,  False, True,  True,  False),
{XIRW} (True,  True,  False, False, False, True,  False),
{RW}   (True,  False, True,  False, False, True,  False),
{U}    (True,  True,  True,  True,  True,  True,  False),
{X}    (False, False, False, False, False, False, False)
       );
// SIRW-SIRW, SIRW-XIRW compatibility have some exceptions from this table

 type
 //TABSLockType = (ltIS = 0,ltS = 1,ltIRW = 2,ltRW = 3,ltU = 4,ltX = 5);
 TABSLockObjectType = (lotDatabase,lotTable,lotRecord);
 TABSTablePageType = (tptRowStart,tptRowContinue,tptVarchar,tptBLOB);
 
 PABSDBHeader = ^TABSDBHeader;
 TABSDBHeader = packed record
  Signature:        Array [0..15] of Char;
  HeaderSize:       Smallint;
  Version:          Double;
  PageSize:         Word;
  PageCountInExtent:Word;
  TotalPageCount:   TABSPageNo;
  LastUsedPageNo:   TABSPageNo;
  State:            Integer;
  WriteChangesState:Byte;
  Encrypted:        ByteBool;
  Reserved:         array [1..32] of Byte;
 end;

 TABSCryptoHeader = packed record
  CryptoHeaderSize:  Smallint;
  CryptoAlgorithm:   Byte;
  CryptoMode:        Byte;
  ControlBlock:      array [0..ABS_CONTROL_BLOCK_SIZE-1] of Byte;
  ControlBlockCRC:   Cardinal;
  Reserverd:         array [1..16] of Byte;
 end;

 TABSLockedBytes = packed record
  LockedByteSize:   Smallint;
  FSMByte:          Byte;
  TablesByte:       Byte;
  DBHeaderByte:     Byte;
  Reserved:         array [1..15] of Byte;
 end;

 TABSLastObjectID = Integer;

 TABSPageTypeID = Word;
 
 TABSDiskPageHeader = packed record
  Signature:        Array [0..3] of Char;
  State:            Integer;
  PageType:         TABSPageTypeID;
  NextPageNo:       TABSPageNo;
  CRC32:            Longword;
  CRCType:          Byte;
  HashType:         Byte;
  Cipherype:        Byte;
  MACType:          Byte;
  ObjectID:         TABSObjectID;
  RecordID:         TABSRecordID;
  Reserved:         Array [0..7] of Byte;
 end; // 40 bytes
 PABSDiskPageHeader = ^TABSDiskPageHeader;
 
  // ABSDatabaseFile Mode Types
  TABSShareMode = (smExclusive, smShareDenyNone, smShareDenyWrite);
  TABSAccessMode = (amReadOnly, amReadWrite);
 
 // Any list header
 PABSListHeader = ^TABSListHeader;
 TABSListHeader = packed record
   Count:       Integer;
   ItemSize:    Integer;
   NextPageNo:  TABSPageNo; // or INVALID_PAGE_NO
 end;// 12 byte

 // Header for internal file
 PABSInternalFileHeader = ^TABSInternalFileHeader;
 TABSInternalFileHeader = packed record
   FileHeaderSize:       Byte;
   FileSize:             Integer;
   DecompressedSize:     Integer;
   CompressionAlgorithm: Byte;
 end;

 // System Directory List Item
 TABSSystemDirectoryListItem = packed record
   FileID:      TABSDBFileType;
   FirstPageNo: TABSPageNo;
 end;// 6 byte

 
 // Table List Item
 PABSTableListItem = ^TABSTableListItem;
 TABSTableListItem = packed record
   TableName:                           ShortString;
   TableID:                             TABSTableID;
   MetaDataFilePageNo:                  TABSPageNo;
   MostUpdatedFilePageNo:               TABSPageNo;
   LocksFilePageNo:                     TABSPageNo;
 end;

 TABSTablePFSPageMapItem = packed record
   PageNo:          TABSPageNo;
   PageRecordCount: TABSPageRecordCount;
 end;

 TABSLockParams = record
    SessionID:    Integer;
    LockType:     TABSLockType;
    ObjectType:   TABSLockObjectType;
    RowID:        TABSPageItemID;
    TableID:      TABSObjectID;
 end;

//------------------------------------------------------------------------------
// SQL types
//------------------------------------------------------------------------------


 // join type
 TABSJoinType = (ajtCross, ajtInner, ajtLeftOuter,
                 ajtRightOuter, ajtFullOuter);

 // union type
 TABSUnionType = (autUnion, autIntersect, autExcept);

 // table | joined table | subquery
 TABSTableType = (attTable, attJoinedTable, attSubQuery);

 // table | joined table | subquery
 TABSQueryExprType = (qetSelect, qetUnion, qetExcept, qetIntersect);

 TABSBatchMoveType = (bmtAppend, bmtAppendUpdate, bmtCopy, bmtDelete, bmtUpdate, bmtSynchronize);


 // field types
 TABSBaseFieldType = (
                        bftUnknown,

                        bftChar,
                        bftWideChar,
                        bftVarchar,
                        bftWideVarchar,

                        bftSignedInt8,        // Shortint
                        bftSignedInt16,       // Smallint
                        bftSignedInt32,       // Integer
                        bftSignedInt64,       // Int64
                        bftUnsignedInt8,      // Byte
                        bftUnsignedInt16,     // Word
                        bftUnsignedInt32,     // Cardinal
                        //bftUnSignedInt64,

                        bftSingle,
                        bftDouble,
                        bftExtended,

                        bftDate,
                        bftTime,
                        bftDateTime,

                        bftBlob,
                        bftClob,
                        bftWideClob,

                        bftLogical,
                        bftCurrency,

                        bftBytes,
                        bftVarBytes,
                        //bftTimeStamp, == bftDateTime 
                        bftBFile
                     );


  TABSAdvancedFieldType = (
    aftUnknown,

    aftChar,            // = bftChar
    aftString,          // = bftVarChar

    aftWideChar,        // = bftChar
    aftWideString,      // = bftWideVarChar

    aftShortint,        // = bftSignedInt8
    aftSmallint,        // = bftSignedInt16
    aftInteger,         // = bftSignedInt32
    aftLargeint,        // = bftSignedInt64
    aftByte,            // = bftUnsignedInt8
    aftWord,            // = bftUnsignedInt16
    aftCardinal,        // = bftUnsignedInt32

    aftAutoInc,         // = bftSignedInt32
    aftAutoIncShortint, // = bftSignedInt8
    aftAutoIncSmallint, // = bftSignedInt16
    aftAutoIncInteger,  // = bftSignedInt32
    aftAutoIncLargeint, // = bftSignedInt64
    aftAutoIncByte,     // = bftUnsignedInt8
    aftAutoIncWord,     // = bftUnsignedInt16
    aftAutoIncCardinal, // = bftUnsignedInt32


    aftSingle,          // = bftSingle
    aftDouble,          // = bftDouble
    aftExtended,        // = bftExtended

    aftBoolean,         // = bftLogical

    aftCurrency,        // = bftCurrency

    aftDate,            // = bftDate
    aftTime,            // = bftTime
    aftDateTime,        // = bftDateTime
    aftTimeStamp,       // = bftDateTime

    aftBytes,           // = bftBytes
    aftVarBytes,        // = bftVarBytes

    aftBlob,            // = bftBlob
    aftGraphic,         // = bftBlob
    aftMemo,            // = bftClob
    aftFormattedMemo,   // = bftClob
    aftWideMemo,        // = bftWideClob
    aftGuid             // = bftChar(38)
//aftArray,
//    aftParadoxOle,
//    aftDBaseOle,
//    aftTypedBinary,
//    aftCursor,
//    aftReference,
//    aftDataSet,
//    aftVariant,
//    aftInterface,
//    aftIDispatch,
    );

 //TABSDefaultValueType = (dvtNull, dvtConst, dvtSequence, dvtFunction, dvtQuery);
 TABSConstraintType = (ctPK, ctFK, ctUnique, ctNotNull, ctCheck);
 TABSCompareResult = (cmprEqual, cmprLower, cmprGreater,
                      cmprLeftNull, cmprRightNull, cmprBothNull);

 // unary / binary Value operators
 TABSDataOperator = (
    doUNDEFINED,                       // error
    //George doCMP,                             // compare <0,=0,>0
    {Comparison}
    doEQ,                              // equal
    doNE,                              // NOT equal
    doGT,                              // greater than
    doLT,                              // less than
    doGE,                              // greater or equal
    doLE,                              // less or equal
    {Boolean}
    doNOT,                             // NOT
    doAND,                             // AND
    doOR,                              // OR
    doIN,                              // in (a,b,c, ...)
    doNOTIN,                           // not in (a,b,c, ...)
    doEXISTS,                          // exists (subquery)
    doBETWEEN,                         // between (a,b)
    doNOTBETWEEN,                      // not between (a,b)
    doLIKE,                            // like 'a?b%'
    doNOTLIKE,                         // not like
    doISNULL,                          // is null
    doISNOTNULL,                       // is not null
    doTRUE,                            // TRUE const
    doFALSE,                           // FALSE const
    {Arithmetic}
    doADD,                             // addition
    doSUB,                             // subtraction
    doMUL,                             // multiplication
    doDIV,                             // division
    {Functions}
    //doPOSITION,                        // Position (str1) in (str2)
    doCONCAT,                          // str1 || str2
    doUPPER,                           // Upper(str)
    doLOWER,                           // Lower(str)
    doTRIM,                            // TRIM
    doLTRIM,                           // LTRIM
    doRTRIM,                           // RTRIM
    doLENGTH,                          // LENGTH(str)
    doPOS,                             // POS(substr in|, str) { 1 - first char, 0 - not found }
    doSUBSTRING,                       // SUBSTRING(str from|, startindex [for|, length])
    {aggregated functions}
    doSUM,                             // SUM([distinct]expression)
    doAVG,                             // AVG([distinct]expression)
    doMIN,                             // min(expression)
    doMAX,                             // max(expression)
    doCOUNT,                           // COUNT([distinct]expression)
    doCOUNTALL,                        // count(*)
    {datetime functions}
    doSYSDATE,                         // SYSDATE - return current DateTime
    doCURRENT_DATE,                    // CURRENT_DATE
    doCURRENT_TIME,                    // CURRENT_TIME
    doTODATE,                          // TODATE(string, format)
    doTOSTRING,                        // TOSTRING(date, format)
    doEXTRACT,                         // EXTRACT (YEAR FROM datetime_field)
    {cast types}
    doCAST,                            // Cast(expression, type)
    {system}
    doLASTAUTOINC,
    {blob}
    doMIMETOBIN,                       // MimeToBin(MimeString)

    doROWNUM,                          // selected row number (iterated)
    {math}
    doABS,                             // ABS(number)
    doACOS,
    doASIN,
    doATAN,
    doCEIL,
    doCOS,
    doEXP,
    doFLOOR,
    doLOG,
    doPOWER,

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -