{"id":13419220,"url":"https://github.com/skystrife/cpptoml","last_synced_at":"2025-10-21T04:50:49.127Z","repository":{"id":8548502,"uuid":"10170833","full_name":"skystrife/cpptoml","owner":"skystrife","description":"cpptoml is a header-only library for parsing TOML","archived":false,"fork":false,"pushed_at":"2023-10-07T16:28:09.000Z","size":404,"stargazers_count":599,"open_issues_count":38,"forks_count":138,"subscribers_count":25,"default_branch":"master","last_synced_at":"2025-09-30T22:10:49.281Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/skystrife.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2013-05-20T10:44:32.000Z","updated_at":"2025-09-25T03:35:15.000Z","dependencies_parsed_at":"2024-01-11T14:25:58.263Z","dependency_job_id":null,"html_url":"https://github.com/skystrife/cpptoml","commit_stats":{"total_commits":230,"total_committers":24,"mean_commits":9.583333333333334,"dds":0.5869565217391304,"last_synced_commit":"fededad7169e538ca47e11a9ee9251bc361a9a65"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/skystrife/cpptoml","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skystrife%2Fcpptoml","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skystrife%2Fcpptoml/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skystrife%2Fcpptoml/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skystrife%2Fcpptoml/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/skystrife","download_url":"https://codeload.github.com/skystrife/cpptoml/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skystrife%2Fcpptoml/sbom","scorecard":{"id":830814,"data":{"date":"2025-08-11","repo":{"name":"github.com/skystrife/cpptoml","commit":"fededad7169e538ca47e11a9ee9251bc361a9a65"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.6,"checks":[{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Code-Review","score":4,"reason":"Found 12/29 approved changesets -- score normalized to 4","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 13 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-23T17:45:15.995Z","repository_id":8548502,"created_at":"2025-08-23T17:45:15.995Z","updated_at":"2025-08-23T17:45:15.995Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280207180,"owners_count":26290616,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-21T02:00:06.614Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-30T22:01:12.961Z","updated_at":"2025-10-21T04:50:49.095Z","avatar_url":"https://github.com/skystrife.png","language":"C++","readme":"# cpptoml\nA header-only library for parsing [TOML][toml] configuration files.\n\nTargets: [TOML v0.5.0][currver] as of August 2018.\n\nThis includes support for the new DateTime format, inline tables,\nmulti-line basic and raw strings, digit separators, hexadecimal integers,\noctal integers, binary integers, and float special values.\n\nAlternatives:\n- [Boost.toml][boost.toml] is a C++ implementation of a TOML parser using\n  the Boost library. As of writing, it supports v0.5.0 as well.\n- [ctoml][ctoml] is a C++11 implementation of a TOML parser, but only\n  supports v0.2.0.\n- [libtoml][libtoml] is a C implementation of a TOML parser, which can be\n  linked to from your C++ programs easily. As of April 2016, it supports\n  v0.4.0.\n- [tinytoml][tinytoml] is a C++11 implementation of a TOML parser, which\n  also supports v0.4.0 as of November 2015.\n\n## Build Status\n[![Build Status](https://travis-ci.org/skystrife/cpptoml.svg?branch=master)](https://travis-ci.org/skystrife/cpptoml)\n\n## Test Results\n\nFrom [the toml-test suite][toml-test]:\n\n```\n126 passed, 0 failed\n```\n\nWe also currently maintain (but hopefully not indefinitely!) a [fork of the\ntoml-test suite][toml-test-fork] that adds tests for features and\nclarifications that have been added to the TOML spec more recently than\ntoml-test has been updated. We pass every test there.\n\n```\n148 passed, 0 failed\n```\n\n# Compilation\nRequires a well conforming C++11 compiler. On OSX this means clang++ with\nlibc++ and libc++abi (the default clang installed with XCode's command line\ntools is sufficient).\n\nOn Linux, you should be able to use g++ \u003e= 4.8.x, or clang++ with libc++\nand libc++abi (if your package manager supplies this; most don't).\n\nCompiling the examples can be done with cmake:\n\n```\nmkdir build\ncd build\ncmake ../\nmake\n```\n\n# Example Usage\nTo parse a configuration file from a file, you can do the following:\n\n```cpp\nauto config = cpptoml::parse_file(\"config.toml\");\n```\n\n`parse_file()` returns a (shared pointer to a) `cpptoml::table`, which you\ncan then query. It will throw an instance of `cpptoml::parse_exception` in\nthe event that the file failed to parse, and the exception message should\ncontain the line number the error occurred as well as a description of the\nerror.\n\n## Obtaining Basic Values\nYou can find basic values like so:\n\n```cpp\nauto val = config-\u003eget_as\u003cint64_t\u003e(\"my-int\");\n// val is a cpptoml::option\u003cint64_t\u003e\n\nif (val)\n{\n    // *val is the integer value for the key \"my-int\"\n}\nelse\n{\n    // \"my-int\" either did not exist or was not an integer\n}\n```\n\nTo simplify things, you can specify default a default value using the\n`value_or` function on the `option`:\n\n```cpp\nauto baz = config-\u003eget_as\u003cdouble\u003e(\"baz\").value_or(0.5);\n// baz is now the double value for key \"baz\", if it exists, or 0.5 otherwise\n```\n\ncpptoml has extended support for dates and times beyond the TOML v0.4.0\nspec. Specifically, it supports\n\n- Local Date (`local_date`), which simply represents a date and lacks any time\n  information, e.g. `1980-08-02`;\n- Local Time (`local_time`), which simply represents a time and lacks any\n  date or zone information, e.g. `12:10:03.001`;\n- Local Date-time (`local_datetime`), which represents a date and a time,\n  but lacks zone information, e.g. `1980-08-02T12:10:03.001`;\n- and Offset Date-time (`offset_datetime`), which represents a date, a\n  time, and timezone information, e.g. `1980-08-02T12:10:03.001-07:00`\n\nHere are the fields of the date/time objects in cpptoml:\n\n- year (`local_date`, `local_datetime`, `offset_datetime`)\n- month (`local_date`, `local_datetime`, `offset_datetime`)\n- day (`local_date`, `local_datetime`, `offset_datetime`)\n- hour (`local_time`, `local_datetime`, `offset_datetime`)\n- minute (`local_time`, `local_datetime`, `offset_datetime`)\n- second (`local_time`, `local_datetime`, `offset_datetime`)\n- microsecond (`local_time`, `local_datetime`, `offset_datetime`)\n- hour\\_offset (`offset_datetime`)\n- minute\\_offset (`offset_datetime`)\n\nThere are convenience functions `cpptoml::offset_datetime::from_zoned()` and\n`cpptoml::offset_datetime::from_utc()` to convert `struct tm`s to\n`cpptoml::offset_datetime`s.\n\n## Nested Tables\nIf you want to look up things in nested tables, there are two ways of doing\nthis. Suppose you have the following structure:\n\n```toml\n[first-table]\nkey1 = 0.1\nkey2 = 1284\n\n[first-table.inner]\nkey3 = \"hello world\"\n```\n\nHere's an idiomatic way of obtaining all three keys' values:\n\n```cpp\nauto config = cpptoml::parse_file(\"config.toml\");\nauto key1 = config-\u003eget_qualified_as\u003cdouble\u003e(\"first-table.key1\");\nauto key2 = config-\u003eget_qualified_as\u003cint\u003e(\"first-table.key2\");\nauto key3 = config-\u003eget_qualified_as\u003cstd::string\u003e(\"first-table.inner.key3\");\n```\n\n(Note that, because the TOML spec allows for \".\" to occur in a table name,\nyou won't *always* be able to do this for any nested key, but in practice\nyou should be fine.)\n\nA slightly more verbose way of getting them would be to first obtain the\nindividual tables, and then query those individual tables for their keys\nlike so:\n\n```cpp\nauto config = cpptoml::parse_file(\"config.toml\");\n\nauto first = config-\u003eget_table(\"first-table\");\nauto key1 = first-\u003eget_as\u003cdouble\u003e(\"key1\");\nauto key2 = first-\u003eget_as\u003cint\u003e(\"key2\");\n\nauto inner = first-\u003eget_table(\"inner\");\nauto key3 = inner-\u003eget_as\u003cstd::string\u003e(\"key3\");\n```\n\nThe function `get_table_qualified` also exists, so obtaining the inner\ntable could be written as\n\n```cpp\nauto inner2 = config-\u003eget_table_qualified(\"first-table.inner\");\n```\n\n## Arrays of Values\nSuppose you had a configuration file like the following:\n\n```toml\narr = [1, 2, 3, 4, 5]\nmixed-arr = [[1, 2, 3, 4, 5], [\"hello\", \"world\"], [0.1, 1.1, 2.1]]\n```\n\nTo obtain an array of values, you can do the following:\n\n```cpp\nauto config = cpptoml::parse_file(\"config.toml\");\n\nauto vals = config-\u003eget_array_of\u003cint64_t\u003e(\"arr\");\n// vals is a cpptoml::option\u003cstd::vector\u003cint64_t\u003e\u003e\n\nfor (const auto\u0026 val : *vals)\n{\n    // val is an int64_t\n}\n```\n\n`get_array_of` will return an `option\u003cvector\u003cT\u003e\u003e`, which will be empty if\nthe key does not exist, is not of the array type, or contains values that\nare not of type `T`.\n\nFor nested arrays, it looks like the following:\n\n```cpp\nauto nested = config-\u003eget_array_of\u003ccpptoml::array\u003e(\"mixed-arr\");\n\nauto ints = (*nested)[0]-\u003eget_array_of\u003cint64_t\u003e();\n// ints is a cpptoml::option\u003cstd::vector\u003cint64_t\u003e\u003e\n\nauto strings = (*nested)[1]-\u003eget_array_of\u003cstd::string\u003e();\nauto doubles = (*nested)[2]-\u003eget_array_of\u003cdouble\u003e();\n```\n\nThere is also a `get_qualified_array_of` for simplifying arrays located\ninside nested tables.\n\n## Arrays of Tables\nSuppose you had a configuration file like the following:\n\n```toml\n[[table-array]]\nkey1 = \"hello\"\n\n[[table-array]]\nkey1 = \"can you hear me\"\n```\n\nArrays of tables are represented as a separate type in `cpptoml`. They can\nbe obtained like so:\n\n```cpp\nauto config = cpptoml::parse_file(\"config.toml\");\n\nauto tarr = config-\u003eget_table_array(\"table-array\");\n\nfor (const auto\u0026 table : *tarr)\n{\n    // *table is a cpptoml::table\n    auto key1 = table-\u003eget_as\u003cstd::string\u003e(\"key1\");\n}\n```\n\n## More Examples\nYou can look at the files files `parse.cpp`, `parse_stdin.cpp`, and\n`build_toml.cpp` in the root directory for some more examples.\n\n`parse_stdin.cpp` shows how to use the visitor pattern to traverse an\nentire `cpptoml::table` for serialization.\n\n`build_toml.cpp` shows how to construct a TOML representation in-memory and\nthen serialize it to a stream.\n\n[currver]: https://github.com/toml-lang/toml/blob/master/versions/en/toml-v0.5.0.md\n[toml]: https://github.com/toml-lang/toml\n[toml-test]: https://github.com/BurntSushi/toml-test\n[toml-test-fork]: https://github.com/skystrife/toml-test\n[ctoml]: https://github.com/evilncrazy/ctoml\n[libtoml]: https://github.com/ajwans/libtoml\n[tinytoml]: https://github.com/mayah/tinytoml\n[boost.toml]: https://github.com/ToruNiina/Boost.toml\n","funding_links":[],"categories":["TODO scan for Android support in followings","C++","Data Formats","Libraries"],"sub_categories":["Parsing \u0026 Serialization"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskystrife%2Fcpptoml","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fskystrife%2Fcpptoml","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskystrife%2Fcpptoml/lists"}