📄 kbmmemtable.pas
字号:
// null fields would be skipped.
// Claudio Driussi (c.driussi@popmail.iol.it) send me version including
// a sort routine, and Ive used some of he's ideas to implement a sorting
// mechanism. Further he's code contained MoveRecords and MoveCurRec which
// I decided to include in a modified form for Drag and Drop record
// rearrangements.
//
//1.10: Support for Locate. (17. May. 99)
// Claudio Driussi (c.driussi@popmail.iol.it) came up with a fix for
// GetRecNo. MoveRecord is now public.
// Andrius Adamonis (andrius@prototechnika.lt) came up with fix for
// call to validation routines in SetFieldData and support for
// OldValue and NewValue in GetActiveRecordBuffer.
//
//1.11: Pascalis Bochoridis from SATO S.A Greece (pbohor@sato.gr)
// Corrected bookmark behavior (substituted RecordNo from TRecInfo with unused Bookmark)
// Corrected GetRecNo & SetRecNo (Scrollbars now work ok at First and Last record)
// Added LocateRecord, Locate, Lookup (I decided to use his Locate instead of my own).
//
//1.12: Added CloseBlob. Corrected destructor. (26. May. 99)
// Corrected GetFieldData and SetFieldData. Could Result in overwritten
// memory elsewhere because of use of DataSize instead of Size.
// Pascalis Bochoridis from SATO S.A Greece (phohor@sato.gr) send me a corrected
// LocateRecord which solves problems regarding multiple keyfields.
// Thomas Bogenrieder (tbogenrieder@wuerzburg.netsurf.de) have suggested a faster
// LoadFromStream version which is much faster, but loads the full stream contents into
// memory before processing. I fixed a few bugs in it, rearranged it and decided
// to leave it up to you what you want to use.
// I suggest that if you need speed for smaller streams, use his method, else use mine.
// You c an activate his method by uncommenting the define statement FAST_LOADFROMSTREAM
// a few lines down.
//
//1.13 Corrected SetRecNo and MoveRecord. (31. May. 99)
// By Pascalis Bochoridis from SATO S.A Greece (phohor@sato.gr)
//
//1.14 Respecting DefaultFields differently. (3. Jun. 99)
// LoadFromDataset now includes a CopyStructure flag.
// Supporting Master/Detail relations.
// Now the Sort uses a new property for determining the fields to sort on,
// which means its possible to sort on other fields than is used for
// master/detail. Added SortOn(FieldNames:string) which is used for quick
// addhoc sorting by just supplying the fieldnames as parameters to the
// SortOn command.
// Fixed memory leak in LoadFromDataset (forgot to free bookmark).
// Added CopyFieldProperties parameter to LoadFromDataset and CreateTableAs which
// if set to TRUE will copy f.ex. DisplayName, DisplayFormat, EditMask etc. from
// the source.
// Corrected OnValidate in SetFieldData. Was placed to late to have any impact.
// Now checking for read only fields in SetFieldData.
//
//1.15 Totally rearranged LocateRecord to handle binary search when (23. Jun. 99)
// the data searched is sorted.
// I was inspired by Paulo Conzon (paolo.conzon@smc.it) who send me a version with the Locate method
// hacked for binary search. New methods PopulateRecord and PopulateField is used to create
// a key record to search for.
// Changed Sort and SortOn to accept sortoptions by a parameter instead of having a property.
// The following sort options exists: mtsoCaseInsensitive and mtsoDescending.
// mtsoPartialKey is used internally from LocateRecord where the TLocateOptions are remapped to
// TkbmMemTableCompareOptions.
//
//1.16 Bug fixed in SaveToDataset. Close called where it shouldnt. (19. Jul. 99)
// Bug reported by Reinhard Kalinke (R_Kalinke@compuserve.com)
// Fixed a few bugs + introduced Blob saving/loading in LoadFromStream/SaveToStream and thus
// also LoadFromFile/SaveToFile. To save blob fields specify mtfSaveBlobs in save flags.
// Full AutoInc implementation (max. 1 autoinc field/table).
// These fixes and enhancements was contributed by Ars閚e von Wys (arsene@vonwyss.ch)
// SetFieldData triggered the OnChange event to often. This is now fixed. Bug discovered by
// Andrius Adamonis (andrius@prototechnika.lt).
// Added mtfSkipRest save flag which if set will ONLY write out the fields specified by the rest of
// the flags, while default operation is to put a marker to indicate a field skipped.
// Usually mtfSkipRest shouldnt be specified if the stream should be reloaded by LoadFromStream later on.
// But for generating Excel CSV files or other stuff which doesnt need to be reloaded,
// mtfSkipRest can be valuable.
// Greatly speeded up LoadFromStream (GetLine and GetWord).
//
//1.17 Supporting fieldtypes ftFixedChar,ftWideString.
// Added runtime fieldtype checking for catching unsupported fields.
// Raymond J. Schappe (rschappe@isthmus-ts.com) found a bug in CompareFields which he send a fix for.
// Added a read only Version property.
// The faster LoadFromStream added in 1.12 has now been removed due to the optimization of
// the original LoadFromStream in 1.16. Tests shows no noticably performance difference anymore.
// Inspired by Bruno Depero (bdepero@usa.net) which send me some methods for saving and
// loading table definitions, I added mtfSaveDef to TkbmMemTableSaveFlag. If used the table
// definition will be saved in a file. To copy another datasets definition, first do a CreateTableAs,
// then SaveToFile/SaveToStream with mtfSaveDef.
// Renamed TkbmSupportedFieldTypes to kbmSupportedFieldTypes and TkbmBlobTypes to kbmBlobTypes.
// Generalized Delphi/BCB definitions.
// Denis Tsyplakov (den@vrn.sterling.ru) suggested two new events: OnLoadField and OnLoadRecord
// which have been implemented.
// Added OnCompressSave and OnDecompressLoad for user defined (de)compression of SaveToStream,
// LoadFromStream, SaveToFile and LoadFromFile.
// Bruno Depero (bdepero@usa.net) inspired me to do this, since he send me a version including
// Zip compression. But I like to generalize things and not to depend on any other specific
// 3. part library. Now its up to you which compression to use.
// Added OnCompressBlobStream and OnDecompressBlobStream for (de)compression of inmemory blobs.
// Added LZH compression to the Demo project by Bruno Depero (bdepero@usa.net).
//
//1.18 Changed SaveToStream and LoadFromStream to code special characters in string fields
// (ftString,ftWideString,ftFixedChar,ftMemo,ftFmtMemo).
// You may change this behaviour to the old way by setting kbmStringTypes to an empty set.
// Fixed severe blob null bug. Blobs fields was sometimes reported IsNull=true even if
// they had data in them.
// Fixed a few minor bugs.
//
//1.19 Fixed a bug in CodedStringToString where SetLength was to long. (10. Aug. 1999)
// Bug reported by Del Piero (tomli@mail.tycoon.com.tw).
// Fixed bug in LoadFromStream where DuringTableDef was wrongly initialized
// to true. Should be false. Showed when a CSV file without definition was loaded.
// Bug reported by Mr. Schmidt (ISAT.Schmidt@t-online.de)
//
//1.20 Marcelo Roberto Jimenez (mroberto@jaca.cetuc.puc-rio.br) reported a few bugs(23. Aug. 1999)
// to do with empty dataset, which he also corrected (GetRecNo, FilterMasterDetail).
// Furthermore he suggested and provided code for a Capacity property, which
// can be used to preallocate room in the internal recordlist for a specific
// minimum number of records.
// Explicitly typecasted @ to PChar in several places to avoid problem about
// people checking 'Typed @' in compile options.
//
//1.21 Corrected Locate on filtered recordssets. (24. Aug. 1999)
// Problem observed by Keith Blows (keithblo@woollyware.com)
//
//1.22 Corrected GetActiveRecord and added overridden SetBlockReadSize to be (30. Aug. 1999)
// compatible with D4/BCB4's TProvider functionality. The information and
// code has been generously supplied by Jason Wharton (jwharton@ibobjects.com).
// Paul Moorcroft (pmoor@netspace.net.au) added SaveToBinaryFile, LoadFromBinaryFile,
// SaveToBinaryStream and LoadFromBinaryStream. They save/load the contents incl.
// structure to/from the stream/file in a binary form which saves space and is
// faster.
// Added support for ftLargeInt (D4/D5/BCB4).
//
//1.23 Forgot to add defines regarding Delphi 5. I havnt got D5 yet, and thus (12. Sep. 1999)
// not tested this myself, but have relied on another person telling me that it
// do work in D5. Let me know if it doesnt.
// Added save flag mtfSaveFiltered to allow saving all records regardless if they are
// filtered or not. Suggestion posed by Jose Mauro Teixeira Marinho (marinho@aquarius.ime.eb.br)
// Added automatic resort when records are inserted/edited into a sorted table by
// Jir
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -