2024-06-15 10:28:16 +00:00
# toml11
2017-05-13 06:04:02 +00:00
2020-07-19 10:09:47 +00:00
[![Build Status on GitHub Actions ](https://github.com/ToruNiina/toml11/workflows/build/badge.svg )](https://github.com/ToruNiina/toml11/actions)
2024-06-16 10:28:10 +00:00
[![Build status ](https://ci.appveyor.com/api/projects/status/m2n08a926asvg5mg/branch/main?svg=true )](https://ci.appveyor.com/project/ToruNiina/toml11/branch/main)
2019-02-13 13:36:29 +00:00
[![Version ](https://img.shields.io/github/release/ToruNiina/toml11.svg?style=flat )](https://github.com/ToruNiina/toml11/releases)
[![License ](https://img.shields.io/github/license/ToruNiina/toml11.svg?style=flat )](LICENSE)
2018-03-28 10:21:17 +00:00
[![DOI ](https://zenodo.org/badge/DOI/10.5281/zenodo.1209136.svg )](https://doi.org/10.5281/zenodo.1209136)
2017-05-13 07:30:56 +00:00
2024-06-16 11:33:10 +00:00
[日本語版 ](https://github.com/ToruNiina/toml11/blob/main/README_ja.md )
2020-02-29 15:35:27 +00:00
2024-06-28 14:52:58 +00:00
toml11 is a feature-rich TOML language library for C++11/14/17/20.
2024-06-15 10:28:16 +00:00
- It complies with [the latest TOML language specification ](https://toml.io/en/v1.0.0 ).
- It passes all the standard TOML language [test cases ](https://github.com/toml-lang/toml-test ).
- It supports new features merged into the upcoming TOML version (v1.1.0).
- It provides clear error messages, including the location of the error.
- It parses and retains comments, associating them with corresponding values.
- It maintains formatting information such as hex integers and considers these during serialization.
- It provides exception-less parse function.
- It supports complex type conversions from TOML values.
- It allows customization of the types stored in `toml::value` .
- It provides some extensions not present in the TOML language standard.
2019-03-17 16:50:23 +00:00
2019-03-24 12:30:27 +00:00
## Example
```cpp
2019-07-09 23:45:09 +00:00
#include <toml.hpp>
2019-03-24 12:30:27 +00:00
#include <iostream>
2024-06-15 10:28:16 +00:00
// ```toml
// title = "an example toml file"
// nums = [3, 1, 4, 1, 5] # pi!
// ```
2019-03-24 12:30:27 +00:00
int main()
{
2024-06-15 10:28:16 +00:00
// select TOML version at runtime (optional)
auto data = toml::parse("example.toml", toml::spec::v(1,1,0));
2019-03-24 12:30:27 +00:00
2020-02-29 15:35:27 +00:00
// find a value with the specified type from a table
2019-06-15 10:50:31 +00:00
std::string title = toml::find< std::string > (data, "title");
2019-03-24 12:30:27 +00:00
2024-06-15 10:28:16 +00:00
// convert the whole array into STL-like container automatically
2020-02-29 15:35:27 +00:00
std::vector< int > nums = toml::find< std::vector < int > >(data, "nums");
// access with STL-like manner
2024-06-15 10:28:16 +00:00
if( ! data.contains("foo"))
2020-02-29 15:35:27 +00:00
{
2021-01-25 08:25:29 +00:00
data["foo"] = "bar";
2020-02-29 15:35:27 +00:00
}
2024-06-15 10:28:16 +00:00
if(data.at("nums").is_array())
{
data.push_back(9);
}
// check comments
assert(data.at("nums").comments().at(0) == "# pi!");
2020-02-29 15:35:27 +00:00
// pass a fallback
std::string name = toml::find_or< std::string > (data, "name", "not found");
2024-06-15 10:28:16 +00:00
// serialization considering format info
data.at("nums").as_array_fmt().fmt = toml::array_format::multiline;
data.at("nums").as_array_fmt().indent_type = toml::indent_char::space;
data.at("nums").as_array_fmt().body_indent = 2;
std::cout < < toml::format ( data ) < < std::endl ;
2019-03-24 12:30:27 +00:00
return 0;
}
```
2024-06-16 11:33:10 +00:00
For more details, please refer to the [documentation ](https://toruniina.github.io/toml11/ ).
2024-06-15 10:28:16 +00:00
2019-03-20 02:35:34 +00:00
## Table of Contents
- [Integration ](#integration )
2024-06-15 10:28:16 +00:00
- [Features ](#features )
- [parsing a file ](#parsing-a-file )
- [finding a value ](#finding-a-value )
- [comments ](#comments )
- [error messages ](#error-messages )
- [serialization ](#serialization )
2024-06-20 15:05:09 +00:00
- [Breaking Changes from v3 ](#changes-from-v3 )
2019-03-20 02:35:34 +00:00
- [Contributors ](#contributors )
- [Licensing Terms ](#licensing-terms )
## Integration
2018-12-12 10:33:01 +00:00
2024-06-15 10:28:16 +00:00
There are several ways to use toml11.
2017-05-13 06:04:02 +00:00
2024-06-16 11:33:10 +00:00
Here is a brief overview of each method. For more details, please refer to the [documentation ](https://toruniina.github.io/toml11/docs/installation/ ).
2018-12-12 10:33:01 +00:00
2024-06-15 10:28:16 +00:00
### Single Include File
2018-12-12 10:33:01 +00:00
2024-06-15 10:28:16 +00:00
Copy `single_include/toml.hpp` to your preferred location and add it to your include path.
2018-12-12 10:33:01 +00:00
2024-06-15 10:28:16 +00:00
### git submodule
2018-12-12 10:33:01 +00:00
2024-06-15 10:28:16 +00:00
By adding toml11 as a subdirectory using `git submodule` (or any other way),
you can either add `toml11/include` to your include path or use `add_subdirectory(toml11)` in your CMake project.
2018-12-12 10:33:01 +00:00
2024-07-06 09:58:50 +00:00
### CMake `FetchContent`
Using `FetchContent` , you can automatically download it.
```cmake
include(FetchContent)
FetchContent_Declare(
toml11
GIT_REPOSITORY https://github.com/ToruNiina/toml11.git
2024-07-22 16:29:13 +00:00
GIT_TAG v4.1.0
2024-07-06 09:58:50 +00:00
)
FetchContent_MakeAvailable(toml11)
add_executable(main main.cpp)
target_link_libraries(main PRIVATE toml11::toml11)
```
2024-07-22 16:29:13 +00:00
### CMake Package Manager (CPM)
After [adding cpm to your project ](https://github.com/cpm-cmake/CPM.cmake?tab=readme-ov-file#adding-cpm ), you can use toml11 by doing:
```cmake
include(cmake/CPM.cmake)
CPMAddPackage("gh:ToruNiina/toml11@4.1.0")
add_executable(main main.cpp)
target_link_libraries(main PUBLIC toml11::toml11)
```
2024-06-15 10:28:16 +00:00
### Install Using CMake
2018-12-13 14:47:32 +00:00
2024-06-15 10:28:16 +00:00
You can install toml11 using CMake with the following steps:
2019-06-17 03:59:29 +00:00
```console
2024-06-15 10:28:16 +00:00
$ git clone https://github.com/ToruNiina/toml11
$ cd toml11
$ git submodule update --init --recursive
$ cmake -B ./build/
$ cmake --build ./build/
$ cmake --install ./build/ --prefix /path/to/toml11
2019-06-17 03:59:29 +00:00
```
2024-06-15 10:28:16 +00:00
### Precompile Library
2017-05-13 06:04:02 +00:00
2024-06-15 10:28:16 +00:00
By setting `-DTOML11_PRECOMPILE=ON` , you can precompile some of the library functions.
In this case, the standard library features available will vary with the C++ version, and part of the interface will change.
Therefore, you need to specify `CMAKE_CXX_STANDARD` .
2019-06-15 10:50:31 +00:00
```console
2024-06-15 10:28:16 +00:00
$ cmake -B ./build/ -DTOML11_PRECOMPILE=ON -DCMAKE_CXX_STANDARD=11/14/17/20
$ cmake --build ./build/
2017-05-13 06:04:02 +00:00
```
2024-06-28 14:52:58 +00:00
When linking the library, use `target_link_libraries` in CMake
```cmake
target_link_libraries(your_target PUBLIC toml11::toml11)
```
or pass `-DTOML11_COMPILE_SOURCES` to the compiler.
2024-06-15 10:28:16 +00:00
### Building Example
2018-12-12 14:23:59 +00:00
2024-06-15 10:28:16 +00:00
To compile the examples in the `examples/` directory, set `-DTOML11_BUILD_EXAMPLES=ON` .
2019-07-19 11:42:47 +00:00
```console
2024-06-15 10:28:16 +00:00
$ cmake -B ./build/ -DTOML11_BUILD_EXAMPLES=ON
$ cmake --build ./build/
2019-04-23 14:27:53 +00:00
```
2024-06-15 10:28:16 +00:00
### Building Tests
2019-06-15 10:50:31 +00:00
2024-06-15 10:28:16 +00:00
To compile unit tests, set `-DTOML11_BUILD_TESTS=ON` .
Additionally, to compile the encoder and decoder for toml-test, set `-DTOML11_BUILD_TOML_TESTS=ON` .
2017-05-13 06:14:16 +00:00
2018-12-12 10:33:01 +00:00
```console
2024-06-15 10:28:16 +00:00
$ cmake -B ./build/ -DTOML11_BUILD_EXAMPLES=ON
$ cmake --build ./build/
2019-06-15 10:50:31 +00:00
```
2024-06-15 10:28:16 +00:00
## Features
2019-06-15 10:50:31 +00:00
2024-06-15 10:28:16 +00:00
Here is a brief overview of the features provided by toml11.
2019-06-15 10:50:31 +00:00
2024-06-16 11:33:10 +00:00
For more details, please refer to the [documentation ](https://toruniina.github.io/toml11/docs/features/ ).
2019-06-15 10:50:31 +00:00
2024-06-15 10:28:16 +00:00
### Parsing a File
2019-06-15 10:50:31 +00:00
2024-06-15 10:28:16 +00:00
To parse a file, use `toml::parse` .
2019-06-15 10:50:31 +00:00
2024-06-15 10:28:16 +00:00
The overall type of the file is always a table.
However, since `toml::value` contains metadata such as comments and formatting information,
`toml::parse` returns a `toml::value` rather than a `toml::table` .
2019-06-15 10:50:31 +00:00
```cpp
2024-06-15 10:28:16 +00:00
const toml::value input = toml::parse("input.toml");
2019-06-15 10:50:31 +00:00
```
2024-06-15 10:28:16 +00:00
To parse a string directly, use `toml::parse_str` .
2019-06-15 10:50:31 +00:00
```cpp
2024-06-15 10:28:16 +00:00
const toml::value input = toml::parse_str("a = 42");
2019-06-15 10:50:31 +00:00
```
2024-07-06 09:58:50 +00:00
When parsing string literals, you can use the `""_toml` literal.
```cpp
using namespace toml::literals::toml_literals;
const toml::value lit = "a = 42"_toml;
```
`toml::parse` , `parse_str` and `_toml` literal throw a `toml::syntax_error` exception in case of a syntax error.
The error message obtained with `what()` will look like this:
```
[error] bad integer: `_` must be surrounded by digits
--> internal string at line 64 in file main.cpp
|
1 | a = 123__456
| ^-- invalid underscore
Hint: valid : -42, 1_000, 1_2_3_4_5, 0xC0FFEE, 0b0010, 0o755
Hint: invalid: _42, 1__000, 0123
```
Error messages can also be colorized by calling `toml::color::enable()` .
By using `toml::try_parse` , you can receive a `toml::result<toml::value, std::vector<toml::error_info>>` without throwing exceptions.
2020-06-21 05:11:26 +00:00
```cpp
2024-06-15 10:28:16 +00:00
const auto input = toml::try_parse("input.toml");
if(input.is_ok())
2020-06-21 05:11:26 +00:00
{
2024-06-15 10:28:16 +00:00
std::cout < < input.unwrap ( ) . at ( " a " ) . as_integer ( ) < < std::endl ;
2020-06-21 05:11:26 +00:00
}
```
2024-06-15 10:28:16 +00:00
Additionally, toml11 allows easy and precise control over the version of the TOML language being used.
2019-10-09 12:09:38 +00:00
2024-06-15 10:28:16 +00:00
You can enable specific new features from TOML v1.1.0 while using TOML v1.0.0.
2019-12-10 11:06:01 +00:00
```cpp
2024-06-15 10:28:16 +00:00
toml::spec s = toml::spec::v(1, 0, 0);
s.v1_1_0_allow_trailing_comma_in_inline_tables = true;
2019-12-10 11:06:01 +00:00
2024-06-15 10:28:16 +00:00
const toml::value input = toml::parse("input.toml");
2019-12-10 11:06:01 +00:00
```
2024-06-15 10:28:16 +00:00
Moreover, several language extensions not included in the TOML standard are available.
2019-06-15 10:50:31 +00:00
```cpp
2024-06-15 10:28:16 +00:00
toml::spec s = toml::spec::v(1, 0, 0);
s.ext_hex_float = true; // this allows hexadecimal floating-point numbers
s.ext_null_value = true; // this allows `key = null` value
s.ext_num_suffix = true; // this allows numeric suffixes like `100_msec`
2019-06-15 10:50:31 +00:00
```
2024-06-16 11:33:10 +00:00
For more detail and reference of each feature, please refer to the [documentation ](https://toruniina.github.io/toml11/docs/features/ ).
2019-06-15 10:50:31 +00:00
2024-06-15 10:28:16 +00:00
### finding a value
2019-06-15 10:50:31 +00:00
2024-06-15 10:28:16 +00:00
`toml::value` provides member functions for accessing values, such as `at()` , `is_xxx()` , and `as_xxx()` .
2019-06-15 10:50:31 +00:00
```cpp
2024-06-15 10:28:16 +00:00
const toml::value input = toml::parse("input.toml");
if(input.contains("a") & & input.at("a").is_integer())
2019-06-15 10:50:31 +00:00
{
2024-06-15 10:28:16 +00:00
std::cout < < input.at ( " a " ) . as_integer ( ) < < std::endl ;
2019-06-15 10:50:31 +00:00
}
```
2024-06-15 10:28:16 +00:00
By using `toml::find` , you can perform type conversion and search simultaneously.
2017-05-13 06:04:02 +00:00
```cpp
2024-06-15 10:28:16 +00:00
const toml::value input = toml::parse("input.toml");
std::cout < < toml::find < int > (input, "a") < < std::endl ;
2017-05-13 06:04:02 +00:00
```
2024-07-06 09:58:50 +00:00
If type conversion or value lookup fails, a `toml::type_error` is thrown. The error message will look like this:
```
[error] toml::value::as_string(): bad_cast to string
--> input.toml
|
1 | a = 123_456
| ^^^^^^^-- the actual type is integer
```
You can access nested tables or arrays of tables in the same way.
```cpp
// [a]
// b = [
// {c = 42},
// {c = 54}
// ]
const toml::value input = toml::parse("input.toml");
std::cout < < toml::find < int > (input, "a", "b", 1, "c") < < std::endl ;
```
Most STL containers and those with similar interfaces can be converted.
```cpp
// array = [3,1,4,1,5]
const toml::value input = toml::parse("input.toml");
const auto a1 = toml::find< std::vector < int > >(input, "array");
const auto a2 = toml::find< std::array < int , 5 > >(input, "array");
const auto a3 = toml::find< std::deque < int > >(input, "array");
const auto a4 = toml::find< boost::container::small_vector < int , 8 > >(input, "array");
```
2024-06-15 10:28:16 +00:00
You can perform advanced type conversions on complex TOML values.
2017-05-13 06:04:02 +00:00
2018-12-12 10:33:01 +00:00
```toml
2024-06-15 10:28:16 +00:00
mixed_array = [
42,
3.14,
{a = "foo", b = "bar"}
]
2018-12-12 10:33:01 +00:00
```
```cpp
2024-06-15 10:28:16 +00:00
const toml::value input = toml::parse("input.toml");
2018-12-12 10:33:01 +00:00
2024-06-15 10:28:16 +00:00
const auto mixed = toml::find<
std::tuple< int , double , std::map < std::string , std::string > >
>(input, "mixed_array") < < std::endl ;
2017-05-13 06:04:02 +00:00
```
2024-07-06 09:58:50 +00:00
User-defined types can also be converted by using macros or defining some specific functions.
```cpp
namespace extlib
{
struct foo
{
int a;
std::string b;
};
} // extlib
TOML11_DEFINE_CONVERSION_NON_INTRUSIVE(extlib::foo, a, b)
// ...
const auto input = R"(
[foo]
a = 42
b = "bar"
)"_toml;
const extlib::foo f = toml::find< extlib::foo > (input, "foo");
```
Using `toml::find_or` , you can get a default value in case of failure.
```cpp
const toml::value input = toml::parse("input.toml");
std::cout < < toml::find_or ( input , " a " , 6 * 9 ) < < std::endl ;
```
2024-06-16 11:33:10 +00:00
For more details, please refer to the [documentation ](https://toruniina.github.io/toml11/docs/features/value/ ).
2017-05-13 06:04:02 +00:00
2024-06-15 10:28:16 +00:00
### comments
2019-06-15 10:50:31 +00:00
2024-06-15 10:28:16 +00:00
toml11 stores comments related to values within the value itself.
2017-05-19 05:58:52 +00:00
2024-06-15 10:28:16 +00:00
Comments related to a value include a series of comments written immediately before the value
and any comments written after the value without a newline in between.
2017-05-19 05:58:52 +00:00
```toml
2024-06-15 10:28:16 +00:00
# This is a comment for a.
# This is also a comment for a.
a = 42 # This is also a comment for a.
2019-03-20 02:35:34 +00:00
2024-06-15 10:28:16 +00:00
# This is separated by a newline, so it is not a comment for b.
2018-12-12 10:33:01 +00:00
2024-06-15 10:28:16 +00:00
# This is a comment for b.
b = "foo"
2019-06-15 10:50:31 +00:00
```
2024-06-15 10:28:16 +00:00
These comments are stored in `toml::value` with an interface similar to `std::vector<std::string>` .
2017-05-13 06:04:02 +00:00
2018-12-12 10:33:01 +00:00
```cpp
2024-06-15 10:28:16 +00:00
const toml::value input = toml::parse("input.toml");
std::cout < < input.at ( " a " ) . comments ( ) . size ( ) < < std::endl ;
std::cout < < input.at ( " a " ) . comments ( ) . at ( 0 ) < < std::endl ;
2018-12-12 10:33:01 +00:00
```
2017-05-13 06:04:02 +00:00
2024-06-16 11:33:10 +00:00
For more details, please refer to the [documentation ](https://toruniina.github.io/toml11/docs/features/value/#accessing-comments ).
2019-12-06 12:15:31 +00:00
2024-06-15 10:28:16 +00:00
### error messages
2019-03-20 02:35:34 +00:00
2024-06-15 10:28:16 +00:00
One of the goals of toml11 is to provide clear and understandable error messages.
2017-05-13 06:04:02 +00:00
2024-06-15 10:28:16 +00:00
For parsing errors, you might see an error message like the following:
2019-06-15 10:50:31 +00:00
```
2024-06-15 10:28:16 +00:00
[error] bad integer: `_` must be surrounded by digits
--> internal string at line 64 in file main.cpp
|
1 | a = 123__456
| ^-- invalid underscore
Hint: valid : -42, 1_000, 1_2_3_4_5, 0xC0FFEE, 0b0010, 0o755
Hint: invalid: _42, 1__000, 0123
2021-05-15 12:47:03 +00:00
```
2024-06-15 10:28:16 +00:00
If you request a type different from the actual stored type, an error message like this will be displayed:
2017-05-13 06:04:02 +00:00
2018-12-12 10:33:01 +00:00
```
2024-06-15 10:28:16 +00:00
[error] toml::value::as_string(): bad_cast to string
--> input.toml
|
1 | a = 123_456
| ^^^^^^^-- the actual type is integer
2019-03-20 02:35:34 +00:00
```
2018-12-12 10:33:01 +00:00
2024-06-15 10:28:16 +00:00
Such error messages can also be produced for user-specific algorithm that is not related to TOML syntax.
2018-12-12 10:33:01 +00:00
```cpp
2024-06-15 10:28:16 +00:00
const toml::value& a = input.at("a");
if(a.as_integer() < 0 )
{
const toml::error_info err = toml::make_error_info(
"positive integer is required",
a, "but got negative value"
);
std::cerr < < toml::format_error ( err ) < < std::endl ;
2018-12-12 10:33:01 +00:00
}
```
2024-06-16 11:33:10 +00:00
For more details, please refer to the [documentation ](https://toruniina.github.io/toml11/docs/features/error_message/ ).
2018-12-12 17:00:42 +00:00
2024-06-15 10:28:16 +00:00
### serialization
2018-12-12 17:00:42 +00:00
2024-06-15 10:28:16 +00:00
You can format a `toml::value` into a `std::string` using `toml::format` .
2019-06-18 12:26:17 +00:00
```cpp
2024-06-15 10:28:16 +00:00
const toml::value input = toml::parse("input.toml");
std::cout < < toml::format ( input ) < < std::endl ;
2018-12-12 17:00:42 +00:00
```
2024-06-15 10:28:16 +00:00
`toml::format` references the formatting information, allowing you to change the formatting method.
2018-12-12 17:00:42 +00:00
```cpp
2024-06-15 10:28:16 +00:00
toml::value output(toml::table{ {"a", 0xDEADBEEF} });
output.at("a").as_integer_fmt().fmt = toml::integer_format::hex;
2024-07-06 09:58:50 +00:00
output.at("a").as_integer_fmt().spacer = 4; // position of `_`
2018-12-12 17:00:42 +00:00
2024-06-15 10:28:16 +00:00
std::cout < < toml::format ( input ) < < std::endl ;
2024-07-06 09:58:50 +00:00
// a = 0xdead_beef
2019-06-16 11:31:08 +00:00
```
2018-12-12 17:00:42 +00:00
2024-07-06 09:58:50 +00:00
You can also specify the formatting for tables and arrays.
```cpp
toml::value output(toml::table{
{"array-of-tables", toml::array{}},
{"subtable", toml::table{}},
});
auto& aot = output.at("array-of-tables");
aot.as_array_fmt().fmt = toml::array_format::multiline; // one element per line
aot.as_array_fmt().body_indent = 4;
aot.as_array_fmt().closing_indent = 2;
toml::value v1(toml::table{ {"a", 42}, {"b", 3.14} });
v1.as_table_fmt().fmt = toml::table_format::oneline;
aot.push_back(std::move(v1));
toml::value v2(toml::table{ {"a", 42}, {"b", 3.14} });
v2.as_table_fmt().fmt = toml::table_format::oneline;
aot.push_back(std::move(v2));
output.at("subtable").as_table_fmt().fmt = toml::table_format::dotted;
output.at("subtable")["a"] = 42;
output.at("subtable")["b"] = 3.14;
std::cout < < toml::format ( output ) < < std::endl ;
// subtable.b = 3.14
// subtable.a = 42
// array-of-tables = [
// {b = 3.14, a = 42},
// {b = 3.14, a = 42},
// ]
```
These settings are read during parsing and will be maintained as long as the value type does not change when modified.
2024-06-16 11:33:10 +00:00
For details on possible formatting specifications, please refer to the [documentation ](https://toruniina.github.io/toml11/docs/features/serialize/ ).
2019-06-18 12:26:17 +00:00
2024-07-06 09:58:50 +00:00
### Configuring Types
Many types held by `toml::value` , such as `integer_type` and `array_type` , can be modified by changing the `type_config` type.
Refer to the [`examples` directory ](https://github.com/ToruNiina/toml11/tree/main/examples ) for complex use cases such as using multi-precision integers, changing containers, and normalizing Unicode.
2018-12-12 17:00:42 +00:00
2024-07-06 09:58:50 +00:00
Use these examples as references for implementing such configurations.
2019-03-20 02:35:34 +00:00
2024-07-06 09:58:50 +00:00
## Examples
The [`examples` ](https://github.com/ToruNiina/toml11/tree/main/examples ) directory provides various implementation examples in addition to type configurations.
- [boost_container ](https://github.com/ToruNiina/toml11/tree/main/examples/boost_container )
- This example shows how to use `boost::container` containers for `array_type` and `table_type` .
- [boost_multiprecision ](https://github.com/ToruNiina/toml11/tree/main/examples/boost_multiprecision )
- This example demonstrates the use of `boost::multiprecision` multi-precision numeric types for `integer_type` and `floating_type` .
- [parse_file ](https://github.com/ToruNiina/toml11/tree/main/examples/parse_file )
- This example includes type conversion implementations, covering slightly more complex cases. The corresponding TOML file is included.
- [reflect ](https://github.com/ToruNiina/toml11/tree/main/examples/reflect )
- This example shows self-type conversion using boost-ext/reflect for user-defined types.
- [unicode ](https://github.com/ToruNiina/toml11/tree/main/examples/unicode )
- This example demonstrates normalizing Unicode strings when searching for keys using uni-algo.
2020-01-17 11:26:36 +00:00
2024-06-15 10:28:16 +00:00
## Changes from v3
2020-01-17 11:26:36 +00:00
2024-06-15 10:28:16 +00:00
toml11 v4 introduces several breaking changes.
2020-01-17 11:26:36 +00:00
2024-06-15 10:28:16 +00:00
Efforts have been made to minimize the need for changes for those using simple functionality.
However, if you were utilizing advanced features, some adjustments may be necessary.
2019-03-20 02:35:34 +00:00
2024-06-15 10:28:16 +00:00
Nevertheless, we believe that the added or streamlined features will provide enhanced convenience in return.
2019-06-16 11:31:08 +00:00
2024-06-15 10:28:16 +00:00
### Breaking Changes
2018-12-12 10:33:01 +00:00
2024-06-15 10:28:16 +00:00
- Changed branch from `master` to `main` .
- Changed template arguments of `toml::basic_value` .
- Removed `toml::string` and explicitly store formatting information of all the values.
- Modified arguments of `toml::format` to accommodate formatting information.
- Changed default arguments of `toml::parse` to take `toml::spec` for specifying TOML version information.
- Updated the interface of `toml::source_location` to accommodate multiline regions.
- Modified arguments of `toml::format_error` .
- Renamed `toml::format_underline` to `toml::format_location` .
- Unified control method of `toml::color` to `toml::color::enable/disable()` .
2019-03-12 13:18:25 +00:00
2024-06-15 10:28:16 +00:00
### Added features
2019-03-20 02:35:34 +00:00
2024-06-15 10:28:16 +00:00
- Added `toml::parse_str` .
- Added `toml::try_parse` .
- Added support for parsing byte sequences.
- Added formatting information to `toml::value` .
- Changed to saving comments in `toml::value` by default.
- Added `single_include/toml.hpp` .
- Enabled to use as a precompiled library.
2019-03-20 02:35:34 +00:00
2018-03-28 10:14:29 +00:00
## Contributors
2019-03-20 02:35:34 +00:00
I appreciate the help of the contributors who introduced the great feature to this library.
2018-03-28 10:14:29 +00:00
- Guillaume Fraux (@Luthaf)
- Windows support and CI on Appvayor
- Intel Compiler support
2019-01-31 06:37:25 +00:00
- Quentin Khan (@xaxousis)
- Found & Fixed a bug around ODR
2021-08-27 23:52:45 +00:00
- Improved error messages for invalid keys to show the location where the parser fails
2019-04-19 03:41:24 +00:00
- Petr Beneš (@wbenny)
- Fixed warnings on MSVC
2019-05-10 14:02:23 +00:00
- Ivan Shynkarenka (@chronoxor)
- Fixed Visual Studio 2019 warnings
2022-06-22 12:24:22 +00:00
- Fix compilation error in `<filesystem>` with MinGW
2022-03-12 16:40:43 +00:00
- Khoi Dinh Trinh (@khoitd1997)
2019-06-11 13:45:46 +00:00
- Fixed warnings while type conversion
2019-06-18 12:28:50 +00:00
- @KerstinKeller
- Added installation script to CMake
2019-10-04 05:28:43 +00:00
- J.C. Moyer (@jcmoyer)
- Fixed an example code in the documentation
2019-12-12 09:02:16 +00:00
- Jt Freeman (@blockparty-sh)
- Fixed feature test macro around `localtime_s`
- Suppress warnings in Debug mode
- OGAWA Kenichi (@kenichiice)
- Suppress warnings on intel compiler
2022-06-22 12:24:22 +00:00
- Fix include path in README
2020-02-14 10:25:27 +00:00
- Jordan Williams (@jwillikers)
- Fixed clang range-loop-analysis warnings
- Fixed feature test macro to suppress -Wundef
- Use cache variables in CMakeLists.txt
2020-02-27 10:30:34 +00:00
- Automate test set fetching, update and refactor CMakeLists.txt
2020-07-19 10:46:51 +00:00
- Scott McCaskill
- Parse 9 digits (nanoseconds) of fractional seconds in a `local_time`
- Shu Wang (@halfelf)
- fix "Finding a value in an array" example in README
- @maass -tv and @SeverinLeonhardt
- Fix MSVC warning C4866
2020-09-19 11:35:37 +00:00
- Mohammed Alyousef (@MoAlyousef)
- Made testing optional in CMake
2021-03-25 13:33:05 +00:00
- Alex Merry (@amerry)
- Add missing include files
- sneakypete81 (@sneakypete81)
- Fix typo in error message
2021-05-25 18:51:08 +00:00
- Oliver Kahrmann (@founderio)
- Fix missing filename in error message if parsed file is empty
2021-12-08 12:50:09 +00:00
- Karl Nilsson (@karl-nilsson)
- Fix many spelling errors
- ohdarling88 (@ohdarling)
- Fix a bug in a constructor of serializer
- estshorter (@estshorter)
- Fix MSVC warning C26478
- Philip Top (@phlptp)
- Improve checking standard library feature availability check
- Louis Marascio (@marascio)
- Fix free-nonheap-object warning
2022-03-12 16:40:43 +00:00
- Axel Huebl (@ax3l)
- Make installation optional if the library is embedded
2022-06-14 14:31:58 +00:00
- Ken Matsui (@ken-matsui)
- Support user-defined error message prefix
- Support dynamic color mode
2024-01-05 16:58:51 +00:00
- Giel van Schijndel (@muggenhor)
2022-06-14 14:31:58 +00:00
- Remove needless copy in `parse` function
2023-04-24 13:34:49 +00:00
- Lukáš Hrázký (@lukash)
- Add a `parse(FILE *)` interface and improve file-related error messages
2024-01-05 16:58:51 +00:00
- spiderman idog (@spiderman-idog)
- Fix typo in README
- Jajauma's GitHub (@Jajauma)
- Avoid possible lexer truncation warnings
2023-04-24 13:34:49 +00:00
- Moritz Klammler (@ctcmkl)
- Many patches in (#200) including:
- Improve CMake scripts, build process, and test file handling
- Detect error when `discard_comments` is accessed
- And more.
- Chris White (@cxw42)
- Fix address-sanitizer error when parsing literal strings having invalid UTF-8 characters
2024-01-05 16:58:51 +00:00
- Fix function name in error messages
2023-04-24 13:34:49 +00:00
- offa (@offa)
- Update checkout action to v3
2024-01-05 16:58:51 +00:00
- Update Required CMake version
- Cleanup old CI settings
2023-04-24 13:34:49 +00:00
- Sergey Vidyuk (@VestniK)
- Fix for case when vector iterator is raw pointer
2024-01-05 16:58:51 +00:00
- Kfir Gollan (@kfirgollan)
- Add installation example with checkinstall and cmake
- Martin Tournoij (@arp242)
- Escape control characters in keys
- @DavidKorczynski
- Add fuzzing test based on ClusterFuzzLite
- Esonhugh Skyworship (@Esonhugh)
- Fix function signature of `strerror_r` on macos
2024-07-06 09:58:50 +00:00
- Alberto (@0X1A)
- Fix issues with CMake package configuration when used with vcpkg
- Egor Pugin (@egorpugin)
- Fix incorrect operator<< () argument type that gives build error
2024-07-21 05:34:20 +00:00
- Andreas Keller (@andreaskeller96)
- Fix not checking for \r\n when parsing line comments
- 萧迩珀 (@CDK6182CHR)
- Support template into_toml members
2018-03-28 10:14:29 +00:00
2017-05-13 06:04:02 +00:00
## Licensing terms
This product is licensed under the terms of the [MIT License ](LICENSE ).
2024-01-05 16:58:51 +00:00
- Copyright (c) 2017-2024 Toru Niina
2017-05-13 06:04:02 +00:00
All rights reserved.