v3.4.0
This commit is contained in:
parent
cc1962eac7
commit
30172438ce
@ -10,9 +10,6 @@ trim_trailing_whitespace = true
|
|||||||
charset = utf-8
|
charset = utf-8
|
||||||
max_line_length = 120
|
max_line_length = 120
|
||||||
|
|
||||||
[*.{md,markdown}]
|
|
||||||
trim_trailing_whitespace = false
|
|
||||||
|
|
||||||
[*.{gitattributes,yaml,yml,vcxproj,vcxproj.filters,sln,rc,clang-format,toml,py,cmake}]
|
[*.{gitattributes,yaml,yml,vcxproj,vcxproj.filters,sln,rc,clang-format,toml,py,cmake}]
|
||||||
indent_style = space
|
indent_style = space
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ template:
|
|||||||
|
|
||||||
-->
|
-->
|
||||||
|
|
||||||
## Unreleased
|
## v3.4.0
|
||||||
|
|
||||||
#### Fixes
|
#### Fixes
|
||||||
|
|
||||||
@ -37,7 +37,7 @@ template:
|
|||||||
|
|
||||||
#### Additions
|
#### Additions
|
||||||
|
|
||||||
- improved support for using enums with `value_or()`
|
- added support for using enums with `value_or()`
|
||||||
|
|
||||||
#### Changes:
|
#### Changes:
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.14)
|
|||||||
|
|
||||||
project(
|
project(
|
||||||
tomlplusplus
|
tomlplusplus
|
||||||
VERSION 3.3.0
|
VERSION 3.4.0
|
||||||
DESCRIPTION "Header-only TOML config file parser and serializer for C++17"
|
DESCRIPTION "Header-only TOML config file parser and serializer for C++17"
|
||||||
HOMEPAGE_URL "https://marzer.github.io/tomlplusplus/"
|
HOMEPAGE_URL "https://marzer.github.io/tomlplusplus/"
|
||||||
LANGUAGES CXX
|
LANGUAGES CXX
|
||||||
|
@ -68,7 +68,7 @@ cd build-debug && ninja && ninja test \
|
|||||||
|
|
||||||
## Testing with the [toml-test] suite
|
## Testing with the [toml-test] suite
|
||||||
|
|
||||||
As an optional extra you may wish to test against the 'official' test TOML test suite, [BurntSushi/toml-test]. See the
|
As an optional extra you may wish to test against the official test TOML test suite, [toml-test]. See the
|
||||||
instructions at [toml-test/README](./toml-test/README.md). Note that the toml++ tests already consume tests from the
|
instructions at [toml-test/README](./toml-test/README.md). Note that the toml++ tests already consume tests from the
|
||||||
offical suite via a C++ code-generation script so you are not expected to take this extra step as part of contributing
|
offical suite via a C++ code-generation script so you are not expected to take this extra step as part of contributing
|
||||||
to the library.
|
to the library.
|
||||||
@ -77,5 +77,4 @@ to the library.
|
|||||||
[test adapter for catch2]: https://marketplace.visualstudio.com/items?itemName=JohnnyHendriks.ext01
|
[test adapter for catch2]: https://marketplace.visualstudio.com/items?itemName=JohnnyHendriks.ext01
|
||||||
[reporting issues]: https://github.com/marzer/tomlplusplus/issues
|
[reporting issues]: https://github.com/marzer/tomlplusplus/issues
|
||||||
[catch2]: https://github.com/catchorg/Catch2
|
[catch2]: https://github.com/catchorg/Catch2
|
||||||
[toml-test]: https://github.com/BurntSushi/toml-test
|
[toml-test]: https://github.com/toml-lang/toml-test
|
||||||
[burntsushi/toml-test]: https://github.com/BurntSushi/toml-test
|
|
||||||
|
@ -113,7 +113,7 @@ You'll find some more code examples in the `examples` directory, and plenty more
|
|||||||
|
|
||||||
### Conan
|
### Conan
|
||||||
|
|
||||||
Add `tomlplusplus/3.3.0` to your conanfile.
|
Add `tomlplusplus/3.4.0` to your conanfile.
|
||||||
|
|
||||||
### DDS
|
### DDS
|
||||||
|
|
||||||
@ -121,7 +121,7 @@ Add `tomlpp` to your `package.json5`, e.g.:
|
|||||||
|
|
||||||
```plaintext
|
```plaintext
|
||||||
depends: [
|
depends: [
|
||||||
'tomlpp^3.3.0',
|
'tomlpp^3.4.0',
|
||||||
]
|
]
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -166,7 +166,7 @@ include(FetchContent)
|
|||||||
FetchContent_Declare(
|
FetchContent_Declare(
|
||||||
tomlplusplus
|
tomlplusplus
|
||||||
GIT_REPOSITORY https://github.com/marzer/tomlplusplus.git
|
GIT_REPOSITORY https://github.com/marzer/tomlplusplus.git
|
||||||
GIT_TAG v3.3.0
|
GIT_TAG v3.4.0
|
||||||
)
|
)
|
||||||
FetchContent_MakeAvailable(tomlplusplus)
|
FetchContent_MakeAvailable(tomlplusplus)
|
||||||
```
|
```
|
||||||
|
@ -6,17 +6,17 @@
|
|||||||
|
|
||||||
@section mainpage-features Features
|
@section mainpage-features Features
|
||||||
|
|
||||||
- Header-only (optional!)
|
- Header-only (optional!)
|
||||||
- Supports the latest [TOML](https://toml.io/) release ([v1.0.0](https://toml.io/en/v1.0.0)), plus
|
- Supports the latest [TOML](https://toml.io/) release ([v1.0.0](https://toml.io/en/v1.0.0)), plus
|
||||||
optional support for some unreleased TOML features
|
optional support for some unreleased TOML features
|
||||||
- Passes all tests in the [toml-test](https://github.com/BurntSushi/toml-test) suite
|
- Passes all tests in the [toml-test](https://github.com/BurntSushi/toml-test) suite
|
||||||
- Supports serializing to JSON and YAML
|
- Supports serializing to JSON and YAML
|
||||||
- Proper UTF-8 handling (incl. BOM)
|
- Proper UTF-8 handling (incl. BOM)
|
||||||
- C++17 (plus some C++20 features where available, e.g. experimental support for char8_t strings)
|
- C++17 (plus some C++20 features where available, e.g. experimental support for char8_t strings)
|
||||||
- Doesn't require RTTI
|
- Doesn't require RTTI
|
||||||
- Works with or without exceptions
|
- Works with or without exceptions
|
||||||
- Tested on Clang (8+), GCC (8+) and MSVC (VS2019)
|
- Tested on Clang (8+), GCC (8+) and MSVC (VS2019)
|
||||||
- Tested on x64, x86 and ARM
|
- Tested on x64, x86 and ARM
|
||||||
|
|
||||||
<!-- --------------------------------------------------------------------------------------------------------------- -->
|
<!-- --------------------------------------------------------------------------------------------------------------- -->
|
||||||
|
|
||||||
@ -38,29 +38,31 @@ Call toml::parse_file() and work with the toml::table you get back, or handle an
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <toml++/toml.hpp>
|
#include <toml++/toml.hpp>
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char\*\* argv)
|
||||||
{
|
{
|
||||||
toml::table tbl;
|
toml::table tbl;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
tbl = toml::parse_file(argv[1]);
|
tbl = toml::parse_file(argv[1]);
|
||||||
std::cout << tbl << "\n";
|
std::cout << tbl << "\n";
|
||||||
}
|
}
|
||||||
catch (const toml::parse_error& err)
|
catch (const toml::parse_error& err)
|
||||||
{
|
{
|
||||||
std::cerr << "Parsing failed:\n" << err << "\n";
|
std::cerr << "Parsing failed:\n" << err << "\n";
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@endcpp
|
@endcpp
|
||||||
|
|
||||||
@see
|
@see
|
||||||
- toml::parse_file()
|
|
||||||
- toml::table
|
- toml::parse_file()
|
||||||
- toml::parse_error
|
- toml::table
|
||||||
|
- toml::parse_error
|
||||||
|
|
||||||
<!-- --------------------------------------------------------------------------------------------------------------- -->
|
<!-- --------------------------------------------------------------------------------------------------------------- -->
|
||||||
|
|
||||||
@ -78,35 +80,37 @@ using namespace std::string_view_literals;
|
|||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
static constexpr std::string_view some_toml = R"(
|
static constexpr std::string_view some_toml = R"(
|
||||||
[library]
|
[library]
|
||||||
name = "toml++"
|
name = "toml++"
|
||||||
authors = ["Mark Gillard <mark.gillard@outlook.com.au>"]
|
authors = ["Mark Gillard <mark.gillard@outlook.com.au>"]
|
||||||
cpp = 17
|
cpp = 17
|
||||||
)"sv;
|
)"sv;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// parse directly from a string view:
|
|
||||||
{
|
|
||||||
toml::table tbl = toml::parse(some_toml);
|
|
||||||
std::cout << tbl << "\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
// parse from a string stream:
|
// parse directly from a string view:
|
||||||
{
|
{
|
||||||
std::stringstream ss{ std::string{ some_toml } };
|
toml::table tbl = toml::parse(some_toml);
|
||||||
toml::table tbl = toml::parse(ss);
|
std::cout << tbl << "\n";
|
||||||
std::cout << tbl << "\n";
|
}
|
||||||
}
|
|
||||||
}
|
// parse from a string stream:
|
||||||
catch (const toml::parse_error& err)
|
{
|
||||||
{
|
std::stringstream ss{ std::string{ some_toml } };
|
||||||
std::cerr << "Parsing failed:\n" << err << "\n";
|
toml::table tbl = toml::parse(ss);
|
||||||
return 1;
|
std::cout << tbl << "\n";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
catch (const toml::parse_error& err)
|
||||||
|
{
|
||||||
|
std::cerr << "Parsing failed:\n" << err << "\n";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
@endcpp
|
@endcpp
|
||||||
|
|
||||||
@ -123,9 +127,10 @@ name = 'toml++'
|
|||||||
@endout
|
@endout
|
||||||
|
|
||||||
@see
|
@see
|
||||||
- toml::parse_file()
|
|
||||||
- toml::table
|
- toml::parse_file()
|
||||||
- toml::parse_error
|
- toml::table
|
||||||
|
- toml::parse_error
|
||||||
|
|
||||||
<!-- --------------------------------------------------------------------------------------------------------------- -->
|
<!-- --------------------------------------------------------------------------------------------------------------- -->
|
||||||
|
|
||||||
@ -143,15 +148,16 @@ the parsing functions return a toml::parse_result instead of a toml::table:
|
|||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
toml::parse_result result = toml::parse_file("configuration.toml");
|
toml::parse_result result = toml::parse_file("configuration.toml");
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
std::cerr << "Parsing failed:\n" << result.error() << "\n";
|
std::cerr << "Parsing failed:\n" << result.error() << "\n";
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
do_stuff_with_your_config(std::move(result).table()); // 'steal' the table from the result
|
||||||
|
return 0;
|
||||||
|
|
||||||
do_stuff_with_your_config(std::move(result).table()); // 'steal' the table from the result
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
@endcpp
|
@endcpp
|
||||||
|
|
||||||
@ -162,7 +168,7 @@ int main()
|
|||||||
The examples above use an overloaded `operator<<` with ostreams to print basic error messages, and look like this:
|
The examples above use an overloaded `operator<<` with ostreams to print basic error messages, and look like this:
|
||||||
@out
|
@out
|
||||||
Error while parsing key: expected bare key starting character or string delimiter, saw '?'
|
Error while parsing key: expected bare key starting character or string delimiter, saw '?'
|
||||||
(error occurred at line 2, column 5)
|
(error occurred at line 2, column 5)
|
||||||
@endout
|
@endout
|
||||||
|
|
||||||
The library doesn't natively support error colouring in TTY environments, but instead provides the requisite information
|
The library doesn't natively support error colouring in TTY environments, but instead provides the requisite information
|
||||||
@ -173,22 +179,23 @@ and description() members:
|
|||||||
toml::table tbl;
|
toml::table tbl;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
tbl = toml::parse_file("configuration.toml");
|
tbl = toml::parse_file("configuration.toml");
|
||||||
}
|
}
|
||||||
catch (const toml::parse_error& err)
|
catch (const toml::parse_error& err)
|
||||||
{
|
{
|
||||||
std::cerr
|
std::cerr
|
||||||
<< "Error parsing file '" << *err.source().path
|
<< "Error parsing file '" << \*err.source().path
|
||||||
<< "':\n" << err.description()
|
<< "':\n" << err.description()
|
||||||
<< "\n (" << err.source().begin << ")\n";
|
<< "\n (" << err.source().begin << ")\n";
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@endcpp
|
@endcpp
|
||||||
|
|
||||||
@see
|
@see
|
||||||
- toml::parse_error
|
|
||||||
- toml::source_region
|
- toml::parse_error
|
||||||
- toml::source_position
|
- toml::source_region
|
||||||
|
- toml::source_position
|
||||||
|
|
||||||
<!-- --------------------------------------------------------------------------------------------------------------- -->
|
<!-- --------------------------------------------------------------------------------------------------------------- -->
|
||||||
|
|
||||||
@ -207,68 +214,69 @@ using namespace std::string_view_literals;
|
|||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
static constexpr auto source = R"(
|
static constexpr auto source = R"(
|
||||||
str = "hello world"
|
str = "hello world"
|
||||||
|
|
||||||
numbers = [ 1, 2, 3, "four", 5.0 ]
|
numbers = [ 1, 2, 3, "four", 5.0 ]
|
||||||
vegetables = [ "tomato", "onion", "mushroom", "lettuce" ]
|
vegetables = [ "tomato", "onion", "mushroom", "lettuce" ]
|
||||||
minerals = [ "quartz", "iron", "copper", "diamond" ]
|
minerals = [ "quartz", "iron", "copper", "diamond" ]
|
||||||
|
|
||||||
[animals]
|
[animals]
|
||||||
cats = [ "tiger", "lion", "puma" ]
|
cats = [ "tiger", "lion", "puma" ]
|
||||||
birds = [ "macaw", "pigeon", "canary" ]
|
birds = [ "macaw", "pigeon", "canary" ]
|
||||||
fish = [ "salmon", "trout", "carp" ]
|
fish = [ "salmon", "trout", "carp" ]
|
||||||
|
|
||||||
)"sv;
|
)"sv;
|
||||||
toml::table tbl = toml::parse(source);
|
toml::table tbl = toml::parse(source);
|
||||||
|
|
||||||
// different ways of directly querying data
|
// different ways of directly querying data
|
||||||
std::optional<std::string_view> str1 = tbl["str"].value<std::string_view>();
|
std::optional<std::string_view> str1 = tbl["str"].value<std::string_view>();
|
||||||
std::optional<std::string> str2 = tbl["str"].value<std::string>();
|
std::optional<std::string> str2 = tbl["str"].value<std::string>();
|
||||||
std::string_view str3 = tbl["str"].value_or(""sv);
|
std::string_view str3 = tbl["str"].value_or(""sv);
|
||||||
std::string& str4 = tbl["str"].ref<std::string>(); // ~~dangerous~~
|
std::string& str4 = tbl["str"].ref<std::string>(); // ~~dangerous~~
|
||||||
|
|
||||||
std::cout << *str1 << "\n";
|
std::cout << *str1 << "\n";
|
||||||
std::cout << *str2 << "\n";
|
std::cout << *str2 << "\n";
|
||||||
std::cout << str3 << "\n";
|
std::cout << str3 << "\n";
|
||||||
std::cout << str4 << "\n";
|
std::cout << str4 << "\n";
|
||||||
|
|
||||||
// get a toml::node_view of the element 'numbers' using operator[]
|
// get a toml::node_view of the element 'numbers' using operator[]
|
||||||
auto numbers = tbl["numbers"];
|
auto numbers = tbl["numbers"];
|
||||||
std::cout << "table has 'numbers': " << !!numbers << "\n";
|
std::cout << "table has 'numbers': " << !!numbers << "\n";
|
||||||
std::cout << "numbers is an: " << numbers.type() << "\n";
|
std::cout << "numbers is an: " << numbers.type() << "\n";
|
||||||
std::cout << "numbers: " << numbers << "\n";
|
std::cout << "numbers: " << numbers << "\n";
|
||||||
|
|
||||||
// get the underlying array object to do some more advanced stuff
|
// get the underlying array object to do some more advanced stuff
|
||||||
if (toml::array* arr = numbers.as_array())
|
if (toml::array* arr = numbers.as_array())
|
||||||
{
|
{
|
||||||
// visitation with for_each() helps deal with heterogeneous data
|
// visitation with for_each() helps deal with heterogeneous data
|
||||||
arr->for_each([](auto&& el)
|
arr->for_each([](auto&& el)
|
||||||
{
|
{
|
||||||
if constexpr (toml::is_number<decltype(el)>)
|
if constexpr (toml::is_number<decltype(el)>)
|
||||||
(*el)++;
|
(*el)++;
|
||||||
else if constexpr (toml::is_string<decltype(el)>)
|
else if constexpr (toml::is_string<decltype(el)>)
|
||||||
el = "five"sv;
|
el = "five"sv;
|
||||||
});
|
});
|
||||||
|
|
||||||
// arrays are very similar to std::vector
|
// arrays are very similar to std::vector
|
||||||
arr->push_back(7);
|
arr->push_back(7);
|
||||||
arr->emplace_back<toml::array>(8, 9);
|
arr->emplace_back<toml::array>(8, 9);
|
||||||
std::cout << "numbers: " << numbers << "\n";
|
std::cout << "numbers: " << numbers << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
// node-views can be chained to quickly query deeper
|
// node-views can be chained to quickly query deeper
|
||||||
std::cout << "cats: " << tbl["animals"]["cats"] << "\n";
|
std::cout << "cats: " << tbl["animals"]["cats"] << "\n";
|
||||||
std::cout << "fish[1]: " << tbl["animals"]["fish"][1] << "\n";
|
std::cout << "fish[1]: " << tbl["animals"]["fish"][1] << "\n";
|
||||||
|
|
||||||
// can also be retrieved via absolute path
|
// can also be retrieved via absolute path
|
||||||
std::cout << "cats: " << tbl.at_path("animals.cats") << "\n";
|
std::cout << "cats: " << tbl.at_path("animals.cats") << "\n";
|
||||||
std::cout << "fish[1]: " << tbl.at_path("animals.fish[1]") << "\n";
|
std::cout << "fish[1]: " << tbl.at_path("animals.fish[1]") << "\n";
|
||||||
|
|
||||||
// ...even if the element doesn't exist
|
// ...even if the element doesn't exist
|
||||||
std::cout << "dinosaurs: " << tbl["animals"]["dinosaurs"] << "\n"; //no dinosaurs :(
|
std::cout << "dinosaurs: " << tbl["animals"]["dinosaurs"] << "\n"; //no dinosaurs :(
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
@endcpp
|
@endcpp
|
||||||
|
|
||||||
@ -287,11 +295,12 @@ dinosaurs:
|
|||||||
@endout
|
@endout
|
||||||
|
|
||||||
@see
|
@see
|
||||||
- toml::node
|
|
||||||
- toml::node_view
|
- toml::node
|
||||||
- toml::value
|
- toml::node_view
|
||||||
- toml::array
|
- toml::value
|
||||||
- toml::table
|
- toml::array
|
||||||
|
- toml::table
|
||||||
|
|
||||||
<!-- --------------------------------------------------------------------------------------------------------------- -->
|
<!-- --------------------------------------------------------------------------------------------------------------- -->
|
||||||
|
|
||||||
@ -309,37 +318,39 @@ but via a toml::json_formatter and toml::yaml_formatter.
|
|||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
auto tbl = toml::table{
|
auto tbl = toml::table{
|
||||||
{ "lib", "toml++" },
|
{ "lib", "toml++" },
|
||||||
{ "cpp", toml::array{ 17, 20, "and beyond" } },
|
{ "cpp", toml::array{ 17, 20, "and beyond" } },
|
||||||
{ "toml", toml::array{ "1.0.0", "and beyond" } },
|
{ "toml", toml::array{ "1.0.0", "and beyond" } },
|
||||||
{ "repo", "https://github.com/marzer/tomlplusplus/" },
|
{ "repo", "https://github.com/marzer/tomlplusplus/" },
|
||||||
{ "author", toml::table{
|
{ "author", toml::table{
|
||||||
{ "name", "Mark Gillard" },
|
{ "name", "Mark Gillard" },
|
||||||
{ "github", "https://github.com/marzer" },
|
{ "github", "https://github.com/marzer" },
|
||||||
{ "twitter", "https://twitter.com/marzer8789" }
|
{ "twitter", "https://twitter.com/marzer8789" }
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
// serializing as TOML
|
// serializing as TOML
|
||||||
std::cout << "###### TOML ######" << "\n\n";
|
std::cout << "###### TOML ######" << "\n\n";
|
||||||
std::cout << tbl << "\n\n";
|
std::cout << tbl << "\n\n";
|
||||||
|
|
||||||
// serializing as JSON using toml::json_formatter:
|
// serializing as JSON using toml::json_formatter:
|
||||||
std::cout << "###### JSON ######" << "\n\n";
|
std::cout << "###### JSON ######" << "\n\n";
|
||||||
std::cout << toml::json_formatter{ tbl } << "\n\n";
|
std::cout << toml::json_formatter{ tbl } << "\n\n";
|
||||||
|
|
||||||
// serializing as YAML using toml::yaml_formatter:
|
// serializing as YAML using toml::yaml_formatter:
|
||||||
std::cout << "###### YAML ######" << "\n\n";
|
std::cout << "###### YAML ######" << "\n\n";
|
||||||
std::cout << toml::yaml_formatter{ tbl } << "\n\n";
|
std::cout << toml::yaml_formatter{ tbl } << "\n\n";
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
@endcpp
|
@endcpp
|
||||||
|
|
||||||
@out
|
@out
|
||||||
###### TOML ######
|
|
||||||
|
###### TOML
|
||||||
|
|
||||||
cpp = [ 17, 20, 'and beyond' ]
|
cpp = [ 17, 20, 'and beyond' ]
|
||||||
lib = 'toml++'
|
lib = 'toml++'
|
||||||
@ -351,48 +362,50 @@ github = 'https://github.com/marzer'
|
|||||||
name = 'Mark Gillard'
|
name = 'Mark Gillard'
|
||||||
twitter = 'https://twitter.com/marzer8789'
|
twitter = 'https://twitter.com/marzer8789'
|
||||||
|
|
||||||
###### JSON ######
|
###### JSON
|
||||||
|
|
||||||
{
|
{
|
||||||
"author" : {
|
"author" : {
|
||||||
"github" : "https://github.com/marzer",
|
"github" : "https://github.com/marzer",
|
||||||
"name" : "Mark Gillard",
|
"name" : "Mark Gillard",
|
||||||
"twitter" : "https://twitter.com/marzer8789"
|
"twitter" : "https://twitter.com/marzer8789"
|
||||||
},
|
},
|
||||||
"cpp" : [
|
"cpp" : [
|
||||||
17,
|
17,
|
||||||
20,
|
20,
|
||||||
"and beyond"
|
"and beyond"
|
||||||
],
|
],
|
||||||
"lib" : "toml++",
|
"lib" : "toml++",
|
||||||
"repo" : "https://github.com/marzer/tomlplusplus/",
|
"repo" : "https://github.com/marzer/tomlplusplus/",
|
||||||
"toml" : [
|
"toml" : [
|
||||||
"1.0.0",
|
"1.0.0",
|
||||||
"and beyond"
|
"and beyond"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
###### YAML ######
|
###### YAML
|
||||||
|
|
||||||
author:
|
author:
|
||||||
github: 'https://github.com/marzer'
|
github: 'https://github.com/marzer'
|
||||||
name: 'Mark Gillard'
|
name: 'Mark Gillard'
|
||||||
twitter: 'https://twitter.com/marzer8789'
|
twitter: 'https://twitter.com/marzer8789'
|
||||||
cpp:
|
cpp:
|
||||||
- 17
|
|
||||||
- 20
|
- 17
|
||||||
- 'and beyond'
|
- 20
|
||||||
lib: 'toml++'
|
- 'and beyond'
|
||||||
repo: 'https://github.com/marzer/tomlplusplus/'
|
lib: 'toml++'
|
||||||
toml:
|
repo: 'https://github.com/marzer/tomlplusplus/'
|
||||||
- '1.0.0'
|
toml:
|
||||||
- 'and beyond'
|
- '1.0.0'
|
||||||
@endout
|
- 'and beyond'
|
||||||
|
@endout
|
||||||
|
|
||||||
@see
|
@see
|
||||||
- toml::toml_formatter
|
|
||||||
- toml::json_formatter
|
- toml::toml_formatter
|
||||||
- toml::yaml_formatter
|
- toml::json_formatter
|
||||||
|
- toml::yaml_formatter
|
||||||
|
|
||||||
<!-- --------------------------------------------------------------------------------------------------------------- -->
|
<!-- --------------------------------------------------------------------------------------------------------------- -->
|
||||||
|
|
||||||
@ -420,7 +433,7 @@ do it manually before including toml++ in some global header that's used everywh
|
|||||||
// some_code_file.cpp
|
// some_code_file.cpp
|
||||||
|
|
||||||
#define TOML_IMPLEMENTATION
|
#define TOML_IMPLEMENTATION
|
||||||
#include "global_header_that_includes_toml++.h"
|
#include "global_header_that_includes_toml++.hpp"
|
||||||
@endcpp
|
@endcpp
|
||||||
|
|
||||||
<strong>Bonus Step: Disable any library features you don't need</strong>
|
<strong>Bonus Step: Disable any library features you don't need</strong>
|
||||||
@ -454,12 +467,11 @@ and [emoji sundae] Regular. The API is the same for both.
|
|||||||
2. Add `tomlplusplus/include` to your include paths
|
2. Add `tomlplusplus/include` to your include paths
|
||||||
3. `#include <toml++/toml.hpp>`
|
3. `#include <toml++/toml.hpp>`
|
||||||
|
|
||||||
|
|
||||||
<!-- --------------------------------------------------------------------------------------------------------------- -->
|
<!-- --------------------------------------------------------------------------------------------------------------- -->
|
||||||
|
|
||||||
@subsection mainpage-adding-lib-conan Conan
|
@subsection mainpage-adding-lib-conan Conan
|
||||||
|
|
||||||
Add `tomlplusplus/3.3.0` to your conanfile.
|
Add `tomlplusplus/3.4.0` to your conanfile.
|
||||||
|
|
||||||
<!-- --------------------------------------------------------------------------------------------------------------- -->
|
<!-- --------------------------------------------------------------------------------------------------------------- -->
|
||||||
|
|
||||||
@ -467,7 +479,7 @@ Add `tomlplusplus/3.3.0` to your conanfile.
|
|||||||
Add `tomlpp` to your `package.json5`, e.g.:
|
Add `tomlpp` to your `package.json5`, e.g.:
|
||||||
@json
|
@json
|
||||||
depends: [
|
depends: [
|
||||||
'tomlpp^3.3.0',
|
'tomlpp^3.4.0',
|
||||||
]
|
]
|
||||||
@endjson
|
@endjson
|
||||||
|
|
||||||
@ -498,7 +510,7 @@ You can also add it as a subproject directly.
|
|||||||
|
|
||||||
@json
|
@json
|
||||||
{
|
{
|
||||||
"marzer/tomlplusplus": { }
|
"marzer/tomlplusplus": { }
|
||||||
}
|
}
|
||||||
@endjson
|
@endjson
|
||||||
|
|
||||||
@ -510,7 +522,6 @@ You can also add it as a subproject directly.
|
|||||||
vcpkg install tomlplusplus
|
vcpkg install tomlplusplus
|
||||||
@endshell
|
@endshell
|
||||||
|
|
||||||
|
|
||||||
<!-- --------------------------------------------------------------------------------------------------------------- -->
|
<!-- --------------------------------------------------------------------------------------------------------------- -->
|
||||||
|
|
||||||
@subsection mainpage-adding-lib-cmake-fetch-content CMake FetchContent
|
@subsection mainpage-adding-lib-cmake-fetch-content CMake FetchContent
|
||||||
@ -518,9 +529,9 @@ vcpkg install tomlplusplus
|
|||||||
@cmake
|
@cmake
|
||||||
include(FetchContent)
|
include(FetchContent)
|
||||||
FetchContent_Declare(
|
FetchContent_Declare(
|
||||||
tomlplusplus
|
tomlplusplus
|
||||||
GIT_REPOSITORY https://github.com/marzer/tomlplusplus.git
|
GIT_REPOSITORY https://github.com/marzer/tomlplusplus.git
|
||||||
GIT_TAG v3.3.0
|
GIT_TAG v3.4.0
|
||||||
)
|
)
|
||||||
FetchContent_MakeAvailable(tomlplusplus)
|
FetchContent_MakeAvailable(tomlplusplus)
|
||||||
@endcmake
|
@endcmake
|
||||||
@ -552,12 +563,12 @@ TOML libraries available for python, and thus one of the fastest options availab
|
|||||||
|
|
||||||
@out
|
@out
|
||||||
Parsing data.toml 5000 times:
|
Parsing data.toml 5000 times:
|
||||||
pytomlpp: 0.694 s
|
pytomlpp: 0.694 s
|
||||||
rtoml: 0.871 s ( 1.25x)
|
rtoml: 0.871 s ( 1.25x)
|
||||||
tomli: 2.625 s ( 3.78x)
|
tomli: 2.625 s ( 3.78x)
|
||||||
toml: 5.642 s ( 8.12x)
|
toml: 5.642 s ( 8.12x)
|
||||||
qtoml: 7.760 s (11.17x)
|
qtoml: 7.760 s (11.17x)
|
||||||
tomlkit: 32.708 s (47.09x)
|
tomlkit: 32.708 s (47.09x)
|
||||||
@endout
|
@endout
|
||||||
|
|
||||||
Install it using `pip`:
|
Install it using `pip`:
|
||||||
@ -606,6 +617,7 @@ it is embedded in the preamble at the top of the header.
|
|||||||
|
|
||||||
For bug reports and feature requests please use the \github{marzer/tomlplusplus/issues, Github Issues}
|
For bug reports and feature requests please use the \github{marzer/tomlplusplus/issues, Github Issues}
|
||||||
system. For anything else you're welcome to reach out via other means. In order of likely response speed:
|
system. For anything else you're welcome to reach out via other means. In order of likely response speed:
|
||||||
- Twitter: [marzer8789](https://twitter.com/marzer8789)
|
|
||||||
- Gitter: [marzer/tomlplusplus](https://gitter.im/marzer/tomlplusplus) ("Discord for repos")
|
- Twitter: [marzer8789](https://twitter.com/marzer8789)
|
||||||
- Email: [mark.gillard@outlook.com.au](mailto:mark.gillard@outlook.com.au)
|
- Gitter: [marzer/tomlplusplus](https://gitter.im/marzer/tomlplusplus) ("Discord for repos")
|
||||||
|
- Email: [mark.gillard@outlook.com.au](mailto:mark.gillard@outlook.com.au)
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define TOML_LIB_MAJOR 3
|
#define TOML_LIB_MAJOR 3
|
||||||
#define TOML_LIB_MINOR 3
|
#define TOML_LIB_MINOR 4
|
||||||
#define TOML_LIB_PATCH 0
|
#define TOML_LIB_PATCH 0
|
||||||
|
|
||||||
#define TOML_LANG_MAJOR 1
|
#define TOML_LANG_MAJOR 1
|
||||||
|
@ -7,7 +7,7 @@ project(
|
|||||||
'tomlplusplus',
|
'tomlplusplus',
|
||||||
'cpp',
|
'cpp',
|
||||||
license: 'MIT',
|
license: 'MIT',
|
||||||
version: '3.3.0',
|
version: '3.4.0',
|
||||||
meson_version: '>=0.61.0',
|
meson_version: '>=0.61.0',
|
||||||
default_options: [
|
default_options: [
|
||||||
# https://mesonbuild.com/Builtin-options.html
|
# https://mesonbuild.com/Builtin-options.html
|
||||||
|
@ -47,6 +47,6 @@ ninja && toml-test ./toml-test/tt_decoder && toml-test ./toml-test/tt_encoder --
|
|||||||
> ℹ️ Pass `-Duse_vendored_libs=false` to meson if you wish to use the system-installed version
|
> ℹ️ Pass `-Duse_vendored_libs=false` to meson if you wish to use the system-installed version
|
||||||
> of nlohmann/json rather than the vendored one.
|
> of nlohmann/json rather than the vendored one.
|
||||||
|
|
||||||
[toml-test]: https://github.com/BurntSushi/toml-test
|
[toml-test]: https://github.com/toml-lang/toml-test
|
||||||
[contributing]: ../CONTRIBUTING.md
|
[contributing]: ./../CONTRIBUTING.md
|
||||||
[meson]: https://mesonbuild.com/
|
[meson]: https://mesonbuild.com/
|
||||||
|
4
toml.hpp
4
toml.hpp
@ -1,6 +1,6 @@
|
|||||||
//----------------------------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// toml++ v3.3.0
|
// toml++ v3.4.0
|
||||||
// https://github.com/marzer/tomlplusplus
|
// https://github.com/marzer/tomlplusplus
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
//
|
//
|
||||||
@ -1152,7 +1152,7 @@ TOML_ENABLE_WARNINGS;
|
|||||||
//******** impl/version.hpp ******************************************************************************************
|
//******** impl/version.hpp ******************************************************************************************
|
||||||
|
|
||||||
#define TOML_LIB_MAJOR 3
|
#define TOML_LIB_MAJOR 3
|
||||||
#define TOML_LIB_MINOR 3
|
#define TOML_LIB_MINOR 4
|
||||||
#define TOML_LIB_PATCH 0
|
#define TOML_LIB_PATCH 0
|
||||||
|
|
||||||
#define TOML_LANG_MAJOR 1
|
#define TOML_LANG_MAJOR 1
|
||||||
|
@ -31,7 +31,7 @@ if __name__ == '__main__':
|
|||||||
args.add_argument(r'version', type=str)
|
args.add_argument(r'version', type=str)
|
||||||
args = args.parse_args()
|
args = args.parse_args()
|
||||||
|
|
||||||
version = re.fullmatch(r'\s*([0-9]+)\s*[.,;]\s*([0-9]+)\s*[.,;]\s*([0-9]+)\s*', args.version)
|
version = re.fullmatch(r'\s*[vV]?\s*([0-9]+)\s*[.,;]+\s*([0-9]+)\s*[.,;]+\s*([0-9]+)\s*', args.version)
|
||||||
if not version:
|
if not version:
|
||||||
print(rf"Couldn't parse version triplet from '{args.version}'", file=sys.stderr)
|
print(rf"Couldn't parse version triplet from '{args.version}'", file=sys.stderr)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
@ -51,15 +51,15 @@ if __name__ == '__main__':
|
|||||||
text = re.sub(r'''(\s|^)VERSION\s+[0-9](?:[.][0-9]){2}''', rf"\1VERSION {version_str}", text, count=1, flags=re.I)
|
text = re.sub(r'''(\s|^)VERSION\s+[0-9](?:[.][0-9]){2}''', rf"\1VERSION {version_str}", text, count=1, flags=re.I)
|
||||||
write_text_file(path, text)
|
write_text_file(path, text)
|
||||||
|
|
||||||
path = root / r'include/toml++/impl/version.h'
|
for path in (root / r'include/toml++/impl/version.hpp', root / r'toml.hpp'):
|
||||||
text = read_text_file(path)
|
text = read_text_file(path)
|
||||||
text = re.sub(r'''(\s*#\s*define\s+TOML_LIB_MAJOR)\s+[0-9]+''', rf"\1 {version[0]}", text)
|
text = re.sub(r'''(\s*#\s*define\s+TOML_LIB_MAJOR)\s+[0-9]+''', rf"\1 {version[0]}", text)
|
||||||
text = re.sub(r'''(\s*#\s*define\s+TOML_LIB_MINOR)\s+[0-9]+''', rf"\1 {version[1]}", text)
|
text = re.sub(r'''(\s*#\s*define\s+TOML_LIB_MINOR)\s+[0-9]+''', rf"\1 {version[1]}", text)
|
||||||
text = re.sub(r'''(\s*#\s*define\s+TOML_LIB_PATCH)\s+[0-9]+''', rf"\1 {version[2]}", text)
|
text = re.sub(r'''(\s*#\s*define\s+TOML_LIB_PATCH)\s+[0-9]+''', rf"\1 {version[2]}", text)
|
||||||
write_text_file(path, text)
|
write_text_file(path, text)
|
||||||
|
|
||||||
noop_sub = r'#$%^nbsp^%$#'
|
noop_sub = r'#$%^nbsp^%$#'
|
||||||
for file in (r'README.md', r'docs/pages/main_page.dox'):
|
for file in (r'README.md', r'docs/pages/main_page.md'):
|
||||||
path = root / file
|
path = root / file
|
||||||
text = read_text_file(path)
|
text = read_text_file(path)
|
||||||
text = re.sub(r'''(toml(?:plusplus|\+\+|pp)\s*[/:^]\s*)[0-9](?:[.][0-9]){2}''', rf"\1{noop_sub}{version_str}", text, flags=re.I)
|
text = re.sub(r'''(toml(?:plusplus|\+\+|pp)\s*[/:^]\s*)[0-9](?:[.][0-9]){2}''', rf"\1{noop_sub}{version_str}", text, flags=re.I)
|
||||||
|
Loading…
Reference in New Issue
Block a user