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

用法

來自本倉庫自己的測試專案 —— CI 真的編譯並執行過,不是為了網站寫的。

// 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 · 專案 tests/examples/marzer.tomlplusplus

建置

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

原始檔 (1)

  • mcpp_generated/tomlplusplus.cppm

產生的檔案

  • mcpp_generated/tomlplusplus.cppm

版本

版本平台 鏡像sha256
3.4.0 最新 LinuxWindowsmacOS CN GLOBAL 8517f65938a4…