Commons

Commons

🌍 Language: English | Español

Cross-cutting utilities for DAFce applications — smart pointers, cancellation tokens, async futures, process execution, RTTI helpers, enumerable abstractions, command-line parsing, and more.

Delphi 12+ License


Modules at a glance

Unit Highlights
Daf.MemUtils ARC<T> smart pointer (reference to function: T), TFinalizer, TPurgatory
Daf.Threading ICancellationToken, ICancellationTokenSource (factory: CreateCancellationTokenSource), TShutdownHook
Daf.Enumerable ToIEnumerable<T> adapter, IInterfaceList<T>, TInterfaceList<T>
Daf.SystemProcess TSystemProcess — async external process runner with events
Daf.CmdLn.Parser Command-line argument parser
Daf.Rtti RTTI helpers — _T.Extends, type predicates
Daf.Activator Create class instances via RTTI
Daf.Arrays TArrayHelper (Map, Trim), TSmartArray<T> (LINQ-style: Where, Select, Contains, Sort, …)
Daf.Expression Simple expression evaluator
Daf.Types Common base types

Quick examples

ARC smart pointer

uses Daf.MemUtils;

var Ref := ARC.From<TMyObject>(TMyObject.Create);
Ref().DoWork;
// auto-freed when Ref goes out of scope

Cancellation token

uses Daf.Threading;

var Cts   := CreateCancellationTokenSource;
var Token := Cts.Token;

TThread.CreateAnonymousThread(procedure
begin
  while not Token.IsCancellationRequested do
    DoWork;
end).Start;

Sleep(5000);
Cts.Cancel;

External process (async)

uses Daf.SystemProcess;

var Process := TSystemProcess.Builder
  .Command('git')
  .CmdArgs(['--version'])
  .OnStdOut(procedure(Line: string) begin WriteLn(Line); end)
  .OnCompleted(procedure(R: TProcessResult) begin WriteLn('Done, exit=', R.ExitCode); end)
  .Build;

Process.ExecuteAsync;

Documentation

  • 📖 Usage Guide — full API reference for all units