Quarkonium-System

6. Interfaces

JSON in, JSON out

The public surface is one function from a request object to an answer object. A small strict JSON parser (api/value) avoids a dependency; unknown keys are errors, so a typo cannot silently fall back to a default.

--8<-- "src/api/engine.cpp:run"

The answer includes the request and the version: any stored result can be replayed.

The C boundary

C++ types cannot cross into other languages portably, C functions can. capi/qs.cpp is deliberately thin: strings in, a malloc‘d string out (freed by qs_free), no exception ever crosses the boundary, and the typed calls keep the last error per thread.

Bindings

Python (ctypes), Julia (ccall) and Wolfram (ForeignFunctionLoad) each need under a hundred lines: encode, call, decode, free. None contains physics, so none can disagree with the engine. Each has a test that asks for the same numbers.

One command line

apps/qs.cpp dispatches subcommands. Until version 2 there were several programs and a Python layer; folding them into one binary removed the duplicated option handling and made the sweep runner trivial (it starts itself).

Build

CMake with presets release, debug, asan. The static library qgem holds everything but the command line, the C interface and the ROOT code; libqs and qs link it, and so do the tests. The CI builds in an Arch Linux container (for current CMake, GCC and Eigen) in release and sanitizer mode, and checks formatting with clang-format.