ASL
ASL - All-purpose Simple Library

ASL is a collection of general purpose classes and utilities intended to be easy to use. It is mostly compatible with Windows, Linux, macOS and Android, 32 and 64 bits.

Operating system functionalities:

  • Threads, mutexes and semaphores
  • Processes (run programs and read their output)
  • Binary and text files
  • Directory enumeration and file system operations (copy, move, delete)
  • Sockets TCP, UDP, Unix and SSL/TLS encrypted sockets, IPv4/IPv6
  • Runtime dynamically loadable libraries (DLLs/shared libraries)
  • Console attributes: text color and cursor position
  • Serial ports
  • Shared memory

Utilities:

  • JSON, XML and XDL parsing/encoding
  • HTTP/HTTPS 1.1 server and client
  • WebSocket server and client
  • Configuration INI files reading/writing
  • CSV file reading/writing, ARFF write
  • Log messages to console and/or files (with limited growth)
  • Command line arguments and options parsing
  • Singletons and Factories
  • Base64, hex encoding/decoding
  • Binary buffer endian-aware reading/writing
  • Random number generator
  • Simple testing functionality
  • Linear and non-linear systems solving (with the Matrix class)

Basic data types:

  • Strings with UTF8 support
  • Dynamic and static arrays, including 2D arrays
  • Maps and hashmaps
  • Date/time
  • 2D, 3D, 4D vectors, 3x3, 4x4, NxM matrices and quaternions
  • Variants (similar to JavaScript vars)

Compilation and use

ASL can be used as a static or as a dynamic/shared library. The easiest way to build and use it is via CMake (2.8.12 or later). By default both the dynamic and static libraries will be built. You can enable the ASL_USE_LOCAL8BIT option to disable interpretation of strings as UTF-8 and treat them as local 8- bit strings.

Just compile the library with whatever compilers and architecturs (32/64bit) you need. There is no need to install.

In order to use the library in another project just find the ASL package and link against one of the imported targets, asl for the dynamic version or asls for the static version. The static library is recommended as you don't need to copy or distribute a DLL at runtime.

find_package(ASL REQUIRED)
target_link_libraries(my_application asls) # for the static version (recommended), or
target_link_libraries(my_application asl) # for the dynamic library

There is no need to provide the library directory or set include_directories. find_package will find the library compatible with the current project among the versions compiled.

With CMake 3.14+, instead of using find_package(), you can download and build the library automatically as a subproject (and then link with it as before):

include(FetchContent)
FetchContent_Declare(asl URL https://github.com/aslze/asl/archive/1.11.10.zip)
FetchContent_MakeAvailable(asl)

Remember that all header files have the asl/ prefix directory and are named like the class they define (case-sensitively), and that all symbols are in the asl namespace. So, for example, to use the Directory class:

#include <asl/Directory.h>
This class allows enumerating the contents of a directory: its files and subdirectories.
Definition: Directory.h:44

SSL/TLS sockets and HTTPS support

This requires the mbedTLS library (up to v3.2.1). Download and compile the library, enable ASL_TLS in CMake and provide the mbedTLS install directory (and library locations, which should normally be automatically found).

In Ubuntu Linux you can just install package libmbedtls-dev with:

sudo apt-get install libmbedtls-dev

With a recent CMake you can also build mbedTLS together with ASL as subprojects (e.g. using FetchContent):

set(ASL_TLS ON)
set(ENABLE_PROGRAMS OFF CACHE BOOL "") # skip samples
FetchContent_Declare(mbedtls URL https://github.com/Mbed-TLS/mbedtls/archive/v3.2.1.zip)
FetchContent_Declare(asl URL https://github.com/aslze/asl/archive/1.11.8.zip)
FetchContent_MakeAvailable(mbedtls asl)

Then just link your project to asls after that block.