dsDBFilter

dsDBFilter was developed for TBTRVTable and was later used for TDBFTable as well. TBTRVTable and TDBFTable are TDataset descendant. We needed filtering capability in such style:

Table.Filter := 'Name = ''John'' AND Height > 170';
Table.Filtered := true;

TBTRVTable knows so called extended filter which is much like SQL. That means you send this filter to the database and database already returns filtered records. But extended filter has certain limitations so it's neccesary sometimes to filter records on the client side as it's always the case for TDBFable. Filtering is usually done in overriden procedure GetRecord and that is the case in TBTRVTable and TDBFTable as well.

We know two types of filter expression:

FieldName-operator-Value (example: Name='John')
FieldName-operator-FieldName (example. Height=Weight)

dsDBFilter takes string as a parameter, parses that string and builds inverse field notation of expressions. That expressions are pointers to fields and values. So when filter needs to be calculated, it goes trough that list, calculated expressions and puts results into boolean stack from which final result is then taken.

That means dsDBFilter is quite fast. In fact I don't see any better or faster option to do this. dsDBFilter is here for anybody who needs it and would like to play with it. In case you do, let me know.

source