wiki:sqlite3:disqlite3zlib.pas
Delphi 12 Athens Updates Available!
To download, click your product: DIContainers, DIConverters, DICreole, DIFileFinder, DIGoogleReader, DIHtmlLabel, DIHtmlParser, DIMime, DIRegEx, DISQLite3, DITidy, DIUcl, DIUnicode, DIXml, YuBrotli, YuImage, YuNetSurf, YuOpenSSL, YuPcre2, YuPdf, YuStemmer, YuXmlSec, YuZip.
To download, click your product: DIContainers, DIConverters, DICreole, DIFileFinder, DIGoogleReader, DIHtmlLabel, DIHtmlParser, DIMime, DIRegEx, DISQLite3, DITidy, DIUcl, DIUnicode, DIXml, YuBrotli, YuImage, YuNetSurf, YuOpenSSL, YuPcre2, YuPdf, YuStemmer, YuXmlSec, YuZip.
no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
— | wiki:sqlite3:disqlite3zlib.pas [2020/08/28 11:42] (current) – created - external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== DISQLite3: DISQLite3ZLib.pas====== | ||
+ | {{page>: | ||
+ | {{page>: | ||
+ | |||
+ | <WRAP tip>An updated version of this unit is distributed with the DISQLite3 package.</ | ||
+ | |||
+ | <code delphi> | ||
+ | {------------------------------------------------------------------------------- | ||
+ | |||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | -------------------------------------------------------------------------------} | ||
+ | |||
+ | unit DISQLite3ZLib; | ||
+ | |||
+ | {$I DI.inc} | ||
+ | {$I DISQLite3.inc} | ||
+ | |||
+ | {$IFDEF DISQLite3_Personal} | ||
+ | !!! This unit does not compile with DISQLite3 Personal !!! | ||
+ | !!! Download DISQLite3 Pro from www.yunqa.de/ | ||
+ | {$ENDIF DISQLite3_Personal} | ||
+ | |||
+ | interface | ||
+ | |||
+ | uses | ||
+ | DISQLite3Api; | ||
+ | |||
+ | procedure sqlite3_create_function_zlib(const DB: sqlite3); | ||
+ | |||
+ | implementation | ||
+ | |||
+ | uses | ||
+ | SysUtils, zlib; | ||
+ | |||
+ | resourcestring | ||
+ | SCompressError = ' | ||
+ | SDecompressError = ' | ||
+ | |||
+ | procedure sqlite3_zlib_compress_func( | ||
+ | pCtx: sqlite3_context; | ||
+ | nArgs: Integer; | ||
+ | Args: PPointerArray); | ||
+ | var | ||
+ | Arg0: Pointer; | ||
+ | InBuf, OutBuf: Pointer; | ||
+ | InBytes, OutBytes: Integer; | ||
+ | begin | ||
+ | Arg0 := Args[0]; | ||
+ | case sqlite3_value_type(Arg0) of | ||
+ | SQLITE_TEXT: | ||
+ | begin | ||
+ | InBuf := sqlite3_value_text(Arg0); | ||
+ | InBytes := sqlite3_value_bytes(Arg0); | ||
+ | if InBytes > 0 then | ||
+ | begin | ||
+ | try | ||
+ | CompressBuf(InBuf, | ||
+ | if OutBytes > 0 then | ||
+ | sqlite3_result_text( | ||
+ | pCtx, OutBuf, OutBytes, sqlite3_destroy_mem) | ||
+ | else | ||
+ | sqlite3_result_text(pCtx, | ||
+ | except | ||
+ | sqlite3_result_error( | ||
+ | pCtx, PAnsiChar(SCompressError), | ||
+ | end; | ||
+ | Exit; | ||
+ | end; | ||
+ | end; | ||
+ | SQLITE_BLOB: | ||
+ | begin | ||
+ | InBuf := sqlite3_value_blob(Arg0); | ||
+ | InBytes := sqlite3_value_bytes(Arg0); | ||
+ | if InBytes > 0 then | ||
+ | begin | ||
+ | try | ||
+ | CompressBuf(InBuf, | ||
+ | if OutBytes > 0 then | ||
+ | sqlite3_result_blob( | ||
+ | pCtx, OutBuf, OutBytes, sqlite3_destroy_mem) | ||
+ | else | ||
+ | sqlite3_result_blob(pCtx, | ||
+ | except | ||
+ | sqlite3_result_error( | ||
+ | pCtx, PAnsiChar(SCompressError), | ||
+ | end; | ||
+ | Exit; | ||
+ | end; | ||
+ | end; | ||
+ | end; | ||
+ | sqlite3_result_value(pCtx, | ||
+ | end; | ||
+ | |||
+ | procedure sqlite3_zlib_uncompress_func( | ||
+ | pCtx: sqlite3_context; | ||
+ | nArgs: Integer; | ||
+ | Args: PPointerArray); | ||
+ | var | ||
+ | Arg0: Pointer; | ||
+ | InBuf, OutBuf: Pointer; | ||
+ | InBytes, OutBytes: Integer; | ||
+ | begin | ||
+ | Arg0 := Args[0]; | ||
+ | case sqlite3_value_type(Arg0) of | ||
+ | SQLITE_TEXT: | ||
+ | begin | ||
+ | InBuf := sqlite3_value_text(Arg0); | ||
+ | InBytes := sqlite3_value_bytes(Arg0); | ||
+ | if InBytes > 0 then | ||
+ | begin | ||
+ | try | ||
+ | DeCompressBuf(InBuf, | ||
+ | if OutBytes > 0 then | ||
+ | sqlite3_result_text( | ||
+ | pCtx, OutBuf, OutBytes, sqlite3_destroy_mem) | ||
+ | else | ||
+ | sqlite3_result_text(pCtx, | ||
+ | except | ||
+ | sqlite3_result_error( | ||
+ | pCtx, PAnsiChar(SDecompressError), | ||
+ | end; | ||
+ | Exit; | ||
+ | end; | ||
+ | end; | ||
+ | SQLITE_BLOB: | ||
+ | begin | ||
+ | InBuf := sqlite3_value_blob(Arg0); | ||
+ | InBytes := sqlite3_value_bytes(Arg0); | ||
+ | if InBytes > 0 then | ||
+ | begin | ||
+ | try | ||
+ | DeCompressBuf(InBuf, | ||
+ | if OutBytes > 0 then | ||
+ | sqlite3_result_blob( | ||
+ | pCtx, OutBuf, OutBytes, sqlite3_destroy_mem) | ||
+ | else | ||
+ | sqlite3_result_blob(pCtx, | ||
+ | except | ||
+ | sqlite3_result_error( | ||
+ | pCtx, PAnsiChar(SDecompressError), | ||
+ | end; | ||
+ | Exit; | ||
+ | end; | ||
+ | end; | ||
+ | end; | ||
+ | sqlite3_result_value(pCtx, | ||
+ | end; | ||
+ | |||
+ | procedure sqlite3_create_function_zlib(const DB: sqlite3); | ||
+ | begin | ||
+ | sqlite3_check(sqlite3_create_function(DB, | ||
+ | SQLITE_ANY, nil, sqlite3_zlib_compress_func, | ||
+ | sqlite3_check(sqlite3_create_function(DB, | ||
+ | SQLITE_ANY, nil, sqlite3_zlib_uncompress_func, | ||
+ | end; | ||
+ | |||
+ | end. | ||
+ | </ |
wiki/sqlite3/disqlite3zlib.pas.txt · Last modified: 2020/08/28 11:42 by 127.0.0.1