📄 kbmmemtable.pas
字号:
unit kbmMemTable;
interface
{$include kbmMemTable.inc}
uses
SysUtils,
Classes,
DB,
DBCommon
{$IFDEF LINUX}
,Types
,Libc
{$ELSE}
,Windows
{$ENDIF}
{$IFDEF LEVEL5}
,SyncObjs
,Masks
{$ENDIF}
{$IFDEF LEVEL6}
,variants
,fmtbcd
,SqlTimSt
{$ENDIF};
{$B-} // Enable short circuit evaluation.
// kbmMemTable v. 3.07
const COMPONENT_VERSION = '3.07';
// =========================================================================
// An inmemory temporary table.
// Can be used as a demonstration of how to create descendents of TDataSet,
// or as in my case, to allow a program to generate temporary data that can
// be used directly by all data aware controls.
//
// Copyright 1999,2000,2001 Kim Bo Madsen/Components4Developers DK
// All rights reserved.
//
// LICENSE AGREEMENT
// PLEASE NOTE THAT THE LICENSE AGREEMENT HAS CHANGED!!! 16. Feb. 2000
//
// You are allowed to use this component in any project for free.
// You are NOT allowed to claim that you have created this component or to
// copy its code into your own component and claim that it was your idea.
//
// -----------------------------------------------------------------------------------
// IM OFFERING THIS FOR FREE FOR YOUR CONVINIENCE, BUT
// YOU ARE REQUIRED TO SEND AN E-MAIL ABOUT WHAT PROJECT THIS COMPONENT (OR DERIVED VERSIONS)
// IS USED FOR !
// -----------------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------------
// PLEASE NOTE THE FOLLOWING ADDITION TO THE LICENSE AGREEMENT:
// If you choose to use this component for generating middleware libraries (with similar
// functionality as dbOvernet, Midas, Asta etc.), those libraries MUST be released as
// Open Source and Freeware!
// -----------------------------------------------------------------------------------
//
// You dont need to state my name in your software, although it would be
// appreciated if you do.
//
// If you find bugs or alter the component (f.ex. see suggested enhancements
// further down), please DONT just send the corrected/new code out on the internet,
// but instead send it to me, so I can put it into the official version. You will
// be acredited if you do so.
//
//
// DISCLAIMER
// By using this component or parts theirof you are accepting the full
// responsibility of the use. You are understanding that the author cant be
// made responsible in any way for any problems occuring using this component.
// You also recognize the author as the creator of this component and agrees
// not to claim otherwize!
//
// Please forward corrected versions (source code ONLY!), comments,
// and emails saying you are using it for this or that project to:
// kbm@components4developers.com
//
// Latest version can be found at:
// http://www.components4developers.com
//
// Suggestions for future enhancements:
//
// - IDE designer for adding static data to the memtable.
// - Optimized sorting. Combosort, many way mergesort or the like for large datasets.
// - Swap functionality for storing parts of an active table on disk for
// preserving memory.
//
// History:
//
//1.00: The first release. Was created due to a need for a component like this.
// (15. Jan. 99)
//1.01: The first update. Release 1.00 contained some bugs related to the ordering
// of records inserted and to bookmarks. Problems fixed. (21. Jan. 99)
//1.02: Fixed handling of NULL values. Added SaveToStream, SaveToFile,
// LoadFromStream and LoadFromFile. SaveToStream and SaveToFile is controlled
// by a flag telling if to save data, contents of calculated fields,
// contents of lookupfields and contents of non visible fields.
// Added an example application with Delphi 3 source code. (26. Jan. 99)
//
//1.03: Claude Rieth from Computer Team sarl (clrieth@team.lu) came up with an
// implementation of CommaText and made a validation check in _InternalInsert.
// Because I allready have implemented the saveto.... functions, I decided
// to implement Claude's idea using my own saveto.... functions. (27. Jan. 99)
// I have decided to rename the component, because Claude let me know that
// the RX library have a component with the same name as this.
// Thus in the future the component will be named TkbmMemTable.
// SaveToStream and LoadFromStream now set up date and decimal separator
// temporary to make sure that the data saved can be loaded on another
// installation with different date and decimal separator setups.
// Added EmptyTable method to clear the contents of the memory table.
//
//1.04: Wagner ADP (wagner@cads-informatica.com.br) found a bug in the _internalinsert
// procedure which he came up with a fix for. (4. Feb. 99)
// Added support for the TDataset protected function findrecord.
// Added support for CreateTable, DeleteTable.
//
//1.05: Charlie McKeegan from Task Software Limited (charlie@task.co.uk) found
// a minor bug (and came up with a fix) in SetRecNo which mostly is
// noticeable in a grid where the grid wont refresh when the record slider
// is moved to the end of the recordset. (5. Feb. 99)
// Changed SaveToStream to use the displayname of the field as the header
// instead of the fieldname.
//
//1.06: Introduced a persistence switch and a reference to a file. If the
// persistence switch is set, the file will be read aut. on table open,
// and the contents of the table will be saved in the table on table close.
//
//1.07: Changed calculation of fieldofsets in InternalOpen to follow the fielddefs
// instead of fields. It has importance when rearranging fields.
// Because of this change the calculation of fieldoffsets into the buffer
// has been changed too. These corrections was found to be needed to
// support the new components tkbmPooledQuery and tkbmPooledStoredProc
// (found in the package tkbmPooledConn)
// which in turn handles pooled connections to a database. Very usefull
// in f.ex a WWW application as they also makes the BDE function threadsafe,
// and limits the concurrent connections to a database.
//
//1.08: Changed buffer algorithm in GetLine since the old one was faulty.
// Problem was pointed out by: Markus Roessler@gmx.de
//
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -