ada-util icon indicating copy to clipboard operation
ada-util copied to clipboard

Ada Utility Library - Composing streams, processes, logs, serialization, encoders and more

Ada Utility Library

Alire Alire Alire Alire Alire Alire Build Status Test Status codecov Documentation Status Download License GitLab Commits

This Ada05 library contains various utility packages for building Ada05 applications. This includes:

  • A logging framework close to Java log4j framework,
  • Support for properties
  • A serialization/deserialization framework for XML, JSON, CSV
  • Ada beans framework
  • Encoding/decoding framework (Base16, Base64, SHA, HMAC-SHA, AES-256)
  • A composing stream framework (raw, files, buffers, pipes, sockets)
  • Several concurrency tools (reference counters, counters, pools, fifos, arrays)
  • Process creation and pipes
  • Support for loading shared libraries (on Windows or Unix)
  • HTTP client library on top of CURL or AWS

Ada Util also provides a small test utility library on top of Ahven or AUnit to help in writing unit tests. Ahven is the default testing framework as it provides better reports.

Version 2.5.0 - Aug 2022

  • New examples to illustrate the IO stream composition
  • New examples for JSON parser and Util.Beans.Objects
  • Add support to set environment variables when launching a process (without changing the current process environment!)
  • Add support to indent XML output streams
  • New package Util.Files.Rolling to provide a rolling file manager
  • New package Util.Beans.Objects.Iterators to easily iterate over objects
  • Add a new log appender to support rolling log files with size and time based policies
  • New operation Util.Files.Delete_Tree to delete a directory tree and work arround for GNAT bug gcc/63222 and gcc/56055
  • New operation Util.Files.Realpath to find the canonicalized absolute path of a file
  • New package Util.Blobs to hold binary content with reference counting
  • New package Util.Http.Headers to provide some HTTP helper operations
  • Add support for Blob in bean objects
  • Fix compilation on NetBSD 9.2
  • Fix compilation with AWS >= 22.0

List all versions

Build

For a detailed description on how you can configure, build and install the library refer to the Installation guide. Otherwise, you can easily configure and build the library with the steps described below.

To use Ahven testing framework, configure and build as follows:

./configure
make

To use AUnit, build with the following commands:

./configure --enable-aunit
make

The unit tests are built and executed with:

   make test

And unit tests are executed with (256 success, 0 failed):

   bin/util_harness

For the installation, use the following command:

   make install

Build without configure

Since the integration with Alire, you can build without running configure. However, there are a number of checks and dependencies which are not verified and you must run several commands manually, choosing the correct values for UTIL_ASM_TYPE and UTIL_OS build variables. The trick is to give gprbuild the Alire configuration project in .alire/utilada_conf.gpr.

For a simple Linux 64-bit build, use:

gprbuild -aP.alire -Putilada_core -p
gprbuild -aP.alire -Putilada_base -p
gprbuild -aP.alire -Putilada_sys -p
gprbuild -aP.alire -Putilada_aws -p
gprbuild -aP.alire -Putilada_curl -p
gprbuild -aP.alire -Putilada_xml -p

For a Linux 32-bit build, use

gprbuild -aP.alire -Putilada_sys -p -XUTIL_OS=linux32

For Windows-64 try:

gprbuild -aP.alire -Putilada_sys -p -XUTIL_OS=win64

Checkout the file .alire/utilada_conf.gpr for other alternatives.

You can then use gprinstall for the installation:

gprinstall -aP.alire -Putilada_core -p
gprinstall -aP.alire -Putilada_base -p
gprinstall -aP.alire -Putilada_sys -p
gprinstall -aP.alire -Putilada_aws -p
gprinstall -aP.alire -Putilada_curl -p
gprinstall -aP.alire -Putilada_xml -p

I've never tried to build on Windows without msys2. I don't know if it works. I suspect there will be problems.

Samples

The samples can be built using:

   gnatmake -Psamples
Package Example
Util.Dates.Formats date.adb
Util.Beans.Objects objcalc.adb, jsonobj.adb, jsonread.adb
Util.Beans.Objects.Maps jsonobj.adb, genentities.adb
Util.Beans.Objects.Vectors datasets.adb, jsonobj.adb
Util.Beans.Objects.Datasets datasets.adb
Util.Beans.Objects.Iterators jsonread.adb
Util.Encoders encodes.adb
Util.Encoders.AES decrypt.adb, encrypt.adb
Util.Encoders.SHA256 sha256.adb
Util.Files realpath.adb, gperfhash.adb
Util.Files.Rolling rolling_file.adb
Util.Http.Clients wget.adb, facebook.adb
Util.Log.Loggers log.adb, multipro_refs.adb, date.adb, xmlrd.adb, gperfhash.adb, multipro.adb, mapping.adb, csv_city.adb, bundles.adb
Util.Measures measures.adb
Util.Processes launch.adb, env.adb, popen.adb
Util.Properties properties.adb, proplist.adb, bundles.adb
Util.Refs multipro_refs.adb
Util.Streams.AES decrypt.adb, encrypt.adb
Util.Streams.Base64 lzma_encrypt_b64.adb, lzma_decrypt_b64.adb
Util.Streams.Files copy.adb, sha256.adb, compress.adb, decompress.adb, decrypt.adb, encrypt.adb, lzma_encrypt.adb, lzma_decrypt.adb
Util.Streams.Pipes launch.adb, popen.adb
Util.Serialize.IO.CSV csv_city.adb
Util.Serialize.IO.JSON serialize.adb, json.adb, jsonobj.adb, jsonread.adb, genentities.adb
Util.Serialize.IO.XML serialize_xml.adb, xmi.adb, xmlrd.adb
Util.Serialize.Mappers csv_reader.adb, csv_city.adb, xmi.adb, xmlrd.adb
Util.Serialize.Mappers.Record_Mapper xmi.adb, xmlrd.adb
Util.Serialize.Mappers.Vector_Mapper json.adb, xmlrd.adb
Util.Strings cut.adb, escape.adb
Util.Strings.Tokenizers cut.adb, escape.adb
Util.Strings.Transforms escape.adb, gperfhash.adb
Util.Strings.Vectors gperfhash.adb

Documentation

Articles