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…