AnCH Framework 0.2
Another C++ Hack: C++23 utility libraries
Loading...
Searching...
No Matches
AnCH Framework

Introduction

AnCH Framework ("Another C++ Hack") is a set of small and independent C++ libraries for common programming needs: command line, configuration, logging, events, JSON, SQL, REST, cryptography, UUID, network, dates, unit tests, ... They are designed to be used as simply as possible.

The framework is also a playground for new C++ standards: it targets C++23. Only POSIX systems are supported.

Libraries are licensed under the LGPL v3: they can be used with the least possible restrictions.

Libraries

Library Description
anch-utils Header only utilities: thread pool, resource pool, singleton, conversions, ...
anch-cli Command line arguments parsing and terminal formatting
anch-events Observers, event bus and event handlers
anch-cutils C++ streams over C style read and write functions
anch-network TCP (as C++ streams) and UDP sockets, IPv4 and IPv6
anch-ut Unit tests library, integrated with CTest
anch-uuid UUID generation and parsing (RFC 9562)
anch-date Dates, formatting and parsing, RFC 3339
anch-ini INI files parser
anch-conf Configuration cascade (includes, profiles) and placeholders resolution
anch-log Configurable loggers and writers, stream API with compile-time levels
anch-device Network interfaces and CPU features
anch-val Fields constraints and validation, shared by formats (JSON, ...)
anch-json JSON serialization and deserialization
anch-crypto Hashes, HMAC, Base64, AES and block cipher modes (not audited)
anch-sql SQL abstraction layer and connection pools for MySQL/MariaDB, PostgreSQL and SQLite
anch-csv CSV records reading and writing (RFC 4180), as streams
anch-codec Codecs (media types, negotiation) and format plugins: JSON, Protocol Buffers, Thrift
anch-rest REST API declaration (nginx module), HTTP client (libcurl), Protobuf / gRPC / Connect and Thrift RPC
anch-oas OpenAPI 3.0 models generator (anch-oas-gen )

anch-app (application bootstrap) is a work in progress and is not documented yet.

Prerequisites

  • GCC 13 or later (C++23)
  • CMake 3.25 or later
  • POSIX system

Optional dependencies:

  • SQL drivers: libmariadb (or libmysqlclient), libpq, libsqlite3
  • anch-rest curl transport: libcurl
  • anch-rest nginx module: nginx sources (built with --with-threads )
  • anch-rest Protobuf codecs and RPC: Protobuf (and gRPC for the gRPC server), built when they are found
  • anch-rest Thrift codecs and RPC: Thrift and Boost headers, built when they are found

Installation

Build, test and install with CMake presets (release , debug , asan , no-db ):

cmake --preset release
cmake --build --preset release
ctest --preset release
cmake --install build/release --prefix /usr/local

Main options: ANCH_BUILD_TESTS , BUILD_SHARED_LIBS , optional libraries (ANCH_BUILD_CRYPTO , ANCH_BUILD_SQL , ANCH_BUILD_OAS , ANCH_BUILD_REST ) and features (ANCH_UUID , ANCH_DATE , ANCH_SQL_MYSQL , ANCH_SQL_POSTGRESQL , ANCH_SQL_SQLITE3 , ANCH_REST_CURL , ANCH_REST_NGINX , ANCH_LOG_MIN_LEVEL , ...).

Installed libraries are used with their CMake targets:

find_package(Anch REQUIRED)
target_link_libraries(my-app PRIVATE anch::conf anch::log anch::json)

Libraries dependencies

  • anch-utils, anch-cli, anch-cutils, anch-date, anch-ini, anch-uuid: none
  • anch-events: anch-utils
  • anch-network: anch-cutils
  • anch-ut: anch-cli
  • anch-conf: anch-ini, anch-utils
  • anch-log: anch-conf, anch-date, anch-utils
  • anch-device: anch-uuid, anch-utils
  • anch-val: none ; anch-uuid and anch-date with ANCH_UUID and ANCH_DATE options
  • anch-json: anch-events, anch-utils, anch-val ; anch-uuid and anch-date with ANCH_UUID and ANCH_DATE options
  • anch-csv: anch-utils
  • anch-crypto: anch-uuid, anch-utils
  • anch-sql: anch-conf, anch-date, anch-utils
  • anch-codec: anch-utils ; plugins: anch-codec-json (anch-json), anch-codec-protobuf (Protobuf), anch-codec-thrift (Thrift, Boost headers)
  • anch-rest: anch-codec-json, anch-uuid
  • anch-oas: anch-json

Versions

Current version is 0.2 . Versions are numbered A.B.C: until 1.0.0, backward compatibility is not ensured and API can change on every B change. From 1.0.0, A changes will break API, B changes will add features and C changes will fix bugs. Shared libraries SONAME holds A and B (libanch-conf.so.0.2 ).

Until 1.0.0, APIs are changed or removed directly, without deprecation: breaking changes are listed in the changelog. From 1.0.0, B and C versions keep backward compatibility: deprecated APIs are marked with [[deprecated]] (compilation warning) and \deprecated in their documentation, with their replacement, and are removed in the next A version.

Shared libraries are built with hidden symbols visibility: only the public API is exported, with the ANCH_<NAME>_EXPORT macros of the generated anch-<name>-export.hpp headers.

Version 0.2 brings: single CMake project with presets and package, C++23 and GCC 13, rewritten anch-network, anch-date, anch-rest and anch-conf cascade, anch-log stream API, anch-oas generator, RFC 3339 dates in anch-json, many fixes found with sanitizers and fuzzing, and a CI (GCC, Clang, sanitizers, coverage, fuzzing, installation). Changes and breaking changes of each version are listed in the changelog.

AI assisted development

Since version 0.2, part of the work on AnCH Framework has been done with an AI assistant (Claude Code, by Anthropic): code analyses, bug fixes (several found with the sanitizers), rewrites (anch-rest, anch-network, anch-date, ...), tests, CI and this documentation. Design decisions remain the maintainer's.

Commits written with the assistant are identified in the git history with a Co-Authored-By: Claude trailer.