BeniBela online

Sources

You can find all my published sources usable in your projects. Only components for Delphi are on another page. All sources published under the terms of the MPL-, GPL- or BSD-License can you change and distribute in any way you want.
But in case of MPL or GPL you must publish changes and you mustn't change the license. In case of GPL you must also publish extensions and the source of every program (from you) using it under the terms of the GPL.
Is any of the files published under the terms of more than one license, you can choose one of them.
You can find more and legally valid information in the source files.

Titel Beschreibung Sprache Lizenz
Internet Tools Containing a full XPath 2/XQuery/JSONiq engine, a pattern matcher for html/xml, an auto update class and a http connection wrapper. FPC GPL
Farbauswahldialog A color select dialog with hls- and rgb-mode. Delphi GPL
TCommandLineReader An unit for the parsing of command line parameters FPC, Delphi GPL
Big Decimal Math An arbitrary precision bcd floating point library FPC GPL
Diagram-Tools A diagram component based on a model/view system. FPC/Lazarus GPL
Non-VCL Canvas A translation of the Delphi-Canvas to non vcl. Delphi MPL, GPL
BBUtils Often needed functions missing in FPC. Delphi, FPC (LC)LGPL
Diffreader A unit to read and write unified diffs. FPC GPL
TCVirus An unit/component for the development of joke programs Delphi MPL, GPL
TAutoUpdater An unit for an automatically update FPC GPL
SimpleBrowser A simple IE-based browser (Delphi), (EXE) GPL
Huffmankomprimierer A collection of function for huffman (de-)compression. Delphi MPL, GPL
TRegExpr Mirror of TRegExpr of Andrey V. Sorokin Delphi, FPC GPL

 Internet Tools

2006 - 2013
GPL
This package consists of several units working together:

  • The simple html parser at the lowest level, parses a xml/html file and calls callback functions for every tag and text it has read.
  • The html tree parser, uses the simpler parser to read an xml/html file and create a linked element-stream from it, which is equivalent to a dom-like tree. This parser takes much care to make the tree usable, e.g. by correcting errors in invalid html files and auto detecting its encoding.
  • With the XPath 2 / XQuery engine you can then run arbitrary XPath 2 / XQuery queries on the dom-like representation. It is completely implemented in Pascal, supports all XPath 2 / XQuery functions and is nearly standard compatible. (compare its XQuery Testsuite results or the results on the XPath 2 subset). It also supports JSONiq.
  • The parser for CSS 3 selectors is part of then XQuery class, converts the CSS selector to a XPath expression and evaluates that.
  • The pattern-matching html template engine at the highest level, can be used to process an html file by annotating a subset of it and applying the resulting template to the html file. All elements in the template are searched in the html file and template instructions in matching elements can be used to extract data. For example a template like
    <a>{@href}</a>*
    will read the urls of all links in a html file.
    A template like this:
    <table id="foobar"><tr><td>abc</td><td>{.}</td>*</tr>*</table>
    will read all table cells after the cell containing abc in all rows of the table with id foobar. And a template like this:
    <table id="foobar"><tr>{temp := 0}<td>abc</td><td>{temp := $temp + .}</td>*{result := $temp}</tr>*</table>
    will calculate the sum of all table cells after the abc cell in all rows.
    You can also try these templates online or with Xidel.
  • The multi page template engine can be used to download several pages, and apply a single-page template to each of them. Contrary to the single-page template it does not do any pattern matching itself (of course the single-page templates contained in a multi-page template do pattern matching against each page), but simply executes the actions in the order given in the template. It also supports variables, condition and loops, so it is even Turing complete.
  • The http/s-wrapper let you switch dynamically between Wininet (default library installed on every Windows computer), Synapse (platform-independent, but not always installed and problematic with https) and Apache HttpComponents (called through JNI and runs on Android).
  • The auto update class is a trivial example for the other classes and can be used to add an auto update function to a program which will check online for a more recent version, download that version automatically and (optionally) install it.


Summary of features:

  • Parsers/interpreters:
    • for xml/html files, with a sax or dom-like interface
    • for XPath 2 / XQuery expressions
      • nearly completely standard compatible: passes 99.3% of the XPath 2 only tests and 97.8% of the XQuery 1 tests in the XQuery Testsuite
        (skipping tests for invalid input queries; most failing tests depend on xml schemas which are not supported, yet)
      • Some extension for objects, css, regular expressions, pattern matching and JSONiq
    • ! and || operators of XPath/XQuery 3.0
    • for JSONiq: An extension to XQuery to handle JSON data
    • for CSS 3 Selectors
      • standard compatible (afaik)
      • standalone or within XPath queries //foobar/css("p#x a.class")/@href
    • for pattern-matching html/xml templates:
      • Templates can be easily created/updated from the existing html file
      • The template languages allows the inclusion of regular, XPath 2 / XQuery, JSONiq and CSS 3 Selectors expressions
      • The language has variables, optional elements, loops and conditions
      • e.g. <p class="test"><span>Caption:</span><a>{.}</a>*</p> will read all links after the span-element containing Caption: in a paragraph with class test
    • for multi-page "scraping" templates
      • A collection of pattern-matching template to apply to several webpages
      • has variables, conditions and loops => Turing complete
  • HTTP/S-Wrapper:
    • Can be used for transmissions over http and https
    • Allows arbitrary http methods, e.g. GET, POST, PUT, ...
    • Supported platforms:
      • Windows: using wininet with the standard system configuration
      • Android: using the Apache HttpComponents through JNI
      • Others (Linux, Mac): using the platform-independent Synapse
      • Offline: simulating an internet connection locally for unit tests
    • Supports http, https and socks-Proxy (not on Android)
  • Auto update:
    • Uses a xml format to store the most recent version and a changelog on the server.
    • Supports different updates for 32/64-bit platforms and linux,Windows or BSD systems
    • Checks if a new version is available without downloading the whole, large changelog
    • Allows the execution of an arbitrary command line after the update, runas administrator if necessary
Mercurial repository

Online Documentation

Source on GitHub

Download (984 KB ) jump to top

 Farbauswahldialog

2005
GPL
This color select dialog is similar to the default one, but has more possibilities:
  • All components of rgb and hls are shown.
  • You can change any component of rgb/hls in a color gradient
  • This component is shown depending of the other two as well as independent
  • You can change the other two components in a two-dimensional gradient
  • This one is drawn depending on the first component
  • Additional you can enable a list of colors to change
screenshot:example screenshot:example


Source on GitHub

Download (16 KB ) jump to top

 TCommandLineReader

GPL
This is a command line parser working with Delphi as well as with Free Pascal, and on Windows and Linux.
Before you can read the command line arguments, all allowed arguments needs to be declared. So the parser can ensure that the user only uses allowed arguments and each given argument has the correct type (e.g. int or string). Furthermore, the parser can automatically generate a help summary displaying all allowed arguments with description. This again ensures that there are no hidden, undocumented command line arguments.
There are three different versions of the parser. The first two read the arguments from the command line and show the help list of all allowed arguments on stdout or respectively in a message box. The third version (fpc only) runs as cgi service and reads the argument from get/post requests.

