mcpp index

marzer.tomlplusplus

import

TOML config file parser and serializer for C++, exposed as C++23 module tomlplusplus

import tomlplusplus;
mcpp add marzer.tomlplusplus@3.4.0

Usage

From this repository's own test project — built and run by CI, not written for the website.

// Behavioral test: parse → typed access → array/table nodes → _toml literal →
// serialize-and-reparse round-trip, all through the C++23 module surface
// (`import tomlplusplus;`, no #include).
import std;
import tomlplusplus;

int main() {
    auto cfg = toml::parse(R"(
        [server]
        host = "localhost"
        port = 8080
        tags = ["a", "b"]
    )");

    // typed access — value<std::string> so this compares strings, not pointers
    bool ok = cfg["server"]["port"].value<int>() == 8080
              && cfg["server"]["host"].value<std::string>() == "localhost"
              && cfg["server"]["tags"].as_array()->size() == 2;

    // the _toml literal re-exported through toml::literals
    using namespace toml::literals;
    auto lit = "x = 1"_toml;
// …

tests/examples/marzer.tomlplusplus/tests/parse.cpp · project tests/examples/marzer.tomlplusplus

Build

modules
tomlplusplus
targets
tomlplusplus (lib)
language
c++23
import std
no
include dirs
*/include

Sources (1)

  • mcpp_generated/tomlplusplus.cppm

Generated files

  • mcpp_generated/tomlplusplus.cppm

Versions

VersionPlatforms Mirrorssha256
3.4.0 latest LinuxWindowsmacOS CN GLOBAL 8517f65938a4…