ThorsAnvil

A set of modern C++20 libraries for writing interactive Web-Services.

The main goal of these libraries is to remove the need to write boilerplate code. Using a declarative style, an engineer can define C++ classes and their serializable members, then send and receive them over the network with no manual serialization code.


Libraries

Application Layer

  1. Mug | Internal Documentation A configurable HTTP server application that dynamically loads shared-library plugins at runtime. Define your REST endpoints in plugins and Mug handles the server lifecycle, configuration, and hot-reloading.

  2. ThorsMug | Internal Documentation The plugin interface for Mug. Implement MugPlugin to register HTTP route handlers that are dynamically loaded and unloaded by the Mug server.

  3. ThorsSlack | Internal Documentation Type-safe C++ API for the Slack platform. Supports the Slack REST API, webhooks, event callbacks, slash commands, and Block Kit – all with automatic JSON serialization via ThorsSerializer.

Server Framework

  1. NisseServer | Internal Documentation An event-driven, coroutine-based C++ server framework. Provides non-blocking async I/O over TCP and TLS sockets with a synchronous-looking API powered by boost::coroutines2 and libEvent.

  2. NisseHTTP | Internal Documentation HTTP/1.x layer built on NisseServer. Provides request parsing, response generation, URL routing with path captures, chunked transfer encoding, and client-side HTTP utilities.

Core Libraries

  1. ThorsSocket | Internal Documentation Unified C++ socket library for files, pipes, TCP sockets, and TLS sockets. Exposes all transport types through std::iostream with optional non-blocking I/O and coroutine yield support.

  2. ThorsCrypto | Internal Documentation Header-only cryptographic primitives: MD5, SHA-1, SHA-256 hashing, HMAC, PBKDF2 key derivation, SCRAM authentication, Base64 encoding/decoding, and CRC32 checksums.

  3. ThorsSerializer | Internal Documentation Declarative C++ serialization for JSON, YAML, and BSON. Declare which members to serialize with a single macro and use operator<< / operator>> for automatic conversion.

  4. ThorsMongo | Internal Documentation Type-safe MongoDB client for C++20. Builds BSON commands via ThorsSerializer, sends them over ThorsSocket, and exposes results as normal C++ objects and cursor-backed ranges.

  5. ThorsLogging | Internal Documentation Leveled logging macros with optional exception throwing. Wraps loguru for full builds or falls back to std::cerr in header-only mode.

  6. ThorsIOUtil | Internal Documentation Type-safe printf-style formatting through std::ostream. Validates format specifiers against C++ argument types at runtime.


Installation

Requires a C++20 compatible compiler.

Homebrew (Mac and Linux)

brew install thors-anvil

Header-Only (from GitHub)

git clone --single-branch --branch header-only https://github.com/Loki-Astari/ThorsAnvil.git

Add the cloned directory to your include path.

From Source

git clone https://github.com/Loki-Astari/ThorsAnvil.git
cd ThorsAnvil
./configure
make
sudo make install

Build Instructions

# Basic compilation
g++ -std=c++20 myfile.cpp -lThorSerialize -lThorsLogging

# With YAML support
g++ -std=c++20 myfile.cpp -lThorSerialize -lThorsLogging -lyaml

# Windows: add /Zc:preprocessor for conforming preprocessor