Here is a nice comparison between TCommandLineReader and the standard pascal command line functions, when the program is called as executable '" a "'
SystemTCommandLineReaderParamStrstring(cmdline)
Windows (Delphi 4)" a "' a '"executable" '" a "'
Windows (fpc 2.6)" a "' a 'executable '" a "'
Linux/bash (fpc 2.6)" a "" a "executable "" a ""
The feature list of rcmdline is:

  • supports linux (--xyz=bar or -x bar) and windows (/) style parameters
  • different input possibilities for boolean flags (-f, --flag, --enable-flag, --disable-flag)
  • understands single (') and double (") quotation marks (even on Windows)
  • type conversion of the string arguments to the declared types
  • automatically user notification about wrong parameters
  • existing files with names containing spaces can be parsed without quotation marks
  • can run as cgi service and answer to GET/POST requests (fpc only)
  • Arguments can be read from: a simple string (e.g. cmdline) or an array of arguments (e.g. paramstr)


Online Documentation

Source on GitHub

Download (40 KB ) jump to top

 Big Decimal Math

2013
GPL
This unit provides a BigDecimal-Typ which stores arbitrary precision (bcd) decimal numbers and can be used like any numeric type. For example:
  var bd: BigDecimal;
  bd := 12.34;
  bd := bd * 1000 - 42;  // bd = 12298
  bd := bd / 7.0;        // bd = 1756.85714285714286
  bd := StrToBigDecimal('123456789012345678901234567890123456789') + 1; // bd = 123456789012345678901234567890123456790
    


Summary of features:

  • Supports at least numbers between 10-19327352814 to 1019327352814 with up to 4831838208 decimal digit precision
  • And all standard arithmetic and comparison operators
  • The operators are overloaded, so that it can be used like normal numeric types
  • Rounding functions (floor, ceil, to-even, ..)
  • Some more advanced operations, e.g. power and sqrt
  • Also provides exact native float to string conversion functions
  • Written in pure Pascal, therefore platform-independent and without dependencies
  • Designed for correctness and simplicity (rather than speed)


Online Documentation

Source on GitHub

Download (68 KB ) jump to top

 Diagram-Tools

GPL
This diagram drawing unit follows a model/view concept like qt: There is a view component responsible for showing the data, and a model class storing them.
This is much more flexible than the traditional way, where the data is handled within the viewing class.
Features:
  • Model/view-concept with automatical synchronisation between different views showing the same model
  • Filling with horizontal/vertical color gradient and different line/point-styles
  • Interpolation using linear lines or splines
  • The diagram data can be modified by the user if wanted
  • Multiple axis and point rows as well as a legend naming the latter
  • Automatical calculation of the view range and support for floats
  • Standardmodels with lists of points, cyclic lists, and a model to merge other ones
  • There is a help file
screenshot:grid like screenshot:filled


Online Documentation

Source on GitHub

Download (72 KB ) jump to top

 Non-VCL Canvas

MPL, GPL
You can draw in a non vcl as if you would be able to use the normal Delphi, when you use this units. They contain a methode as replacement for every TCanvas methode.
The most important features are:
  • Functions for drawing texts, ellipses, lines, rectangles and polygones.
  • Functions for copying parts of pictures.
  • Classes for setting font, pen and brush properties.
  • A hash class and a ressources manager.
In some field they are even better than the Delphi functions, for example they can draw rotated text.
There is a good, German help, and you could use the documentation of TCanvas from Delphi.

Download (28 KB ) jump to top

 BBUtils

(LC)LGPL
These units consist of low-level functions missing in FPC. E.g.:
  • Various array functions (add, delete, search, prealloc, ...)
  • Various string functions (pchar/ansistring, compare, split, search, convert html entities, ...)
  • Various date/time parsing/formatting functions, supporting years before 0 and after 65535, and timezones
  • Stable sorting function for arbitrary sized data arrays (merge+insert sort)
  • Mathematical functions (gcd, primes, Bernoulli statistics,...)
  • Automatical translation of with tr['marked strings'] and components
  • A Pascal template language which is "compiled" to Pascal (similar to the C preprocessor)


Online Documentation

Source on GitHub

Download (200 KB ) jump to top

 Diffreader

GPL
You can use this unit to read a Unified Diff, do some work on its tree structure and save it finally.
  • Reads Unified Diffs of one or many files
  • Creates valid diffs
  • Has functions to remove unnecessary data (see also Simplify Diff)


Download (4 KB ) jump to top

 TCVirus

2000
MPL, GPL
These are the most important features of TCvirus:
  • It gives a canvas for direct drawing on the screen.
  • It can mirror the screen.
  • It returns handle of important objects like the task button, the task list, and the desktop.
  • It can hide your program from the task manager.
  • It can open and close the CD door.
Because TCvirus has originally been a component, there are 2 units, a component for the VCL and a unit for non VCL.

Download (68 KB ) jump to top

 TAutoUpdater

GPL
This allows an automatical update about the internt.
To use the class you need a wininet unit containing the windows internet functions (above is a new class which use a better customizable xml format).
Features:
  • check for new versions
  • download them in a compressed zip archive
  • extract this
  • replace the current executable with the new one on every Windows
  • detect missing access rights on Windows NT...


Download (12 KB ) jump to top

 SimpleBrowser

GPL
This is a small browser based on the IE.
It is completely useless for a normal user, but you can use it to implement a browser for a certain web page in your program. The appearance and behaviour can be controlled over command line switches, so it allows, for example restricted access.

Download (196 KB ) jump to top

 Huffmankomprimierer

MPL, GPL
This unit can (de-)compress strings with using the huffman algorithm. In a compressed string a character isn't stored with 8 bit, but the bit count is different.
It is also possible to compress strings in the Unicode Format, arrays and files. These types are simply regarded as Ansi Strings.
This unit doesn't need the VCL.
You get the best compression rates in data which contains many equal characters, but it is always worse than modern compression processes like ACE or RAR.

Download (16 KB ) jump to top

 TRegExpr

GPL
This is a mirror of TRegExpr of Andrey V. Sorokin whose page www.regexpstudio.com seems to be vanished from the internet. It is a highly advanced regular expression parser which supports all regexp operations, even backtracking. Hence, although it was written in 2004, it is still more advanced than most regexpr packages.
This copy is a little bit modified to improve fpc support, one of the biggest changes is that I renamed the file to dregexpr.

Download (92 KB ) jump to top

www.benibela.de/sources_en.html
Last change of the content of this page: 2014-10-10 19:19:32+0200
Last change of this page: 2014-10-14 18:51:09+0200
For G+ authorship:
Personal home page of