Skip to content

Repository files navigation

DelphiBoostPack

The bits of the modern RTL that Delphi 2007 never got - as drop-in units, not a framework.

HTTP, JSON, hash dictionaries, SHA-256, background tasks. Pure Pascal source, no third-party DLLs, no packages to register. Copy in a unit and use it.

Delphi Dependencies Tests License

Install

Nothing to install, two ways in:

  • Modular. Put src\Core\Classes and src\Core\Units on your library path, or copy the units you use. A few want a companion: the dictionaries want BpVariantUtils and BpKeyFold, TbpStringList wants BpKeyFold, BpJson wants BpStringBuilder, BpHMACSHA256 and BpPasswordHash want BpBase64, BpPathUtils wants BpKeyFold, BpObjectComparer wants BpStrDictionary, and everything that touches TBytes wants BpCompat.
  • One file. Take a bundle from dist/ instead. Each is self-contained, so do not also use the modular units it embeds.

An HTTPS call and a JSON parse, on a 2007 compiler, with nothing else installed:

uses BpHttpClient, BpJson;

lvJson := TbpJsonValue.Parse(TbpHttpClient.FetchUrl('https://api.github.com/repos/dimitar-grigorov/DelphiBoostPack'));
try
  ShowMessage(Format('%s, %d stars', [lvJson.GetStr('full_name'),
    lvJson.GetIntDef('stargazers_count', 0)]));
finally
  lvJson.Free;
end;

A big download that does not freeze the UI, in one line:

FTask := BpDownloadAsync('https://host/big.zip', 'C:\temp\big.zip', HandleProgress, HandleDone);

Worker thread, progress and completion events on the main thread, no ProcessMessages, FTask.Cancel whenever you like. More examples ->

Why

Rewriting a 300-unit legacy app just to get a TDictionary is not a plan. This is the missing RTL as loose units you can lift one at a time: it targets Delphi 2007 first and is written to compile unchanged from Delphi 7 to 11.3, so it goes wherever your codebase happens to live. The scripts here build and test on Delphi 2007 and compile every unit on Delphi 7, so the low end of that range is checked rather than claimed.

Nearly every unit has a DUnit test unit behind it, and the crypto and hash units are checked against the published standard vectors (FIPS, RFC) and the Windows CryptoAPI, so the numbers match other implementations.

What's inside

Full descriptions and examples in the feature guide.

Network and async

Unit What you get
TbpHttpClient Get / Post / PostJson / Put / Delete, all cancellable, bearer and basic auth, streaming downloads, keep-alive. WinInet, so TLS comes from Windows and no OpenSSL DLLs ride along
TbpHttpDownloadTask non-blocking downloads with progress, prompt cancel and partial-file cleanup
TbpTask run any method on a worker thread, completion and failure as events on the main thread, any thread may create or free it
TbpCancellationToken the C# CancellationToken idea, for Delphi 7

Data

Unit What you get
TbpJsonValue strict RFC 8259 reader and writer, FindPath('data.items[0].name'), pretty printing
BpDateUtils ISO 8601 / RFC 3339 and Unix time both ways, in Int64 - what D2007 has no ISO8601ToDate for
TbpStrDictionary / TbpIntDictionary real hash maps for compilers with no generics, TDictionary-style API, typed accessors that refuse to coerce
TbpStringList the TStringList API on a TStrings with O(1) IndexOf and IndexOfName, a stable Sort and one ordinal relation behind hash, equality and order
TbpIntList a list of integers that behaves like TStringList, with O(1) IndexOf
TbpInt64List the same list for Int64 - keys, file sizes, millisecond timestamps

Strings

Unit What you get
TbpStringBuilder the XE6 TStringBuilder API on compilers that never got it; appends through a cached buffer pointer instead of resizing the string every time
BpStrUtils Split, Join, StartsWith / EndsWith, and a FastStringReplace that stays linear where StringReplace goes quadratic

Hashing and encoding

Unit What you get
BpSHA256 / BpMD5 one-shot or streaming digests for buffers, strings and files; hex or Base64 out
BpHMACSHA256 request signing and webhook verification (RFC 2104)
BpPasswordHash PBKDF2-HMAC-SHA256 with CSPRNG salt, 600k iterations and a self-describing record
BpBase64 Base64 and Base64url; the decoder forgives padding and whitespace, and a UTF-8 set for text
BpEncoding strict UTF-8 decoding that fails instead of handing back U+FFFD, with a documented fallback
BpHashBobJenkins lookup3, interoperable with the RTL's BobJenkinsHash

Windows and odds and ends

Unit What you get
TbpCredentials secrets in the Windows Credential Manager, keyring style, instead of plaintext in an INI
TbpObjectComparer diff two objects by RTTI and get the changed properties, collections included
BpKeyFold case folding for hash keys with no allocation per lookup, and correct outside ASCII
BpPathUtils one path relation instead of one per call site, and the Windows shapes hand-rolled helpers get wrong
BpVariantUtils / BpSysUtils / StopWatch strict Variant conversions, old-compiler shims, a QueryPerformanceCounter stopwatch

One file instead of ten

dist/ holds amalgamated builds, SQLite style: BpDictionaries.pas, BpHashes.pas, BpHttpClientStandalone.pas, BpJsonStandalone.pas. Each is self-contained - take the one you need and nothing else. They can be combined: no two of them export the same helper. Treat them as build artifacts: fix the real unit and regenerate. Details ->

Building and testing

The .cmd scripts at the repo root are thin wrappers over tools/Build_Delphi.cmd, which drives MSBuild for a .dproj, dcc32 for a .dpr, and either compiler:

Build_Main_D2007.cmd Release
Build_Main_D7.cmd             compile every unit with Delphi 7
RunTests_D2007.cmd            unit + integration
RunTests_D2007.cmd /nointeg   offline run
RunTests_D2007.cmd /bench     add the benchmarks
tools\VerifyBundles.cmd /d7   compile the dist bundles standalone on Delphi 7

RunTests_D2007.cmd builds the DUnit runner and runs it. See tests/README.md for the breakdown, and note that the tests are also the most complete set of examples in the repo. The Delphi 7 claim is a compile gate, not a test run: DUnit is not part of that install, so Build_Main_D7.cmd compiles every unit through src\DelphiBoostPack.dpr, which uses them all.

Add /ci to any of them to skip the pause on failure. The compilers are found from BDS and DELPHI7, then the registry, then the default install path.

Contributing

Fork it, fix or add something, open a pull request. Bugs, new units and better docs are all fair game.

House style: locals lv, globals gv, constants lc / gc, parameters a (aValue); classes get the Tbp prefix, one class per unit where it makes sense and the unit named after it; comments are // lines.

Getting Delphi

Official ISOs and web installers for the older Delphi and RAD Studio releases are collected here:

License

GPL-3.0 - see LICENSE.

About

A comprehensive suite of utilities enhancing Delphi development needs.

Resources

Stars

6 stars

Watchers

2 watching

Forks

Releases

Packages

Contributors

Languages