/mORMot/SynCommons.pas

https://bitbucket.org/sas_team/sas.requires · Pascal · 58304 lines · 42541 code · 3634 blank · 12129 comment · 4784 complexity · 31b9de4c98a1393c30d5e2b5ff69db45 MD5 · raw file

Large files are truncated click here to view the full file

  1. /// common functions used by most Synopse projects
  2. // - this unit is a part of the freeware Synopse mORMot framework,
  3. // licensed under a MPL/GPL/LGPL tri-license; version 1.18
  4. unit SynCommons;
  5. (*
  6. This file is part of Synopse framework.
  7. Synopse framework. Copyright (C) 2016 Arnaud Bouchez
  8. Synopse Informatique - http://synopse.info
  9. *** BEGIN LICENSE BLOCK *****
  10. Version: MPL 1.1/GPL 2.0/LGPL 2.1
  11. The contents of this file are subject to the Mozilla Public License Version
  12. 1.1 (the "License"); you may not use this file except in compliance with
  13. the License. You may obtain a copy of the License at
  14. http://www.mozilla.org/MPL
  15. Software distributed under the License is distributed on an "AS IS" basis,
  16. WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  17. for the specific language governing rights and limitations under the License.
  18. The Original Code is Synopse framework.
  19. The Initial Developer of the Original Code is Arnaud Bouchez.
  20. Portions created by the Initial Developer are Copyright (C) 2016
  21. the Initial Developer. All Rights Reserved.
  22. Contributor(s):
  23. - Aleksandr (sha)
  24. - Alfred Glaenzer (alf)
  25. - BigStar
  26. - itSDS
  27. - Johan Bontes
  28. - kevinday
  29. - mazinsw
  30. - Marius Maximus (mariuszekpl)
  31. - RalfS
  32. - Sanyin
  33. - Pavel (mpv)
  34. - Wloochacz
  35. - zed
  36. Alternatively, the contents of this file may be used under the terms of
  37. either the GNU General Public License Version 2 or later (the "GPL"), or
  38. the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  39. in which case the provisions of the GPL or the LGPL are applicable instead
  40. of those above. If you wish to allow use of your version of this file only
  41. under the terms of either the GPL or the LGPL, and not to allow others to
  42. use your version of this file under the terms of the MPL, indicate your
  43. decision by deleting the provisions above and replace them with the notice
  44. and other provisions required by the GPL or the LGPL. If you do not delete
  45. the provisions above, a recipient may use your version of this file under
  46. the terms of any one of the MPL, the GPL or the LGPL.
  47. ***** END LICENSE BLOCK *****
  48. Version 1.7
  49. - first public release, corresponding to SQLite3 Framework 1.7
  50. Version 1.8
  51. - includes Unitary Testing class and functions
  52. - bug fixed in WinAnsiBufferToUtf8() and all WinAnsi to UTF-8 encoding
  53. functions (issue identified thanks to new _UTF8 testing function)
  54. - bug fixed in val() under Delphi 2009/2010 for some values (issue identified
  55. thanks to new NumericalConversion testing function)
  56. - bug fixed in AnsiICompW() - used in SynPdf unit
  57. - ambiguous SameText() function rewritten as SameTextU() with UTF-8 decoding
  58. - TTextWriter class moved from SQLite3Commons to SynCommons
  59. - new JSONEncode and JSONDecode functions to directly encode or decode any
  60. content to/from a valid UTF-8 JSON object content
  61. - enhanced URLEncode() and URLDecode() functions
  62. - new ExtendedToStr/ExtendedToString functions
  63. - new tests added (mostly relative to the new functions or classes)
  64. Version 1.9
  65. - now compiles under CrossKylix, and tested under Linux
  66. - new JSONEncodeArray procedures, to create JSON array content from
  67. supplied Delphi arrays (handle RawUTF8 text, double or integer arrays)
  68. - new AddCSV methods in TTextWriter handling Delphi arrays to be added
  69. as Comma-Separated-Values (handle RawUTF8 text, double or integer arrays)
  70. - new definition of PtrInt/PtrUInt, to match NativeInt/NativeUInt types,
  71. available since Delphi 2007 - some code rewrite in order to avoid any
  72. implicit conversion from/to integer/cardinal
  73. Version 1.9.2
  74. - new StringReplaceChars function
  75. Version 1.10
  76. - code modifications to compile with Delphi 6 compiler (Delphi 5 failed due
  77. to some obscure compiler bugs in SynCrypto.pas)
  78. Version 1.11
  79. - fix some obscure Delphi 2009 bug according to NativeUInt :(
  80. - source code modified to be 7 bit Ansi (so will work with all encodings)
  81. - a lot of code refactoring for our internal fork of ZeosLib
  82. (e.g. ISO 8601 date time extracted from SQLite3Commons, QuotedStr..)
  83. - new TRawUTF8List class, which is able to emulate a TStringList with our
  84. native UTF-8 string type (cross-compiler, from Delphi 6 up to XE)
  85. - new TRawUTF8Stream class, to typecast a RawUTF8 into a TStream
  86. - new IsWow64 and SystemInfo global variables
  87. Version 1.12
  88. - fixed issue "JSON floats decimal separator depends on language settings"
  89. - new UTF8ToWideChar() overloaded function, with MaxDestChars parameter
  90. - new FillIncreasing() procedure
  91. - now handle our 32/64-bit variable-length integer encoding, via new
  92. FromVarUInt32/64 and ToVarUInt32/64 functions
  93. - new TFileBufferReader and TFileBufferWriter objects, implementing very fast
  94. read/write access to huge files, with new 32/64-bit variable-length integer
  95. encoding and optimized storage of IDs or Offsets (used in TSynBigTable)
  96. - new function UnQuoteSQLString()
  97. - another review of Pos() calls in the code (now use our fast PosEx)
  98. - TSynMemoryStream now replaces TRawUTF8Stream class, with constructors using
  99. either an AnsiString, either a memory buffer
  100. - new TSynTable, TSynTableFieldProperties and TSynTableStatement classes
  101. to handle a generic database table storing field values using our SBF
  102. compact binary format (more compact than BSON, similar to Protocol Buffers)
  103. - new WinAnsiToUnicodeString and Ansi7ToString functions
  104. - new TTextWriter.AddBinToHex method
  105. - new CompareOperator() functions and associated TCompareOperator type
  106. - new IntToThousandString() function (used for TSynTests e.g.)
  107. - new CreateInternalWindow() for creating a Windows Message handler in any object
  108. Version 1.13
  109. - unit now compiles and works with Delphi 5 compiler
  110. - new low-level RTTI functions for handling record types: RecordEquals,
  111. RecordSave, RecordSaveLength, RecordLoad, RecordClear and RecordCopy
  112. - new TDynArray object, which is a wrapper around any dynamic array: you can
  113. now access to the dynamic array using TList-like properties and methods,
  114. e.g. Count, Add, Insert, Delete, Clear, IndexOf, Find, Sort and some
  115. new methods like LoadFromStream, SaveToStream, LoadFrom and SaveTo which
  116. allow fast binary serialization of any dynamic array, even containing
  117. strings or records; a CreateOrderedIndex method is also available to
  118. create individual index according to the dynamic array content; and any
  119. dynamic array can be serialized as UTF-8 JSON via TTextWriter.AddDynArrayJSON
  120. and TDynArray.LoadFromJSON methods
  121. - introducing direct content filtering and validation using
  122. TSynFilterOrValidate dedicated classes, for both TSQLRecord and SynBigTable
  123. - filtering is handled via some TSynFilter classes - TSynFilterUpperCase,
  124. TSynFilterUpperCaseU, TSynFilterLowerCase, TSynFilterLowerCaseU and
  125. TSynFilterTrim e.g.
  126. - validation is handled via some TSynValidate classes - TSynValidateRest,
  127. TSynValidateIPAddress, TSynValidateEmail, TSynValidatePattern,
  128. TSynValidatePatternI, TSynValidateText, TSynValidatePassWord e.g.
  129. - dedicated TSynTableFieldProperties.Validate method for validation (e.g. a
  130. TSynValidateTableUniqueField instance is created if tfoUnique is in Options)
  131. - dedicated TSynTableFieldProperties.Filter method for filtering (using
  132. common TSynFilter classes, working at UTF-8 Text content)
  133. - faster implementation of Move() for Delphi versions with no FastCode inside
  134. - new ConvertCaseUTF8(), UpperCaseU(), LowerCaseU(), Int64ToUInt32(),
  135. GetCardinalDef(), IsValidEmail, IsValidIP4Address(), PatchCodePtrUInt(),
  136. GetCaptionFromClass(), GetDisplayNameFromClass(), DateTimeToIso8601Text()
  137. StrUInt32(), StringBufferToUtf8(), IsZero(), AddPrefixToCSV(), IntToString(),
  138. RawUTF8DynArrayEquals(), FromVarString(), GetBitCSV(), SetBitCSV()
  139. procedures or functions (with associated tests)
  140. - new grep-like IsMatch() function for basic pattern matching
  141. - new BinToBase64, Base64ToBin and IsBase64 *fast* conversion functions
  142. (with optimized assembler version, using CPU pipelining and lookup table)
  143. - introducing the GarbageCollector TObjectList for handling a global garbage
  144. collector for instances which must live during the whole executable process
  145. (used e.g. to avoid a memory leak for "class var" or such variables)
  146. - new TSynLog class to handle enhanced logging to any application, with
  147. exception handling (+stack trace) and customer-side performance profiling
  148. - new TSynMapFile class to retrieve debugging information from .map file (and
  149. able to save and read smaller .mab files) - used by TSynLog if available
  150. - new TSynTestsLogged test suit class, with automated test case logging
  151. - Windows version detection enhanced, now retrieving TWindowsVersion enumerate
  152. - great performance improvement in TSynTableFieldProperties for update process
  153. - added TMemoryMap and TSynMemoryStreamMapped to handle memory-mapped files
  154. - added TMemoryMapText class to fast handle big UTF-8 text files (like logs)
  155. - now TTextWriter can have a custom internal buffer size (default 4096 bytes)
  156. - now TFileBufferWriter and TFileVersion are regular classes, not an
  157. object/record any more (this was incoherent since Delphi 2010)
  158. - new TFileBufferReader.OpenFrom(Stream) and ReadRawUTF8 methods
  159. - now TSynCache will use faster TDynArrayHashed for its content hashing
  160. - new Escape: TTextWriterKind optional parameter for TTextWriter.Add()
  161. - new SynLZ related compression functions: FileSynLZ/FileUnSynLZ and
  162. StreamSynLZ/StreamUnSynLZ
  163. - source can now be parsed per all Delphi IDE pre-parser (dual declaration as
  164. record or object because of Delphi 2010 and up was not understood)
  165. - fixed issue in TSynTable.Data() method: ID was not set as expected
  166. - fixed issue in TSynTableFieldProperties: wrong constraint evaluation and
  167. index refresh at records update
  168. - fixed issue in ToVarUInt32Length/ToVarUInt32LengthWithData
  169. Version 1.14
  170. - fix issues with Curr64ToStr() and Curr64ToPChar() with negative amounts,
  171. with some speed enhancements and new associated tests
  172. - fixed issue in produced JSON stream using '=' instead of ':'
  173. - new DoubleToStr(), StrCurr64(), UnicodeBufferToString(),
  174. RawUnicodeToString(), FillChar(), UpperCopy255W(), GetCaptionFromEnum(),
  175. SortDynArrayUnicodeString(), SortDynArrayUnicodeStringI() functions
  176. Version 1.15
  177. - unit now tested with Delphi XE2 (32 Bit)
  178. - TSynLog now writes the elapsed time (in us) for Enter/Leave events, and
  179. will flush the log content to disk on any exception (for safety)
  180. - new sllTrace and sllWarning levels for TSynLog class
  181. - new TSynLog.DefaultExtension property (set to '.log' by default)
  182. - new TSynLogFile.LogProc[] property for customer-side method profiling,
  183. with LogProcSort method available for sorting the resulting array, and
  184. LogProcMerged property to merge the location name timing
  185. - new TSynMapFile.FindLocation method for high-level .map symbol access
  186. - TSynMapFile now handles huge .map file (bigger default in-memory buffer)
  187. - fix potential GPF issue in code using ConvertHexToBin[]
  188. - new TSynLog.EventCount method
  189. - new TMemoryMapText.LineContains method for fast case-insensitive search
  190. - TSynTests now writes the elapsed time in each test in the final report
  191. - faster late binding process for our variants custom types (i.e.
  192. TSynTableVariantType and TSQLDBRowVariantType): you can call
  193. SynRegisterCustomVariantType() function to register any other custom
  194. variant type, and enhance GetProperty/SetProperty process speed
  195. - includes our optimized RecordCopy procedure in replacement to the slower
  196. default System.@CopyRecord internal RTL function
  197. - our optimized Move() and FillChar() will replace the default System RTL
  198. function, for Delphi versions prior to 2007 (which didn't contain those)
  199. - new AnsiCharToUTF8(), StringToWinAnsi(), WideStringToWinAnsi(),
  200. WideStringToUTF8(), CSVOfValue(), IdemPCharArray(), FindUnicode(),
  201. UpperCaseUnicode(), LowerCaseUnicode() and Split() functions
  202. - faster GetInt64() function
  203. - Iso8601ToSecondsPUTF8Char() now returns 0 in case of unexpected format
  204. - fixed issue in StrCurr64() low-level conversion routine
  205. - fixed issue in Utf8DecodeToRawUnicodeUI() function
  206. - new TSynTableFieldProperties.OrderedIndexRefresh method, to allow access
  207. on OrderedIndex[] even if the index needs to be refreshed
  208. - new TDynArrayHashed.AddAndMakeUniqueName() method and Hash[] property
  209. - new TRawByteStringStream class (a TStream using a RawByteString as internal
  210. storage), especially useful since Delphi 2009
  211. - new TSynNameValue object, to efficiently handle Name/Value RawUTF8 pairs
  212. (using hashing for Name search)
  213. - TTextWriter.CreateOwnedStream now create an internal TRawByteStringStream
  214. instance for faster process and direct retrieval in the Text method
  215. - JSONEncode*() global functions will use an internal TRawByteStringStream
  216. instead of a supplied TMemoryStream
  217. - new FormatUTF8() overloaded function, handling both '%' and '?' parameters
  218. (inserting '?' as inlined :(...): parameters, with proper string quote) -
  219. with associated regression tests
  220. Version 1.16
  221. - introducing new TSynAnsiConvert and TSynAnsiFixedWidth classes, able to
  222. process Unicode to/from Ansi conversion in all possible code pages, with
  223. generic access methods and optimized handling of fixed width encodings
  224. - added dedicated Exception classes (ESynException, ETableDataException)
  225. - TSynLog allows read sharing of the .log created file
  226. - TSynLog now stores the executable build time, and library name (if any) -
  227. this is a small change of the .log format as expected by the LogViewer tool
  228. (so you should upgrade your LogViewer.exe to its latest version)
  229. - TSynLog and TSynMapFile now handle libraries (.dll/.ocx/.bpl) .map/.mab
  230. debugging information (only .exe was previously handled)
  231. - TSynCache now handles an optional Tag: PtrInt value parameter (used e.g.
  232. to store the row counts of a SQL result cache in mORMot)
  233. - TSynCache now uses the generic TSynNameValue object from its internal
  234. hashed list implementation (avoid duplicated code)
  235. - TMemoryMapText class (and therefore TSynLogFile) is now able to map/open
  236. an existing file: it will allow e.g. the SynLogViewer to browse a .log file
  237. which is actually still opened and working by the main application
  238. - faster RawUnicodeToUtf8() and UTF8ToWideChar() functions, thanks to very
  239. clever speed-up proposals by Sha (also included in TSynAnsi* classes)
  240. - JSONDecode() overloaded functions now accept parameter names without case
  241. sensibility (and a new HandleValuesAsObjectOrArray parameter)
  242. - new JSONDecode() overloaded function, to properly handle unserialization
  243. of a JSON object within a buffer (used e.g. for TDynArrayJSONCustomReader)
  244. - JSON functions now handle '0' as number according to http://json.org specs
  245. - new TTextWriter.AddJSONEscape() overloaded function, to be used to directly
  246. serialize some name/value pairs as a JSON object content (used e.g. for
  247. TDynArrayJSONCustomWriter callbacks)
  248. - new FileSize(), RoundTo2Digits() and RawByteStringArrayConcat() functions
  249. - new TPrecisionTimer Pause and Resume methods
  250. - new TSynTestCase.CheckFailed method (most of the time, Check is sufficient)
  251. - new TSynLogFamily.IncludeComputerNameInFileName property
  252. - new TTextWriter.WrRecord method for direct adding of a Base-64 record content
  253. - new TTextWriter.AddNoJSONEscapeString method
  254. - new TRawUTF8ListHashed class, with extend TRawUTF8List by using an internal
  255. hash table to optimized IndexOf() method call (including case sensitivity)
  256. - new ToVarInt64() and FromVarInt64() functions to encode and decode
  257. variable-length signed Int64 values (with the corresponding new tftVarInt64
  258. kind of variable-length column in TSynTableFieldType enumeration)
  259. - new GotoNextJSONObjectOrArray() and RawUTF8ArrayToQuotedCSV() functions
  260. - new ReadStringFromStream() and WriteStringToStream() functions
  261. - fixed some compilation warnings with Delphi XE and XE2
  262. - fixed issue in TDynArrayHashed if you do not use the external Count
  263. - fixed potential GPF in TDynArrayHashed.ReHash after TDynArray.Clear call
  264. - fixed issue in TSynTableFieldProperties.SaveTo about saving wrong indexes
  265. - fixed issue TSynTableStatement when only one column was retrieved
  266. - fixed rounding issue in ExtendedToString() and all corresponding wrappers
  267. like DoubleToStr*, Add(Double...)
  268. - fixed issue in Hash32() implementation (potential GPF when reading ahead
  269. by DWORD - get rid of unnecessary asm optimization)
  270. - fixed issues in function IsJSONString() which returned TRUE for '-' or '+',
  271. or false positives in some border-line cases (due to wrong uppercase guess):
  272. now this function is split into IsString() and IsStringJSON() functions
  273. to explicitely handle null/false/true constant recognition
  274. - fixed potential false positives of null/false/true in function GetJSONField
  275. - get rid of wrong "Decimal" parameter in float to text conversion
  276. - TFileBufferWriter.Create now accepts up to 4 MB internal buffer size
  277. - increased TDynArrayHashed number of void entries (for speed)
  278. - modified TDynArray.SaveToStream/LoadFromStream to read or save the data
  279. from the current stream position
  280. - fixed GPF in TDynArray.SaveTo in case of invalid internal record layout
  281. - modified StreamUnSynLZ() so that Source stream will point after all read data
  282. - TDynArray.SaveToStream() method can now save to any TStream class
  283. - added TTextWriter.RegisterCustomJSONSerializer() method to allow JSON
  284. serialization of any dynamic array content (used by TDynArray.LoadFromJSON
  285. and TTextWriter.AddDynArrayJSON) and record content (used by RecordLoadJSON
  286. and TTextWriter.AddRecordJSON)
  287. - added USEPACKAGES conditional to help compiling the unit within packages
  288. - added optional DOPATCHTRTL to patch the RTL (e.g. RecordCopy, RecordClear
  289. TObject.CleanupInstance low-level functions) only if needed (not patched
  290. by default, for compatibility reasons) - you may want to use our Enhanced
  291. RTL patchs instead for a whole better response
  292. - new function BinToBase64URI()
  293. - circumvent some bugs of Delphi XE2 background compiler (main compiler is OK)
  294. - add premilinary Windows 8 operating system detection (as wEight/wEightServer)
  295. Version 1.17
  296. - check of QueryPerformanceFrequency failure, and rollback to low-resolution timer
  297. - handle properly old .synlz layout (reading compatibility was broken)
  298. - added TObjectListHashed class, which behaves like TList/TObjectList, but
  299. will use hashing for (much) faster IndexOf() method, and associated
  300. TObjectListPropertyHashed class, which allows hashing of a sub-property
  301. of an object (including some changes made to TDynArray/TDynArrayHashed)
  302. - new TTextWriter.AddDateTime() overloaded method able to quote the output
  303. - new TTextWriter.AddFloatStr() method handling partial floating-point text
  304. - both TTextWriter.AddDateTime() overloaded methods will store '' when value
  305. is 0, or a pure ISO-8601 date or time if the value is defined as such,
  306. just as expected by http://www.sqlite.org/lang_datefunc.html - it will also
  307. reduce average generated JSON/text content size
  308. - fixed issue about BLOB unproperly serialized into JSON (e.g. now uses null)
  309. - fixed ticket [e5ad3684b2] about some .map files parsing in TSynMapFile
  310. - TSynLog stack tracing uses low-level RtlCaptureStackBackTrace() API on CPU64
  311. - changed the non expanded JSON format to use lowercase first column names:
  312. {"fieldCount":1,"values":["col1"... instead of {"FieldCount":1,"Values":[..
  313. - new SetInt64() procedure for direct assignment of the result
  314. - TSynTableStatement class now accepts '_' in table and column identifiers
  315. - fixed implementation issue in function FindNextUTF8WordBegin()
  316. - fixed false negative issue in TSynSoundEx.UTF8 and TSynSoundEx.Ansi
  317. - fixed wrong UTF-8 encoding of U+FFF0 used for JSON_BASE64_MAGIC
  318. - added an optional parameter to StrToCurr64() function, able to return
  319. a true Int64 value if no decimal is supplied within the input text buffer
  320. - enhanced TSynAnsiFixedWidth.UnicodeBufferToAnsi average process speed
  321. - TSynCache.Reset now returns a boolean stating if something was flushed
  322. - new SynUnicodeToUtf8(), ShortStringToUTF8(), StringToSynUnicode(),
  323. SynUnicodeToString() functions
  324. - new StrToCurrency() wrapper function
  325. - new IdemPropName() overloaded function with two PUTF8Char arguments
  326. - new UTF8UpperCopy() and UTF8UpperCopy255() optimized functions
  327. - new GotoNextNotSpace() and GotoEndOfQuotedString() functions
  328. - new TMemoryMap.Map() method expecting a file name as parameter
  329. - new TRawUTF8List.LoadFromFile method
  330. - new DateToSQL(), DateTimeToSQL() and Iso8601ToSQL() functions, returning
  331. a string with a JSON_SQLDATE_MAGIC prefix and proper UTF-8/ISO-8601 encoding
  332. to be inlined as ? bound parameter in any SQL query (allow binding of
  333. date/time parameters as request by some external database engine
  334. which does not accept ISO-8601 text in this case)
  335. - added TDynArray.Equals() method to compare two arrays efficiently
  336. - added TDynArray and TDynArrayHashed InitSpecific() method able to specify
  337. how (hashing and) comparison should be processed for a given record
  338. (includes also some TDynArray/TDynArrayHashed refactoring and optimization)
  339. - new TObjectHash abstract class to use hashing to find an object
  340. - TTextWriter.AddJSONEscape() method speed up
  341. - moved logging threadvars and associated structures into hidden internal
  342. declaration, for better work with packages (avoid W1032 warning)
  343. - now JSON parser will handle #1..' ' chars as whitespace (not only ' ')
  344. - now JSON parser will allow whitespace inserted between any pair of tokens,
  345. even after true/false/null, as expected by the specification
  346. - fixed potential Integer Overflow error in Iso8601ToDateTimePUTF8Char*()
  347. - added PatchCode() and RedirectCodeRestore() procedures, and some code
  348. refactoring about process in-memory code patching
  349. - internal FillChar() will now use faster SSE2 instructions on supported CPUs
  350. Version 1.18
  351. - BREAKING CHANGE: SynLog.pas and SynTests.pas were extracted from SynCommons
  352. - BREAKING CHANGE of TTextWriter.WriteObject() method: serialization is now
  353. defined with a new TTextWriterWriteObjectOptions set
  354. - BREAKING CHANGE rename of Iso8601 low-level structure as TTimeLogBits, to use
  355. explicitly the TTimeLog type and name for all Int64 bit-oriented functions -
  356. now "Iso8601" naming will be only for standard ISO-8601 text, not Int64 value
  357. - BREAKING CHANGE: TTextWriter.Add(Format) won't handle the alternate $ % tags
  358. any more, unless you define the OLDTEXTWRITERFORMAT conditional
  359. - BREAKING CHANGE: TTextWriter.AddDouble() and AddSingle() dedicated methods
  360. replacing ambiquituous Add(), which was not appropriate for single values
  361. - BREAKING CHANGE: FormatUTF8() and TTextWriter.Add(Format) PUTF8Char type for
  362. constant text parameter has been changed into RawUTF8, to let the compiler
  363. handle any Unicode content as expected
  364. - RawByteString is now defined as "= type AnsiString" under non Unicode Delphi
  365. so that it would be recognized with its own encoding (pseudo code page 65535)
  366. - Delphi XE4/XE5/XE6/XE7/XE8/10/10.1 compatibility (Win32/Win64 target
  367. platforms only for the SynCommons and mORMot* units, but SynCrossPlatform*
  368. supports clients on all other targets, including OSX and NextGen compilers)
  369. - unit fixed and tested with Delphi XE2 (and up) 64-bit compiler under Windows
  370. - now all variants created within our units will create string instances of
  371. kind varString and type RawUTF8 - prior to Delphi 2009, ensure you call
  372. UTF8ToString(aVariant) if you want to use the value with the VCL
  373. - introducing TDocVariant for variant-based process of any hierarchy
  374. of objects and/or arrays, with late binding optimized access and JSON
  375. serialization/unserialization (will also be used for BSON documents storage)
  376. - UTF-8 process will now handle UTF-16 surrogates - see ticket [4a0382367d] -
  377. UnicodeCharToUTF8/NextUTF8Char are renamed WideCharToUTF8/NextUTF8UCS4 and
  378. new UTF16CharToUTF8/UCS4ToUTF8 functions have been introduced
  379. - added ToUTF8() overloaded functions, which could be used on most simple types
  380. - introducing TSynTimeZone class, for cross-platform local time handling
  381. - added TextColor() and TextBackground() functions - will initialize internal
  382. console process after any manual AllocConsole call
  383. - added ConsoleWaitForEnterKey function, able to handle Synchronize() calls
  384. - StrLen() function will now use SSE2 or SSE4.2 instructions on supported CPUs
  385. - introduced StrLenPas() function, to be used when buffer is protected
  386. - UpperCopy255Buf() function will use SSE4.2 instrctions on supported CPUs
  387. to speed up e.g. HashAnsiStringI()
  388. - included Windows-1258 code page to be recognized as a fixed-width charset
  389. - TSynAnsiFixedWidth.Create(CODEPAGE_US) will now use a hard-coded table,
  390. since some Russian system do tweak the registry to force 1252 page maps 1251
  391. - introducing TSynAnsiUTF8/TSynAnsiUTF16 to handle CP_UTF8/CP_UTF16 codepages
  392. - added UTF8AnsiConvert instance, and let TSynAnsiConvert.Engine(0) return
  393. the main CurrentAnsiConvert instance
  394. - StrComp/StrIComp/StrLen() functions will now expect blank pointers, to
  395. circumvent type mismatchs when passing PAnsiChar or PUTF8Char buffers
  396. - get rid of 12 maximum count of supplied argument in FormatUTF8()
  397. - FormatUTF8() and VarRecToUTF8() will append the class name of any TObject
  398. - added JSONFormat optional parameter to FormatUTF8() to produce valid JSON
  399. content from a given set of values identified by ? - used e.g. by _JsonFmt()
  400. - added ESynException.CreateUTF8() constructor, more powerful than the
  401. default Exception.CreateFmt(): this CreateUTF8 method is now used everywhere
  402. - added QuotedStrJSON() and NextNotSpaceCharIs() functions
  403. - refactored GetMimeContentType() implementation - see also [fca72ba0ce] -
  404. and introduced GetMimeContentTypeHeader() function
  405. - added MultiPartFormDataDecode() to decode multipart/form-data POST requests
  406. - included x64 asm of FillChar() and Move() for Win64 - Delphi RTL will be
  407. patched at startup, if the DOPATCHTRTL conditional is defined
  408. - introduced FillcharFast() and MoveFast() global function variables,
  409. pointing to optimized asm versions, depending on the CPU abilities
  410. - FastCode-based x86 asm Move() procedure will handle source=dest
  411. - faster x86/x64 asm versions of StrUInt32() StrInt32() StrInt64() functions
  412. - new StrUInt64(), UniqueRawUTF8(), FastNewRawUTF8() and SetRawUTF8() functions
  413. - introducing UTF8ToInteger() overloaded functions
  414. - recognize 8.1 and upcoming "Threshold" 9 in TWindowsVersion
  415. - added TypeInfo, ElemSize, ElemType read-only properties to TDynArray
  416. - added DynArrayLoad() and DynArraySave() helper functions
  417. - introducing TObjectDynArrayWrapper class and IObjectDynArray interface
  418. - introducing T*ObjArray dynamic array storage via ObjArrayAdd/ObjArrayFind/
  419. ObjArrayDelete/ObjArraySort and ObjArrayClear functions
  420. - introducing T*InterfaceArray dynamic array storage via InterfaceArrayAdd/
  421. InterfaceArrayFind/InterfaceArrayDelete functions
  422. - added TPersistentWithCustomCreate, TInterfacedObjectWithCustomCreate and
  423. TSynPersistent abstract classes, allowing to define virtual constructors for
  424. TPersistent kind of objects (used e.g. with internal JSON serialization,
  425. for interface-based services, or for DDD objects)
  426. - introducing TSynPersistentLocked and TInterfacedObjectLocked classes,
  427. avoiding CPU cache line performance issue (so to be preferred to TMonitor or
  428. TCriticalSection)
  429. - new TSynPersistentWithPassword class, able to store the password with
  430. a custom simple encryption when serialized as JSON
  431. - introducing TSynAuthentication class for simple generic authentication
  432. - introducing TSynConnectionDefinition class used e.g. for JSON-defined
  433. runtime instantiation of a TSQLDBConnectionProperties or TSQLRest instance
  434. - added TDynArrayHashed.HashElement property
  435. - new TDynArrayHashed.AddUniqueName() method
  436. - introduced TSingleDynArray, recognized as such in JSON serialization
  437. - fixed "single" floating-point values JSON serialization
  438. - added WordScanIndex() and swap32() functions
  439. - speed improvement of IdemPropNameU() function, with new overload function
  440. - now FileSize() function won't raise any exception if the file does not exist
  441. and will return any size > 2 GB as expected
  442. - faster PosEx() function in pure pascal mode (based on Avatar Zondertau work)
  443. - introducing StreamToRawByteString() / RawByteStringToStream() functions
  444. - introducing RawByteStringToBytes() / BytesToRawByteString() functions
  445. - added StringDynArrayToRawUTF8DynArray() and StringListToRawUTF8DynArray()
  446. - added CSVToRawUTF8DynArray() overloaded functions
  447. - added GetLastCSVItem() function and dedicated HashPointer() function
  448. - added DirectoryDelete() and EnsureDirectoryExists() function
  449. - added FileOpenSequentialRead() function, used e.g. by StringFromFile()
  450. - added GetNextItemInteger(), GetNextItemCardinalStrict() and UpperCaseCopy()
  451. - added GetEnumNameValue() and UnQuotedSQLSymbolName() functions
  452. - added JSONEncodeArrayOfConst() function
  453. - JSONEncode() and TTextWriter.AddJSONEscape() with NameValuePairs parameters
  454. will now handle nested arrays or objects specified with '['..']' or '{'..'}'
  455. and nil parameter as null JSON value
  456. - new TTextWriter.AddJSON() method and JSONEncode() overloaded function able
  457. to recognize (extended) JSON content, including MongoDB shell extensions
  458. - added IsHTMLContentTypeTextual() function, and modified ExistsIniNameValue()
  459. - added ShortStringToAnsi7String() and UpperCopyWin255() functions
  460. - added IsEqualGUID/IsNullGuid/GUIDToText/GUIDToRawUTF8/GUIDToString functions
  461. - added AddGUID/RandomGUID/TextToGUID/RawUTF8ToGUID/StringToGUID functions
  462. - added TDynArray.ElemPtr() low-level method
  463. - let TDynArray.LoadFrom() accept Win32/Win64 cross platform binary content
  464. - new TDynArray.CopyFrom() method and associated procedure DynArrayCopy()
  465. - TDynArray will now recognize variant/interface fields
  466. - new TDynArray.FastLocateSorted FastAddSorted FastLocateOrAddSorted methods
  467. - new TPendingTaskList class, for storing e.g. a time-ordered list of tasks
  468. - code refactoring of TTextWriter to simplify flushing mechanism, and
  469. allow internal buffer auto-grow if it was found out to be too small (see
  470. FlushToStream / FlushFinal methods and FlushToStreamNoAutoResize property)
  471. - fixed ticket [5bd9df5979] about TTextWriter.CancelAll issue
  472. - added optional internal buffer size for TTextWriter.CreateOwnedStream()
  473. - added new constructor TTextWriter.CreateOwnedFileStream()
  474. - added TTextWriter.LastChar and TTextWriter.AddStrings() methods
  475. - added TTextWriter.ForceContent method
  476. - added faster TTextWriter.SetText() method in conjuction to Text function
  477. - added TTextWriter.Add(const guid: TGUID) and Add(Value: boolean) methods
  478. - TTextWriter.Add(Format..) will now ignore any character afer |, i.e. |$ = $
  479. - added TTextWriter.AddQuotedStr() and AddStringCopy() methods
  480. - added TTextWriter.AddVoidRecordJSON() method
  481. - added TTextWriter.AddJSONEscapeAnsiString() method
  482. - added TTextWriter.AddAnyAnsiString() method and AnyAnsiToUTF8() function
  483. - added TTextWriter.EndOfLineCRLF property
  484. - for Delphi 2010 and up, RecordSaveJSON/RecordLoadJSON will use enhanced RTTI
  485. - before Delphi 2010, you can specify the record layout as text to
  486. TTextWriter.RegisterCustomJSONSerializerFromText() for JSON serialization
  487. - added TTextWriter.RegisterCustomJSONSerializerSetOptions() for [da22968223]
  488. - added TTextWriter.AddDynArrayJSON() overloaded method and new functions
  489. DynArrayLoadJSON() and DynArraySaveJSON() to be used e.g. for custom
  490. record JSON serialization, using TDynArrayJSONCustomReader/Writer
  491. callbacks and/or RegisterCustomJSONSerializerFromText(), or enhanced RTTI
  492. - added TTextWriter.AddDynArrayJSONAsString method, and moved
  493. TTextWriter.WriteObjectAsString from TJSONSerializer
  494. - added TTextWriter.UnRegisterCustomJSONSerializer() method
  495. - added TTextWriter.RegisterCustomJSONSerializerFromTextSimpleType() method
  496. - added TTextWriter.AddTypedJSON() and AddCRAndIdent methods
  497. - added TTextWriter.SetDefaultJSONClass to force TJSONSerializer use
  498. - added TJSONWriter.EndJSONObject() method, for writing an optional
  499. ',"rowCount":' field in non expanded mode - used for all JSON creation
  500. - added TTextWriter.EchoAdd() and EchoRemove() methods
  501. - added QuickSortIndexedPUTF8Char() and FastFindIndexedPUTF8Char()
  502. - added overloaded QuickSortInteger() for synchronous sort of two arrays
  503. - fixed potential critical issue [99fe8a1eba] in SortDynArrayInt64/Cardinal
  504. - added GetNextItem64() Int64Scan() Int64ScanExists() QuickSortInt64()
  505. FastFindInt64Sorted() AddInt64() CSVToInt64DynArray() Int64DynArrayToCSV()
  506. and VariantToInt64() functions (used during TID=Int64 introduction in ORM)
  507. - added RawUnicodeToUtf8() and UTF8ToSynUnicode() overloaded procedures
  508. - added HexToChar/HexToCharValid and UrlDecodeNextName(), UrlDecodeNextValue()
  509. and UrlDecodeNextNameValue() functions
  510. - added Utf8DecodeToRawUnicodeUI() overloaded function returning text as var
  511. - added UrlEncodeJsonObject() and new overloaded JSONDecode() function
  512. - added TRawUTF8DynArrayFrom(const Values: array of RawUTF8) function
  513. - added overloaded function FindRawUTF8() using array of RawUTF8 parameter
  514. - added TPropNameList record/object to maintain a stack-based list of names
  515. - speeed enhancement for TRawUTF8List.Add()
  516. - new TRawUTF8List.SaveToStream and SaveToFile methods
  517. - new TRawUTF8List.PopFirst and PopLast methods
  518. - added optional aOwnObjects parameter to TRawUTF8List.Create() constructor
  519. - new TRawUTF8List.GetObjectByName() method
  520. - refactoring of CaseSensitive property for TRawUTF8List / TRawUTF8ListHashed
  521. - added TRawUTF8List.CaseSensitive property as requested by [806332d296]
  522. - added TRawUTF8MethodList class (based on TRawUTF8ListHashed)
  523. - added TRawUTF8ListHashedLocked class (based on TRawUTF8ListHashed)
  524. - added TPointerClassHash and TPointerClassHashLocked classes (used e.g.
  525. to store RTTI cache, for T*ObjArray process)
  526. - added TAutoLocker/IAutoLocker and TLockedDocVariant/ILockedDocVariant types
  527. - added TAutoFree class, for automatic local variable lifetime management
  528. - added JSON_CONTENT_TYPE_HEADER and XML_CONTENT_TYPE[_HEADER] constants
  529. - new DateToSQL() overloaded function with direct Year/Month/Day parameters
  530. - added Base64MagicDecode(), Base64MagicCheckAndDecode() and SQLToDateTime()
  531. - added IsEqual(const A,B: TSQLFieldBits): boolean function
  532. - enhanced FPC/Lazarus Win32/Win64 compilation
  533. - TDynArrayHashed is now a record with Delphi 2009+, due to a bug in latest
  534. version of Delphi compiler when using TDynArrayHashed = object(TDynArray)
  535. - fixed [7658da5529] unexpected hash collision in TDynArrayHashed
  536. - fixed unexpected GPF in TSynCache.Find() e.g. when cache is disabled
  537. - handle variant serialization in/from JSON using new VariantLoadJSON(),
  538. VariantSaveJSON(), VariantSaveJSONLength() functions and corresponding
  539. TTextWriter.AddVariant() method
  540. - handle variant serialization in/from our binary custom format, using new
  541. VariantLoad(), VariantSaveLength() and VariantSave() functions
  542. - added VariantToUTF8() overloaded functions for fast conversion
  543. - added VariantToInteger()/VariantToIntegerDef()/VariantToInt64() functions
  544. for direct process of numerical variants (e.g. array indexes)
  545. - new RawUTF8ToVariant() and VarRecToVariant() functions
  546. - new RawByteStringToVariant() and VariantToRawByteString() functions
  547. - added VariantDynArrayToJSON/JSONToVariantDynArray/ValuesToVariantDynArray()
  548. - added VariantDynArrayClear() function (faster e.g. for array of TDocVariant)
  549. - added VariantToInlineValue() and VarRecToInlineValue() functions
  550. - added VarRecToInt64(), VarRecToDouble() and VarRecAsChar() functions
  551. - added overloaded Int32ToUTF8() Int64ToStr() Curr64ToStr() ExtendedToStr()
  552. PointerToHex() UInt32ToUtf8() procedures
  553. - handle binary serialization of variant via FromVarVariant() procedure and
  554. TFileBufferWriter.Write() method
  555. - added ToVarString(), FromVarInt64Value() and FromVarBlob() functions
  556. - added TFileBufferWriter.WriteVarInt64 and TFileBufferReader.ReadVarInt64
  557. - added TFileBufferWriter.Write1/Write4/Write8 methods and Tag property
  558. - new overloaded TFileBufferWriter.Create() constructor able to use a TStream
  559. class to replace CreateInRawByteStringStream and CreateInMemoryStream methods
  560. - now TFileBufferReader.Read() allows forward reading when Data=nil
  561. - added RecordSaveJSON() function which follows TTextWriter.AddRecordJSON() format
  562. - added SaveJSON() function to handle any kind of complex types from RTTI
  563. - added TSynNameValue.InitFromIniSection() method and optional default value
  564. parameter to TSynNameValue.Value()
  565. - added TSynNameValue.Delete() and SetBlobDataPtr() methods
  566. - added TSynNameValue.OnAfterAdd callback event
  567. - added TObjectListLocked class
  568. - expose all internal Hash*() functions (following TDynArrayHashOne prototype)
  569. in interface section of the unit
  570. - added crc32c() function using either optimized unrolled version, or SSE 4.2
  571. instruction: crc32cfast() is 1.7 GB/s, crc32csse42() is 3.7 GB/s
  572. - added fnv32() function, slower than kr32, but with less collisions
  573. - added SynLZCompress/SynLZDecompress functions, using crc32c() for hashing
  574. - added SymmetricEncrypt() function
  575. - added GetAllBits() function
  576. - changed GetBitCSV/SetBitCSV CSV format to use 'first-last,' pattern to
  577. regroup set bits (reduce storage size e.g. for TSQLAccessRights) - format
  578. is still compatible with old layout, but will more optimized and readable
  579. - TSynTableStatement.Create() SQL statement parser will handle optional
  580. LIMIT [OFFSET] clause (in new Limit/Offset integer properties),
  581. ORDER BY ... [DESC/ASC] clause (in new OrderByField/OrderByDesc properties),
  582. GROUP BY ... clause (in GroupByField property), "LIKE", "IN(...)" and
  583. "IS [NOT] NULL" operators and custom functions in the WHERE clause
  584. - TSynTableStatement.Where[] is now an array to allow complex WHERE clause
  585. - TSynTableStatement.Select[] is now an array to allow aggregate functions,
  586. (e.g. Count,Max or Distinct), column aliases, or simple +/- computation
  587. - introducing TSQLFieldIndex and TSQLFieldIndexDynArray types and associated
  588. functions so that TSynTableStatement would store the SELECT column order
  589. - SQLParamContent() / ExtractInlineParameters() functions moved from mORMot.pas
  590. (now properly handles SQL null and more than MAX_SQLFIELDS parameters)
  591. - introducing TSQLParamType / TSQLParamTypeDynArray generic parameters
  592. - added RemoveCommentsFromJSON() procedure - from MPV proposal
  593. - added GarbageCollectorFreeAndNil() procedure to handle global variables
  594. proper finalization to nil - avoid error [8e3073c8c7] and [8546b4af1d] e.g.
  595. when used as design package in Delphi IDE (for all globals and class VMTs)
  596. - made GarbageCollectorFree public - may be usefull e.g. with packages
  597. - added GlobalLock/GlobalUnlock functions, used e.g. for ticket [ea4e8bd544]
  598. - fixed rouding issue e.g. for ExtendedToString(double(22.99999999999997))
  599. - fixed potential GPF in TRawUTF8List.SetTextPtr() - ticket [d947b36cf9]
  600. - fixed potential GPF in function UrlDecodeNeedParameters()
  601. - fixed ticket [c8a8c71b12] allowing decoding of URI computed by browsers,
  602. even if they do not follow the RFC 3986 specifications
  603. - fixed potential GPF in serveral functions, when working with WideString
  604. (WideString aka OleStr do store their length in bytes, not WideChars)
  605. - fixed TDynArray.AddArray() method when Count parameter is not specified,
  606. and introducing TDynArray.AddDynArray() method
  607. - fixed ticket [ad55566b10] about JSON string escape parsing
  608. - fixed ticket [cce54e98ca], [388c2768b6] and [355249a9d1] about overflow in
  609. TTextWriter.AddJSONEscapeW()
  610. - fixed ticket [a75c0c6759] about TTextWriter.AddNoJSONEscapeW()
  611. - added TTextWriter.AddHtmlEscape() and TTextWriter.AddXmlEscape() methods
  612. - new TTextWriter.AddHtmlEscapeWiki() method, supporting wiki-like syntax
  613. - TTextWriter.AddJSONEscape/AddJSONEscapeW methods speed up
  614. - fixed ticket [01408fd389] in TRawUTF8List.GetText()
  615. - fixed ticket [e3ae1005dc] about potential GPF in TRawUTF8List.Delete()
  616. - fixed ticket [1c940a4437] to avoid negative value in TPrecisionTimer.PerSec,
  617. in case of incorrect Start/Stop methods sequence
  618. - implement ticket [e3f9742865] for enhanced JSON in soWriteHumanReadable mode
  619. - added TPrecisionTimer.ProfileCurrentMethod() and TimeInMicroSec property
  620. for feature request [1abca090ee]
  621. - added TLocalPrecisionTimer/ILocalPrecisionTimer to alllocate a local timer
  622. instance on the stack
  623. - fixed ticket [815facfe57] in UTF8ILComp()
  624. - fixed UTF8ToWideChar() functions to always append a WideChar(0) to the end
  625. of the destination buffer, even if returned length is 0
  626. - added AnyTextFileToString, AnyTextFileToSynUnicode and AnyTextFileToRawUTF8
  627. - declared PByteArray, PWordArray, PPointerArray here - see [d6b38a96e6]
  628. - fixed IdemPChar() in pure pascal to behave like the asm version (i.e.
  629. if up parameter is nil, will return TRUE)
  630. - added IdemPCharWithoutWhiteSpace() function
  631. - confusing-named RoundTo2Digits() function renamed into Trunc2ToDigit()
  632. - added simple, non banker rounding SimpleRoundTo2Digits() function
  633. - fixed potential comparison error in TSynTableFieldProperties.SortCompare()
  634. when sorting UTF8 Field with tfoCaseInsensitive in Options
  635. - speedup of QuotedStr() function and TDynArrayHashed hashing process
  636. - added GotoEndOfJSONString() function
  637. - added GetJSONPropName() and GotoNextJSONPropName() functions, able to
  638. understand MongoDB extended syntax
  639. - added JSONArrayCount/JSONObjectPropCount, JsonArayItem and
  640. JsonObjectItem/JsonObjectByPath/JsonObjectsByPath functions
  641. - several speedup in GetJSONField() and JSON parsing: it will now expect true,
  642. false or null to be in lowercase only (as in json.org specifications)
  643. - fixed function GetJSONField() to properly decode JSON number with exponent
  644. - added function GetJSONFieldOrObjectOrArray() in unit's interface section
  645. - function GotoNextJSONField() renamed GotoNextJSONItem(), and fixed to
  646. handle nested JSON array or objects in addition to string/numbers
  647. - added GotoEndJSONItem() and GetJSONItemAsRawJSON() functions
  648. - added function JSONRetrieveIDField() for fast retrieval of a "ID":.. value
  649. - added function JSONRetrieveStringField() for retrieval of a string field
  650. name or value from JSON buffer
  651. - added PtrUIntScanIndex() and UnixTimeToDateTime/DateTimeToUnixTime()
  652. UnixMSTimeToDateTime/DateTimeToUnixMSTime functions
  653. - fixed ticket [aff1352239] to identify 9999-12-31 dates as valid
  654. - added Iso8601ToTimePUTF8Char[Var]() and IntervalTextToDateTime[Var]() functions
  655. - added DateTimeToIso8601ExpandedPChar() and Iso8601CheckAndDecode() functions
  656. - added TTimeLogBits.FromUTCTime method and NowUTC / TimeLogNowUTC functions
  657. - added TTimeLogBits.FromUnixTime/FromUnixMSTime/ToUnixTime/ToUnixMSTime
  658. - added TTimeLogBits.Year/Month/Day/Hour/Minute/Second functions
  659. - added GetTickCount64() function, native since Vista, emulated e.g. for XP
  660. - introducing InterlockedIncrement/IntelrlockedDecrement compatibility functions
  661. - fixed TTextWriter.RegisterCustomJSONSerializer() method when unregistering
  662. - fixed TTextWriter.AddFloatStr() method when processing '-.5' input
  663. - fixed potential random GPF in TTextWriter after Flush - see [577ad95cfd0]
  664. - added TTextWriter.Add(const Values: array of const) method
  665. - added JSONToXML() JSONBufferToXML() and TTextWriter.JSONBufferToXML()
  666. for direct and fast conversion of any JSON into the corresponding <XML>
  667. - added JSONReformat() JSONBufferReformat() JSONReformatToFile()
  668. JSONBufferReformatToFile() and TTextWriter.AddJSONReformat()
  669. for fast conversion into more readable, compact or extended layout
  670. - fixed potential GPF issue in TMemoryMapText.LoadFromMap()
  671. - added TMemoryMapText.AddInMemoryLine method to allow runtime appending of
  672. new lines of text - used e.g. by TSynLogFile for life update of remote logs
  673. - added TMemoryMapText.SaveToFile() and TMemoryMapText.SaveToStream() methods
  674. - allow file size of 0 byte in TMemoryMap.Map()
  675. - introduced TSynInvokeableVariantType.Clear() and Copy() default methods
  676. - added TSynInvokeableVariantType.CopyByValue() virtual method
  677. - added TSynInvokeableVariantType.IsOfType() method
  678. - TSynInvokeableVariantType.SetProperty() will now convert any varOleStr into
  679. a RawUTF8/varString, and dereference any simple varByRef transmitted values
  680. so that we could safely use late-binding with any kind of value
  681. - internal DispInvoke() function speed-up by caching the latest accessed type
  682. - enabled DispInvoke() function for Delphi XE2 and up (it will also fix the
  683. regression issue in the new RTL which let the field names be uppercased)
  684. - several TSynTableFieldProperties speed up, when working with variants
  685. - removed several compilation hints when assertions are set to off
  686. - UnCamelCase() functions will now handle capital words and numbers at the
  687. beginning, middle or end of the text - implements request [d0c8210fae]
  688. - added TSynBackgroundThreadAbstract class for generic background process, and
  689. callback-driven TSynBackgroundThreadEvent / TSynBackgroundThreadProcedure /
  690. TSynBackgroundThreadMethod inherited classes
  691. - new TSynParallelProcess for parallel processing of indexed information
  692. - added SetThreadName/SetCurrentThreadName functions for request [6acfd0a3d3]
  693. - added TSynFPUException class to allow per-method customization of the FPU
  694. exception mapping: to be used e.g. when mixing code between external
  695. libraries and Delphi code
  696. - added new TSynValidateNonVoidText and TSynFilterTruncate classes
  697. - added Utf8TruncateToUnicodeLength() and Utf8TruncateToLength() functions
  698. - added MaxAlphaCount, MaxDigitCount, MaxPunctCount, MaxLowerCount and
  699. MaxUpperCount properties to TSynValidateText class
  700. - added ResourceToRawByteString and ResourceSynLZToRawByteString functions
  701. - if DOPATCHTRTL is defined, will enable asm-optimized RecordClear and
  702. _InitializeRecord functions in replacement to the slower RTL version, and
  703. patch TObject.CleanupInstance before Delphi 2009 (since TMonitor.Destroy
  704. is sadly private to System.pas)
  705. - introducing TSQLVar to define database-oriented values
  706. used by SynDB, mORMot, mORMotDB and mORMotSQLite3 units (instead of former
  707. confusing TVarData record, which is now dedicated to variant mapping)
  708. - moved TSQLDBFieldType from SynDB to SynCommons, and used by TSQLVar and all
  709. database-related process (i.e. in mORMot and SynDB units)
  710. - SYNOPSE_FRAMEWORK_VERSION constant will now include a per-commit increasing
  711. number (generated by SourceCodeRep tool), to specify the exact source state
  712. and a more complete SYNOPSE_FRAMEWORK_FULLVERSION constant has been added
  713. *)
  714. {$I Synopse.inc} // define HASINLINE USETYPEINFO CPU32 CPU64 OWNNORMTOUPPER
  715. interface
  716. uses
  717. {$ifndef LVCL}
  718. {$ifndef FPC}
  719. {$ifndef HASFASTMM4}
  720. FastMM4,
  721. {$endif}
  722. {$endif}
  723. {$endif}
  724. {$ifdef MSWINDOWS}
  725. Windows,
  726. Messages,
  727. {$ifndef LVCL}
  728. Registry,
  729. {$endif}
  730. {$else MSWINDOWS}
  731. {$ifdef KYLIX3}
  732. Types,
  733. LibC,
  734. SynKylix,
  735. {$endif}
  736. {$ifdef FPC}
  737. BaseUnix,
  738. {$endif}
  739. {$endif MSWINDOWS}
  740. Classes,
  741. {$ifndef LVCL}
  742. SyncObjs, // for TEvent and TCriticalSection
  743. Contnrs, // for TObjectList
  744. {$ifdef HASINLINE}
  745. Types,
  746. {$endif}
  747. {$endif}
  748. {$ifndef NOVARIANTS}
  749. Variants,
  750. {$endif}
  751. SynLZ, // needed for TSynMapFile .mab format
  752. SysUtils;
  753. const
  754. /// the corresponding version of the freeware Synopse framework
  755. // - includes a commit increasing number (generated by SourceCodeRep tool)
  756. // - a similar constant shall be defined in SynCrtSock.pas
  757. SYNOPSE_FRAMEWORK_VERSION = {$I SynopseCommit.inc};
  758. /// a text including the version and the main active conditional options
  759. // - usefull for low-level debugging purpose
  760. SYNOPSE_FRAMEWORK_FULLVERSION = SYNOPSE_FRAMEWORK_VERSION
  761. {$ifdef LVCL}+'_LVCL'{$else}
  762. {$ifdef ENHANCEDRTL}+' ERTL'{$endif}{$endif}
  763. {$ifdef DOPATCHTRTL}+' PRTL'{$endif}
  764. {$ifdef INCLUDE_FTS3}+' FTS3'{$endif};
  765. { ************ common types used for compatibility between compilers and CPU }
  766. const
  767. /// internal Code Page for UTF-16 Unicode encoding
  768. // - used e.g. for Delphi 2009+ UnicodeString=St…