-
Notifications
You must be signed in to change notification settings - Fork 4
feat: add compat.tomlplusplus 3.4.0 (C++ toml parse library) #64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
yspbwx2010
wants to merge
2
commits into
mcpplibs:main
Choose a base branch
from
yspbwx2010:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+108
−0
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| -- Form B inline descriptor for toml++ — a TOML config file parser and | ||
| -- serializer for C++17 (and later), exposed as the C++23 module | ||
| -- `tomlplusplus` so users can write `import tomlplusplus;` out of the box | ||
| -- (no opt-in, no `#include` needed). | ||
| -- | ||
| -- Why the fork: upstream's released v3.4.0 tarball is header-only and ships | ||
| -- NO module interface unit at a release tag. Upstream HAS authored an official | ||
| -- one at `src/modules/tomlplusplus.cppm` (`export module tomlplusplus;`), but | ||
| -- it lives on the master branch only and is not in the v3.4.0 release. So this | ||
| -- package uses a fork (yspbwx2010/tomlplusplus @ v3.4.0-mcpp) that carries the | ||
| -- module unit plus mcpp packaging (mcpp.toml, tests, docs) at a reproducible tag. | ||
| -- | ||
| -- The module unit (`src/modules/tomlplusplus.cppm`) does `#include | ||
| -- <toml++/toml.hpp>` in its global-module fragment then re-exports the `toml` | ||
| -- namespace, so `include_dirs` exposes `include/` for that include to resolve | ||
| -- (and `#include <toml++/toml.hpp>` remains available to users who want it). | ||
| -- | ||
| -- All upstream paths are GLOBS relative to the verdir; the leading `*` absorbs | ||
| -- the GitHub archive's `tomlplusplus-<tag>/` wrap layer. | ||
| package = { | ||
| spec = "1", | ||
| namespace = "compat", | ||
| name = "compat.tomlplusplus", | ||
| description = "TOML config file parser and serializer, exposed as C++23 module tomlplusplus", | ||
| licenses = {"MIT"}, | ||
| repo = "https://github.com/yspbwx2010/tomlplusplus", | ||
| type = "package", | ||
|
|
||
| xpm = { | ||
| linux = { | ||
| ["3.4.0"] = { | ||
| url = { | ||
| GLOBAL = "https://github.com/yspbwx2010/tomlplusplus/archive/refs/tags/v3.4.0-mcpp.tar.gz", | ||
| CN = "https://github.com/yspbwx2010/tomlplusplus/archive/refs/tags/v3.4.0-mcpp.tar.gz", | ||
| }, | ||
| sha256 = "cefd81c09ae8eade62f254ba0903e4585944cc86e84c320a92116a95cb725862", | ||
| }, | ||
| }, | ||
| macosx = { | ||
| ["3.4.0"] = { | ||
| url = { | ||
| GLOBAL = "https://github.com/yspbwx2010/tomlplusplus/archive/refs/tags/v3.4.0-mcpp.tar.gz", | ||
|
yspbwx2010 marked this conversation as resolved.
|
||
| CN = "https://github.com/yspbwx2010/tomlplusplus/archive/refs/tags/v3.4.0-mcpp.tar.gz", | ||
| }, | ||
| sha256 = "cefd81c09ae8eade62f254ba0903e4585944cc86e84c320a92116a95cb725862", | ||
| }, | ||
| }, | ||
| windows = { | ||
| ["3.4.0"] = { | ||
| url = { | ||
| GLOBAL = "https://github.com/yspbwx2010/tomlplusplus/archive/refs/tags/v3.4.0-mcpp.tar.gz", | ||
| CN = "https://github.com/yspbwx2010/tomlplusplus/archive/refs/tags/v3.4.0-mcpp.tar.gz", | ||
| }, | ||
| sha256 = "cefd81c09ae8eade62f254ba0903e4585944cc86e84c320a92116a95cb725862", | ||
| }, | ||
| }, | ||
| }, | ||
|
|
||
| mcpp = { | ||
| schema = "0.1", | ||
| language = "c++23", | ||
| import_std = false, | ||
| modules = { "tomlplusplus" }, | ||
| -- Tarball's include/ subdirectory: the module unit's global-module | ||
| -- fragment does `#include <toml++/toml.hpp>`, resolved from here. | ||
| include_dirs = { "*/include" }, | ||
| -- Upstream's official module unit (fork @ src/modules/tomlplusplus.cppm). | ||
| sources = { "*/src/modules/tomlplusplus.cppm" }, | ||
| targets = { ["tomlplusplus"] = { kind = "lib" } }, | ||
| features = {}, | ||
| deps = {}, | ||
| }, | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| [package] | ||
| name = "test-tomlplusplus" | ||
| version = "0.1.0" | ||
|
|
||
| [targets.test-tomlplusplus] | ||
| kind = "bin" | ||
| main = "src/main.cpp" | ||
|
|
||
| [indices] | ||
| compat = { path = "../../.." } | ||
|
|
||
| [dependencies] | ||
| "compat.tomlplusplus" = "3.4.0" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| import tomlplusplus; | ||
| import std; | ||
|
|
||
| int main() { | ||
| // Parse TOML from string | ||
| auto config = toml::parse(R"( | ||
| [server] | ||
| port = 8080 | ||
| host = "localhost" | ||
| )"); | ||
|
|
||
| // Access values | ||
| auto port = config["server"]["port"].value<int>(); | ||
| auto host = config["server"]["host"].value<std::string>(); | ||
|
|
||
| // Verify | ||
| bool ok = (port.value_or(0) == 8080) && | ||
| (host.value_or("") == "localhost"); | ||
|
|
||
| std::println("toml++ test: {}", ok ? "OK" : "FAILED"); | ||
| return ok ? 0 : 1; | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.