From fe0ac89500f0a34d2b42a7bb7363fe52f874f21f Mon Sep 17 00:00:00 2001 From: Mark Gillard Date: Fri, 9 Oct 2020 08:50:15 +0300 Subject: [PATCH] fixed parser memory leak (fixes #64) also: - build/infra improvements - updated submodules - updated conformance tests - misc code review/refactors - library version bump - TOML version bump --- README.md | 11 +- docs/badge-TOML.svg | 2 +- docs/main_page.dox | 8 +- docs/muu.css | 1 + extern/Catch2 | 2 +- extern/mcss | 2 +- extern/toml-test | 2 +- include/toml++/toml.h | 1 + include/toml++/toml_array.h | 13 +- include/toml++/toml_array.hpp | 41 +- include/toml++/toml_parser.hpp | 116 ++++-- include/toml++/toml_preprocessor.h | 8 +- include/toml++/toml_table.h | 14 +- include/toml++/toml_table.hpp | 41 +- include/toml++/toml_utf8.h | 100 +++-- include/toml++/toml_value.h | 37 +- include/toml++/toml_version.h | 2 +- meson.build | 121 +++--- python/generate_documentation.py | 104 +++-- python/generate_single_header.py | 1 + python/generate_windows_test_targets.py | 2 + python/requirements.txt | 3 + tests/conformance_burntsushi_valid.cpp | 25 ++ tests/impl_catch2.cpp | 46 ++- tests/leakproof.h | 19 + tests/settings.h | 6 + tests/unicode.cpp | 18 +- toml.hpp | 371 ++++++++++++++---- vs/tests/test_debug_x64.vcxproj | 2 + vs/tests/test_debug_x64_cpplatest.vcxproj | 2 + .../test_debug_x64_cpplatest_noexcept.vcxproj | 2 + ...debug_x64_cpplatest_noexcept_unrel.vcxproj | 2 + .../test_debug_x64_cpplatest_unrel.vcxproj | 2 + vs/tests/test_debug_x64_noexcept.vcxproj | 2 + .../test_debug_x64_noexcept_unrel.vcxproj | 2 + vs/tests/test_debug_x64_unrel.vcxproj | 2 + vs/tests/test_debug_x86.vcxproj | 2 + vs/tests/test_debug_x86_cpplatest.vcxproj | 2 + .../test_debug_x86_cpplatest_noexcept.vcxproj | 2 + ...debug_x86_cpplatest_noexcept_unrel.vcxproj | 2 + .../test_debug_x86_cpplatest_unrel.vcxproj | 2 + vs/tests/test_debug_x86_noexcept.vcxproj | 2 + .../test_debug_x86_noexcept_unrel.vcxproj | 2 + vs/tests/test_debug_x86_unrel.vcxproj | 2 + vs/tests/test_release_x64.vcxproj | 2 + vs/tests/test_release_x64_cpplatest.vcxproj | 2 + ...est_release_x64_cpplatest_noexcept.vcxproj | 2 + ...lease_x64_cpplatest_noexcept_unrel.vcxproj | 2 + .../test_release_x64_cpplatest_unrel.vcxproj | 2 + vs/tests/test_release_x64_noexcept.vcxproj | 2 + .../test_release_x64_noexcept_unrel.vcxproj | 2 + vs/tests/test_release_x64_unrel.vcxproj | 2 + vs/tests/test_release_x86.vcxproj | 2 + vs/tests/test_release_x86_cpplatest.vcxproj | 2 + ...est_release_x86_cpplatest_noexcept.vcxproj | 2 + ...lease_x86_cpplatest_noexcept_unrel.vcxproj | 2 + .../test_release_x86_cpplatest_unrel.vcxproj | 2 + vs/tests/test_release_x86_noexcept.vcxproj | 2 + .../test_release_x86_noexcept_unrel.vcxproj | 2 + vs/tests/test_release_x86_unrel.vcxproj | 2 + vs/toml++.vcxproj | 5 +- vs/toml++.vcxproj.filters | 15 +- 62 files changed, 901 insertions(+), 300 deletions(-) create mode 100644 tests/leakproof.h diff --git a/README.md b/README.md index 8abf410a..360ced5a 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![Releases](https://img.shields.io/github/v/release/marzer/tomlplusplus?style=flat-square)](https://github.com/marzer/tomlplusplus/releases) [![C++17](docs/badge-C++17.svg)][cpp_compilers] [![C++20](docs/badge-C++20.svg)][cpp_compilers] -[![TOML](docs/badge-TOML.svg)][v1.0.0-rc.2] +[![TOML](docs/badge-TOML.svg)][v1.0.0-rc.3] [![MIT license](docs/badge-license-MIT.svg)](./LICENSE) [![CircleCI](https://img.shields.io/circleci/build/github/marzer/tomlplusplus?label=circle%20ci&logo=circleci&logoColor=white&style=flat-square)](https://circleci.com/gh/marzer/tomlplusplus) [![Mentioned in Awesome C++](docs/badge-awesome.svg)](https://github.com/fffaraz/awesome-cpp) @@ -19,7 +19,7 @@ # Library features - Header-only - - Supports the latest [TOML] release ([v1.0.0-rc.2]), plus optional support for some [unreleased TOML language features] + - Supports the latest [TOML] release ([v1.0.0-rc.3]), plus optional support for some [unreleased TOML language features] - C++17 (plus some C++20 features where available, e.g. experimental support for char8_t strings) - Proper UTF-8 handling (incl. BOM) - Works with or without exceptions @@ -165,12 +165,13 @@ defines `TOML_LANG_MAJOR`, `TOML_LANG_MINOR` and `TOML_LANG_PATCH`. > ℹ _`#define TOML_UNRELEASED_FEATURES 1` to enable these features (see [Configuration](#Configuration))._ -### 🔹 **TOML v1.0.0-rc.2:** +### 🔹 **TOML v1.0.0-rc.3:** All features supported, including: - [#356]: Allow leading zeros in the exponent part of a float - [#567]: Control characters are not permitted in comments - [#571]: Allow raw tabs inside strings - [#665]: Make arrays heterogeneous +- [#766]: Allow comments before commas in arrays ### 🔹 **TOML v0.5.0:** All features supported. @@ -202,6 +203,7 @@ UTF-8 decoding is performed using a state machine based on Bjoern Hoehrmann's '[ - **[@Reedbeta](https://github.com/Reedbeta)** - Fixed a bug and added additional Visual Studio debugger native visualizers - **[@shdnx](https://github.com/shdnx)** - Fixed a bug on GCC 8.2.0 and some meson config issues - **[@sobczyk](https://github.com/sobczyk)** - Reported some bugs +- **[@sneves](https://github.com/sneves)** - Reported a bug - **[@traversaro](https://github.com/traversaro)** - Added vcpkg support and reported a bunch of bugs - **[@ximion](https://github.com/ximion)** - Added support for installation with meson - **[@whiterabbit963](https://github.com/whiterabbit963)** - Fixed a bug with value_or conversions @@ -227,7 +229,7 @@ though you're welcome to reach out via other means. In order of likely response [TOML]: https://toml.io/ [TOML master]: https://github.com/toml-lang/toml/blob/master/README.md [TOML issues list]: https://github.com/toml-lang/toml/issues -[v1.0.0-rc.2]: https://toml.io/en/v1.0.0-rc.2 +[v1.0.0-rc.3]: https://toml.io/en/v1.0.0-rc.3 [CONTRIBUTING]: ./CONTRIBUTING.md [LICENSE]: ./LICENSE [Flexible and Economical UTF-8 Decoder]: http://bjoern.hoehrmann.de/utf-8/decoder/dfa/ @@ -246,6 +248,7 @@ though you're welcome to reach out via other means. In order of likely response [#671]: https://github.com/toml-lang/toml/issues/671 [#687]: https://github.com/toml-lang/toml/issues/687 [#709]: https://github.com/toml-lang/toml/pull/709 +[#766]: https://github.com/toml-lang/toml/issues/766 [LICENSE-utf8-decoder]: ./LICENSE-utf8-decoder [something better than std::optional]: https://github.com/TartanLlama/optional [m.css]: https://mcss.mosra.cz/documentation/doxygen diff --git a/docs/badge-TOML.svg b/docs/badge-TOML.svg index eba4432e..19485cff 100644 --- a/docs/badge-TOML.svg +++ b/docs/badge-TOML.svg @@ -1 +1 @@ -TOML: v1.0.0-rc.2TOMLv1.0.0-rc.2 \ No newline at end of file +TOML: v1.0.0-rc.3TOMLv1.0.0-rc.3 \ No newline at end of file diff --git a/docs/main_page.dox b/docs/main_page.dox index a1ce9404..d55edfaa 100644 --- a/docs/main_page.dox +++ b/docs/main_page.dox @@ -6,7 +6,7 @@ ////////////////////////////////////////////////////////////////////// /// /// \section mainpage-features Features -/// - Supports the latest [TOML](https://toml.io/) release ([v1.0.0-rc.2](https://toml.io/en/v1.0.0-rc.2)), plus +/// - Supports the latest [TOML](https://toml.io/) release ([v1.0.0-rc.3](https://toml.io/en/v1.0.0-rc.3)), plus /// optional support for some unreleased TOML features /// - Supports serializing to JSON /// - Proper UTF-8 handling (incl. BOM) @@ -316,7 +316,7 @@ /// auto tbl = toml::table{{ /// { "lib", "toml++" }, /// { "cpp", toml::array{ 17, 20, "and beyond" } }, -/// { "toml", toml::array{ "1.0.0-rc.2", "and beyond" } }, +/// { "toml", toml::array{ "1.0.0-rc.3", "and beyond" } }, /// { "repo", "https://github.com/marzer/tomlplusplus/" }, /// { "author", toml::table{{ /// { "name", "Mark Gillard" }, @@ -343,7 +343,7 @@ /// cpp = [ 17, 20, 'and beyond' ] /// lib = 'toml++' /// repo = 'https://github.com/marzer/tomlplusplus/' -/// toml = [ '1.0.0-rc.2', 'and beyond' ] +/// toml = [ '1.0.0-rc.3', 'and beyond' ] /// /// [author] /// github = 'https://github.com/marzer' @@ -366,7 +366,7 @@ /// "lib" : "toml++", /// "repo" : "https://github.com/marzer/tomlplusplus/", /// "toml" : [ -/// "1.0.0-rc.2", +/// "1.0.0-rc.3", /// "and beyond" /// ] /// } diff --git a/docs/muu.css b/docs/muu.css index c4cd3e2b..addc5ac4 100644 --- a/docs/muu.css +++ b/docs/muu.css @@ -162,6 +162,7 @@ pre.m-code .c1 } /* int and float literals */ +pre.m-code .mb, pre.m-code .mi, pre.m-code .mf, pre.m-code .mh diff --git a/extern/Catch2 b/extern/Catch2 index ad1940f3..87074da7 160000 --- a/extern/Catch2 +++ b/extern/Catch2 @@ -1 +1 @@ -Subproject commit ad1940f336b4527544d435372a5f5c65fe7d783d +Subproject commit 87074da73ecb1c2e7c35fd14f50ca21c4c002adc diff --git a/extern/mcss b/extern/mcss index e6eff549..de86049b 160000 --- a/extern/mcss +++ b/extern/mcss @@ -1 +1 @@ -Subproject commit e6eff549fb5edeabacf01369d6b845a2a59c2ebe +Subproject commit de86049b87f8dc12c022406c201abb533bc78f68 diff --git a/extern/toml-test b/extern/toml-test index 280497fa..6538e544 160000 --- a/extern/toml-test +++ b/extern/toml-test @@ -1 +1 @@ -Subproject commit 280497fa5f12e43d7233aed0d74e07ca61ef176b +Subproject commit 6538e544c3c32ca5134769fbd6dd1005f29a0c26 diff --git a/include/toml++/toml.h b/include/toml++/toml.h index cdad5384..3586067f 100644 --- a/include/toml++/toml.h +++ b/include/toml++/toml.h @@ -108,6 +108,7 @@ TOML_POP_WARNINGS // TOML_DISABLE_SPAM_WARNINGS #undef TOML_LANG_HIGHER_THAN #undef TOML_LANG_UNRELEASED #undef TOML_LAUNDER + #undef TOML_LIFETIME_HOOKS #undef TOML_LIKELY #undef TOML_MAKE_BITOPS #undef TOML_MAKE_VERSION diff --git a/include/toml++/toml_array.h b/include/toml++/toml_array.h index ecbb7dcf..36fafb74 100644 --- a/include/toml++/toml_array.h +++ b/include/toml++/toml_array.h @@ -315,6 +315,11 @@ TOML_NAMESPACE_START elements.emplace_back(impl::make_node(std::forward(val))); } + #if TOML_LIFETIME_HOOKS + void lh_ctor() noexcept; + void lh_dtor() noexcept; + #endif + public: using value_type = node; @@ -346,6 +351,9 @@ TOML_NAMESPACE_START /// \brief Move-assignment operator. array& operator= (array&& rhs) noexcept; + /// \brief Destructor. + ~array() noexcept override; + /// \brief Constructs an array with one or more initial elements. /// /// \detail \cpp @@ -395,8 +403,11 @@ TOML_NAMESPACE_START ... ); } - } + #if TOML_LIFETIME_HOOKS + lh_ctor(); + #endif + } [[nodiscard]] node_type type() const noexcept override; [[nodiscard]] bool is_table() const noexcept override; diff --git a/include/toml++/toml_array.hpp b/include/toml++/toml_array.hpp index 3d838027..a65f78c7 100644 --- a/include/toml++/toml_array.hpp +++ b/include/toml++/toml_array.hpp @@ -15,8 +15,29 @@ TOML_NAMESPACE_START { + #if TOML_LIFETIME_HOOKS + + TOML_EXTERNAL_LINKAGE + void array::lh_ctor() noexcept + { + TOML_ARRAY_CREATED; + } + TOML_EXTERNAL_LINKAGE - array::array() noexcept = default; + void array::lh_dtor() noexcept + { + TOML_ARRAY_DESTROYED; + } + + #endif + + TOML_EXTERNAL_LINKAGE + array::array() noexcept + { + #if TOML_LIFETIME_HOOKS + lh_ctor(); + #endif + } TOML_EXTERNAL_LINKAGE array::array(const array& other) noexcept @@ -25,13 +46,21 @@ TOML_NAMESPACE_START elements.reserve(other.elements.size()); for (const auto& elem : other) elements.emplace_back(impl::make_node(elem)); + + #if TOML_LIFETIME_HOOKS + lh_ctor(); + #endif } TOML_EXTERNAL_LINKAGE array::array(array&& other) noexcept : node{ std::move(other) }, elements{ std::move(other.elements) } - {} + { + #if TOML_LIFETIME_HOOKS + lh_ctor(); + #endif + } TOML_EXTERNAL_LINKAGE array& array::operator= (const array& rhs) noexcept @@ -58,6 +87,14 @@ TOML_NAMESPACE_START return *this; } + TOML_EXTERNAL_LINKAGE + array::~array() noexcept + { + #if TOML_LIFETIME_HOOKS + lh_dtor(); + #endif + } + TOML_EXTERNAL_LINKAGE void array::preinsertion_resize(size_t idx, size_t count) noexcept { diff --git a/include/toml++/toml_parser.hpp b/include/toml++/toml_parser.hpp index 71a7cbb7..39437390 100644 --- a/include/toml++/toml_parser.hpp +++ b/include/toml++/toml_parser.hpp @@ -39,6 +39,15 @@ TOML_DISABLE_SWITCH_WARNINGS TOML_ANON_NAMESPACE_START { + template + [[nodiscard]] + TOML_ATTR(const) + constexpr bool is_match(char32_t codepoint, T... vals) noexcept + { + static_assert((std::is_same_v && ...)); + return ((codepoint == vals) || ...); + } + template struct parse_integer_traits; template <> struct parse_integer_traits<2> final { @@ -239,6 +248,65 @@ TOML_ANON_NAMESPACE_START #define push_parse_scope_1(scope, line) push_parse_scope_2(scope, line) #define push_parse_scope(scope) push_parse_scope_1(scope, __LINE__) + // Q: "why not std::unique_ptr?? + // A: It caused a lot of bloat on some implementations so this exists an internal substitute. + class node_ptr + { + private: + toml::node* node_ = {}; + + public: + TOML_NODISCARD_CTOR + node_ptr() noexcept = default; + + TOML_NODISCARD_CTOR + explicit node_ptr(toml::node* n) noexcept + : node_{ n } + {} + + ~node_ptr() noexcept + { + delete node_; + } + + node_ptr& operator=(toml::node* val) noexcept + { + if (val != node_) + { + delete node_; + node_ = val; + } + return *this; + } + + node_ptr(const node_ptr&) = delete; + node_ptr& operator=(const node_ptr&) = delete; + node_ptr(node_ptr&&) = delete; + node_ptr& operator=(node_ptr&&) = delete; + + [[nodiscard]] + TOML_ATTR(pure) + operator bool() const noexcept + { + return node_ != nullptr; + } + + [[nodiscard]] + TOML_ATTR(pure) + toml::node* get() const noexcept + { + return node_; + } + + [[nodiscard]] + toml::node* release() noexcept + { + auto n = node_; + node_ = nullptr; + return n; + } + }; + struct parsed_key final { std::vector segments; @@ -247,7 +315,7 @@ TOML_ANON_NAMESPACE_START struct parsed_key_value_pair final { parsed_key key; - toml::node* value; + node_ptr value; }; } @@ -1808,7 +1876,7 @@ TOML_IMPL_NAMESPACE_START set_error_and_return_default("values may not begin with underscores"sv); const auto begin_pos = cp->position; - node* val{}; + node_ptr val; do { @@ -2024,17 +2092,17 @@ TOML_IMPL_NAMESPACE_START else if (has_any(has_x)) { val = new value{ parse_integer<16>() }; - reinterpret_cast*>(val)->flags(value_flags::format_as_hexadecimal); + reinterpret_cast*>(val.get())->flags(value_flags::format_as_hexadecimal); } else if (has_any(has_o)) { val = new value{ parse_integer<8>() }; - reinterpret_cast*>(val)->flags(value_flags::format_as_octal); + reinterpret_cast*>(val.get())->flags(value_flags::format_as_octal); } else if (has_any(has_b)) { val = new value{ parse_integer<2>() }; - reinterpret_cast*>(val)->flags(value_flags::format_as_binary); + reinterpret_cast*>(val.get())->flags(value_flags::format_as_binary); } else if (has_any(has_e) || (has_any(begins_zero | begins_digit) && chars[1] == U'.')) val = new value{ parse_float() }; @@ -2075,14 +2143,14 @@ TOML_IMPL_NAMESPACE_START // 0b10 case bzero_msk | has_b: val = new value{ parse_integer<2>() }; - reinterpret_cast*>(val)->flags(value_flags::format_as_binary); + reinterpret_cast*>(val.get())->flags(value_flags::format_as_binary); break; //=================== octal integers // 0o10 case bzero_msk | has_o: val = new value{ parse_integer<8>() }; - reinterpret_cast*>(val)->flags(value_flags::format_as_octal); + reinterpret_cast*>(val.get())->flags(value_flags::format_as_octal); break; //=================== decimal integers @@ -2101,7 +2169,7 @@ TOML_IMPL_NAMESPACE_START // 0x10 case bzero_msk | has_x: val = new value{ parse_integer<16>() }; - reinterpret_cast*>(val)->flags(value_flags::format_as_hexadecimal); + reinterpret_cast*>(val.get())->flags(value_flags::format_as_hexadecimal); break; //=================== decimal floats @@ -2275,8 +2343,8 @@ TOML_IMPL_NAMESPACE_START } #endif - val->source_ = { begin_pos, current_position(1), reader.source_path() }; - return val; + val.get()->source_ = { begin_pos, current_position(1), reader.source_path() }; + return val.release(); } [[nodiscard]] @@ -2293,7 +2361,7 @@ TOML_IMPL_NAMESPACE_START while (!is_error()) { #if TOML_LANG_UNRELEASED // toml/issues/687 (unicode bare keys) - if (is_unicode_combining_mark(*cp)) + if (is_combining_mark(*cp)) set_error_and_return_default("bare keys may not begin with unicode combining marks"sv); else #endif @@ -2378,7 +2446,7 @@ TOML_IMPL_NAMESPACE_START // get the value if (is_value_terminator(*cp)) set_error_and_return_default("expected value, saw '"sv, to_sv(*cp), "'"sv); - return { std::move(key), parse_value() }; + return { std::move(key), node_ptr{ parse_value() } }; } [[nodiscard]] @@ -2592,12 +2660,12 @@ TOML_IMPL_NAMESPACE_START ).first->second.get(); dotted_key_tables.push_back(&child->ref_cast()); dotted_key_tables.back()->inline_ = true; - child->source_ = kvp.value->source_; + child->source_ = kvp.value.get()->source_; } else if (!child->is_table() || !find(dotted_key_tables, &child->ref_cast
())) set_error("cannot redefine existing "sv, to_sv(child->type()), " as dotted key-value pair"sv); else - child->source_.end = kvp.value->source_.end; + child->source_.end = kvp.value.get()->source_.end; return_if_error(); tab = &child->ref_cast
(); } @@ -2605,7 +2673,7 @@ TOML_IMPL_NAMESPACE_START if (auto conflicting_node = tab->get(kvp.key.segments.back())) { - if (conflicting_node->type() == kvp.value->type()) + if (conflicting_node->type() == kvp.value.get()->type()) set_error( "cannot redefine existing "sv, to_sv(conflicting_node->type()), " '"sv, to_sv(recording_buffer), "'"sv @@ -2614,14 +2682,14 @@ TOML_IMPL_NAMESPACE_START set_error( "cannot redefine existing "sv, to_sv(conflicting_node->type()), " '"sv, to_sv(recording_buffer), - "' as "sv, to_sv(kvp.value->type()) + "' as "sv, to_sv(kvp.value.get()->type()) ); } return_if_error(); tab->map.emplace( std::move(kvp.key.segments.back()), - std::unique_ptr{ kvp.value } + std::unique_ptr{ kvp.value.release() } ); } @@ -2776,8 +2844,8 @@ TOML_IMPL_NAMESPACE_START // skip opening '[' advance_and_return_if_error_or_eof({}); - auto arr = new array{}; - auto& vals = arr->elements; + node_ptr arr{ new array{} }; + auto& vals = reinterpret_cast(arr.get())->elements; enum parse_elem : int { none, @@ -2827,7 +2895,7 @@ TOML_IMPL_NAMESPACE_START } return_if_error({}); - return arr; + return reinterpret_cast(arr.release()); } TOML_EXTERNAL_LINKAGE @@ -2841,8 +2909,8 @@ TOML_IMPL_NAMESPACE_START // skip opening '{' advance_and_return_if_error_or_eof({}); - auto tab = new table{}; - tab->inline_ = true; + node_ptr tab{ new table{} }; + reinterpret_cast(tab.get())->inline_ = true; enum parse_elem : int { none, @@ -2902,7 +2970,7 @@ TOML_IMPL_NAMESPACE_START else { prev = kvp; - parse_key_value_pair_and_insert(tab); + parse_key_value_pair_and_insert(reinterpret_cast(tab.get())); } } @@ -2912,7 +2980,7 @@ TOML_IMPL_NAMESPACE_START } return_if_error({}); - return tab; + return reinterpret_cast(tab.release()); } TOML_API diff --git a/include/toml++/toml_preprocessor.h b/include/toml++/toml_preprocessor.h index db0d2287..bfe490ee 100644 --- a/include/toml++/toml_preprocessor.h +++ b/include/toml++/toml_preprocessor.h @@ -472,7 +472,11 @@ is no longer necessary. { \ return static_cast(::toml::impl::unwrap_enum(lhs) | ::toml::impl::unwrap_enum(rhs)); \ } - + +#ifndef TOML_LIFETIME_HOOKS + #define TOML_LIFETIME_HOOKS 0 +#endif + //#==================================================================================================================== //# EXTENDED INT AND FLOAT TYPES //#==================================================================================================================== @@ -485,7 +489,7 @@ is no longer necessary. && __FLT16_MIN_10_EXP__ == -4 \ && __FLT16_MAX_EXP__ == 16 \ && __FLT16_MAX_10_EXP__ == 4 - #if (TOML_ARM && TOML_GCC) || TOML_CLANG + #if TOML_ARM && (TOML_GCC || TOML_CLANG) #define TOML_FP16 __fp16 #endif #if TOML_ARM && TOML_CLANG // not present in g++ diff --git a/include/toml++/toml_table.h b/include/toml++/toml_table.h index 0bfff1ae..83cf06df 100644 --- a/include/toml++/toml_table.h +++ b/include/toml++/toml_table.h @@ -210,6 +210,11 @@ TOML_NAMESPACE_START impl::string_map> map; bool inline_ = false; + #if TOML_LIFETIME_HOOKS + void lh_ctor() noexcept; + void lh_dtor() noexcept; + #endif + table(impl::table_init_pair*, size_t) noexcept; public: @@ -237,6 +242,9 @@ TOML_NAMESPACE_START /// \brief Move-assignment operator. table& operator= (table&& rhs) noexcept; + /// \brief Destructor. + ~table() noexcept override; + /// \brief Constructs a table with one or more initial key-value pairs. /// /// \detail \cpp @@ -270,7 +278,11 @@ TOML_NAMESPACE_START TOML_NODISCARD_CTOR explicit table(impl::table_init_pair(&& arr)[N]) noexcept : table{ arr, N } - {} + { + #if TOML_LIFETIME_HOOKS + lh_ctor(); + #endif + } [[nodiscard]] node_type type() const noexcept override; [[nodiscard]] bool is_table() const noexcept override; diff --git a/include/toml++/toml_table.hpp b/include/toml++/toml_table.hpp index 71aec113..504a6b80 100644 --- a/include/toml++/toml_table.hpp +++ b/include/toml++/toml_table.hpp @@ -16,8 +16,29 @@ TOML_NAMESPACE_START { + #if TOML_LIFETIME_HOOKS + + TOML_EXTERNAL_LINKAGE + void table::lh_ctor() noexcept + { + TOML_TABLE_CREATED; + } + TOML_EXTERNAL_LINKAGE - table::table() noexcept {} + void table::lh_dtor() noexcept + { + TOML_TABLE_DESTROYED; + } + + #endif + + TOML_EXTERNAL_LINKAGE + table::table() noexcept + { + #if TOML_LIFETIME_HOOKS + lh_ctor(); + #endif + } TOML_EXTERNAL_LINKAGE table::table(const table& other) noexcept @@ -26,6 +47,10 @@ TOML_NAMESPACE_START { for (auto&& [k, v] : other) map.emplace_hint(map.end(), k, impl::make_node(v)); + + #if TOML_LIFETIME_HOOKS + lh_ctor(); + #endif } TOML_EXTERNAL_LINKAGE @@ -33,7 +58,11 @@ TOML_NAMESPACE_START : node{ std::move(other) }, map{ std::move(other.map) }, inline_{ other.inline_ } - {} + { + #if TOML_LIFETIME_HOOKS + lh_ctor(); + #endif + } TOML_EXTERNAL_LINKAGE table& table::operator= (const table& rhs) noexcept @@ -61,6 +90,14 @@ TOML_NAMESPACE_START return *this; } + TOML_EXTERNAL_LINKAGE + table::~table() noexcept + { + #if TOML_LIFETIME_HOOKS + lh_dtor(); + #endif + } + TOML_EXTERNAL_LINKAGE table::table(impl::table_init_pair* pairs, size_t count) noexcept { diff --git a/include/toml++/toml_utf8.h b/include/toml++/toml_utf8.h index cc3be7fb..7d87e05a 100644 --- a/include/toml++/toml_utf8.h +++ b/include/toml++/toml_utf8.h @@ -8,15 +8,6 @@ TOML_IMPL_NAMESPACE_START { - template - [[nodiscard]] - TOML_ATTR(const) - constexpr bool is_match(char32_t codepoint, T... vals) noexcept - { - static_assert((std::is_same_v && ...)); - return ((codepoint == vals) || ...); - } - [[nodiscard]] TOML_ATTR(const) constexpr bool is_ascii_whitespace(char32_t codepoint) noexcept @@ -26,7 +17,7 @@ TOML_IMPL_NAMESPACE_START [[nodiscard]] TOML_ATTR(const) - constexpr bool is_unicode_whitespace(char32_t codepoint) noexcept + constexpr bool is_non_ascii_whitespace(char32_t codepoint) noexcept { // see: https://en.wikipedia.org/wiki/Whitespace_character#Unicode // (characters that don't say "is a line-break") @@ -44,7 +35,7 @@ TOML_IMPL_NAMESPACE_START TOML_ATTR(const) constexpr bool is_whitespace(char32_t codepoint) noexcept { - return is_ascii_whitespace(codepoint) || is_unicode_whitespace(codepoint); + return is_ascii_whitespace(codepoint) || is_non_ascii_whitespace(codepoint); } template @@ -58,7 +49,7 @@ TOML_IMPL_NAMESPACE_START [[nodiscard]] TOML_ATTR(const) - constexpr bool is_unicode_line_break(char32_t codepoint) noexcept + constexpr bool is_non_ascii_line_break(char32_t codepoint) noexcept { // see https://en.wikipedia.org/wiki/Whitespace_character#Unicode // (characters that say "is a line-break") @@ -74,7 +65,7 @@ TOML_IMPL_NAMESPACE_START TOML_ATTR(const) constexpr bool is_line_break(char32_t codepoint) noexcept { - return is_ascii_line_break(codepoint) || is_unicode_line_break(codepoint); + return is_ascii_line_break(codepoint) || is_non_ascii_line_break(codepoint); } [[nodiscard]] @@ -140,7 +131,7 @@ TOML_IMPL_NAMESPACE_START //# Ll, Lm, Lo, Lt, Lu [[nodiscard]] TOML_ATTR(const) - constexpr bool is_unicode_letter(char32_t c) noexcept + constexpr bool is_non_ascii_letter(char32_t c) noexcept { if (U'\xAA' > c || c > U'\U0003134A') return false; @@ -176,7 +167,7 @@ TOML_IMPL_NAMESPACE_START }; return bitmask_table_1[(static_cast(c) - 0xAAull) / 0x40ull] & (0x1ull << ((static_cast(c) - 0xAAull) % 0x40ull)); - // 1922 codepoints from 124 ranges (spanning a search area of 3147) + // 1922 code units from 124 ranges (spanning a search area of 3145) } case 0x01: // [1] 0CF5 - 193F { @@ -201,7 +192,7 @@ TOML_IMPL_NAMESPACE_START }; return bitmask_table_1[(static_cast(c) - 0xD04ull) / 0x40ull] & (0x1ull << ((static_cast(c) - 0xD04ull) % 0x40ull)); - // 2239 codepoints from 83 ranges (spanning a search area of 3147) + // 2239 code units from 83 ranges (spanning a search area of 3099) } case 0x02: // [2] 1940 - 258A { @@ -222,7 +213,7 @@ TOML_IMPL_NAMESPACE_START }; return bitmask_table_1[(static_cast(c) - 0x1950ull) / 0x40ull] & (0x1ull << ((static_cast(c) - 0x1950ull) % 0x40ull)); - // 1184 codepoints from 59 ranges (spanning a search area of 3147) + // 1184 code units from 59 ranges (spanning a search area of 2101) } case 0x03: // [3] 258B - 31D5 { @@ -240,7 +231,7 @@ TOML_IMPL_NAMESPACE_START }; return bitmask_table_1[(static_cast(c) - 0x2C00ull) / 0x40ull] & (0x1ull << (static_cast(c) % 0x40ull)); - // 771 codepoints from 30 ranges (spanning a search area of 3147) + // 771 code units from 30 ranges (spanning a search area of 1472) } case 0x04: return (U'\u31F0' <= c && c <= U'\u31FF') || U'\u3400' <= c; case 0x06: return c <= U'\u4DBF' || U'\u4E00' <= c; @@ -267,7 +258,7 @@ TOML_IMPL_NAMESPACE_START }; return bitmask_table_1[(static_cast(c) - 0xA079ull) / 0x40ull] & (0x1ull << ((static_cast(c) - 0xA079ull) % 0x40ull)); - // 2554 codepoints from 52 ranges (spanning a search area of 3147) + // 2554 code units from 52 ranges (spanning a search area of 3147) } case 0x11: return c <= U'\uD7A3' || (U'\uD7B0' <= c && c <= U'\uD7C6') || (U'\uD7CB' <= c && c <= U'\uD7FB'); case 0x14: // [20] F686 - 102D0 @@ -291,7 +282,7 @@ TOML_IMPL_NAMESPACE_START }; return bitmask_table_1[(static_cast(c) - 0xF900ull) / 0x40ull] & (0x1ull << (static_cast(c) % 0x40ull)); - // 1710 codepoints from 34 ranges (spanning a search area of 3147) + // 1710 code units from 34 ranges (spanning a search area of 2513) } case 0x15: // [21] 102D1 - 10F1B { @@ -317,7 +308,7 @@ TOML_IMPL_NAMESPACE_START }; return bitmask_table_1[(static_cast(c) - 0x10300ull) / 0x40ull] & (0x1ull << (static_cast(c) % 0x40ull)); - // 1620 codepoints from 48 ranges (spanning a search area of 3147) + // 1620 code units from 48 ranges (spanning a search area of 3100) } case 0x16: // [22] 10F1C - 11B66 { @@ -342,7 +333,7 @@ TOML_IMPL_NAMESPACE_START }; return bitmask_table_1[(static_cast(c) - 0x10F1Cull) / 0x40ull] & (0x1ull << ((static_cast(c) - 0x10F1Cull) % 0x40ull)); - // 1130 codepoints from 67 ranges (spanning a search area of 3147) + // 1130 code units from 67 ranges (spanning a search area of 3037) } case 0x17: // [23] 11B67 - 127B1 { @@ -364,7 +355,7 @@ TOML_IMPL_NAMESPACE_START }; return bitmask_table_1[(static_cast(c) - 0x11C00ull) / 0x40ull] & (0x1ull << (static_cast(c) % 0x40ull)); - // 1304 codepoints from 16 ranges (spanning a search area of 3147) + // 1304 code units from 16 ranges (spanning a search area of 2372) } case 0x18: return U'\U00013000' <= c; case 0x19: return c <= U'\U0001342E'; @@ -390,7 +381,7 @@ TOML_IMPL_NAMESPACE_START }; return bitmask_table_1[(static_cast(c) - 0x16800ull) / 0x40ull] & (0x1ull << (static_cast(c) % 0x40ull)); - // 1250 codepoints from 14 ranges (spanning a search area of 3147) + // 1250 code units from 14 ranges (spanning a search area of 2420) } case 0x1F: return c <= U'\U000187F7' || U'\U00018800' <= c; case 0x20: return c <= U'\U00018CD5' || (U'\U00018D00' <= c && c <= U'\U00018D08'); @@ -407,7 +398,7 @@ TOML_IMPL_NAMESPACE_START }; return bitmask_table_1[(static_cast(c) - 0x1B000ull) / 0x40ull] & (0x1ull << (static_cast(c) % 0x40ull)); - // 690 codepoints from 4 ranges (spanning a search area of 3147) + // 690 code units from 4 ranges (spanning a search area of 764) } case 0x24: // [36] 1BB36 - 1C780 { @@ -420,7 +411,8 @@ TOML_IMPL_NAMESPACE_START case 0x02: return (1u << (static_cast(c) - 0x1BC80u)) & 0x3FF01FFu; default: return true; } - // 139 codepoints from 4 ranges (spanning a search area of 3147) + // 139 code units from 4 ranges (spanning a search area of 154) + TOML_UNREACHABLE; } case 0x26: // [38] 1D3CC - 1E016 { @@ -436,7 +428,7 @@ TOML_IMPL_NAMESPACE_START }; return bitmask_table_1[(static_cast(c) - 0x1D400ull) / 0x40ull] & (0x1ull << (static_cast(c) % 0x40ull)); - // 936 codepoints from 30 ranges (spanning a search area of 3147) + // 936 code units from 30 ranges (spanning a search area of 972) } case 0x27: // [39] 1E017 - 1EC61 { @@ -457,7 +449,7 @@ TOML_IMPL_NAMESPACE_START }; return bitmask_table_1[(static_cast(c) - 0x1E100ull) / 0x40ull] & (0x1ull << (static_cast(c) % 0x40ull)); - // 363 codepoints from 7 ranges (spanning a search area of 3147) + // 363 code units from 7 ranges (spanning a search area of 2124) } case 0x28: // [40] 1EC62 - 1F8AC { @@ -472,7 +464,8 @@ TOML_IMPL_NAMESPACE_START case 0x02: return (1ull << (static_cast(c) - 0x1EE80u)) & 0xFFFFBEE0FFFFBFFull; TOML_NO_DEFAULT_CASE; } - // 141 codepoints from 33 ranges (spanning a search area of 3147) + // 141 code units from 33 ranges (spanning a search area of 188) + TOML_UNREACHABLE; } case 0x29: return U'\U00020000' <= c; case 0x37: return c <= U'\U0002A6DD' || U'\U0002A700' <= c; @@ -483,14 +476,15 @@ TOML_IMPL_NAMESPACE_START case 0x3E: return U'\U00030000' <= c; TOML_NO_DEFAULT_CASE; } - // 131189 codepoints from 620 ranges (spanning a search area of 1114112) + // 131189 code units from 620 ranges (spanning a search area of 201377) + TOML_UNREACHABLE; } //# Returns true if a codepoint belongs to any of these categories: //# Nd, Nl [[nodiscard]] TOML_ATTR(const) - constexpr bool is_unicode_number(char32_t c) noexcept + constexpr bool is_non_ascii_number(char32_t c) noexcept { if (U'\u0660' > c || c > U'\U0001FBF9') return false; @@ -519,7 +513,7 @@ TOML_IMPL_NAMESPACE_START }; return bitmask_table_1[(static_cast(c) - 0x660ull) / 0x40ull] & (0x1ull << ((static_cast(c) - 0x660ull) % 0x40ull)); - // 130 codepoints from 13 ranges (spanning a search area of 2007) + // 130 code units from 13 ranges (spanning a search area of 1936) } case 0x01: // [1] 0E37 - 160D { @@ -534,7 +528,7 @@ TOML_IMPL_NAMESPACE_START }; return bitmask_table_1[(static_cast(c) - 0xE50ull) / 0x40ull] & (0x1ull << ((static_cast(c) - 0xE50ull) % 0x40ull)); - // 50 codepoints from 5 ranges (spanning a search area of 2007) + // 50 code units from 5 ranges (spanning a search area of 586) } case 0x02: // [2] 160E - 1DE4 { @@ -552,7 +546,7 @@ TOML_IMPL_NAMESPACE_START }; return bitmask_table_1[(static_cast(c) - 0x16EEull) / 0x40ull] & (0x1ull << ((static_cast(c) - 0x16EEull) % 0x40ull)); - // 103 codepoints from 11 ranges (spanning a search area of 2007) + // 103 code units from 11 ranges (spanning a search area of 1388) } case 0x03: return U'\u2160' <= c && c <= U'\u2188' && (1ull << (static_cast(c) - 0x2160u)) & 0x1E7FFFFFFFFull; case 0x05: return U'\u3007' <= c && c <= U'\u303A' && (1ull << (static_cast(c) - 0x3007u)) & 0xE0007FC000001ull; @@ -571,7 +565,7 @@ TOML_IMPL_NAMESPACE_START }; return bitmask_table_1[(static_cast(c) - 0xA620ull) / 0x40ull] & (0x1ull << ((static_cast(c) - 0xA620ull) % 0x40ull)); - // 70 codepoints from 7 ranges (spanning a search area of 2007) + // 70 code units from 7 ranges (spanning a search area of 1082) } case 0x15: return U'\uABF0' <= c && c <= U'\uABF9'; case 0x1F: return U'\uFF10' <= c && c <= U'\uFF19'; @@ -590,7 +584,7 @@ TOML_IMPL_NAMESPACE_START }; return bitmask_table_1[(static_cast(c) - 0x10140ull) / 0x40ull] & (0x1ull << (static_cast(c) % 0x40ull)); - // 70 codepoints from 5 ranges (spanning a search area of 2007) + // 70 code units from 5 ranges (spanning a search area of 874) } case 0x21: return (U'\U00010D30' <= c && c <= U'\U00010D39') || (U'\U00011066' <= c && c <= U'\U0001106F'); case 0x22: // [34] 110EE - 118C4 @@ -610,7 +604,7 @@ TOML_IMPL_NAMESPACE_START }; return bitmask_table_1[(static_cast(c) - 0x110F0ull) / 0x40ull] & (0x1ull << ((static_cast(c) - 0x110F0ull) % 0x40ull)); - // 90 codepoints from 9 ranges (spanning a search area of 2007) + // 90 code units from 9 ranges (spanning a search area of 1610) } case 0x23: // [35] 118C5 - 1209B { @@ -627,7 +621,7 @@ TOML_IMPL_NAMESPACE_START }; return bitmask_table_1[(static_cast(c) - 0x118E0ull) / 0x40ull] & (0x1ull << ((static_cast(c) - 0x118E0ull) % 0x40ull)); - // 50 codepoints from 5 ranges (spanning a search area of 2007) + // 50 code units from 5 ranges (spanning a search area of 1226) } case 0x24: return U'\U00012400' <= c && c <= U'\U0001246E'; case 0x2D: return (U'\U00016A60' <= c && c <= U'\U00016A69') || (U'\U00016B50' <= c && c <= U'\U00016B59'); @@ -637,14 +631,15 @@ TOML_IMPL_NAMESPACE_START case 0x3F: return U'\U0001FBF0' <= c; TOML_NO_DEFAULT_CASE; } - // 876 codepoints from 72 ranges (spanning a search area of 1114112) + // 876 code units from 72 ranges (spanning a search area of 128410) + TOML_UNREACHABLE; } //# Returns true if a codepoint belongs to any of these categories: //# Mn, Mc [[nodiscard]] TOML_ATTR(const) - constexpr bool is_unicode_combining_mark(char32_t c) noexcept + constexpr bool is_combining_mark(char32_t c) noexcept { if (U'\u0300' > c || c > U'\U000E01EF') return false; @@ -711,7 +706,7 @@ TOML_IMPL_NAMESPACE_START }; return bitmask_table_1[(static_cast(c) - 0x300ull) / 0x40ull] & (0x1ull << (static_cast(c) % 0x40ull)); - // 1106 codepoints from 156 ranges (spanning a search area of 14332) + // 1106 code units from 156 ranges (spanning a search area of 11675) } case 0x02: // [2] 72F8 - AAF3 { @@ -728,7 +723,7 @@ TOML_IMPL_NAMESPACE_START }; return bitmask_table_1[(static_cast(c) - 0xA66Full) / 0x40ull] & (0x1ull << ((static_cast(c) - 0xA66Full) % 0x40ull)); - // 137 codepoints from 28 ranges (spanning a search area of 14332) + // 137 code units from 28 ranges (spanning a search area of 1153) } case 0x03: return (U'\uAAF5' <= c && c <= U'\uAAF6') || (U'\uABE3' <= c && c <= U'\uABEA') || (U'\uABEC' <= c && c <= U'\uABED'); case 0x04: // [4] E2F0 - 11AEB @@ -773,7 +768,7 @@ TOML_IMPL_NAMESPACE_START }; return bitmask_table_1[(static_cast(c) - 0xFB1Eull) / 0x40ull] & (0x1ull << ((static_cast(c) - 0xFB1Eull) % 0x40ull)); - // 402 codepoints from 63 ranges (spanning a search area of 14332) + // 402 code units from 63 ranges (spanning a search area of 8060) } case 0x05: // [5] 11AEC - 152E7 { @@ -788,7 +783,7 @@ TOML_IMPL_NAMESPACE_START }; return bitmask_table_1[(static_cast(c) - 0x11C2Full) / 0x40ull] & (0x1ull << ((static_cast(c) - 0x11C2Full) % 0x40ull)); - // 85 codepoints from 13 ranges (spanning a search area of 14332) + // 85 code units from 13 ranges (spanning a search area of 712) } case 0x06: // [6] 152E8 - 18AE3 { @@ -806,7 +801,7 @@ TOML_IMPL_NAMESPACE_START }; return bitmask_table_1[(static_cast(c) - 0x16AF0ull) / 0x40ull] & (0x1ull << ((static_cast(c) - 0x16AF0ull) % 0x40ull)); - // 75 codepoints from 7 ranges (spanning a search area of 14332) + // 75 code units from 7 ranges (spanning a search area of 1282) } case 0x07: return U'\U0001BC9D' <= c && c <= U'\U0001BC9E'; case 0x08: // [8] 1C2E0 - 1FADB @@ -843,12 +838,13 @@ TOML_IMPL_NAMESPACE_START }; return bitmask_table_1[(static_cast(c) - 0x1D165ull) / 0x40ull] & (0x1ull << ((static_cast(c) - 0x1D165ull) % 0x40ull)); - // 223 codepoints from 21 ranges (spanning a search area of 14332) + // 223 code units from 21 ranges (spanning a search area of 6118) } case 0x3F: return U'\U000E0100' <= c; TOML_NO_DEFAULT_CASE; } - // 2282 codepoints from 293 ranges (spanning a search area of 1114112) + // 2282 code units from 293 ranges (spanning a search area of 917232) + TOML_UNREACHABLE; } #endif // TOML_LANG_UNRELEASED @@ -863,9 +859,9 @@ TOML_IMPL_NAMESPACE_START || codepoint == U'_' #if TOML_LANG_UNRELEASED // toml/issues/644 ('+' in bare keys) & toml/issues/687 (unicode bare keys) || codepoint == U'+' - || is_unicode_letter(codepoint) - || is_unicode_number(codepoint) - || is_unicode_combining_mark(codepoint) + || is_non_ascii_letter(codepoint) + || is_non_ascii_number(codepoint) + || is_combining_mark(codepoint) #endif ; } @@ -880,8 +876,8 @@ TOML_IMPL_NAMESPACE_START || codepoint == U'}' || codepoint == U',' || codepoint == U'#' - || is_unicode_line_break(codepoint) - || is_unicode_whitespace(codepoint) + || is_non_ascii_line_break(codepoint) + || is_non_ascii_whitespace(codepoint) ; } diff --git a/include/toml++/toml_value.h b/include/toml++/toml_value.h index c6f58d7e..11d2c5a9 100644 --- a/include/toml++/toml_value.h +++ b/include/toml++/toml_value.h @@ -202,6 +202,18 @@ TOML_NAMESPACE_START ValueType val_; value_flags flags_ = value_flags::none; + #if TOML_LIFETIME_HOOKS + void lh_ctor() noexcept + { + TOML_VALUE_CREATED; + } + + void lh_dtor() noexcept + { + TOML_VALUE_DESTROYED; + } + #endif + public: /// \brief The value's underlying data type. @@ -229,7 +241,11 @@ TOML_NAMESPACE_START impl::native_value_maker...>::make(std::forward(args)...) ))) : val_(impl::native_value_maker...>::make(std::forward(args)...)) - {} + { + #if TOML_LIFETIME_HOOKS + lh_ctor(); + #endif + } /// \brief Copy constructor. TOML_NODISCARD_CTOR @@ -237,7 +253,11 @@ TOML_NAMESPACE_START : node{ other }, val_{ other.val_ }, flags_{ other.flags_ } - {} + { + #if TOML_LIFETIME_HOOKS + lh_ctor(); + #endif + } /// \brief Move constructor. TOML_NODISCARD_CTOR @@ -245,7 +265,11 @@ TOML_NAMESPACE_START : node{ std::move(other) }, val_{ std::move(other.val_) }, flags_{ other.flags_ } - {} + { + #if TOML_LIFETIME_HOOKS + lh_ctor(); + #endif + } /// \brief Copy-assignment operator. value& operator= (const value& rhs) noexcept @@ -268,6 +292,13 @@ TOML_NAMESPACE_START return *this; } + #if TOML_LIFETIME_HOOKS + ~value() noexcept override + { + lh_dtor(); + } + #endif + /// \brief Returns the value's node type identifier. /// /// \returns One of: diff --git a/include/toml++/toml_version.h b/include/toml++/toml_version.h index b6df3d57..87d2cd7f 100644 --- a/include/toml++/toml_version.h +++ b/include/toml++/toml_version.h @@ -6,7 +6,7 @@ #pragma once #define TOML_LIB_MAJOR 2 -#define TOML_LIB_MINOR 1 +#define TOML_LIB_MINOR 2 #define TOML_LIB_PATCH 0 #define TOML_LANG_MAJOR 1 diff --git a/meson.build b/meson.build index 01a82d27..01e37f66 100644 --- a/meson.build +++ b/meson.build @@ -1,7 +1,7 @@ project( 'tomlplusplus', 'cpp', - version : '2.1.0', + version : '2.2.0', meson_version : '>=0.53.0', license : 'MIT', default_options : [ @@ -35,6 +35,7 @@ is_clang = compiler.get_id() == 'clang' is_msvc = compiler.get_id() == 'msvc' is_icc_cl = compiler.get_id() == 'intel-cl' is_icc = is_icc_cl or compiler.get_id() == 'intel' +is_lld = compiler.get_linker_id() == 'ld.lld' is_debug = get_option('debug') is_release = not is_debug is_pedantic = get_option('pedantic') @@ -81,51 +82,53 @@ if is_gcc language : 'cpp' ) if is_pedantic - add_project_arguments([ - '-Wcast-align', - '-Wcast-qual', - '-Wctor-dtor-privacy', - '-Wdisabled-optimization', - '-Wextra', - '-Wfloat-equal', - '-Wimport', - '-Winit-self', - '-Wlogical-op', - '-Wmissing-declarations', - '-Wmissing-field-initializers', - '-Wmissing-format-attribute', - '-Wmissing-include-dirs', - '-Wmissing-noreturn', - '-Wnoexcept', - '-Wold-style-cast', - '-Woverloaded-virtual', - '-Wpacked', - '-Wpadded', - '-Wpedantic', - '-Wpointer-arith', - '-Wredundant-decls', - '-Wshadow', - '-Wsign-conversion', - '-Wsign-promo', - '-Wstack-protector', - '-Wstrict-null-sentinel', - '-Wswitch-default', - '-Wswitch-enum', - '-Wundef', - '-Wunreachable-code', - '-Wunused', - '-Wunused-parameter', - '-Wvariadic-macros', - '-Wwrite-strings', - '-Wmissing-noreturn', - '-Wsuggest-attribute=const', - '-Wsuggest-attribute=pure' - ], + add_project_arguments( + '-Wcast-align', + '-Wcast-qual', + '-Wctor-dtor-privacy', + '-Wdisabled-optimization', + '-Wextra', + '-Wfloat-equal', + '-Wimport', + '-Winit-self', + '-Wlogical-op', + '-Wmissing-declarations', + '-Wmissing-field-initializers', + '-Wmissing-format-attribute', + '-Wmissing-include-dirs', + '-Wmissing-noreturn', + '-Wnoexcept', + '-Wold-style-cast', + '-Woverloaded-virtual', + '-Wpacked', + '-Wpadded', + '-Wpedantic', + '-Wpointer-arith', + '-Wredundant-decls', + '-Wshadow', + '-Wsign-conversion', + '-Wsign-promo', + '-Wstack-protector', + '-Wstrict-null-sentinel', + '-Wswitch-default', + '-Wswitch-enum', + '-Wundef', + '-Wunreachable-code', + '-Wunused', + '-Wunused-parameter', + '-Wvariadic-macros', + '-Wwrite-strings', + '-Wmissing-noreturn', + '-Wsuggest-attribute=const', + '-Wsuggest-attribute=pure', language : 'cpp' ) endif if is_release - add_project_arguments('-fmerge-constants', language : 'cpp') + add_project_arguments( + '-fmerge-constants', + language : 'cpp' + ) endif endif @@ -151,7 +154,11 @@ if is_clang add_project_arguments('-ftime-trace', language : 'cpp') endif if is_release - add_project_arguments('-Oz', '-fmerge-all-constants', language : 'cpp') + add_project_arguments( + '-Oz', + '-fmerge-all-constants', + language : 'cpp' + ) endif endif @@ -234,6 +241,11 @@ elif is_release overrides += 'strip=true' endif +# LTO +if is_lld or is_debug + overrides += 'b_lto=false' +endif + ####################################################################################################################### # c++ 20 check # (used by tests) @@ -310,17 +322,18 @@ compiler_supports_char8 = compiler_supports_cpp20 and compiler.links(''' compiler_supports_consteval = compiler_supports_cpp20 and compiler.compiles(''' - consteval int kek() noexcept + consteval int test() noexcept { return 42; } int main() { - return kek(); + constexpr auto val = test(); // test() should be compiletime-callable + return val; } ''', - name : 'supports consteval', + name : 'supports consteval keyword', args : compiler_supports_cpp20_args ) @@ -341,12 +354,12 @@ float_16_preprocessor_single_check_template = ''' float_16_preprocessor_checks = ''' #define MAKE_STRING(s) MAKE_STRING_1(s) #define MAKE_STRING_1(s) #s - ''' + float_16_preprocessor_single_check_template.format('__FLT_RADIX__', '2') \ - + float_16_preprocessor_single_check_template.format('__FLT16_MANT_DIG__', '11') \ - + float_16_preprocessor_single_check_template.format('__FLT16_DIG__', '3') \ - + float_16_preprocessor_single_check_template.format('__FLT16_MIN_EXP__', '-13') \ - + float_16_preprocessor_single_check_template.format('__FLT16_MIN_10_EXP__', '-4') \ - + float_16_preprocessor_single_check_template.format('__FLT16_MAX_EXP__', '16') \ + ''' + float_16_preprocessor_single_check_template.format('__FLT_RADIX__', '2') \ + + float_16_preprocessor_single_check_template.format('__FLT16_MANT_DIG__', '11') \ + + float_16_preprocessor_single_check_template.format('__FLT16_DIG__', '3') \ + + float_16_preprocessor_single_check_template.format('__FLT16_MIN_EXP__', '-13') \ + + float_16_preprocessor_single_check_template.format('__FLT16_MIN_10_EXP__', '-4') \ + + float_16_preprocessor_single_check_template.format('__FLT16_MAX_EXP__', '16') \ + float_16_preprocessor_single_check_template.format('__FLT16_MAX_10_EXP__', '4') compiler_supports_float16_args = [] @@ -354,8 +367,6 @@ if is_gcc compiler_supports_float16_args += '-mfp16-format=ieee' endif compiler_supports_fp16 = compiler.links(''' - @0@ - int main() { static_assert(sizeof(__fp16) == 2); @@ -364,7 +375,7 @@ compiler_supports_fp16 = compiler.links(''' const auto f3 = static_cast<__fp16>(0.2L); return 0; } - '''.format(float_16_preprocessor_checks), + ''', name : 'supports __fp16', args : compiler_supports_float16_args ) diff --git a/python/generate_documentation.py b/python/generate_documentation.py index 5f03ba8b..98c61e8a 100644 --- a/python/generate_documentation.py +++ b/python/generate_documentation.py @@ -29,46 +29,66 @@ inline_namespace_explainer = 'All members of this namespace are automatically members of the parent namespace. ' \ + 'It does not require an explicit \'using\' statement.' type_names = [ - #------ standard types - 'size_t', - 'uint8_t', - 'uint16_t', - 'uint32_t', - 'uint64_t', - 'int8_t', + #------ standard/built-in types + '_Float16', + '__float128', + '__fp16', + '__int128_t', + '__m128', + '__m128d', + '__m128i', + '__m256', + '__m256d', + '__m256i', + '__m512', + '__m512d', + '__m512i', + '__m64', + '__uint128_t', + 'bool', + 'byte', + 'char', + 'const_iterator', + 'double', + 'exception', + 'float', + 'fstream', + 'ifstream', + 'int', + 'int128_t', 'int16_t', 'int32_t', 'int64_t', - 'ptrdiff_t', + 'int8_t', 'intptr_t', - 'uintptr_t', - 'exception', + 'istream', + 'istringstream', 'iterator', - 'const_iterator', - 'void', - 'char', - 'wchar_t', - 'int', 'long', - 'short', - 'signed', - 'unsigned', - 'float', - 'double', - 'bool', - 'pair', - 'tuple', - 'istream', - 'ostream', - 'ifstream', 'ofstream', - 'stringstream', - 'istringstream', + 'optional', + 'ostream', 'ostringstream', - 'string_view', + 'pair', + 'ptrdiff_t', + 'short', + 'signed', + 'size_t', + 'span', 'string', - 'byte', - 'optional', + 'string_view', + 'stringstream', + 'tuple', + 'uint128_t', + 'uint16_t', + 'uint32_t', + 'uint64_t', + 'uint8_t', + 'uintptr_t', + 'unsigned', + 'vector', + 'void', + 'wchar_t', #------ toml++ types 'node', 'table', @@ -144,6 +164,7 @@ (r'std::enable_if(?:_t)?', 'https://en.cppreference.com/w/cpp/types/enable_if'), (r'std::exceptions?', 'https://en.cppreference.com/w/cpp/error/exception'), (r'std::has_single_bit(?:\(\))?', 'https://en.cppreference.com/w/cpp/numeric/has_single_bit'), + (r'std::hash', 'https://en.cppreference.com/w/cpp/utility/hash'), (r'std::initializer_lists?', 'https://en.cppreference.com/w/cpp/utility/initializer_list'), (r'std::integral_constants?', 'https://en.cppreference.com/w/cpp/types/integral_constant'), (r'std::is_(?:nothrow_)?convertible(?:_v)?', 'https://en.cppreference.com/w/cpp/types/is_convertible'), @@ -177,6 +198,8 @@ (r'std::spans?', 'https://en.cppreference.com/w/cpp/container/span'), (r'std::to_address(?:\(\))?', 'https://en.cppreference.com/w/cpp/memory/to_address'), (r'std::tuples?', 'https://en.cppreference.com/w/cpp/utility/tuple'), + (r'std::tuple_size(?:_v)?', 'https://en.cppreference.com/w/cpp/utility/tuple/tuple_size'), + (r'std::tuple_element(?:_t)?', 'https://en.cppreference.com/w/cpp/utility/tuple/tuple_element'), (r'std::type_identity(?:_t)?', 'https://en.cppreference.com/w/cpp/types/type_identity'), (r'std::underlying_type(?:_t)?', 'https://en.cppreference.com/w/cpp/types/underlying_type'), (r'std::unique_ptrs?', 'https://en.cppreference.com/w/cpp/memory/unique_ptr'), @@ -219,11 +242,12 @@ + r')', 'https://en.cppreference.com/w/cpp/preprocessor/replace' ), + (r'(?:_Float|__fp)16s?','https://gcc.gnu.org/onlinedocs/gcc/Half-Precision.html'), # toml-specific - (r'toml::values?', 'classtoml_1_1value.html'), - (r'(toml::)?date_times?', 'structtoml_1_1date__time.html'), - (r'(toml::)?time', 'structtoml_1_1time.html'), - (r'(toml::)?dates?', 'structtoml_1_1date.html') + (r'(?:toml::)values?', 'classtoml_1_1value.html'), + (r'(?:toml::)?date_times?', 'structtoml_1_1date__time.html'), + (r'(?:toml::)times?', 'structtoml_1_1time.html'), + (r'(?:toml::)dates?', 'structtoml_1_1date.html') ] header_overrides = [ @@ -245,9 +269,9 @@ 'https://en.cppreference.com/w/cpp/compiler_support' ), ( - 'TOML v1.0.0-rc.2', + 'TOML v1.0.0-rc.3', 'badge-TOML.svg', - 'https://toml.io/en/v1.0.0-rc.2' + 'https://toml.io/en/v1.0.0-rc.3' ), (None, None, None), #
( @@ -1110,9 +1134,9 @@ def main(): , IndexPageFix() , ModifiersFix1() , ModifiersFix2() - , InlineNamespaceFix1() - , InlineNamespaceFix2() - , InlineNamespaceFix3() + #, InlineNamespaceFix1() + #, InlineNamespaceFix2() + #, InlineNamespaceFix3() , ExtDocLinksFix() , EnableIfFix() , ExternalLinksFix() diff --git a/python/generate_single_header.py b/python/generate_single_header.py index aad3a1d9..0ccdf4bf 100644 --- a/python/generate_single_header.py +++ b/python/generate_single_header.py @@ -150,6 +150,7 @@ def main(): preamble.append(''' // TOML Language Specifications: // latest: https://github.com/toml-lang/toml/blob/master/README.md +// v1.0.0-rc.3: https://toml.io/en/v1.0.0-rc.3 // v1.0.0-rc.2: https://toml.io/en/v1.0.0-rc.2 // v1.0.0-rc.1: https://toml.io/en/v1.0.0-rc.1 // v0.5.0: https://toml.io/en/v0.5.0 diff --git a/python/generate_windows_test_targets.py b/python/generate_windows_test_targets.py index dedc6d09..3567b321 100644 --- a/python/generate_windows_test_targets.py +++ b/python/generate_windows_test_targets.py @@ -81,6 +81,7 @@ def main(): Use tests.h TOML_UNRELEASED_FEATURES={unreleased_features};%(PreprocessorDefinitions) + LEAK_TESTS=1;%(PreprocessorDefinitions) _HAS_EXCEPTIONS=0;%(PreprocessorDefinitions) SHOULD_HAVE_EXCEPTIONS=0;%(PreprocessorDefinitions) SHOULD_HAVE_EXCEPTIONS=1;%(PreprocessorDefinitions) @@ -129,6 +130,7 @@ def main(): + diff --git a/python/requirements.txt b/python/requirements.txt index 6ed49807..83dbb9ad 100644 --- a/python/requirements.txt +++ b/python/requirements.txt @@ -2,3 +2,6 @@ requests bs4 pyyaml python-dateutil +jinja2 +pygments +html5lib diff --git a/tests/conformance_burntsushi_valid.cpp b/tests/conformance_burntsushi_valid.cpp index a9b05f07..07deebdb 100644 --- a/tests/conformance_burntsushi_valid.cpp +++ b/tests/conformance_burntsushi_valid.cpp @@ -247,6 +247,11 @@ answer = 42)"sv; [a.'b'] [a.'b'.c] answer = 42)"sv; + static constexpr auto table_without_super = R"(# [x] you +# [x.y] don't +# [x.y.z] need these +[x.y.z.w] # for this to work +[x] # defining a super-table afterwards is ok)"sv; static constexpr auto underscored_float = R"(electron_mass = 9_109.109_383e-3_4)"sv; static constexpr auto underscored_integer = R"(million = 1_000_000)"sv; static constexpr auto unicode_escape = R"(answer4 = "\u03B4" @@ -1120,6 +1125,26 @@ ue)"sv }, REQUIRE(tbl == expected); }); + parsing_should_succeed(FILE_LINE_ARGS, table_without_super, [](toml::table&& tbl) + { + auto expected = toml::table{{ + { + R"(x)"sv, toml::table{{ + { + R"(y)"sv, toml::table{{ + { + R"(z)"sv, toml::table{{ + { R"(w)"sv, toml::table{} }, + }} + }, + }} + }, + }} + }, + }}; + REQUIRE(tbl == expected); + }); + parsing_should_succeed(FILE_LINE_ARGS, underscored_float, [](toml::table&& tbl) { auto expected = toml::table{{ diff --git a/tests/impl_catch2.cpp b/tests/impl_catch2.cpp index c53729ea..a2fd74fb 100644 --- a/tests/impl_catch2.cpp +++ b/tests/impl_catch2.cpp @@ -7,6 +7,27 @@ #include "catch2.h" #include +#if LEAK_TESTS +#include +#include +#include +#include "leakproof.h" +using namespace std::string_view_literals; +namespace leakproof +{ + static std::atomic_llong total_created_ = 0LL; + static std::atomic_llong tables_ = 0LL; + static std::atomic_llong arrays_ = 0LL; + static std::atomic_llong values_ = 0LL; + void table_created() noexcept { tables_++; total_created_++; } + void array_created() noexcept { arrays_++; total_created_++; } + void value_created() noexcept { values_++; total_created_++; } + void table_destroyed() noexcept { tables_--; } + void array_destroyed() noexcept { arrays_--; } + void value_destroyed() noexcept { values_--; } +} +#endif + int main(int argc, char* argv[]) { #ifdef _WIN32 @@ -14,5 +35,28 @@ int main(int argc, char* argv[]) #endif std::setlocale(LC_ALL, ""); std::locale::global(std::locale("")); - return Catch::Session().run(argc, argv); + if (auto result = Catch::Session().run(argc, argv)) + return result; + + #if LEAK_TESTS + constexpr auto handle_leak_result = [](std::string_view name, long long count) noexcept + { + std::cout << "\n"sv << name << ": "sv << std::right << std::setw(6) << count; + if (count > 0LL) + std::cout << " *** LEAK DETECTED ***"sv; + if (count < 0LL) + std::cout << " *** UNBALANCED LIFETIME CALLS ***"sv; + return count == 0LL; + }; + std::cout << "\n---------- leak test results ----------"sv; + bool ok = true; + ok = handle_leak_result("tables"sv, leakproof::tables_.load()) && ok; + ok = handle_leak_result("arrays"sv, leakproof::arrays_.load()) && ok; + ok = handle_leak_result("values"sv, leakproof::values_.load()) && ok; + std::cout << "\n(total objects created: "sv << leakproof::total_created_.load() << ")"sv; + std::cout << "\n---------------------------------------"sv; + return ok ? 0 : -1; + #else + return 0; + #endif } diff --git a/tests/leakproof.h b/tests/leakproof.h new file mode 100644 index 00000000..438734fe --- /dev/null +++ b/tests/leakproof.h @@ -0,0 +1,19 @@ +#pragma once + +namespace leakproof +{ + void table_created() noexcept; + void array_created() noexcept; + void value_created() noexcept; + void table_destroyed() noexcept; + void array_destroyed() noexcept; + void value_destroyed() noexcept; +} + +#define TOML_LIFETIME_HOOKS 1 +#define TOML_TABLE_CREATED ::leakproof::table_created() +#define TOML_TABLE_DESTROYED ::leakproof::table_destroyed() +#define TOML_ARRAY_CREATED ::leakproof::array_created() +#define TOML_ARRAY_DESTROYED ::leakproof::array_destroyed() +#define TOML_VALUE_CREATED ::leakproof::value_created() +#define TOML_VALUE_DESTROYED ::leakproof::value_destroyed() diff --git a/tests/settings.h b/tests/settings.h index 52c7cc51..6a7def8a 100644 --- a/tests/settings.h +++ b/tests/settings.h @@ -13,6 +13,12 @@ #ifndef USE_SINGLE_HEADER #define USE_SINGLE_HEADER 0 #endif +#if defined(LEAK_TESTS) && LEAK_TESTS + #define TOML_CONFIG_HEADER "leakproof.h" +#else + #undef LEAK_TESTS + #define LEAK_TESTS 0 +#endif // use tl::optional? #if defined(USE_TARTANLLAMA_OPTIONAL) && USE_TARTANLLAMA_OPTIONAL diff --git a/tests/unicode.cpp b/tests/unicode.cpp index 6789c126..a334b754 100644 --- a/tests/unicode.cpp +++ b/tests/unicode.cpp @@ -16,13 +16,13 @@ inline constexpr func_type* funcs[] = impl::is_ascii_line_break, impl::is_decimal_digit, impl::is_string_delimiter, - impl::is_unicode_whitespace, - impl::is_unicode_line_break, + impl::is_non_ascii_whitespace, + impl::is_non_ascii_line_break, impl::is_unicode_surrogate, #if TOML_LANG_UNRELEASED - impl::is_unicode_letter, - impl::is_unicode_number, - impl::is_unicode_combining_mark, + impl::is_non_ascii_letter, + impl::is_non_ascii_number, + impl::is_combining_mark, #endif }; @@ -178,9 +178,9 @@ TEST_CASE("unicode - is_string_delimiter") REQUIRE(not_in(fn, { U'(', unimax })); } -TEST_CASE("unicode - is_unicode_whitespace") +TEST_CASE("unicode - is_non_ascii_whitespace") { - static constexpr auto fn = is_unicode_whitespace; + static constexpr auto fn = is_non_ascii_whitespace; REQUIRE(not_in(fn, { U'\0', U'\u009F' })); REQUIRE(in_only(fn, U'\u00A0' )); REQUIRE(not_in(fn, { U'\u00A1', U'\u167F' })); @@ -196,9 +196,9 @@ TEST_CASE("unicode - is_unicode_whitespace") REQUIRE(not_in(fn, { U'\u3001', unimax })); } -TEST_CASE("unicode - is_unicode_line_break") +TEST_CASE("unicode - is_non_ascii_line_break") { - static constexpr auto fn = is_unicode_line_break; + static constexpr auto fn = is_non_ascii_line_break; REQUIRE(not_in(fn, { U'\0', U'\u0084' })); REQUIRE(in_only(fn, U'\u0085' )); REQUIRE(not_in(fn, { U'\u0086', U'\u2027' })); diff --git a/toml.hpp b/toml.hpp index a3581e03..04ef039a 100644 --- a/toml.hpp +++ b/toml.hpp @@ -1,6 +1,6 @@ //---------------------------------------------------------------------------------------------------------------------- // -// toml++ v2.1.0 +// toml++ v2.2.0 // https://github.com/marzer/tomlplusplus // SPDX-License-Identifier: MIT // @@ -17,6 +17,7 @@ // // TOML Language Specifications: // latest: https://github.com/toml-lang/toml/blob/master/README.md +// v1.0.0-rc.3: https://toml.io/en/v1.0.0-rc.3 // v1.0.0-rc.2: https://toml.io/en/v1.0.0-rc.2 // v1.0.0-rc.1: https://toml.io/en/v1.0.0-rc.1 // v0.5.0: https://toml.io/en/v0.5.0 @@ -486,6 +487,10 @@ is no longer necessary. return static_cast(::toml::impl::unwrap_enum(lhs) | ::toml::impl::unwrap_enum(rhs)); \ } +#ifndef TOML_LIFETIME_HOOKS + #define TOML_LIFETIME_HOOKS 0 +#endif + #ifdef __FLT16_MANT_DIG__ #if __FLT_RADIX__ == 2 \ && __FLT16_MANT_DIG__ == 11 \ @@ -494,7 +499,7 @@ is no longer necessary. && __FLT16_MIN_10_EXP__ == -4 \ && __FLT16_MAX_EXP__ == 16 \ && __FLT16_MAX_10_EXP__ == 4 - #if (TOML_ARM && TOML_GCC) || TOML_CLANG + #if TOML_ARM && (TOML_GCC || TOML_CLANG) #define TOML_FP16 __fp16 #endif #if TOML_ARM && TOML_CLANG // not present in g++ @@ -516,7 +521,7 @@ is no longer necessary. #endif #define TOML_LIB_MAJOR 2 -#define TOML_LIB_MINOR 1 +#define TOML_LIB_MINOR 2 #define TOML_LIB_PATCH 0 #define TOML_LANG_MAJOR 1 @@ -2764,6 +2769,18 @@ TOML_NAMESPACE_START ValueType val_; value_flags flags_ = value_flags::none; + #if TOML_LIFETIME_HOOKS + void lh_ctor() noexcept + { + TOML_VALUE_CREATED; + } + + void lh_dtor() noexcept + { + TOML_VALUE_DESTROYED; + } + #endif + public: using value_type = ValueType; @@ -2780,21 +2797,33 @@ TOML_NAMESPACE_START impl::native_value_maker...>::make(std::forward(args)...) ))) : val_(impl::native_value_maker...>::make(std::forward(args)...)) - {} + { + #if TOML_LIFETIME_HOOKS + lh_ctor(); + #endif + } TOML_NODISCARD_CTOR value(const value& other) noexcept : node{ other }, val_{ other.val_ }, flags_{ other.flags_ } - {} + { + #if TOML_LIFETIME_HOOKS + lh_ctor(); + #endif + } TOML_NODISCARD_CTOR value(value&& other) noexcept : node{ std::move(other) }, val_{ std::move(other.val_) }, flags_{ other.flags_ } - {} + { + #if TOML_LIFETIME_HOOKS + lh_ctor(); + #endif + } value& operator= (const value& rhs) noexcept { @@ -2815,6 +2844,13 @@ TOML_NAMESPACE_START return *this; } + #if TOML_LIFETIME_HOOKS + ~value() noexcept override + { + lh_dtor(); + } + #endif + [[nodiscard]] node_type type() const noexcept override { return impl::node_type_of; } [[nodiscard]] bool is_table() const noexcept override { return false; } [[nodiscard]] bool is_array() const noexcept override { return false; } @@ -3623,6 +3659,11 @@ TOML_NAMESPACE_START elements.emplace_back(impl::make_node(std::forward(val))); } + #if TOML_LIFETIME_HOOKS + void lh_ctor() noexcept; + void lh_dtor() noexcept; + #endif + public: using value_type = node; @@ -3644,6 +3685,8 @@ TOML_NAMESPACE_START array& operator= (const array&) noexcept; array& operator= (array&& rhs) noexcept; + ~array() noexcept override; + template 0_sz) || !std::is_same_v, array> @@ -3660,6 +3703,10 @@ TOML_NAMESPACE_START ... ); } + + #if TOML_LIFETIME_HOOKS + lh_ctor(); + #endif } [[nodiscard]] node_type type() const noexcept override; @@ -4127,6 +4174,11 @@ TOML_NAMESPACE_START impl::string_map> map; bool inline_ = false; + #if TOML_LIFETIME_HOOKS + void lh_ctor() noexcept; + void lh_dtor() noexcept; + #endif + table(impl::table_init_pair*, size_t) noexcept; public: @@ -4145,11 +4197,17 @@ TOML_NAMESPACE_START table& operator= (const table&) noexcept; table& operator= (table&& rhs) noexcept; + ~table() noexcept override; + template TOML_NODISCARD_CTOR explicit table(impl::table_init_pair(&& arr)[N]) noexcept : table{ arr, N } - {} + { + #if TOML_LIFETIME_HOOKS + lh_ctor(); + #endif + } [[nodiscard]] node_type type() const noexcept override; [[nodiscard]] bool is_table() const noexcept override; @@ -4891,15 +4949,6 @@ TOML_POP_WARNINGS // TOML_DISABLE_ARITHMETIC_WARNINGS TOML_IMPL_NAMESPACE_START { - template - [[nodiscard]] - TOML_ATTR(const) - constexpr bool is_match(char32_t codepoint, T... vals) noexcept - { - static_assert((std::is_same_v && ...)); - return ((codepoint == vals) || ...); - } - [[nodiscard]] TOML_ATTR(const) constexpr bool is_ascii_whitespace(char32_t codepoint) noexcept @@ -4909,7 +4958,7 @@ TOML_IMPL_NAMESPACE_START [[nodiscard]] TOML_ATTR(const) - constexpr bool is_unicode_whitespace(char32_t codepoint) noexcept + constexpr bool is_non_ascii_whitespace(char32_t codepoint) noexcept { // see: https://en.wikipedia.org/wiki/Whitespace_character#Unicode // (characters that don't say "is a line-break") @@ -4927,7 +4976,7 @@ TOML_IMPL_NAMESPACE_START TOML_ATTR(const) constexpr bool is_whitespace(char32_t codepoint) noexcept { - return is_ascii_whitespace(codepoint) || is_unicode_whitespace(codepoint); + return is_ascii_whitespace(codepoint) || is_non_ascii_whitespace(codepoint); } template @@ -4941,7 +4990,7 @@ TOML_IMPL_NAMESPACE_START [[nodiscard]] TOML_ATTR(const) - constexpr bool is_unicode_line_break(char32_t codepoint) noexcept + constexpr bool is_non_ascii_line_break(char32_t codepoint) noexcept { // see https://en.wikipedia.org/wiki/Whitespace_character#Unicode // (characters that say "is a line-break") @@ -4957,7 +5006,7 @@ TOML_IMPL_NAMESPACE_START TOML_ATTR(const) constexpr bool is_line_break(char32_t codepoint) noexcept { - return is_ascii_line_break(codepoint) || is_unicode_line_break(codepoint); + return is_ascii_line_break(codepoint) || is_non_ascii_line_break(codepoint); } [[nodiscard]] @@ -5021,7 +5070,7 @@ TOML_IMPL_NAMESPACE_START [[nodiscard]] TOML_ATTR(const) - constexpr bool is_unicode_letter(char32_t c) noexcept + constexpr bool is_non_ascii_letter(char32_t c) noexcept { if (U'\xAA' > c || c > U'\U0003134A') return false; @@ -5057,7 +5106,7 @@ TOML_IMPL_NAMESPACE_START }; return bitmask_table_1[(static_cast(c) - 0xAAull) / 0x40ull] & (0x1ull << ((static_cast(c) - 0xAAull) % 0x40ull)); - // 1922 codepoints from 124 ranges (spanning a search area of 3147) + // 1922 code units from 124 ranges (spanning a search area of 3145) } case 0x01: // [1] 0CF5 - 193F { @@ -5082,7 +5131,7 @@ TOML_IMPL_NAMESPACE_START }; return bitmask_table_1[(static_cast(c) - 0xD04ull) / 0x40ull] & (0x1ull << ((static_cast(c) - 0xD04ull) % 0x40ull)); - // 2239 codepoints from 83 ranges (spanning a search area of 3147) + // 2239 code units from 83 ranges (spanning a search area of 3099) } case 0x02: // [2] 1940 - 258A { @@ -5103,7 +5152,7 @@ TOML_IMPL_NAMESPACE_START }; return bitmask_table_1[(static_cast(c) - 0x1950ull) / 0x40ull] & (0x1ull << ((static_cast(c) - 0x1950ull) % 0x40ull)); - // 1184 codepoints from 59 ranges (spanning a search area of 3147) + // 1184 code units from 59 ranges (spanning a search area of 2101) } case 0x03: // [3] 258B - 31D5 { @@ -5121,7 +5170,7 @@ TOML_IMPL_NAMESPACE_START }; return bitmask_table_1[(static_cast(c) - 0x2C00ull) / 0x40ull] & (0x1ull << (static_cast(c) % 0x40ull)); - // 771 codepoints from 30 ranges (spanning a search area of 3147) + // 771 code units from 30 ranges (spanning a search area of 1472) } case 0x04: return (U'\u31F0' <= c && c <= U'\u31FF') || U'\u3400' <= c; case 0x06: return c <= U'\u4DBF' || U'\u4E00' <= c; @@ -5148,7 +5197,7 @@ TOML_IMPL_NAMESPACE_START }; return bitmask_table_1[(static_cast(c) - 0xA079ull) / 0x40ull] & (0x1ull << ((static_cast(c) - 0xA079ull) % 0x40ull)); - // 2554 codepoints from 52 ranges (spanning a search area of 3147) + // 2554 code units from 52 ranges (spanning a search area of 3147) } case 0x11: return c <= U'\uD7A3' || (U'\uD7B0' <= c && c <= U'\uD7C6') || (U'\uD7CB' <= c && c <= U'\uD7FB'); case 0x14: // [20] F686 - 102D0 @@ -5172,7 +5221,7 @@ TOML_IMPL_NAMESPACE_START }; return bitmask_table_1[(static_cast(c) - 0xF900ull) / 0x40ull] & (0x1ull << (static_cast(c) % 0x40ull)); - // 1710 codepoints from 34 ranges (spanning a search area of 3147) + // 1710 code units from 34 ranges (spanning a search area of 2513) } case 0x15: // [21] 102D1 - 10F1B { @@ -5198,7 +5247,7 @@ TOML_IMPL_NAMESPACE_START }; return bitmask_table_1[(static_cast(c) - 0x10300ull) / 0x40ull] & (0x1ull << (static_cast(c) % 0x40ull)); - // 1620 codepoints from 48 ranges (spanning a search area of 3147) + // 1620 code units from 48 ranges (spanning a search area of 3100) } case 0x16: // [22] 10F1C - 11B66 { @@ -5223,7 +5272,7 @@ TOML_IMPL_NAMESPACE_START }; return bitmask_table_1[(static_cast(c) - 0x10F1Cull) / 0x40ull] & (0x1ull << ((static_cast(c) - 0x10F1Cull) % 0x40ull)); - // 1130 codepoints from 67 ranges (spanning a search area of 3147) + // 1130 code units from 67 ranges (spanning a search area of 3037) } case 0x17: // [23] 11B67 - 127B1 { @@ -5245,7 +5294,7 @@ TOML_IMPL_NAMESPACE_START }; return bitmask_table_1[(static_cast(c) - 0x11C00ull) / 0x40ull] & (0x1ull << (static_cast(c) % 0x40ull)); - // 1304 codepoints from 16 ranges (spanning a search area of 3147) + // 1304 code units from 16 ranges (spanning a search area of 2372) } case 0x18: return U'\U00013000' <= c; case 0x19: return c <= U'\U0001342E'; @@ -5271,7 +5320,7 @@ TOML_IMPL_NAMESPACE_START }; return bitmask_table_1[(static_cast(c) - 0x16800ull) / 0x40ull] & (0x1ull << (static_cast(c) % 0x40ull)); - // 1250 codepoints from 14 ranges (spanning a search area of 3147) + // 1250 code units from 14 ranges (spanning a search area of 2420) } case 0x1F: return c <= U'\U000187F7' || U'\U00018800' <= c; case 0x20: return c <= U'\U00018CD5' || (U'\U00018D00' <= c && c <= U'\U00018D08'); @@ -5288,7 +5337,7 @@ TOML_IMPL_NAMESPACE_START }; return bitmask_table_1[(static_cast(c) - 0x1B000ull) / 0x40ull] & (0x1ull << (static_cast(c) % 0x40ull)); - // 690 codepoints from 4 ranges (spanning a search area of 3147) + // 690 code units from 4 ranges (spanning a search area of 764) } case 0x24: // [36] 1BB36 - 1C780 { @@ -5301,7 +5350,8 @@ TOML_IMPL_NAMESPACE_START case 0x02: return (1u << (static_cast(c) - 0x1BC80u)) & 0x3FF01FFu; default: return true; } - // 139 codepoints from 4 ranges (spanning a search area of 3147) + // 139 code units from 4 ranges (spanning a search area of 154) + TOML_UNREACHABLE; } case 0x26: // [38] 1D3CC - 1E016 { @@ -5317,7 +5367,7 @@ TOML_IMPL_NAMESPACE_START }; return bitmask_table_1[(static_cast(c) - 0x1D400ull) / 0x40ull] & (0x1ull << (static_cast(c) % 0x40ull)); - // 936 codepoints from 30 ranges (spanning a search area of 3147) + // 936 code units from 30 ranges (spanning a search area of 972) } case 0x27: // [39] 1E017 - 1EC61 { @@ -5338,7 +5388,7 @@ TOML_IMPL_NAMESPACE_START }; return bitmask_table_1[(static_cast(c) - 0x1E100ull) / 0x40ull] & (0x1ull << (static_cast(c) % 0x40ull)); - // 363 codepoints from 7 ranges (spanning a search area of 3147) + // 363 code units from 7 ranges (spanning a search area of 2124) } case 0x28: // [40] 1EC62 - 1F8AC { @@ -5353,7 +5403,8 @@ TOML_IMPL_NAMESPACE_START case 0x02: return (1ull << (static_cast(c) - 0x1EE80u)) & 0xFFFFBEE0FFFFBFFull; TOML_NO_DEFAULT_CASE; } - // 141 codepoints from 33 ranges (spanning a search area of 3147) + // 141 code units from 33 ranges (spanning a search area of 188) + TOML_UNREACHABLE; } case 0x29: return U'\U00020000' <= c; case 0x37: return c <= U'\U0002A6DD' || U'\U0002A700' <= c; @@ -5364,12 +5415,13 @@ TOML_IMPL_NAMESPACE_START case 0x3E: return U'\U00030000' <= c; TOML_NO_DEFAULT_CASE; } - // 131189 codepoints from 620 ranges (spanning a search area of 1114112) + // 131189 code units from 620 ranges (spanning a search area of 201377) + TOML_UNREACHABLE; } [[nodiscard]] TOML_ATTR(const) - constexpr bool is_unicode_number(char32_t c) noexcept + constexpr bool is_non_ascii_number(char32_t c) noexcept { if (U'\u0660' > c || c > U'\U0001FBF9') return false; @@ -5398,7 +5450,7 @@ TOML_IMPL_NAMESPACE_START }; return bitmask_table_1[(static_cast(c) - 0x660ull) / 0x40ull] & (0x1ull << ((static_cast(c) - 0x660ull) % 0x40ull)); - // 130 codepoints from 13 ranges (spanning a search area of 2007) + // 130 code units from 13 ranges (spanning a search area of 1936) } case 0x01: // [1] 0E37 - 160D { @@ -5413,7 +5465,7 @@ TOML_IMPL_NAMESPACE_START }; return bitmask_table_1[(static_cast(c) - 0xE50ull) / 0x40ull] & (0x1ull << ((static_cast(c) - 0xE50ull) % 0x40ull)); - // 50 codepoints from 5 ranges (spanning a search area of 2007) + // 50 code units from 5 ranges (spanning a search area of 586) } case 0x02: // [2] 160E - 1DE4 { @@ -5431,7 +5483,7 @@ TOML_IMPL_NAMESPACE_START }; return bitmask_table_1[(static_cast(c) - 0x16EEull) / 0x40ull] & (0x1ull << ((static_cast(c) - 0x16EEull) % 0x40ull)); - // 103 codepoints from 11 ranges (spanning a search area of 2007) + // 103 code units from 11 ranges (spanning a search area of 1388) } case 0x03: return U'\u2160' <= c && c <= U'\u2188' && (1ull << (static_cast(c) - 0x2160u)) & 0x1E7FFFFFFFFull; case 0x05: return U'\u3007' <= c && c <= U'\u303A' && (1ull << (static_cast(c) - 0x3007u)) & 0xE0007FC000001ull; @@ -5450,7 +5502,7 @@ TOML_IMPL_NAMESPACE_START }; return bitmask_table_1[(static_cast(c) - 0xA620ull) / 0x40ull] & (0x1ull << ((static_cast(c) - 0xA620ull) % 0x40ull)); - // 70 codepoints from 7 ranges (spanning a search area of 2007) + // 70 code units from 7 ranges (spanning a search area of 1082) } case 0x15: return U'\uABF0' <= c && c <= U'\uABF9'; case 0x1F: return U'\uFF10' <= c && c <= U'\uFF19'; @@ -5469,7 +5521,7 @@ TOML_IMPL_NAMESPACE_START }; return bitmask_table_1[(static_cast(c) - 0x10140ull) / 0x40ull] & (0x1ull << (static_cast(c) % 0x40ull)); - // 70 codepoints from 5 ranges (spanning a search area of 2007) + // 70 code units from 5 ranges (spanning a search area of 874) } case 0x21: return (U'\U00010D30' <= c && c <= U'\U00010D39') || (U'\U00011066' <= c && c <= U'\U0001106F'); case 0x22: // [34] 110EE - 118C4 @@ -5489,7 +5541,7 @@ TOML_IMPL_NAMESPACE_START }; return bitmask_table_1[(static_cast(c) - 0x110F0ull) / 0x40ull] & (0x1ull << ((static_cast(c) - 0x110F0ull) % 0x40ull)); - // 90 codepoints from 9 ranges (spanning a search area of 2007) + // 90 code units from 9 ranges (spanning a search area of 1610) } case 0x23: // [35] 118C5 - 1209B { @@ -5506,7 +5558,7 @@ TOML_IMPL_NAMESPACE_START }; return bitmask_table_1[(static_cast(c) - 0x118E0ull) / 0x40ull] & (0x1ull << ((static_cast(c) - 0x118E0ull) % 0x40ull)); - // 50 codepoints from 5 ranges (spanning a search area of 2007) + // 50 code units from 5 ranges (spanning a search area of 1226) } case 0x24: return U'\U00012400' <= c && c <= U'\U0001246E'; case 0x2D: return (U'\U00016A60' <= c && c <= U'\U00016A69') || (U'\U00016B50' <= c && c <= U'\U00016B59'); @@ -5516,12 +5568,13 @@ TOML_IMPL_NAMESPACE_START case 0x3F: return U'\U0001FBF0' <= c; TOML_NO_DEFAULT_CASE; } - // 876 codepoints from 72 ranges (spanning a search area of 1114112) + // 876 code units from 72 ranges (spanning a search area of 128410) + TOML_UNREACHABLE; } [[nodiscard]] TOML_ATTR(const) - constexpr bool is_unicode_combining_mark(char32_t c) noexcept + constexpr bool is_combining_mark(char32_t c) noexcept { if (U'\u0300' > c || c > U'\U000E01EF') return false; @@ -5588,7 +5641,7 @@ TOML_IMPL_NAMESPACE_START }; return bitmask_table_1[(static_cast(c) - 0x300ull) / 0x40ull] & (0x1ull << (static_cast(c) % 0x40ull)); - // 1106 codepoints from 156 ranges (spanning a search area of 14332) + // 1106 code units from 156 ranges (spanning a search area of 11675) } case 0x02: // [2] 72F8 - AAF3 { @@ -5605,7 +5658,7 @@ TOML_IMPL_NAMESPACE_START }; return bitmask_table_1[(static_cast(c) - 0xA66Full) / 0x40ull] & (0x1ull << ((static_cast(c) - 0xA66Full) % 0x40ull)); - // 137 codepoints from 28 ranges (spanning a search area of 14332) + // 137 code units from 28 ranges (spanning a search area of 1153) } case 0x03: return (U'\uAAF5' <= c && c <= U'\uAAF6') || (U'\uABE3' <= c && c <= U'\uABEA') || (U'\uABEC' <= c && c <= U'\uABED'); case 0x04: // [4] E2F0 - 11AEB @@ -5650,7 +5703,7 @@ TOML_IMPL_NAMESPACE_START }; return bitmask_table_1[(static_cast(c) - 0xFB1Eull) / 0x40ull] & (0x1ull << ((static_cast(c) - 0xFB1Eull) % 0x40ull)); - // 402 codepoints from 63 ranges (spanning a search area of 14332) + // 402 code units from 63 ranges (spanning a search area of 8060) } case 0x05: // [5] 11AEC - 152E7 { @@ -5665,7 +5718,7 @@ TOML_IMPL_NAMESPACE_START }; return bitmask_table_1[(static_cast(c) - 0x11C2Full) / 0x40ull] & (0x1ull << ((static_cast(c) - 0x11C2Full) % 0x40ull)); - // 85 codepoints from 13 ranges (spanning a search area of 14332) + // 85 code units from 13 ranges (spanning a search area of 712) } case 0x06: // [6] 152E8 - 18AE3 { @@ -5683,7 +5736,7 @@ TOML_IMPL_NAMESPACE_START }; return bitmask_table_1[(static_cast(c) - 0x16AF0ull) / 0x40ull] & (0x1ull << ((static_cast(c) - 0x16AF0ull) % 0x40ull)); - // 75 codepoints from 7 ranges (spanning a search area of 14332) + // 75 code units from 7 ranges (spanning a search area of 1282) } case 0x07: return U'\U0001BC9D' <= c && c <= U'\U0001BC9E'; case 0x08: // [8] 1C2E0 - 1FADB @@ -5720,12 +5773,13 @@ TOML_IMPL_NAMESPACE_START }; return bitmask_table_1[(static_cast(c) - 0x1D165ull) / 0x40ull] & (0x1ull << ((static_cast(c) - 0x1D165ull) % 0x40ull)); - // 223 codepoints from 21 ranges (spanning a search area of 14332) + // 223 code units from 21 ranges (spanning a search area of 6118) } case 0x3F: return U'\U000E0100' <= c; TOML_NO_DEFAULT_CASE; } - // 2282 codepoints from 293 ranges (spanning a search area of 1114112) + // 2282 code units from 293 ranges (spanning a search area of 917232) + TOML_UNREACHABLE; } #endif // TOML_LANG_UNRELEASED @@ -5740,9 +5794,9 @@ TOML_IMPL_NAMESPACE_START || codepoint == U'_' #if TOML_LANG_UNRELEASED // toml/issues/644 ('+' in bare keys) & toml/issues/687 (unicode bare keys) || codepoint == U'+' - || is_unicode_letter(codepoint) - || is_unicode_number(codepoint) - || is_unicode_combining_mark(codepoint) + || is_non_ascii_letter(codepoint) + || is_non_ascii_number(codepoint) + || is_combining_mark(codepoint) #endif ; } @@ -5757,8 +5811,8 @@ TOML_IMPL_NAMESPACE_START || codepoint == U'}' || codepoint == U',' || codepoint == U'#' - || is_unicode_line_break(codepoint) - || is_unicode_whitespace(codepoint) + || is_non_ascii_line_break(codepoint) + || is_non_ascii_whitespace(codepoint) ; } @@ -7576,8 +7630,29 @@ TOML_NAMESPACE_END TOML_NAMESPACE_START { + #if TOML_LIFETIME_HOOKS + TOML_EXTERNAL_LINKAGE - array::array() noexcept = default; + void array::lh_ctor() noexcept + { + TOML_ARRAY_CREATED; + } + + TOML_EXTERNAL_LINKAGE + void array::lh_dtor() noexcept + { + TOML_ARRAY_DESTROYED; + } + + #endif + + TOML_EXTERNAL_LINKAGE + array::array() noexcept + { + #if TOML_LIFETIME_HOOKS + lh_ctor(); + #endif + } TOML_EXTERNAL_LINKAGE array::array(const array& other) noexcept @@ -7586,13 +7661,21 @@ TOML_NAMESPACE_START elements.reserve(other.elements.size()); for (const auto& elem : other) elements.emplace_back(impl::make_node(elem)); + + #if TOML_LIFETIME_HOOKS + lh_ctor(); + #endif } TOML_EXTERNAL_LINKAGE array::array(array&& other) noexcept : node{ std::move(other) }, elements{ std::move(other.elements) } - {} + { + #if TOML_LIFETIME_HOOKS + lh_ctor(); + #endif + } TOML_EXTERNAL_LINKAGE array& array::operator= (const array& rhs) noexcept @@ -7619,6 +7702,14 @@ TOML_NAMESPACE_START return *this; } + TOML_EXTERNAL_LINKAGE + array::~array() noexcept + { + #if TOML_LIFETIME_HOOKS + lh_dtor(); + #endif + } + TOML_EXTERNAL_LINKAGE void array::preinsertion_resize(size_t idx, size_t count) noexcept { @@ -7886,8 +7977,29 @@ TOML_NAMESPACE_END TOML_NAMESPACE_START { + #if TOML_LIFETIME_HOOKS + + TOML_EXTERNAL_LINKAGE + void table::lh_ctor() noexcept + { + TOML_TABLE_CREATED; + } + TOML_EXTERNAL_LINKAGE - table::table() noexcept {} + void table::lh_dtor() noexcept + { + TOML_TABLE_DESTROYED; + } + + #endif + + TOML_EXTERNAL_LINKAGE + table::table() noexcept + { + #if TOML_LIFETIME_HOOKS + lh_ctor(); + #endif + } TOML_EXTERNAL_LINKAGE table::table(const table& other) noexcept @@ -7896,6 +8008,10 @@ TOML_NAMESPACE_START { for (auto&& [k, v] : other) map.emplace_hint(map.end(), k, impl::make_node(v)); + + #if TOML_LIFETIME_HOOKS + lh_ctor(); + #endif } TOML_EXTERNAL_LINKAGE @@ -7903,7 +8019,11 @@ TOML_NAMESPACE_START : node{ std::move(other) }, map{ std::move(other.map) }, inline_{ other.inline_ } - {} + { + #if TOML_LIFETIME_HOOKS + lh_ctor(); + #endif + } TOML_EXTERNAL_LINKAGE table& table::operator= (const table& rhs) noexcept @@ -7931,6 +8051,14 @@ TOML_NAMESPACE_START return *this; } + TOML_EXTERNAL_LINKAGE + table::~table() noexcept + { + #if TOML_LIFETIME_HOOKS + lh_dtor(); + #endif + } + TOML_EXTERNAL_LINKAGE table::table(impl::table_init_pair* pairs, size_t count) noexcept { @@ -8628,6 +8756,15 @@ TOML_DISABLE_SWITCH_WARNINGS TOML_ANON_NAMESPACE_START { + template + [[nodiscard]] + TOML_ATTR(const) + constexpr bool is_match(char32_t codepoint, T... vals) noexcept + { + static_assert((std::is_same_v && ...)); + return ((codepoint == vals) || ...); + } + template struct parse_integer_traits; template <> struct parse_integer_traits<2> final { @@ -8828,6 +8965,65 @@ TOML_ANON_NAMESPACE_START #define push_parse_scope_1(scope, line) push_parse_scope_2(scope, line) #define push_parse_scope(scope) push_parse_scope_1(scope, __LINE__) + // Q: "why not std::unique_ptr?? + // A: It caused a lot of bloat on some implementations so this exists an internal substitute. + class node_ptr + { + private: + toml::node* node_ = {}; + + public: + TOML_NODISCARD_CTOR + node_ptr() noexcept = default; + + TOML_NODISCARD_CTOR + explicit node_ptr(toml::node* n) noexcept + : node_{ n } + {} + + ~node_ptr() noexcept + { + delete node_; + } + + node_ptr& operator=(toml::node* val) noexcept + { + if (val != node_) + { + delete node_; + node_ = val; + } + return *this; + } + + node_ptr(const node_ptr&) = delete; + node_ptr& operator=(const node_ptr&) = delete; + node_ptr(node_ptr&&) = delete; + node_ptr& operator=(node_ptr&&) = delete; + + [[nodiscard]] + TOML_ATTR(pure) + operator bool() const noexcept + { + return node_ != nullptr; + } + + [[nodiscard]] + TOML_ATTR(pure) + toml::node* get() const noexcept + { + return node_; + } + + [[nodiscard]] + toml::node* release() noexcept + { + auto n = node_; + node_ = nullptr; + return n; + } + }; + struct parsed_key final { std::vector segments; @@ -8836,7 +9032,7 @@ TOML_ANON_NAMESPACE_START struct parsed_key_value_pair final { parsed_key key; - toml::node* value; + node_ptr value; }; } @@ -10395,7 +10591,7 @@ TOML_IMPL_NAMESPACE_START set_error_and_return_default("values may not begin with underscores"sv); const auto begin_pos = cp->position; - node* val{}; + node_ptr val; do { @@ -10611,17 +10807,17 @@ TOML_IMPL_NAMESPACE_START else if (has_any(has_x)) { val = new value{ parse_integer<16>() }; - reinterpret_cast*>(val)->flags(value_flags::format_as_hexadecimal); + reinterpret_cast*>(val.get())->flags(value_flags::format_as_hexadecimal); } else if (has_any(has_o)) { val = new value{ parse_integer<8>() }; - reinterpret_cast*>(val)->flags(value_flags::format_as_octal); + reinterpret_cast*>(val.get())->flags(value_flags::format_as_octal); } else if (has_any(has_b)) { val = new value{ parse_integer<2>() }; - reinterpret_cast*>(val)->flags(value_flags::format_as_binary); + reinterpret_cast*>(val.get())->flags(value_flags::format_as_binary); } else if (has_any(has_e) || (has_any(begins_zero | begins_digit) && chars[1] == U'.')) val = new value{ parse_float() }; @@ -10662,14 +10858,14 @@ TOML_IMPL_NAMESPACE_START // 0b10 case bzero_msk | has_b: val = new value{ parse_integer<2>() }; - reinterpret_cast*>(val)->flags(value_flags::format_as_binary); + reinterpret_cast*>(val.get())->flags(value_flags::format_as_binary); break; //=================== octal integers // 0o10 case bzero_msk | has_o: val = new value{ parse_integer<8>() }; - reinterpret_cast*>(val)->flags(value_flags::format_as_octal); + reinterpret_cast*>(val.get())->flags(value_flags::format_as_octal); break; //=================== decimal integers @@ -10688,7 +10884,7 @@ TOML_IMPL_NAMESPACE_START // 0x10 case bzero_msk | has_x: val = new value{ parse_integer<16>() }; - reinterpret_cast*>(val)->flags(value_flags::format_as_hexadecimal); + reinterpret_cast*>(val.get())->flags(value_flags::format_as_hexadecimal); break; //=================== decimal floats @@ -10862,8 +11058,8 @@ TOML_IMPL_NAMESPACE_START } #endif - val->source_ = { begin_pos, current_position(1), reader.source_path() }; - return val; + val.get()->source_ = { begin_pos, current_position(1), reader.source_path() }; + return val.release(); } [[nodiscard]] @@ -10880,7 +11076,7 @@ TOML_IMPL_NAMESPACE_START while (!is_error()) { #if TOML_LANG_UNRELEASED // toml/issues/687 (unicode bare keys) - if (is_unicode_combining_mark(*cp)) + if (is_combining_mark(*cp)) set_error_and_return_default("bare keys may not begin with unicode combining marks"sv); else #endif @@ -10965,7 +11161,7 @@ TOML_IMPL_NAMESPACE_START // get the value if (is_value_terminator(*cp)) set_error_and_return_default("expected value, saw '"sv, to_sv(*cp), "'"sv); - return { std::move(key), parse_value() }; + return { std::move(key), node_ptr{ parse_value() } }; } [[nodiscard]] @@ -11179,12 +11375,12 @@ TOML_IMPL_NAMESPACE_START ).first->second.get(); dotted_key_tables.push_back(&child->ref_cast
()); dotted_key_tables.back()->inline_ = true; - child->source_ = kvp.value->source_; + child->source_ = kvp.value.get()->source_; } else if (!child->is_table() || !find(dotted_key_tables, &child->ref_cast
())) set_error("cannot redefine existing "sv, to_sv(child->type()), " as dotted key-value pair"sv); else - child->source_.end = kvp.value->source_.end; + child->source_.end = kvp.value.get()->source_.end; return_if_error(); tab = &child->ref_cast
(); } @@ -11192,7 +11388,7 @@ TOML_IMPL_NAMESPACE_START if (auto conflicting_node = tab->get(kvp.key.segments.back())) { - if (conflicting_node->type() == kvp.value->type()) + if (conflicting_node->type() == kvp.value.get()->type()) set_error( "cannot redefine existing "sv, to_sv(conflicting_node->type()), " '"sv, to_sv(recording_buffer), "'"sv @@ -11201,14 +11397,14 @@ TOML_IMPL_NAMESPACE_START set_error( "cannot redefine existing "sv, to_sv(conflicting_node->type()), " '"sv, to_sv(recording_buffer), - "' as "sv, to_sv(kvp.value->type()) + "' as "sv, to_sv(kvp.value.get()->type()) ); } return_if_error(); tab->map.emplace( std::move(kvp.key.segments.back()), - std::unique_ptr{ kvp.value } + std::unique_ptr{ kvp.value.release() } ); } @@ -11361,8 +11557,8 @@ TOML_IMPL_NAMESPACE_START // skip opening '[' advance_and_return_if_error_or_eof({}); - auto arr = new array{}; - auto& vals = arr->elements; + node_ptr arr{ new array{} }; + auto& vals = reinterpret_cast(arr.get())->elements; enum parse_elem : int { none, @@ -11412,7 +11608,7 @@ TOML_IMPL_NAMESPACE_START } return_if_error({}); - return arr; + return reinterpret_cast(arr.release()); } TOML_EXTERNAL_LINKAGE @@ -11426,8 +11622,8 @@ TOML_IMPL_NAMESPACE_START // skip opening '{' advance_and_return_if_error_or_eof({}); - auto tab = new table{}; - tab->inline_ = true; + node_ptr tab{ new table{} }; + reinterpret_cast(tab.get())->inline_ = true; enum parse_elem : int { none, @@ -11487,7 +11683,7 @@ TOML_IMPL_NAMESPACE_START else { prev = kvp; - parse_key_value_pair_and_insert(tab); + parse_key_value_pair_and_insert(reinterpret_cast(tab.get())); } } @@ -11496,7 +11692,7 @@ TOML_IMPL_NAMESPACE_START } return_if_error({}); - return tab; + return reinterpret_cast(tab.release()); } TOML_API @@ -11823,6 +12019,7 @@ TOML_POP_WARNINGS // TOML_DISABLE_SPAM_WARNINGS #undef TOML_LANG_HIGHER_THAN #undef TOML_LANG_UNRELEASED #undef TOML_LAUNDER + #undef TOML_LIFETIME_HOOKS #undef TOML_LIKELY #undef TOML_MAKE_BITOPS #undef TOML_MAKE_VERSION diff --git a/vs/tests/test_debug_x64.vcxproj b/vs/tests/test_debug_x64.vcxproj index 8133b7ba..2f401abc 100644 --- a/vs/tests/test_debug_x64.vcxproj +++ b/vs/tests/test_debug_x64.vcxproj @@ -38,6 +38,7 @@ Use tests.h TOML_UNRELEASED_FEATURES=0;%(PreprocessorDefinitions) + LEAK_TESTS=1;%(PreprocessorDefinitions) _HAS_EXCEPTIONS=0;%(PreprocessorDefinitions) SHOULD_HAVE_EXCEPTIONS=0;%(PreprocessorDefinitions) SHOULD_HAVE_EXCEPTIONS=1;%(PreprocessorDefinitions) @@ -86,6 +87,7 @@ + diff --git a/vs/tests/test_debug_x64_cpplatest.vcxproj b/vs/tests/test_debug_x64_cpplatest.vcxproj index e3780ca9..bccf9365 100644 --- a/vs/tests/test_debug_x64_cpplatest.vcxproj +++ b/vs/tests/test_debug_x64_cpplatest.vcxproj @@ -38,6 +38,7 @@ Use tests.h TOML_UNRELEASED_FEATURES=0;%(PreprocessorDefinitions) + LEAK_TESTS=1;%(PreprocessorDefinitions) _HAS_EXCEPTIONS=0;%(PreprocessorDefinitions) SHOULD_HAVE_EXCEPTIONS=0;%(PreprocessorDefinitions) SHOULD_HAVE_EXCEPTIONS=1;%(PreprocessorDefinitions) @@ -86,6 +87,7 @@ + diff --git a/vs/tests/test_debug_x64_cpplatest_noexcept.vcxproj b/vs/tests/test_debug_x64_cpplatest_noexcept.vcxproj index c1d5a275..72e753f9 100644 --- a/vs/tests/test_debug_x64_cpplatest_noexcept.vcxproj +++ b/vs/tests/test_debug_x64_cpplatest_noexcept.vcxproj @@ -38,6 +38,7 @@ Use tests.h TOML_UNRELEASED_FEATURES=0;%(PreprocessorDefinitions) + LEAK_TESTS=1;%(PreprocessorDefinitions) _HAS_EXCEPTIONS=0;%(PreprocessorDefinitions) SHOULD_HAVE_EXCEPTIONS=0;%(PreprocessorDefinitions) SHOULD_HAVE_EXCEPTIONS=1;%(PreprocessorDefinitions) @@ -86,6 +87,7 @@ + diff --git a/vs/tests/test_debug_x64_cpplatest_noexcept_unrel.vcxproj b/vs/tests/test_debug_x64_cpplatest_noexcept_unrel.vcxproj index 3b961d9d..ababa99d 100644 --- a/vs/tests/test_debug_x64_cpplatest_noexcept_unrel.vcxproj +++ b/vs/tests/test_debug_x64_cpplatest_noexcept_unrel.vcxproj @@ -38,6 +38,7 @@ Use tests.h TOML_UNRELEASED_FEATURES=1;%(PreprocessorDefinitions) + LEAK_TESTS=1;%(PreprocessorDefinitions) _HAS_EXCEPTIONS=0;%(PreprocessorDefinitions) SHOULD_HAVE_EXCEPTIONS=0;%(PreprocessorDefinitions) SHOULD_HAVE_EXCEPTIONS=1;%(PreprocessorDefinitions) @@ -86,6 +87,7 @@ + diff --git a/vs/tests/test_debug_x64_cpplatest_unrel.vcxproj b/vs/tests/test_debug_x64_cpplatest_unrel.vcxproj index c3b4f7e5..f8e2e31e 100644 --- a/vs/tests/test_debug_x64_cpplatest_unrel.vcxproj +++ b/vs/tests/test_debug_x64_cpplatest_unrel.vcxproj @@ -38,6 +38,7 @@ Use tests.h TOML_UNRELEASED_FEATURES=1;%(PreprocessorDefinitions) + LEAK_TESTS=1;%(PreprocessorDefinitions) _HAS_EXCEPTIONS=0;%(PreprocessorDefinitions) SHOULD_HAVE_EXCEPTIONS=0;%(PreprocessorDefinitions) SHOULD_HAVE_EXCEPTIONS=1;%(PreprocessorDefinitions) @@ -86,6 +87,7 @@ + diff --git a/vs/tests/test_debug_x64_noexcept.vcxproj b/vs/tests/test_debug_x64_noexcept.vcxproj index c13724dc..52643063 100644 --- a/vs/tests/test_debug_x64_noexcept.vcxproj +++ b/vs/tests/test_debug_x64_noexcept.vcxproj @@ -38,6 +38,7 @@ Use tests.h TOML_UNRELEASED_FEATURES=0;%(PreprocessorDefinitions) + LEAK_TESTS=1;%(PreprocessorDefinitions) _HAS_EXCEPTIONS=0;%(PreprocessorDefinitions) SHOULD_HAVE_EXCEPTIONS=0;%(PreprocessorDefinitions) SHOULD_HAVE_EXCEPTIONS=1;%(PreprocessorDefinitions) @@ -86,6 +87,7 @@ + diff --git a/vs/tests/test_debug_x64_noexcept_unrel.vcxproj b/vs/tests/test_debug_x64_noexcept_unrel.vcxproj index f4dbda96..d2a0a44e 100644 --- a/vs/tests/test_debug_x64_noexcept_unrel.vcxproj +++ b/vs/tests/test_debug_x64_noexcept_unrel.vcxproj @@ -38,6 +38,7 @@ Use tests.h TOML_UNRELEASED_FEATURES=1;%(PreprocessorDefinitions) + LEAK_TESTS=1;%(PreprocessorDefinitions) _HAS_EXCEPTIONS=0;%(PreprocessorDefinitions) SHOULD_HAVE_EXCEPTIONS=0;%(PreprocessorDefinitions) SHOULD_HAVE_EXCEPTIONS=1;%(PreprocessorDefinitions) @@ -86,6 +87,7 @@ + diff --git a/vs/tests/test_debug_x64_unrel.vcxproj b/vs/tests/test_debug_x64_unrel.vcxproj index c08bca33..57e4b33d 100644 --- a/vs/tests/test_debug_x64_unrel.vcxproj +++ b/vs/tests/test_debug_x64_unrel.vcxproj @@ -38,6 +38,7 @@ Use tests.h TOML_UNRELEASED_FEATURES=1;%(PreprocessorDefinitions) + LEAK_TESTS=1;%(PreprocessorDefinitions) _HAS_EXCEPTIONS=0;%(PreprocessorDefinitions) SHOULD_HAVE_EXCEPTIONS=0;%(PreprocessorDefinitions) SHOULD_HAVE_EXCEPTIONS=1;%(PreprocessorDefinitions) @@ -86,6 +87,7 @@ + diff --git a/vs/tests/test_debug_x86.vcxproj b/vs/tests/test_debug_x86.vcxproj index 71aced41..cbaa4351 100644 --- a/vs/tests/test_debug_x86.vcxproj +++ b/vs/tests/test_debug_x86.vcxproj @@ -38,6 +38,7 @@ Use tests.h TOML_UNRELEASED_FEATURES=0;%(PreprocessorDefinitions) + LEAK_TESTS=1;%(PreprocessorDefinitions) _HAS_EXCEPTIONS=0;%(PreprocessorDefinitions) SHOULD_HAVE_EXCEPTIONS=0;%(PreprocessorDefinitions) SHOULD_HAVE_EXCEPTIONS=1;%(PreprocessorDefinitions) @@ -86,6 +87,7 @@ + diff --git a/vs/tests/test_debug_x86_cpplatest.vcxproj b/vs/tests/test_debug_x86_cpplatest.vcxproj index 67ab2ac0..268b4757 100644 --- a/vs/tests/test_debug_x86_cpplatest.vcxproj +++ b/vs/tests/test_debug_x86_cpplatest.vcxproj @@ -38,6 +38,7 @@ Use tests.h TOML_UNRELEASED_FEATURES=0;%(PreprocessorDefinitions) + LEAK_TESTS=1;%(PreprocessorDefinitions) _HAS_EXCEPTIONS=0;%(PreprocessorDefinitions) SHOULD_HAVE_EXCEPTIONS=0;%(PreprocessorDefinitions) SHOULD_HAVE_EXCEPTIONS=1;%(PreprocessorDefinitions) @@ -86,6 +87,7 @@ + diff --git a/vs/tests/test_debug_x86_cpplatest_noexcept.vcxproj b/vs/tests/test_debug_x86_cpplatest_noexcept.vcxproj index bf2e67e0..5bdddf7d 100644 --- a/vs/tests/test_debug_x86_cpplatest_noexcept.vcxproj +++ b/vs/tests/test_debug_x86_cpplatest_noexcept.vcxproj @@ -38,6 +38,7 @@ Use tests.h TOML_UNRELEASED_FEATURES=0;%(PreprocessorDefinitions) + LEAK_TESTS=1;%(PreprocessorDefinitions) _HAS_EXCEPTIONS=0;%(PreprocessorDefinitions) SHOULD_HAVE_EXCEPTIONS=0;%(PreprocessorDefinitions) SHOULD_HAVE_EXCEPTIONS=1;%(PreprocessorDefinitions) @@ -86,6 +87,7 @@ + diff --git a/vs/tests/test_debug_x86_cpplatest_noexcept_unrel.vcxproj b/vs/tests/test_debug_x86_cpplatest_noexcept_unrel.vcxproj index 52cea097..462a7306 100644 --- a/vs/tests/test_debug_x86_cpplatest_noexcept_unrel.vcxproj +++ b/vs/tests/test_debug_x86_cpplatest_noexcept_unrel.vcxproj @@ -38,6 +38,7 @@ Use tests.h TOML_UNRELEASED_FEATURES=1;%(PreprocessorDefinitions) + LEAK_TESTS=1;%(PreprocessorDefinitions) _HAS_EXCEPTIONS=0;%(PreprocessorDefinitions) SHOULD_HAVE_EXCEPTIONS=0;%(PreprocessorDefinitions) SHOULD_HAVE_EXCEPTIONS=1;%(PreprocessorDefinitions) @@ -86,6 +87,7 @@ + diff --git a/vs/tests/test_debug_x86_cpplatest_unrel.vcxproj b/vs/tests/test_debug_x86_cpplatest_unrel.vcxproj index 7ee61496..d39d4375 100644 --- a/vs/tests/test_debug_x86_cpplatest_unrel.vcxproj +++ b/vs/tests/test_debug_x86_cpplatest_unrel.vcxproj @@ -38,6 +38,7 @@ Use tests.h TOML_UNRELEASED_FEATURES=1;%(PreprocessorDefinitions) + LEAK_TESTS=1;%(PreprocessorDefinitions) _HAS_EXCEPTIONS=0;%(PreprocessorDefinitions) SHOULD_HAVE_EXCEPTIONS=0;%(PreprocessorDefinitions) SHOULD_HAVE_EXCEPTIONS=1;%(PreprocessorDefinitions) @@ -86,6 +87,7 @@ + diff --git a/vs/tests/test_debug_x86_noexcept.vcxproj b/vs/tests/test_debug_x86_noexcept.vcxproj index 7c09af4b..cb5f3f21 100644 --- a/vs/tests/test_debug_x86_noexcept.vcxproj +++ b/vs/tests/test_debug_x86_noexcept.vcxproj @@ -38,6 +38,7 @@ Use tests.h TOML_UNRELEASED_FEATURES=0;%(PreprocessorDefinitions) + LEAK_TESTS=1;%(PreprocessorDefinitions) _HAS_EXCEPTIONS=0;%(PreprocessorDefinitions) SHOULD_HAVE_EXCEPTIONS=0;%(PreprocessorDefinitions) SHOULD_HAVE_EXCEPTIONS=1;%(PreprocessorDefinitions) @@ -86,6 +87,7 @@ + diff --git a/vs/tests/test_debug_x86_noexcept_unrel.vcxproj b/vs/tests/test_debug_x86_noexcept_unrel.vcxproj index 7350aa46..3f558d5b 100644 --- a/vs/tests/test_debug_x86_noexcept_unrel.vcxproj +++ b/vs/tests/test_debug_x86_noexcept_unrel.vcxproj @@ -38,6 +38,7 @@ Use tests.h TOML_UNRELEASED_FEATURES=1;%(PreprocessorDefinitions) + LEAK_TESTS=1;%(PreprocessorDefinitions) _HAS_EXCEPTIONS=0;%(PreprocessorDefinitions) SHOULD_HAVE_EXCEPTIONS=0;%(PreprocessorDefinitions) SHOULD_HAVE_EXCEPTIONS=1;%(PreprocessorDefinitions) @@ -86,6 +87,7 @@ + diff --git a/vs/tests/test_debug_x86_unrel.vcxproj b/vs/tests/test_debug_x86_unrel.vcxproj index 89ee074f..99d8da96 100644 --- a/vs/tests/test_debug_x86_unrel.vcxproj +++ b/vs/tests/test_debug_x86_unrel.vcxproj @@ -38,6 +38,7 @@ Use tests.h TOML_UNRELEASED_FEATURES=1;%(PreprocessorDefinitions) + LEAK_TESTS=1;%(PreprocessorDefinitions) _HAS_EXCEPTIONS=0;%(PreprocessorDefinitions) SHOULD_HAVE_EXCEPTIONS=0;%(PreprocessorDefinitions) SHOULD_HAVE_EXCEPTIONS=1;%(PreprocessorDefinitions) @@ -86,6 +87,7 @@ + diff --git a/vs/tests/test_release_x64.vcxproj b/vs/tests/test_release_x64.vcxproj index 2ab11489..fd2b71ff 100644 --- a/vs/tests/test_release_x64.vcxproj +++ b/vs/tests/test_release_x64.vcxproj @@ -38,6 +38,7 @@ Use tests.h TOML_UNRELEASED_FEATURES=0;%(PreprocessorDefinitions) + LEAK_TESTS=1;%(PreprocessorDefinitions) _HAS_EXCEPTIONS=0;%(PreprocessorDefinitions) SHOULD_HAVE_EXCEPTIONS=0;%(PreprocessorDefinitions) SHOULD_HAVE_EXCEPTIONS=1;%(PreprocessorDefinitions) @@ -86,6 +87,7 @@ + diff --git a/vs/tests/test_release_x64_cpplatest.vcxproj b/vs/tests/test_release_x64_cpplatest.vcxproj index 9eb8ca4e..a3b3ce58 100644 --- a/vs/tests/test_release_x64_cpplatest.vcxproj +++ b/vs/tests/test_release_x64_cpplatest.vcxproj @@ -38,6 +38,7 @@ Use tests.h TOML_UNRELEASED_FEATURES=0;%(PreprocessorDefinitions) + LEAK_TESTS=1;%(PreprocessorDefinitions) _HAS_EXCEPTIONS=0;%(PreprocessorDefinitions) SHOULD_HAVE_EXCEPTIONS=0;%(PreprocessorDefinitions) SHOULD_HAVE_EXCEPTIONS=1;%(PreprocessorDefinitions) @@ -86,6 +87,7 @@ + diff --git a/vs/tests/test_release_x64_cpplatest_noexcept.vcxproj b/vs/tests/test_release_x64_cpplatest_noexcept.vcxproj index ceed3913..f0ed3858 100644 --- a/vs/tests/test_release_x64_cpplatest_noexcept.vcxproj +++ b/vs/tests/test_release_x64_cpplatest_noexcept.vcxproj @@ -38,6 +38,7 @@ Use tests.h TOML_UNRELEASED_FEATURES=0;%(PreprocessorDefinitions) + LEAK_TESTS=1;%(PreprocessorDefinitions) _HAS_EXCEPTIONS=0;%(PreprocessorDefinitions) SHOULD_HAVE_EXCEPTIONS=0;%(PreprocessorDefinitions) SHOULD_HAVE_EXCEPTIONS=1;%(PreprocessorDefinitions) @@ -86,6 +87,7 @@ + diff --git a/vs/tests/test_release_x64_cpplatest_noexcept_unrel.vcxproj b/vs/tests/test_release_x64_cpplatest_noexcept_unrel.vcxproj index 7ff416c1..3576acdc 100644 --- a/vs/tests/test_release_x64_cpplatest_noexcept_unrel.vcxproj +++ b/vs/tests/test_release_x64_cpplatest_noexcept_unrel.vcxproj @@ -38,6 +38,7 @@ Use tests.h TOML_UNRELEASED_FEATURES=1;%(PreprocessorDefinitions) + LEAK_TESTS=1;%(PreprocessorDefinitions) _HAS_EXCEPTIONS=0;%(PreprocessorDefinitions) SHOULD_HAVE_EXCEPTIONS=0;%(PreprocessorDefinitions) SHOULD_HAVE_EXCEPTIONS=1;%(PreprocessorDefinitions) @@ -86,6 +87,7 @@ + diff --git a/vs/tests/test_release_x64_cpplatest_unrel.vcxproj b/vs/tests/test_release_x64_cpplatest_unrel.vcxproj index 5445c2eb..97d927f3 100644 --- a/vs/tests/test_release_x64_cpplatest_unrel.vcxproj +++ b/vs/tests/test_release_x64_cpplatest_unrel.vcxproj @@ -38,6 +38,7 @@ Use tests.h TOML_UNRELEASED_FEATURES=1;%(PreprocessorDefinitions) + LEAK_TESTS=1;%(PreprocessorDefinitions) _HAS_EXCEPTIONS=0;%(PreprocessorDefinitions) SHOULD_HAVE_EXCEPTIONS=0;%(PreprocessorDefinitions) SHOULD_HAVE_EXCEPTIONS=1;%(PreprocessorDefinitions) @@ -86,6 +87,7 @@ + diff --git a/vs/tests/test_release_x64_noexcept.vcxproj b/vs/tests/test_release_x64_noexcept.vcxproj index 7d7bbc14..a7a4a312 100644 --- a/vs/tests/test_release_x64_noexcept.vcxproj +++ b/vs/tests/test_release_x64_noexcept.vcxproj @@ -38,6 +38,7 @@ Use tests.h TOML_UNRELEASED_FEATURES=0;%(PreprocessorDefinitions) + LEAK_TESTS=1;%(PreprocessorDefinitions) _HAS_EXCEPTIONS=0;%(PreprocessorDefinitions) SHOULD_HAVE_EXCEPTIONS=0;%(PreprocessorDefinitions) SHOULD_HAVE_EXCEPTIONS=1;%(PreprocessorDefinitions) @@ -86,6 +87,7 @@ + diff --git a/vs/tests/test_release_x64_noexcept_unrel.vcxproj b/vs/tests/test_release_x64_noexcept_unrel.vcxproj index bc8a2188..eb0c2ed7 100644 --- a/vs/tests/test_release_x64_noexcept_unrel.vcxproj +++ b/vs/tests/test_release_x64_noexcept_unrel.vcxproj @@ -38,6 +38,7 @@ Use tests.h TOML_UNRELEASED_FEATURES=1;%(PreprocessorDefinitions) + LEAK_TESTS=1;%(PreprocessorDefinitions) _HAS_EXCEPTIONS=0;%(PreprocessorDefinitions) SHOULD_HAVE_EXCEPTIONS=0;%(PreprocessorDefinitions) SHOULD_HAVE_EXCEPTIONS=1;%(PreprocessorDefinitions) @@ -86,6 +87,7 @@ + diff --git a/vs/tests/test_release_x64_unrel.vcxproj b/vs/tests/test_release_x64_unrel.vcxproj index 7357c0c4..0d95ae37 100644 --- a/vs/tests/test_release_x64_unrel.vcxproj +++ b/vs/tests/test_release_x64_unrel.vcxproj @@ -38,6 +38,7 @@ Use tests.h TOML_UNRELEASED_FEATURES=1;%(PreprocessorDefinitions) + LEAK_TESTS=1;%(PreprocessorDefinitions) _HAS_EXCEPTIONS=0;%(PreprocessorDefinitions) SHOULD_HAVE_EXCEPTIONS=0;%(PreprocessorDefinitions) SHOULD_HAVE_EXCEPTIONS=1;%(PreprocessorDefinitions) @@ -86,6 +87,7 @@ + diff --git a/vs/tests/test_release_x86.vcxproj b/vs/tests/test_release_x86.vcxproj index f7e452d6..ce59380a 100644 --- a/vs/tests/test_release_x86.vcxproj +++ b/vs/tests/test_release_x86.vcxproj @@ -38,6 +38,7 @@ Use tests.h TOML_UNRELEASED_FEATURES=0;%(PreprocessorDefinitions) + LEAK_TESTS=1;%(PreprocessorDefinitions) _HAS_EXCEPTIONS=0;%(PreprocessorDefinitions) SHOULD_HAVE_EXCEPTIONS=0;%(PreprocessorDefinitions) SHOULD_HAVE_EXCEPTIONS=1;%(PreprocessorDefinitions) @@ -86,6 +87,7 @@ + diff --git a/vs/tests/test_release_x86_cpplatest.vcxproj b/vs/tests/test_release_x86_cpplatest.vcxproj index 4e0fd645..a5cfbaeb 100644 --- a/vs/tests/test_release_x86_cpplatest.vcxproj +++ b/vs/tests/test_release_x86_cpplatest.vcxproj @@ -38,6 +38,7 @@ Use tests.h TOML_UNRELEASED_FEATURES=0;%(PreprocessorDefinitions) + LEAK_TESTS=1;%(PreprocessorDefinitions) _HAS_EXCEPTIONS=0;%(PreprocessorDefinitions) SHOULD_HAVE_EXCEPTIONS=0;%(PreprocessorDefinitions) SHOULD_HAVE_EXCEPTIONS=1;%(PreprocessorDefinitions) @@ -86,6 +87,7 @@ + diff --git a/vs/tests/test_release_x86_cpplatest_noexcept.vcxproj b/vs/tests/test_release_x86_cpplatest_noexcept.vcxproj index 7473a5e3..b2bd7fd4 100644 --- a/vs/tests/test_release_x86_cpplatest_noexcept.vcxproj +++ b/vs/tests/test_release_x86_cpplatest_noexcept.vcxproj @@ -38,6 +38,7 @@ Use tests.h TOML_UNRELEASED_FEATURES=0;%(PreprocessorDefinitions) + LEAK_TESTS=1;%(PreprocessorDefinitions) _HAS_EXCEPTIONS=0;%(PreprocessorDefinitions) SHOULD_HAVE_EXCEPTIONS=0;%(PreprocessorDefinitions) SHOULD_HAVE_EXCEPTIONS=1;%(PreprocessorDefinitions) @@ -86,6 +87,7 @@ + diff --git a/vs/tests/test_release_x86_cpplatest_noexcept_unrel.vcxproj b/vs/tests/test_release_x86_cpplatest_noexcept_unrel.vcxproj index 5fc4a691..b42177df 100644 --- a/vs/tests/test_release_x86_cpplatest_noexcept_unrel.vcxproj +++ b/vs/tests/test_release_x86_cpplatest_noexcept_unrel.vcxproj @@ -38,6 +38,7 @@ Use tests.h TOML_UNRELEASED_FEATURES=1;%(PreprocessorDefinitions) + LEAK_TESTS=1;%(PreprocessorDefinitions) _HAS_EXCEPTIONS=0;%(PreprocessorDefinitions) SHOULD_HAVE_EXCEPTIONS=0;%(PreprocessorDefinitions) SHOULD_HAVE_EXCEPTIONS=1;%(PreprocessorDefinitions) @@ -86,6 +87,7 @@ + diff --git a/vs/tests/test_release_x86_cpplatest_unrel.vcxproj b/vs/tests/test_release_x86_cpplatest_unrel.vcxproj index eff25825..a1ca6545 100644 --- a/vs/tests/test_release_x86_cpplatest_unrel.vcxproj +++ b/vs/tests/test_release_x86_cpplatest_unrel.vcxproj @@ -38,6 +38,7 @@ Use tests.h TOML_UNRELEASED_FEATURES=1;%(PreprocessorDefinitions) + LEAK_TESTS=1;%(PreprocessorDefinitions) _HAS_EXCEPTIONS=0;%(PreprocessorDefinitions) SHOULD_HAVE_EXCEPTIONS=0;%(PreprocessorDefinitions) SHOULD_HAVE_EXCEPTIONS=1;%(PreprocessorDefinitions) @@ -86,6 +87,7 @@ + diff --git a/vs/tests/test_release_x86_noexcept.vcxproj b/vs/tests/test_release_x86_noexcept.vcxproj index 371acc26..074bb226 100644 --- a/vs/tests/test_release_x86_noexcept.vcxproj +++ b/vs/tests/test_release_x86_noexcept.vcxproj @@ -38,6 +38,7 @@ Use tests.h TOML_UNRELEASED_FEATURES=0;%(PreprocessorDefinitions) + LEAK_TESTS=1;%(PreprocessorDefinitions) _HAS_EXCEPTIONS=0;%(PreprocessorDefinitions) SHOULD_HAVE_EXCEPTIONS=0;%(PreprocessorDefinitions) SHOULD_HAVE_EXCEPTIONS=1;%(PreprocessorDefinitions) @@ -86,6 +87,7 @@ + diff --git a/vs/tests/test_release_x86_noexcept_unrel.vcxproj b/vs/tests/test_release_x86_noexcept_unrel.vcxproj index 468fd77a..672f9cb9 100644 --- a/vs/tests/test_release_x86_noexcept_unrel.vcxproj +++ b/vs/tests/test_release_x86_noexcept_unrel.vcxproj @@ -38,6 +38,7 @@ Use tests.h TOML_UNRELEASED_FEATURES=1;%(PreprocessorDefinitions) + LEAK_TESTS=1;%(PreprocessorDefinitions) _HAS_EXCEPTIONS=0;%(PreprocessorDefinitions) SHOULD_HAVE_EXCEPTIONS=0;%(PreprocessorDefinitions) SHOULD_HAVE_EXCEPTIONS=1;%(PreprocessorDefinitions) @@ -86,6 +87,7 @@ + diff --git a/vs/tests/test_release_x86_unrel.vcxproj b/vs/tests/test_release_x86_unrel.vcxproj index bdec6871..ef61035f 100644 --- a/vs/tests/test_release_x86_unrel.vcxproj +++ b/vs/tests/test_release_x86_unrel.vcxproj @@ -38,6 +38,7 @@ Use tests.h TOML_UNRELEASED_FEATURES=1;%(PreprocessorDefinitions) + LEAK_TESTS=1;%(PreprocessorDefinitions) _HAS_EXCEPTIONS=0;%(PreprocessorDefinitions) SHOULD_HAVE_EXCEPTIONS=0;%(PreprocessorDefinitions) SHOULD_HAVE_EXCEPTIONS=1;%(PreprocessorDefinitions) @@ -86,6 +87,7 @@ + diff --git a/vs/toml++.vcxproj b/vs/toml++.vcxproj index 7d38a374..bb3fa9cc 100644 --- a/vs/toml++.vcxproj +++ b/vs/toml++.vcxproj @@ -71,8 +71,8 @@ - - + + @@ -89,6 +89,7 @@ + \ No newline at end of file diff --git a/vs/toml++.vcxproj.filters b/vs/toml++.vcxproj.filters index 6249edc0..d945f2a4 100644 --- a/vs/toml++.vcxproj.filters +++ b/vs/toml++.vcxproj.filters @@ -98,12 +98,6 @@ docs - - docs - - - docs - @@ -123,6 +117,12 @@ + + docs + + + docs + @@ -140,5 +140,8 @@ + + python + \ No newline at end of file