From 7da912c45e6d3c1e172267b3859a98013c33f85b Mon Sep 17 00:00:00 2001 From: Mark Gillard Date: Tue, 26 Oct 2021 00:49:17 +0300 Subject: [PATCH] fixed incorrect clang+GCC flag in meson build script also: - renamed `_impl.h` files to `*.inl` - simplified warning + namespace management boilerplate - applied clang-format to examples - bumped minimum required meson version to `0.54.0` --- examples/error_printer.cpp | 11 +- examples/examples.h | 28 ++-- examples/toml_generator.cpp | 158 ++++++++---------- examples/toml_to_json_transcoder.cpp | 1 - .../toml++/impl/{array_impl.h => array.inl} | 8 - ...formatter_impl.h => default_formatter.inl} | 3 +- .../impl/{formatter_impl.h => formatter.inl} | 2 - ...on_formatter_impl.h => json_formatter.inl} | 2 - include/toml++/impl/{node_impl.h => node.inl} | 2 - include/toml++/impl/node_view.h | 1 + .../impl/{node_view_impl.h => node_view.inl} | 2 - include/toml++/impl/parse_error.h | 1 - .../toml++/impl/{parser_impl.h => parser.inl} | 13 -- include/toml++/impl/preprocessor.h | 46 ++--- ...t_to_stream_impl.h => print_to_stream.inl} | 14 +- .../{std_string_impl.h => std_string.inl} | 2 - .../toml++/impl/{table_impl.h => table.inl} | 8 - include/toml++/impl/value.h | 1 + .../toml++/impl/{value_impl.h => value.inl} | 2 - include/toml++/toml.h | 35 ++-- meson.build | 8 +- tests/{impl_catch2.cpp => main.cpp} | 0 tests/meson.build | 2 +- tests/parsing_dates_and_times.cpp | 39 ++--- tests/parsing_spec_example.cpp | 88 +++++----- tests/vs/test_debug_x64.vcxproj | 4 +- tests/vs/test_debug_x64_cpplatest.vcxproj | 4 +- .../test_debug_x64_cpplatest_noexcept.vcxproj | 4 +- ...debug_x64_cpplatest_noexcept_unrel.vcxproj | 4 +- .../vs/test_debug_x64_cpplatest_unrel.vcxproj | 4 +- tests/vs/test_debug_x64_noexcept.vcxproj | 4 +- .../vs/test_debug_x64_noexcept_unrel.vcxproj | 4 +- tests/vs/test_debug_x64_unrel.vcxproj | 4 +- tests/vs/test_debug_x86.vcxproj | 4 +- tests/vs/test_debug_x86_cpplatest.vcxproj | 4 +- .../test_debug_x86_cpplatest_noexcept.vcxproj | 4 +- ...debug_x86_cpplatest_noexcept_unrel.vcxproj | 4 +- .../vs/test_debug_x86_cpplatest_unrel.vcxproj | 4 +- tests/vs/test_debug_x86_noexcept.vcxproj | 4 +- .../vs/test_debug_x86_noexcept_unrel.vcxproj | 4 +- tests/vs/test_debug_x86_unrel.vcxproj | 4 +- tests/vs/test_release_x64.vcxproj | 4 +- tests/vs/test_release_x64_cpplatest.vcxproj | 4 +- ...est_release_x64_cpplatest_noexcept.vcxproj | 4 +- ...lease_x64_cpplatest_noexcept_unrel.vcxproj | 4 +- .../test_release_x64_cpplatest_unrel.vcxproj | 4 +- tests/vs/test_release_x64_noexcept.vcxproj | 4 +- .../test_release_x64_noexcept_unrel.vcxproj | 4 +- tests/vs/test_release_x64_unrel.vcxproj | 4 +- tests/vs/test_release_x86.vcxproj | 4 +- tests/vs/test_release_x86_cpplatest.vcxproj | 4 +- ...est_release_x86_cpplatest_noexcept.vcxproj | 4 +- ...lease_x86_cpplatest_noexcept_unrel.vcxproj | 4 +- .../test_release_x86_cpplatest_unrel.vcxproj | 4 +- tests/vs/test_release_x86_noexcept.vcxproj | 4 +- .../test_release_x86_noexcept_unrel.vcxproj | 4 +- tests/vs/test_release_x86_unrel.vcxproj | 4 +- toml++.vcxproj | 23 +-- toml++.vcxproj.filters | 25 +-- toml.hpp | 120 ++++--------- tools/clang_format.bat | 33 ++++ tools/generate_single_header.py | 7 +- tools/generate_windows_test_targets.py | 4 +- 63 files changed, 346 insertions(+), 471 deletions(-) rename include/toml++/impl/{array_impl.h => array.inl} (98%) rename include/toml++/impl/{default_formatter_impl.h => default_formatter.inl} (99%) rename include/toml++/impl/{formatter_impl.h => formatter.inl} (99%) rename include/toml++/impl/{json_formatter_impl.h => json_formatter.inl} (99%) rename include/toml++/impl/{node_impl.h => node.inl} (98%) rename include/toml++/impl/{node_view_impl.h => node_view.inl} (99%) rename include/toml++/impl/{parser_impl.h => parser.inl} (99%) rename include/toml++/impl/{print_to_stream_impl.h => print_to_stream.inl} (98%) rename include/toml++/impl/{std_string_impl.h => std_string.inl} (99%) rename include/toml++/impl/{table_impl.h => table.inl} (97%) rename include/toml++/impl/{value_impl.h => value.inl} (99%) rename tests/{impl_catch2.cpp => main.cpp} (100%) create mode 100644 tools/clang_format.bat diff --git a/examples/error_printer.cpp b/examples/error_printer.cpp index 6c00fc7..94c9943 100644 --- a/examples/error_printer.cpp +++ b/examples/error_printer.cpp @@ -8,7 +8,7 @@ #include "examples.h" -#define TOML_EXCEPTIONS 0 +#define TOML_EXCEPTIONS 0 #define TOML_UNRELEASED_FEATURES 0 #include @@ -16,8 +16,7 @@ using namespace std::string_view_literals; namespace { - inline constexpr auto invalid_parses = std::array - { + inline constexpr auto invalid_parses = std::array{ "########## comments"sv, "# bar\rkek"sv, "# bar\bkek"sv, @@ -25,10 +24,10 @@ namespace "########## inline tables"sv, "val = {,}"sv, - "val = {a='b',}"sv, // allowed when TOML_UNRELEASED_FEATURES == 1 + "val = {a='b',}"sv, // allowed when TOML_UNRELEASED_FEATURES == 1 "val = {a='b',,}"sv, "val = {a='b',"sv, - "val = {a='b',\n c='d'}"sv, // allowed when TOML_UNRELEASED_FEATURES == 1 + "val = {a='b',\n c='d'}"sv, // allowed when TOML_UNRELEASED_FEATURES == 1 "val = {?='b'}"sv, "########## tables"sv, @@ -69,7 +68,7 @@ namespace "val = \" \r \""sv, R"(val = ")"sv, R"(val = "\g")"sv, - R"(val = "\x20")"sv, // allowed when TOML_UNRELEASED_FEATURES == 1 + R"(val = "\x20")"sv, // allowed when TOML_UNRELEASED_FEATURES == 1 R"(val = "\uFFF")"sv, R"(val = "\uFFFG")"sv, R"(val = "\UFFFFFFF")"sv, diff --git a/examples/examples.h b/examples/examples.h index f028e74..716a2d5 100644 --- a/examples/examples.h +++ b/examples/examples.h @@ -6,14 +6,14 @@ // this file is for boilerplate unrelated to the toml++ example learning outcomes. #ifdef __clang__ - #pragma clang diagnostic push - #pragma clang diagnostic ignored "-Weverything" -#elif defined (__GNUC__) - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wall" - #pragma GCC diagnostic ignored "-Wextra" +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Weverything" +#elif defined(__GNUC__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wall" +#pragma GCC diagnostic ignored "-Wextra" #elif defined(_MSC_VER) - #pragma warning(push, 0) +#pragma warning(push, 0) #endif #include @@ -25,24 +25,24 @@ #include #include #ifdef _WIN32 - #include +#include #endif #ifdef __clang__ - #pragma clang diagnostic pop +#pragma clang diagnostic pop #elif defined(__GNUC__) - #pragma GCC diagnostic pop +#pragma GCC diagnostic pop #elif defined(_MSC_VER) - #pragma warning(pop) +#pragma warning(pop) #endif namespace examples { inline void init() noexcept { - #ifdef _WIN32 - SetConsoleOutputCP(65001); //CP_UTF8 - #endif +#ifdef _WIN32 + SetConsoleOutputCP(65001); // CP_UTF8 +#endif std::ios_base::sync_with_stdio(false); std::cout << std::boolalpha; diff --git a/examples/toml_generator.cpp b/examples/toml_generator.cpp index 89d2997..41a3c23 100644 --- a/examples/toml_generator.cpp +++ b/examples/toml_generator.cpp @@ -14,77 +14,68 @@ using namespace std::string_view_literals; namespace { - inline constexpr auto words = std::array - { - "acceptable"sv, "contain"sv, "ghost"sv, "mark"sv, "respect"sv, "taboo"sv, - "actually"sv, "cream"sv, "gleaming"sv, "meaty"sv, "rest"sv, "tacky"sv, - "addition"sv, "creature"sv, "glorious"sv, "memory"sv, "rice"sv, "tank"sv, - "adhesive"sv, "crime"sv, "gold"sv, "messy"sv, "rich"sv, "tent"sv, - "adorable"sv, "cross"sv, "grandfather"sv, "miss"sv, "righteous"sv, "terrible"sv, - "advise"sv, "crowded"sv, "gusty"sv, "modern"sv, "room"sv, "threatening"sv, - "afraid"sv, "crown"sv, "haircut"sv, "morning"sv, "rotten"sv, "three"sv, - "ancient"sv, "cure"sv, "hard-to-find"sv, "naughty"sv, "royal"sv, "ticket"sv, - "anxious"sv, "curious"sv, "harm"sv, "neck"sv, "run"sv, "title"sv, - "aromatic"sv, "curtain"sv, "heavy"sv, "night"sv, "satisfy"sv, "torpid"sv, - "attempt"sv, "cycle"sv, "helpless"sv, "nondescript"sv, "scary"sv, "train"sv, - "babies"sv, "deadpan"sv, "high-pitched"sv, "overjoyed"sv, "scatter"sv, "umbrella"sv, - "bake"sv, "decisive"sv, "hilarious"sv, "page"sv, "scene"sv, "unadvised"sv, - "ball"sv, "deeply"sv, "history"sv, "partner"sv, "scintillating"sv, "unbecoming"sv, - "bat"sv, "delightful"sv, "hook"sv, "party"sv, "self"sv, "unbiased"sv, - "behave"sv, "deserted"sv, "ignore"sv, "pause"sv, "selfish"sv, "unite"sv, - "best"sv, "draconian"sv, "imperfect"sv, "pear"sv, "silky"sv, "uptight"sv, - "birds"sv, "dreary"sv, "impossible"sv, "picture"sv, "sisters"sv, "used"sv, - "blind"sv, "dull"sv, "incandescent"sv, "place"sv, "ski"sv, "vengeful"sv, - "blood"sv, "enthusiastic"sv, "influence"sv, "playground"sv, "skip"sv, "versed"sv, - "blue-eyed"sv, "equable"sv, "innocent"sv, "popcorn"sv, "snow"sv, "vessel"sv, - "boiling"sv, "excuse"sv, "insidious"sv, "prefer"sv, "soap"sv, "view"sv, - "bore"sv, "experience"sv, "itch"sv, "productive"sv, "spare"sv, "voyage"sv, - "borrow"sv, "fabulous"sv, "jail"sv, "profuse"sv, "spicy"sv, "wall"sv, - "broken"sv, "familiar"sv, "kindhearted"sv, "protective"sv, "spiritual"sv, "want"sv, - "capable"sv, "finger"sv, "lackadaisical"sv, "pumped"sv, "sprout"sv, "weary"sv, - "charming"sv, "finicky"sv, "laughable"sv, "rabbit"sv, "squirrel"sv, "week"sv, - "cheerful"sv, "fix"sv, "leather"sv, "rapid"sv, "stale"sv, "whip"sv, - "chubby"sv, "flagrant"sv, "legal"sv, "regret"sv, "step"sv, "wilderness"sv, - "clean"sv, "flat"sv, "lewd"sv, "reject"sv, "stingy"sv, "wistful"sv, - "close"sv, "flimsy"sv, "license"sv, "rejoice"sv, "string"sv, "worried"sv, - "cobweb"sv, "fuel"sv, "light"sv, "relation"sv, "sulky"sv, "wretched"sv, - "complex"sv, "furtive"sv, "march"sv, "remarkable"sv, "surprise"sv, "zealous"sv, - "consist"sv, "geese"sv + inline constexpr auto words = std::array{ + "acceptable"sv, "contain"sv, "ghost"sv, "mark"sv, "respect"sv, "taboo"sv, + "actually"sv, "cream"sv, "gleaming"sv, "meaty"sv, "rest"sv, "tacky"sv, + "addition"sv, "creature"sv, "glorious"sv, "memory"sv, "rice"sv, "tank"sv, + "adhesive"sv, "crime"sv, "gold"sv, "messy"sv, "rich"sv, "tent"sv, + "adorable"sv, "cross"sv, "grandfather"sv, "miss"sv, "righteous"sv, "terrible"sv, + "advise"sv, "crowded"sv, "gusty"sv, "modern"sv, "room"sv, "threatening"sv, + "afraid"sv, "crown"sv, "haircut"sv, "morning"sv, "rotten"sv, "three"sv, + "ancient"sv, "cure"sv, "hard-to-find"sv, "naughty"sv, "royal"sv, "ticket"sv, + "anxious"sv, "curious"sv, "harm"sv, "neck"sv, "run"sv, "title"sv, + "aromatic"sv, "curtain"sv, "heavy"sv, "night"sv, "satisfy"sv, "torpid"sv, + "attempt"sv, "cycle"sv, "helpless"sv, "nondescript"sv, "scary"sv, "train"sv, + "babies"sv, "deadpan"sv, "high-pitched"sv, "overjoyed"sv, "scatter"sv, "umbrella"sv, + "bake"sv, "decisive"sv, "hilarious"sv, "page"sv, "scene"sv, "unadvised"sv, + "ball"sv, "deeply"sv, "history"sv, "partner"sv, "scintillating"sv, "unbecoming"sv, + "bat"sv, "delightful"sv, "hook"sv, "party"sv, "self"sv, "unbiased"sv, + "behave"sv, "deserted"sv, "ignore"sv, "pause"sv, "selfish"sv, "unite"sv, + "best"sv, "draconian"sv, "imperfect"sv, "pear"sv, "silky"sv, "uptight"sv, + "birds"sv, "dreary"sv, "impossible"sv, "picture"sv, "sisters"sv, "used"sv, + "blind"sv, "dull"sv, "incandescent"sv, "place"sv, "ski"sv, "vengeful"sv, + "blood"sv, "enthusiastic"sv, "influence"sv, "playground"sv, "skip"sv, "versed"sv, + "blue-eyed"sv, "equable"sv, "innocent"sv, "popcorn"sv, "snow"sv, "vessel"sv, + "boiling"sv, "excuse"sv, "insidious"sv, "prefer"sv, "soap"sv, "view"sv, + "bore"sv, "experience"sv, "itch"sv, "productive"sv, "spare"sv, "voyage"sv, + "borrow"sv, "fabulous"sv, "jail"sv, "profuse"sv, "spicy"sv, "wall"sv, + "broken"sv, "familiar"sv, "kindhearted"sv, "protective"sv, "spiritual"sv, "want"sv, + "capable"sv, "finger"sv, "lackadaisical"sv, "pumped"sv, "sprout"sv, "weary"sv, + "charming"sv, "finicky"sv, "laughable"sv, "rabbit"sv, "squirrel"sv, "week"sv, + "cheerful"sv, "fix"sv, "leather"sv, "rapid"sv, "stale"sv, "whip"sv, + "chubby"sv, "flagrant"sv, "legal"sv, "regret"sv, "step"sv, "wilderness"sv, + "clean"sv, "flat"sv, "lewd"sv, "reject"sv, "stingy"sv, "wistful"sv, + "close"sv, "flimsy"sv, "license"sv, "rejoice"sv, "string"sv, "worried"sv, + "cobweb"sv, "fuel"sv, "light"sv, "relation"sv, "sulky"sv, "wretched"sv, + "complex"sv, "furtive"sv, "march"sv, "remarkable"sv, "surprise"sv, "zealous"sv, + "consist"sv, "geese"sv }; template - [[nodiscard]] - static T rand(T excl_max) noexcept + [[nodiscard]] static T rand(T excl_max) noexcept { return static_cast(static_cast(std::rand()) % excl_max); } template - [[nodiscard]] - static T rand(T incl_min, T excl_max) noexcept + [[nodiscard]] static T rand(T incl_min, T excl_max) noexcept { return static_cast(incl_min + rand(excl_max - incl_min)); } static auto rand_date() noexcept { - return toml::date - { - rand(uint16_t{ 1900 }, uint16_t{ 2021 }), - rand(uint8_t{ 1 }, uint8_t{ 13 }), - rand(uint8_t{ 1 }, uint8_t{ 29 }) - }; + return toml::date{ rand(uint16_t{ 1900 }, uint16_t{ 2021 }), + rand(uint8_t{ 1 }, uint8_t{ 13 }), + rand(uint8_t{ 1 }, uint8_t{ 29 }) }; } static auto rand_time() noexcept { - return toml::time - { - rand(uint8_t{ 24 }), - rand(uint8_t{ 60 }), - rand(uint8_t{ 60 }), - rand(100) > 80 ? rand(1000000000u) : 0u - }; + return toml::time{ rand(uint8_t{ 24 }), + rand(uint8_t{ 60 }), + rand(uint8_t{ 60 }), + rand(100) > 80 ? rand(1000000000u) : 0u }; } static auto rand_string(size_t word_count, char sep = ' ') noexcept @@ -119,14 +110,14 @@ int main(int argc, char** argv) std::vector tree; tree.push_back(&root); constexpr size_t max_depth = 10u; - int container_min_values = 10; - bool in_arr = false; + int container_min_values = 10; + bool in_arr = false; const auto add = [&](auto&& val) noexcept -> auto& { - using value_ref = decltype(val); + using value_ref = decltype(val); using value_type = std::remove_reference_t; - using node_type = toml::inserted_type_of; + using node_type = toml::inserted_type_of; toml::node* new_node{}; @@ -142,10 +133,8 @@ int main(int argc, char** argv) { auto& table = tree.back()->ref(); - const auto it = table.insert_or_assign( - rand_string(rand(1u, 4u), '-'), - std::forward(val) - ); + const auto it = + table.insert_or_assign(rand_string(rand(1u, 4u), '-'), std::forward(val)); new_node = &it.first->second; } @@ -155,7 +144,7 @@ int main(int argc, char** argv) { tree.push_back(new_node); container_min_values = rand(1, 4); - in_arr = toml::is_array; + in_arr = toml::is_array; if constexpr (toml::is_array) tree.back()->as_array()->reserve(static_cast(container_min_values)); } @@ -183,41 +172,30 @@ int main(int argc, char** argv) switch (new_node_type) { - case toml::node_type::array: - if (container_min_values <= 0 && tree.size() < max_depth) - add(toml::array{}); - break; + case toml::node_type::array: + if (container_min_values <= 0 && tree.size() < max_depth) + add(toml::array{}); + break; - case toml::node_type::string: - add(rand_string(rand(8u))); - break; + case toml::node_type::string: add(rand_string(rand(8u))); break; - case toml::node_type::integer: - add(rand()); - break; + case toml::node_type::integer: add(rand()); break; - case toml::node_type::floating_point: - add(rand(10001u) / 10000.0); - break; + case toml::node_type::floating_point: add(rand(10001u) / 10000.0); break; - case toml::node_type::boolean: - add(!rand(2u)); - break; + case toml::node_type::boolean: add(!rand(2u)); break; - case toml::node_type::date: - add(rand_date()); - break; + case toml::node_type::date: add(rand_date()); break; - case toml::node_type::time: - add(rand_time()); - break; + case toml::node_type::time: add(rand_time()); break; - case toml::node_type::date_time: - add(rand(100) >= 75 - ? toml::date_time{ rand_date(), rand_time() } - : toml::date_time{ rand_date(), rand_time(), toml::time_offset{ rand(-11, 12), rand(-45, +46) } } - ); - break; + case toml::node_type::date_time: + add(rand(100) >= 75 + ? toml::date_time{ rand_date(), rand_time() } + : toml::date_time{ rand_date(), + rand_time(), + toml::time_offset{ rand(-11, 12), rand(-45, +46) } }); + break; } if (container_min_values <= 0 && tree.size() >= 2u && rand(100) >= 85) { diff --git a/examples/toml_to_json_transcoder.cpp b/examples/toml_to_json_transcoder.cpp index 175432c..8b95a90 100644 --- a/examples/toml_to_json_transcoder.cpp +++ b/examples/toml_to_json_transcoder.cpp @@ -19,7 +19,6 @@ int main(int argc, char** argv) toml::table table; try { - // read from a file if a path argument is given if (argc > 1) table = toml::parse_file(argv[1]); diff --git a/include/toml++/impl/array_impl.h b/include/toml++/impl/array.inl similarity index 98% rename from include/toml++/impl/array_impl.h rename to include/toml++/impl/array.inl index 72af4d9..91a8586 100644 --- a/include/toml++/impl/array_impl.h +++ b/include/toml++/impl/array.inl @@ -3,7 +3,6 @@ //# See https://github.com/marzer/tomlplusplus/blob/master/LICENSE for the full license text. // SPDX-License-Identifier: MIT #pragma once -/// \cond //# {{ #include "preprocessor.h" @@ -17,16 +16,10 @@ TOML_ANON_NAMESPACE_START { -#if !TOML_HEADER_ONLY - using namespace toml; -#endif - template TOML_INTERNAL_LINKAGE bool array_is_homogeneous(T & elements, node_type ntype, U & first_nonmatch) noexcept { - using namespace toml; - if (elements.empty()) { first_nonmatch = {}; @@ -246,4 +239,3 @@ TOML_NAMESPACE_START TOML_NAMESPACE_END; #include "header_end.h" -/// \endcond diff --git a/include/toml++/impl/default_formatter_impl.h b/include/toml++/impl/default_formatter.inl similarity index 99% rename from include/toml++/impl/default_formatter_impl.h rename to include/toml++/impl/default_formatter.inl index 6d2abf4..b38ac10 100644 --- a/include/toml++/impl/default_formatter_impl.h +++ b/include/toml++/impl/default_formatter.inl @@ -3,7 +3,6 @@ //# See https://github.com/marzer/tomlplusplus/blob/master/LICENSE for the full license text. // SPDX-License-Identifier: MIT #pragma once -/// \cond //# {{ #include "preprocessor.h" @@ -19,6 +18,7 @@ #include "table.h" #include "array.h" #include "header_start.h" +TOML_DISABLE_ARITHMETIC_WARNINGS; TOML_NAMESPACE_START { @@ -451,4 +451,3 @@ TOML_NAMESPACE_START TOML_NAMESPACE_END; #include "header_end.h" -/// \endcond diff --git a/include/toml++/impl/formatter_impl.h b/include/toml++/impl/formatter.inl similarity index 99% rename from include/toml++/impl/formatter_impl.h rename to include/toml++/impl/formatter.inl index 51d2a33..76b3734 100644 --- a/include/toml++/impl/formatter_impl.h +++ b/include/toml++/impl/formatter.inl @@ -3,7 +3,6 @@ //# See https://github.com/marzer/tomlplusplus/blob/master/LICENSE for the full license text. // SPDX-License-Identifier: MIT #pragma once -/// \cond //# {{ #include "preprocessor.h" @@ -230,4 +229,3 @@ TOML_IMPL_NAMESPACE_START TOML_IMPL_NAMESPACE_END; #include "header_end.h" -/// \endcond diff --git a/include/toml++/impl/json_formatter_impl.h b/include/toml++/impl/json_formatter.inl similarity index 99% rename from include/toml++/impl/json_formatter_impl.h rename to include/toml++/impl/json_formatter.inl index 67696ac..7d2e14e 100644 --- a/include/toml++/impl/json_formatter_impl.h +++ b/include/toml++/impl/json_formatter.inl @@ -3,7 +3,6 @@ //# See https://github.com/marzer/tomlplusplus/blob/master/LICENSE for the full license text. // SPDX-License-Identifier: MIT #pragma once -/// \cond //# {{ #include "preprocessor.h" @@ -109,4 +108,3 @@ TOML_NAMESPACE_START TOML_NAMESPACE_END; #include "header_end.h" -/// \endcond diff --git a/include/toml++/impl/node_impl.h b/include/toml++/impl/node.inl similarity index 98% rename from include/toml++/impl/node_impl.h rename to include/toml++/impl/node.inl index b708964..1509d9b 100644 --- a/include/toml++/impl/node_impl.h +++ b/include/toml++/impl/node.inl @@ -3,7 +3,6 @@ //# See https://github.com/marzer/tomlplusplus/blob/master/LICENSE for the full license text. // SPDX-License-Identifier: MIT #pragma once -/// \cond //# {{ #include "preprocessor.h" @@ -56,4 +55,3 @@ TOML_NAMESPACE_START TOML_NAMESPACE_END; #include "header_end.h" -/// \endcond diff --git a/include/toml++/impl/node_view.h b/include/toml++/impl/node_view.h index 7c6433a..60dd959 100644 --- a/include/toml++/impl/node_view.h +++ b/include/toml++/impl/node_view.h @@ -8,6 +8,7 @@ #include "node.h" #include "std_vector.h" #include "header_start.h" +TOML_DISABLE_ARITHMETIC_WARNINGS; TOML_NAMESPACE_START { diff --git a/include/toml++/impl/node_view_impl.h b/include/toml++/impl/node_view.inl similarity index 99% rename from include/toml++/impl/node_view_impl.h rename to include/toml++/impl/node_view.inl index f862e8b..85f6a51 100644 --- a/include/toml++/impl/node_view_impl.h +++ b/include/toml++/impl/node_view.inl @@ -3,7 +3,6 @@ //# See https://github.com/marzer/tomlplusplus/blob/master/LICENSE for the full license text. // SPDX-License-Identifier: MIT #pragma once -/// \cond //# {{ #include "preprocessor.h" @@ -75,4 +74,3 @@ TOML_NAMESPACE_END; #include "header_end.h" #endif // TOML_EXTERN_TEMPLATES -/// \endcond diff --git a/include/toml++/impl/parse_error.h b/include/toml++/impl/parse_error.h index f3de322..185cf57 100644 --- a/include/toml++/impl/parse_error.h +++ b/include/toml++/impl/parse_error.h @@ -11,7 +11,6 @@ #include "source_region.h" #include "print_to_stream.h" #include "header_start.h" -TOML_DISABLE_INIT_WARNINGS; #if defined(DOXYGEN) || !TOML_EXCEPTIONS #define TOML_PARSE_ERROR_BASE diff --git a/include/toml++/impl/parser_impl.h b/include/toml++/impl/parser.inl similarity index 99% rename from include/toml++/impl/parser_impl.h rename to include/toml++/impl/parser.inl index 34a7220..424cdf5 100644 --- a/include/toml++/impl/parser_impl.h +++ b/include/toml++/impl/parser.inl @@ -3,7 +3,6 @@ //# See https://github.com/marzer/tomlplusplus/blob/master/LICENSE for the full license text. // SPDX-License-Identifier: MIT #pragma once -/// \cond #include "preprocessor.h" //# {{ @@ -43,10 +42,6 @@ TOML_ENABLE_WARNINGS; TOML_ANON_NAMESPACE_START { -#if !TOML_HEADER_ONLY - using namespace toml; -#endif - template class utf8_byte_stream; @@ -186,13 +181,6 @@ TOML_ANON_NAMESPACE_START return bytes[3] ? std::string_view{ bytes, 4_sz } : std::string_view{ bytes }; } - TOML_NODISCARD - TOML_ATTR(pure) - constexpr operator char32_t&() noexcept - { - return value; - } - TOML_NODISCARD TOML_ATTR(pure) constexpr operator const char32_t&() const noexcept @@ -3665,4 +3653,3 @@ TOML_NAMESPACE_END; #include "header_end.h" #endif // TOML_PARSER -/// \endcond diff --git a/include/toml++/impl/preprocessor.h b/include/toml++/impl/preprocessor.h index 0e7cd2b..2c2473e 100644 --- a/include/toml++/impl/preprocessor.h +++ b/include/toml++/impl/preprocessor.h @@ -66,25 +66,18 @@ _Pragma("clang diagnostic ignored \"-Wswitch\"") \ static_assert(true) - #define TOML_DISABLE_INIT_WARNINGS \ - _Pragma("clang diagnostic ignored \"-Wmissing-field-initializers\"") \ - static_assert(true) - #define TOML_DISABLE_ARITHMETIC_WARNINGS \ _Pragma("clang diagnostic ignored \"-Wfloat-equal\"") \ _Pragma("clang diagnostic ignored \"-Wdouble-promotion\"") \ - _Pragma("clang diagnostic ignored \"-Wchar-subscripts\"") \ _Pragma("clang diagnostic ignored \"-Wshift-sign-overflow\"") \ static_assert(true) - #define TOML_DISABLE_SHADOW_WARNINGS \ - _Pragma("clang diagnostic ignored \"-Wshadow\"") \ - _Pragma("clang diagnostic ignored \"-Wshadow-field\"") \ - static_assert(true) - #define TOML_DISABLE_SPAM_WARNINGS \ _Pragma("clang diagnostic ignored \"-Wweak-vtables\"") \ _Pragma("clang diagnostic ignored \"-Wweak-template-vtables\"") \ + _Pragma("clang diagnostic ignored \"-Wdouble-promotion\"") \ + _Pragma("clang diagnostic ignored \"-Wchar-subscripts\"") \ + _Pragma("clang diagnostic ignored \"-Wmissing-field-initializers\"") \ _Pragma("clang diagnostic ignored \"-Wpadded\"") \ static_assert(true) @@ -278,23 +271,12 @@ #define TOML_DISABLE_SWITCH_WARNINGS \ _Pragma("GCC diagnostic ignored \"-Wswitch\"") \ _Pragma("GCC diagnostic ignored \"-Wswitch-enum\"") \ - _Pragma("GCC diagnostic ignored \"-Wswitch-default\"") \ - static_assert(true) - - #define TOML_DISABLE_INIT_WARNINGS \ - _Pragma("GCC diagnostic ignored \"-Wmissing-field-initializers\"") \ - _Pragma("GCC diagnostic ignored \"-Wmaybe-uninitialized\"") \ - _Pragma("GCC diagnostic ignored \"-Wuninitialized\"") \ + _Pragma("GCC diagnostic ignored \"-Wswitch-default\"") \ static_assert(true) #define TOML_DISABLE_ARITHMETIC_WARNINGS \ _Pragma("GCC diagnostic ignored \"-Wfloat-equal\"") \ _Pragma("GCC diagnostic ignored \"-Wsign-conversion\"") \ - _Pragma("GCC diagnostic ignored \"-Wchar-subscripts\"") \ - static_assert(true) - - #define TOML_DISABLE_SHADOW_WARNINGS \ - _Pragma("GCC diagnostic ignored \"-Wshadow\"") \ static_assert(true) #define TOML_DISABLE_SPAM_WARNINGS \ @@ -303,8 +285,12 @@ _Pragma("GCC diagnostic ignored \"-Wcomment\"") \ _Pragma("GCC diagnostic ignored \"-Wtype-limits\"") \ _Pragma("GCC diagnostic ignored \"-Wuseless-cast\"") \ + _Pragma("GCC diagnostic ignored \"-Wchar-subscripts\"") \ + _Pragma("GCC diagnostic ignored \"-Wsubobject-linkage\"") \ + _Pragma("GCC diagnostic ignored \"-Wmissing-field-initializers\"") \ + _Pragma("GCC diagnostic ignored \"-Wmaybe-uninitialized\"") \ _Pragma("GCC diagnostic ignored \"-Wsuggest-attribute=const\"") \ - _Pragma("GCC diagnostic ignored \"-Wsuggest-attribute=pure\"") \ + _Pragma("GCC diagnostic ignored \"-Wsuggest-attribute=pure\"") \ static_assert(true) #define TOML_POP_WARNINGS \ @@ -317,9 +303,7 @@ _Pragma("GCC diagnostic ignored \"-Wextra\"") \ _Pragma("GCC diagnostic ignored \"-Wpedantic\"") \ TOML_DISABLE_SWITCH_WARNINGS; \ - TOML_DISABLE_INIT_WARNINGS; \ TOML_DISABLE_ARITHMETIC_WARNINGS; \ - TOML_DISABLE_SHADOW_WARNINGS; \ TOML_DISABLE_SPAM_WARNINGS; \ static_assert(true) @@ -504,18 +488,12 @@ #ifndef TOML_DISABLE_SWITCH_WARNINGS #define TOML_DISABLE_SWITCH_WARNINGS static_assert(true) #endif -#ifndef TOML_DISABLE_INIT_WARNINGS - #define TOML_DISABLE_INIT_WARNINGS static_assert(true) -#endif #ifndef TOML_DISABLE_SPAM_WARNINGS #define TOML_DISABLE_SPAM_WARNINGS static_assert(true) #endif #ifndef TOML_DISABLE_ARITHMETIC_WARNINGS #define TOML_DISABLE_ARITHMETIC_WARNINGS static_assert(true) #endif -#ifndef TOML_DISABLE_SHADOW_WARNINGS - #define TOML_DISABLE_SHADOW_WARNINGS static_assert(true) -#endif #ifndef TOML_POP_WARNINGS #define TOML_POP_WARNINGS static_assert(true) #endif @@ -774,17 +752,15 @@ #define TOML_IMPL_NAMESPACE_START TOML_NAMESPACE_START { namespace impl #define TOML_IMPL_NAMESPACE_END } TOML_NAMESPACE_END #if TOML_HEADER_ONLY - #define TOML_ANON_NAMESPACE_START TOML_IMPL_NAMESPACE_START + #define TOML_ANON_NAMESPACE_START static_assert(TOML_IMPLEMENTATION); TOML_IMPL_NAMESPACE_START #define TOML_ANON_NAMESPACE_END TOML_IMPL_NAMESPACE_END #define TOML_ANON_NAMESPACE TOML_NAMESPACE::impl - #define TOML_USING_ANON_NAMESPACE using namespace TOML_ANON_NAMESPACE #define TOML_EXTERNAL_LINKAGE inline #define TOML_INTERNAL_LINKAGE inline #else - #define TOML_ANON_NAMESPACE_START namespace + #define TOML_ANON_NAMESPACE_START static_assert(TOML_IMPLEMENTATION); using namespace toml; namespace #define TOML_ANON_NAMESPACE_END static_assert(true) #define TOML_ANON_NAMESPACE - #define TOML_USING_ANON_NAMESPACE static_cast(0) #define TOML_EXTERNAL_LINKAGE #define TOML_INTERNAL_LINKAGE static #endif diff --git a/include/toml++/impl/print_to_stream_impl.h b/include/toml++/impl/print_to_stream.inl similarity index 98% rename from include/toml++/impl/print_to_stream_impl.h rename to include/toml++/impl/print_to_stream.inl index c3de816..48bfa3b 100644 --- a/include/toml++/impl/print_to_stream_impl.h +++ b/include/toml++/impl/print_to_stream.inl @@ -3,7 +3,6 @@ //# See https://github.com/marzer/tomlplusplus/blob/master/LICENSE for the full license text. // SPDX-License-Identifier: MIT #pragma once -/// \cond //# {{ #include "preprocessor.h" @@ -35,10 +34,6 @@ TOML_ENABLE_WARNINGS; TOML_ANON_NAMESPACE_START { -#if !TOML_HEADER_ONLY - using namespace toml; -#endif - template inline constexpr size_t charconv_buffer_length = 0; @@ -76,8 +71,6 @@ TOML_ANON_NAMESPACE_START TOML_INTERNAL_LINKAGE void print_integer_to_stream(std::ostream & stream, T val, value_flags format = {}) { - using namespace toml; - if (!val) { stream.put('0'); @@ -138,7 +131,7 @@ TOML_ANON_NAMESPACE_START ss << std::uppercase << std::setbase(base); ss << static_cast(val); const auto str = std::move(ss).str(); - impl::print_to_stream(str, stream); + impl::print_to_stream(stream, str); } #endif @@ -148,8 +141,6 @@ TOML_ANON_NAMESPACE_START TOML_INTERNAL_LINKAGE void print_floating_point_to_stream(std::ostream & stream, T val, value_flags format = {}) { - using namespace toml; - switch (impl::fpclassify(val)) { case impl::fp_class::neg_inf: impl::print_to_stream(stream, "-inf"sv); break; @@ -204,8 +195,6 @@ TOML_ANON_NAMESPACE_START TOML_INTERNAL_LINKAGE void print_integer_leftpad_zeros(std::ostream & stream, T val, size_t min_digits) { - using namespace toml; - #if TOML_INT_CHARCONV char buf[charconv_buffer_length]; @@ -471,4 +460,3 @@ TOML_IMPL_NAMESPACE_START TOML_IMPL_NAMESPACE_END; #include "header_end.h" -/// \endcond diff --git a/include/toml++/impl/std_string_impl.h b/include/toml++/impl/std_string.inl similarity index 99% rename from include/toml++/impl/std_string_impl.h rename to include/toml++/impl/std_string.inl index 806eae9..57520cb 100644 --- a/include/toml++/impl/std_string_impl.h +++ b/include/toml++/impl/std_string.inl @@ -3,7 +3,6 @@ //# See https://github.com/marzer/tomlplusplus/blob/master/LICENSE for the full license text. // SPDX-License-Identifier: MIT #pragma once -/// \cond //# {{ #include "preprocessor.h" @@ -99,4 +98,3 @@ TOML_IMPL_NAMESPACE_END; #include "header_end.h" #endif // TOML_WINDOWS_COMPAT -/// \endcond diff --git a/include/toml++/impl/table_impl.h b/include/toml++/impl/table.inl similarity index 97% rename from include/toml++/impl/table_impl.h rename to include/toml++/impl/table.inl index 7ffe229..40cab66 100644 --- a/include/toml++/impl/table_impl.h +++ b/include/toml++/impl/table.inl @@ -3,7 +3,6 @@ //# See https://github.com/marzer/tomlplusplus/blob/master/LICENSE for the full license text. // SPDX-License-Identifier: MIT #pragma once -/// \cond //# {{ #include "preprocessor.h" @@ -18,16 +17,10 @@ TOML_ANON_NAMESPACE_START { -#if !TOML_HEADER_ONLY - using namespace toml; -#endif - template TOML_INTERNAL_LINKAGE bool table_is_homogeneous(T & map, node_type ntype, U & first_nonmatch) noexcept { - using namespace toml; - if (map.empty()) { first_nonmatch = {}; @@ -174,4 +167,3 @@ TOML_NAMESPACE_START TOML_NAMESPACE_END; #include "header_end.h" -/// \endcond diff --git a/include/toml++/impl/value.h b/include/toml++/impl/value.h index 9d7ef07..d18723b 100644 --- a/include/toml++/impl/value.h +++ b/include/toml++/impl/value.h @@ -7,6 +7,7 @@ #include "node.h" #include "print_to_stream.h" #include "header_start.h" +TOML_DISABLE_ARITHMETIC_WARNINGS; /// \cond // clang-format off diff --git a/include/toml++/impl/value_impl.h b/include/toml++/impl/value.inl similarity index 99% rename from include/toml++/impl/value_impl.h rename to include/toml++/impl/value.inl index d03e5f5..bb3ec69 100644 --- a/include/toml++/impl/value_impl.h +++ b/include/toml++/impl/value.inl @@ -3,7 +3,6 @@ //# See https://github.com/marzer/tomlplusplus/blob/master/LICENSE for the full license text. // SPDX-License-Identifier: MIT #pragma once -/// \cond //# {{ #include "preprocessor.h" @@ -78,4 +77,3 @@ TOML_NAMESPACE_END; #include "header_end.h" #endif // TOML_EXTERN_TEMPLATES -/// \endcond diff --git a/include/toml++/toml.h b/include/toml++/toml.h index 2223a23..72aeb85 100644 --- a/include/toml++/toml.h +++ b/include/toml++/toml.h @@ -12,12 +12,12 @@ #include "impl/preprocessor.h" -//# {{ TOML_PUSH_WARNINGS; #if TOML_MSVC -#pragma warning(disable : 5031) // #pragma warning(pop): likely mismatch +#pragma warning(disable : 5031) // #pragma warning(pop): likely mismatch (false-positive) +#elif TOML_CLANG && !TOML_HEADER_ONLY && TOML_IMPLEMENTATION +#pragma clang diagnostic ignored "-Wheader-hygiene" // false-positive #endif -//# }} #include "impl/std_new.h" #include "impl/std_string.h" @@ -41,22 +41,22 @@ TOML_PUSH_WARNINGS; #include "impl/json_formatter.h" #if TOML_IMPLEMENTATION -#include "impl/std_string_impl.h" -#include "impl/print_to_stream_impl.h" -#include "impl/node_impl.h" -#include "impl/node_view_impl.h" -#include "impl/value_impl.h" -#include "impl/array_impl.h" -#include "impl/table_impl.h" -#include "impl/parser_impl.h" -#include "impl/formatter_impl.h" -#include "impl/default_formatter_impl.h" -#include "impl/json_formatter_impl.h" + +#include "impl/std_string.inl" +#include "impl/print_to_stream.inl" +#include "impl/node.inl" +#include "impl/node_view.inl" +#include "impl/value.inl" +#include "impl/array.inl" +#include "impl/table.inl" +#include "impl/parser.inl" +#include "impl/formatter.inl" +#include "impl/default_formatter.inl" +#include "impl/json_formatter.inl" + #endif // TOML_IMPLEMENTATION -//# {{ TOML_POP_WARNINGS; -//# }} // macro hygiene #if TOML_UNDEF_MACROS @@ -83,8 +83,6 @@ TOML_POP_WARNINGS; #undef TOML_CPP #undef TOML_DISABLE_ARITHMETIC_WARNINGS #undef TOML_DISABLE_CODE_ANALYSIS_WARNINGS -#undef TOML_DISABLE_INIT_WARNINGS -#undef TOML_DISABLE_SHADOW_WARNINGS #undef TOML_DISABLE_SPAM_WARNINGS #undef TOML_DISABLE_SUGGEST_WARNINGS #undef TOML_DISABLE_SWITCH_WARNINGS @@ -156,7 +154,6 @@ TOML_POP_WARNINGS; #undef TOML_UINT128 #undef TOML_UNLIKELY #undef TOML_UNREACHABLE -#undef TOML_USING_ANON_NAMESPACE #endif #endif // TOMLPLUSPLUS_H diff --git a/meson.build b/meson.build index 6c9b9c4..034a2cd 100644 --- a/meson.build +++ b/meson.build @@ -2,7 +2,7 @@ project( 'tomlplusplus', 'cpp', version: '3.0.0', - meson_version: '>=0.53.0', + meson_version: '>=0.54.0', license: 'MIT', default_options: [ # https://mesonbuild.com/Builtin-options.html # core options @@ -62,7 +62,7 @@ if is_gcc or is_clang add_project_arguments( '-march=native', '-fvisibility=hidden', - '-fvisility-inlines-hidden', + '-fvisibility-inlines-hidden', language: 'cpp' ) if is_release @@ -508,9 +508,7 @@ tomlplusplus_dep = declare_dependency( version: meson.project_version(), ) -if meson.version().version_compare('>=0.54.0') - meson.override_dependency('tomlplusplus', tomlplusplus_dep) -endif +meson.override_dependency('tomlplusplus', tomlplusplus_dep) if not is_subproject import('pkgconfig').generate( diff --git a/tests/impl_catch2.cpp b/tests/main.cpp similarity index 100% rename from tests/impl_catch2.cpp rename to tests/main.cpp diff --git a/tests/meson.build b/tests/meson.build index 634b9f3..fff1197 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -4,7 +4,6 @@ test_sources = [ 'conformance_iarna_invalid.cpp', 'conformance_iarna_valid.cpp', 'impl_toml.cpp', - 'impl_catch2.cpp', 'tests.cpp', 'parsing_floats.cpp', 'parsing_arrays.cpp', @@ -16,6 +15,7 @@ test_sources = [ 'parsing_spec_example.cpp', 'parsing_strings.cpp', 'parsing_tables.cpp', + 'main.cpp', 'manipulating_arrays.cpp', 'manipulating_tables.cpp', 'manipulating_values.cpp', diff --git a/tests/parsing_dates_and_times.cpp b/tests/parsing_dates_and_times.cpp index 4909766..3ef6b4b 100644 --- a/tests/parsing_dates_and_times.cpp +++ b/tests/parsing_dates_and_times.cpp @@ -4,8 +4,7 @@ // SPDX-License-Identifier: MIT #include "tests.h" - -TOML_DISABLE_INIT_WARNINGS; +TOML_DISABLE_SPAM_WARNINGS; TEST_CASE("parsing - dates and times") { @@ -42,13 +41,12 @@ TEST_CASE("parsing - dates and times") CHECK(tbl["lt1"] == lt1); static constexpr auto lt2 = toml::time{ 0, 32, 0, 999999000u }; CHECK(tbl["lt2"] == lt2); - } - ); + }); // value tests - parse_expected_value(FILE_LINE_ARGS, "1987-03-16"sv, date{ 1987, 3, 16 } ); - parse_expected_value(FILE_LINE_ARGS, "10:20:30"sv, toml::time{ 10, 20, 30 } ); - parse_expected_value(FILE_LINE_ARGS, "10:20:30.04"sv, toml::time{ 10, 20, 30, 40000000 } ); + parse_expected_value(FILE_LINE_ARGS, "1987-03-16"sv, date{ 1987, 3, 16 }); + parse_expected_value(FILE_LINE_ARGS, "10:20:30"sv, toml::time{ 10, 20, 30 }); + parse_expected_value(FILE_LINE_ARGS, "10:20:30.04"sv, toml::time{ 10, 20, 30, 40000000 }); { const auto val = date_time{ { 1987, 3, 16 }, { 10, 20, 30 } }; parse_expected_value(FILE_LINE_ARGS, "1987-03-16T10:20:30"sv, val); @@ -104,14 +102,14 @@ TEST_CASE("parsing - dates and times") parse_expected_value(FILE_LINE_ARGS, "1987-03-16 10:20:30.04z"sv, val); } - // toml/issues/671 (allow omission of seconds) - #if TOML_LANG_UNRELEASED +// toml/issues/671 (allow omission of seconds) +#if TOML_LANG_UNRELEASED - parse_expected_value(FILE_LINE_ARGS, "10:20"sv, toml::time{ 10, 20 } ); + parse_expected_value(FILE_LINE_ARGS, "10:20"sv, toml::time{ 10, 20 }); { const auto val = date_time{ { 1987, 3, 16 }, { 10, 20 } }; - parse_expected_value(FILE_LINE_ARGS, "1987-03-16T10:20"sv, val ); - parse_expected_value(FILE_LINE_ARGS, "1987-03-16 10:20"sv, val ); + parse_expected_value(FILE_LINE_ARGS, "1987-03-16T10:20"sv, val); + parse_expected_value(FILE_LINE_ARGS, "1987-03-16 10:20"sv, val); } { const auto val = date_time{ { 1987, 3, 16 }, { 10, 20 }, { -9, -30 } }; @@ -129,7 +127,7 @@ TEST_CASE("parsing - dates and times") parse_expected_value(FILE_LINE_ARGS, "1987-03-16 10:20Z"sv, val); } - #else +#else parsing_should_fail(FILE_LINE_ARGS, "10:20"sv); parsing_should_fail(FILE_LINE_ARGS, "1987-03-16T10:20"sv); @@ -141,8 +139,7 @@ TEST_CASE("parsing - dates and times") parsing_should_fail(FILE_LINE_ARGS, "1987-03-16T10:20Z"sv); parsing_should_fail(FILE_LINE_ARGS, "1987-03-16 10:20Z"sv); - - #endif +#endif // eof tests parsing_should_fail(FILE_LINE_ARGS, "val = 1987-03-1"sv); @@ -153,9 +150,9 @@ TEST_CASE("parsing - dates and times") parsing_should_fail(FILE_LINE_ARGS, "val = 10:20:30."sv); parsing_should_fail(FILE_LINE_ARGS, "val = 10:20:3"sv); parsing_should_fail(FILE_LINE_ARGS, "val = 10:20:"sv); - #if !TOML_LANG_UNRELEASED // toml/issues/671 (allow omission of seconds) - parsing_should_fail(FILE_LINE_ARGS, "val = 10:20"sv); - #endif +#if !TOML_LANG_UNRELEASED // toml/issues/671 (allow omission of seconds) + parsing_should_fail(FILE_LINE_ARGS, "val = 10:20"sv); +#endif parsing_should_fail(FILE_LINE_ARGS, "val = 10:2"sv); parsing_should_fail(FILE_LINE_ARGS, "val = 10:"sv); @@ -167,9 +164,9 @@ TEST_CASE("parsing - dates and times") parsing_should_fail(FILE_LINE_ARGS, "val = 1987-03-16 10:20:30."sv); parsing_should_fail(FILE_LINE_ARGS, "val = 1987-03-16 10:20:3"sv); parsing_should_fail(FILE_LINE_ARGS, "val = 1987-03-16 10:20:"sv); - #if !TOML_LANG_UNRELEASED // toml/issues/671 (allow omission of seconds) - parsing_should_fail(FILE_LINE_ARGS, "val = 1987-03-16 10:20"sv); - #endif +#if !TOML_LANG_UNRELEASED // toml/issues/671 (allow omission of seconds) + parsing_should_fail(FILE_LINE_ARGS, "val = 1987-03-16 10:20"sv); +#endif parsing_should_fail(FILE_LINE_ARGS, "val = 1987-03-16 10:2"sv); parsing_should_fail(FILE_LINE_ARGS, "val = 1987-03-16 10:"sv); parsing_should_fail(FILE_LINE_ARGS, "val = 1987-03-16 10"sv); diff --git a/tests/parsing_spec_example.cpp b/tests/parsing_spec_example.cpp index cbca7d9..71f6383 100644 --- a/tests/parsing_spec_example.cpp +++ b/tests/parsing_spec_example.cpp @@ -4,9 +4,7 @@ // SPDX-License-Identifier: MIT #include "tests.h" - -TOML_PUSH_WARNINGS; -TOML_DISABLE_INIT_WARNINGS; +TOML_DISABLE_SPAM_WARNINGS; TEST_CASE("parsing - TOML spec example") { @@ -46,53 +44,49 @@ TEST_CASE("parsing - TOML spec example") ] )"sv; - parsing_should_succeed( - FILE_LINE_ARGS, - toml_text, - [](table&& tbl) - { - CHECK(tbl.size() == 5); + parsing_should_succeed(FILE_LINE_ARGS, + toml_text, + [](table&& tbl) + { + CHECK(tbl.size() == 5); - CHECK(tbl["title"] == "TOML Example"sv); + CHECK(tbl["title"] == "TOML Example"sv); - CHECK(tbl["owner"]); - CHECK(tbl["owner"].as()); - CHECK(tbl["owner"]["name"] == "Tom Preston-Werner"sv); - const auto dob = date_time{ { 1979, 5, 27 }, { 7, 32 }, { -8, 0 } }; - CHECK(tbl["owner"]["dob"] == dob); + CHECK(tbl["owner"]); + CHECK(tbl["owner"].as
()); + CHECK(tbl["owner"]["name"] == "Tom Preston-Werner"sv); + const auto dob = date_time{ { 1979, 5, 27 }, { 7, 32 }, { -8, 0 } }; + CHECK(tbl["owner"]["dob"] == dob); - CHECK(tbl["database"].as
()); - CHECK(tbl["database"]["server"] == "192.168.1.1"sv); - const auto ports = { 8001, 8001, 8002 }; - CHECK(tbl["database"]["ports"] == ports); - CHECK(tbl["database"]["connection_max"] == 5000); - CHECK(tbl["database"]["enabled"] == true); + CHECK(tbl["database"].as
()); + CHECK(tbl["database"]["server"] == "192.168.1.1"sv); + const auto ports = { 8001, 8001, 8002 }; + CHECK(tbl["database"]["ports"] == ports); + CHECK(tbl["database"]["connection_max"] == 5000); + CHECK(tbl["database"]["enabled"] == true); - CHECK(tbl["servers"].as
()); - CHECK(tbl["servers"]["alpha"].as
()); - CHECK(tbl["servers"]["alpha"]["ip"] == "10.0.0.1"sv); - CHECK(tbl["servers"]["alpha"]["dc"] == "eqdc10"sv); - CHECK(tbl["servers"]["beta"].as
()); - CHECK(tbl["servers"]["beta"]["ip"] == "10.0.0.2"sv); - CHECK(tbl["servers"]["beta"]["dc"] == "eqdc10"sv); + CHECK(tbl["servers"].as
()); + CHECK(tbl["servers"]["alpha"].as
()); + CHECK(tbl["servers"]["alpha"]["ip"] == "10.0.0.1"sv); + CHECK(tbl["servers"]["alpha"]["dc"] == "eqdc10"sv); + CHECK(tbl["servers"]["beta"].as
()); + CHECK(tbl["servers"]["beta"]["ip"] == "10.0.0.2"sv); + CHECK(tbl["servers"]["beta"]["dc"] == "eqdc10"sv); - CHECK(tbl["clients"].as
()); - REQUIRE(tbl["clients"]["data"].as()); - CHECK(tbl["clients"]["data"].as()->size() == 2); - REQUIRE(tbl["clients"]["data"][0].as()); - CHECK(tbl["clients"]["data"][0].as()->size() == 2); - CHECK(tbl["clients"]["data"][0][0] == "gamma"sv); - CHECK(tbl["clients"]["data"][0][1] == "delta"sv); - REQUIRE(tbl["clients"]["data"][1].as()); - CHECK(tbl["clients"]["data"][1].as()->size() == 2); - CHECK(tbl["clients"]["data"][1][0] == 1); - CHECK(tbl["clients"]["data"][1][1] == 2); - REQUIRE(tbl["clients"]["hosts"].as()); - CHECK(tbl["clients"]["hosts"].as()->size() == 2); - CHECK(tbl["clients"]["hosts"][0] == "alpha"sv); - CHECK(tbl["clients"]["hosts"][1] == "omega"sv); - } - ); + CHECK(tbl["clients"].as
()); + REQUIRE(tbl["clients"]["data"].as()); + CHECK(tbl["clients"]["data"].as()->size() == 2); + REQUIRE(tbl["clients"]["data"][0].as()); + CHECK(tbl["clients"]["data"][0].as()->size() == 2); + CHECK(tbl["clients"]["data"][0][0] == "gamma"sv); + CHECK(tbl["clients"]["data"][0][1] == "delta"sv); + REQUIRE(tbl["clients"]["data"][1].as()); + CHECK(tbl["clients"]["data"][1].as()->size() == 2); + CHECK(tbl["clients"]["data"][1][0] == 1); + CHECK(tbl["clients"]["data"][1][1] == 2); + REQUIRE(tbl["clients"]["hosts"].as()); + CHECK(tbl["clients"]["hosts"].as()->size() == 2); + CHECK(tbl["clients"]["hosts"][0] == "alpha"sv); + CHECK(tbl["clients"]["hosts"][1] == "omega"sv); + }); } - -TOML_POP_WARNINGS; diff --git a/tests/vs/test_debug_x64.vcxproj b/tests/vs/test_debug_x64.vcxproj index e2626a5..5f1d285 100644 --- a/tests/vs/test_debug_x64.vcxproj +++ b/tests/vs/test_debug_x64.vcxproj @@ -76,10 +76,10 @@ - + NotUsing - + NotUsing diff --git a/tests/vs/test_debug_x64_cpplatest.vcxproj b/tests/vs/test_debug_x64_cpplatest.vcxproj index 2cebfe4..6ded91f 100644 --- a/tests/vs/test_debug_x64_cpplatest.vcxproj +++ b/tests/vs/test_debug_x64_cpplatest.vcxproj @@ -76,10 +76,10 @@ - + NotUsing - + NotUsing diff --git a/tests/vs/test_debug_x64_cpplatest_noexcept.vcxproj b/tests/vs/test_debug_x64_cpplatest_noexcept.vcxproj index a587fc9..a833a88 100644 --- a/tests/vs/test_debug_x64_cpplatest_noexcept.vcxproj +++ b/tests/vs/test_debug_x64_cpplatest_noexcept.vcxproj @@ -76,10 +76,10 @@ - + NotUsing - + NotUsing diff --git a/tests/vs/test_debug_x64_cpplatest_noexcept_unrel.vcxproj b/tests/vs/test_debug_x64_cpplatest_noexcept_unrel.vcxproj index 29ffa88..802c49c 100644 --- a/tests/vs/test_debug_x64_cpplatest_noexcept_unrel.vcxproj +++ b/tests/vs/test_debug_x64_cpplatest_noexcept_unrel.vcxproj @@ -76,10 +76,10 @@ - + NotUsing - + NotUsing diff --git a/tests/vs/test_debug_x64_cpplatest_unrel.vcxproj b/tests/vs/test_debug_x64_cpplatest_unrel.vcxproj index 5903882..1f96e7c 100644 --- a/tests/vs/test_debug_x64_cpplatest_unrel.vcxproj +++ b/tests/vs/test_debug_x64_cpplatest_unrel.vcxproj @@ -76,10 +76,10 @@ - + NotUsing - + NotUsing diff --git a/tests/vs/test_debug_x64_noexcept.vcxproj b/tests/vs/test_debug_x64_noexcept.vcxproj index 93a030e..c003795 100644 --- a/tests/vs/test_debug_x64_noexcept.vcxproj +++ b/tests/vs/test_debug_x64_noexcept.vcxproj @@ -76,10 +76,10 @@ - + NotUsing - + NotUsing diff --git a/tests/vs/test_debug_x64_noexcept_unrel.vcxproj b/tests/vs/test_debug_x64_noexcept_unrel.vcxproj index c252bcf..2fc3ebf 100644 --- a/tests/vs/test_debug_x64_noexcept_unrel.vcxproj +++ b/tests/vs/test_debug_x64_noexcept_unrel.vcxproj @@ -76,10 +76,10 @@ - + NotUsing - + NotUsing diff --git a/tests/vs/test_debug_x64_unrel.vcxproj b/tests/vs/test_debug_x64_unrel.vcxproj index 1d75548..d8ecf04 100644 --- a/tests/vs/test_debug_x64_unrel.vcxproj +++ b/tests/vs/test_debug_x64_unrel.vcxproj @@ -76,10 +76,10 @@ - + NotUsing - + NotUsing diff --git a/tests/vs/test_debug_x86.vcxproj b/tests/vs/test_debug_x86.vcxproj index 8db2fba..a210510 100644 --- a/tests/vs/test_debug_x86.vcxproj +++ b/tests/vs/test_debug_x86.vcxproj @@ -76,10 +76,10 @@ - + NotUsing - + NotUsing diff --git a/tests/vs/test_debug_x86_cpplatest.vcxproj b/tests/vs/test_debug_x86_cpplatest.vcxproj index 1f33445..c8e854d 100644 --- a/tests/vs/test_debug_x86_cpplatest.vcxproj +++ b/tests/vs/test_debug_x86_cpplatest.vcxproj @@ -76,10 +76,10 @@ - + NotUsing - + NotUsing diff --git a/tests/vs/test_debug_x86_cpplatest_noexcept.vcxproj b/tests/vs/test_debug_x86_cpplatest_noexcept.vcxproj index 394d937..6fece00 100644 --- a/tests/vs/test_debug_x86_cpplatest_noexcept.vcxproj +++ b/tests/vs/test_debug_x86_cpplatest_noexcept.vcxproj @@ -76,10 +76,10 @@ - + NotUsing - + NotUsing diff --git a/tests/vs/test_debug_x86_cpplatest_noexcept_unrel.vcxproj b/tests/vs/test_debug_x86_cpplatest_noexcept_unrel.vcxproj index 9affd82..34d6f8b 100644 --- a/tests/vs/test_debug_x86_cpplatest_noexcept_unrel.vcxproj +++ b/tests/vs/test_debug_x86_cpplatest_noexcept_unrel.vcxproj @@ -76,10 +76,10 @@ - + NotUsing - + NotUsing diff --git a/tests/vs/test_debug_x86_cpplatest_unrel.vcxproj b/tests/vs/test_debug_x86_cpplatest_unrel.vcxproj index 8a9e57b..8043f94 100644 --- a/tests/vs/test_debug_x86_cpplatest_unrel.vcxproj +++ b/tests/vs/test_debug_x86_cpplatest_unrel.vcxproj @@ -76,10 +76,10 @@ - + NotUsing - + NotUsing diff --git a/tests/vs/test_debug_x86_noexcept.vcxproj b/tests/vs/test_debug_x86_noexcept.vcxproj index ec396aa..f5ba248 100644 --- a/tests/vs/test_debug_x86_noexcept.vcxproj +++ b/tests/vs/test_debug_x86_noexcept.vcxproj @@ -76,10 +76,10 @@ - + NotUsing - + NotUsing diff --git a/tests/vs/test_debug_x86_noexcept_unrel.vcxproj b/tests/vs/test_debug_x86_noexcept_unrel.vcxproj index caed681..4751bc6 100644 --- a/tests/vs/test_debug_x86_noexcept_unrel.vcxproj +++ b/tests/vs/test_debug_x86_noexcept_unrel.vcxproj @@ -76,10 +76,10 @@ - + NotUsing - + NotUsing diff --git a/tests/vs/test_debug_x86_unrel.vcxproj b/tests/vs/test_debug_x86_unrel.vcxproj index e12b440..7e4c5fd 100644 --- a/tests/vs/test_debug_x86_unrel.vcxproj +++ b/tests/vs/test_debug_x86_unrel.vcxproj @@ -76,10 +76,10 @@ - + NotUsing - + NotUsing diff --git a/tests/vs/test_release_x64.vcxproj b/tests/vs/test_release_x64.vcxproj index ad53b13..4a78136 100644 --- a/tests/vs/test_release_x64.vcxproj +++ b/tests/vs/test_release_x64.vcxproj @@ -76,10 +76,10 @@ - + NotUsing - + NotUsing diff --git a/tests/vs/test_release_x64_cpplatest.vcxproj b/tests/vs/test_release_x64_cpplatest.vcxproj index 6cc46a4..5d5623c 100644 --- a/tests/vs/test_release_x64_cpplatest.vcxproj +++ b/tests/vs/test_release_x64_cpplatest.vcxproj @@ -76,10 +76,10 @@ - + NotUsing - + NotUsing diff --git a/tests/vs/test_release_x64_cpplatest_noexcept.vcxproj b/tests/vs/test_release_x64_cpplatest_noexcept.vcxproj index bb009f2..bb5aac9 100644 --- a/tests/vs/test_release_x64_cpplatest_noexcept.vcxproj +++ b/tests/vs/test_release_x64_cpplatest_noexcept.vcxproj @@ -76,10 +76,10 @@ - + NotUsing - + NotUsing diff --git a/tests/vs/test_release_x64_cpplatest_noexcept_unrel.vcxproj b/tests/vs/test_release_x64_cpplatest_noexcept_unrel.vcxproj index d547256..3f5b7e2 100644 --- a/tests/vs/test_release_x64_cpplatest_noexcept_unrel.vcxproj +++ b/tests/vs/test_release_x64_cpplatest_noexcept_unrel.vcxproj @@ -76,10 +76,10 @@ - + NotUsing - + NotUsing diff --git a/tests/vs/test_release_x64_cpplatest_unrel.vcxproj b/tests/vs/test_release_x64_cpplatest_unrel.vcxproj index 734acdf..15f3f77 100644 --- a/tests/vs/test_release_x64_cpplatest_unrel.vcxproj +++ b/tests/vs/test_release_x64_cpplatest_unrel.vcxproj @@ -76,10 +76,10 @@ - + NotUsing - + NotUsing diff --git a/tests/vs/test_release_x64_noexcept.vcxproj b/tests/vs/test_release_x64_noexcept.vcxproj index 8679841..fc2d926 100644 --- a/tests/vs/test_release_x64_noexcept.vcxproj +++ b/tests/vs/test_release_x64_noexcept.vcxproj @@ -76,10 +76,10 @@ - + NotUsing - + NotUsing diff --git a/tests/vs/test_release_x64_noexcept_unrel.vcxproj b/tests/vs/test_release_x64_noexcept_unrel.vcxproj index ce3239a..7c44949 100644 --- a/tests/vs/test_release_x64_noexcept_unrel.vcxproj +++ b/tests/vs/test_release_x64_noexcept_unrel.vcxproj @@ -76,10 +76,10 @@ - + NotUsing - + NotUsing diff --git a/tests/vs/test_release_x64_unrel.vcxproj b/tests/vs/test_release_x64_unrel.vcxproj index cc8a8a8..dbdb6a0 100644 --- a/tests/vs/test_release_x64_unrel.vcxproj +++ b/tests/vs/test_release_x64_unrel.vcxproj @@ -76,10 +76,10 @@ - + NotUsing - + NotUsing diff --git a/tests/vs/test_release_x86.vcxproj b/tests/vs/test_release_x86.vcxproj index ead38b3..bcdad64 100644 --- a/tests/vs/test_release_x86.vcxproj +++ b/tests/vs/test_release_x86.vcxproj @@ -76,10 +76,10 @@ - + NotUsing - + NotUsing diff --git a/tests/vs/test_release_x86_cpplatest.vcxproj b/tests/vs/test_release_x86_cpplatest.vcxproj index c7d4977..12ade43 100644 --- a/tests/vs/test_release_x86_cpplatest.vcxproj +++ b/tests/vs/test_release_x86_cpplatest.vcxproj @@ -76,10 +76,10 @@ - + NotUsing - + NotUsing diff --git a/tests/vs/test_release_x86_cpplatest_noexcept.vcxproj b/tests/vs/test_release_x86_cpplatest_noexcept.vcxproj index e126afa..c082323 100644 --- a/tests/vs/test_release_x86_cpplatest_noexcept.vcxproj +++ b/tests/vs/test_release_x86_cpplatest_noexcept.vcxproj @@ -76,10 +76,10 @@ - + NotUsing - + NotUsing diff --git a/tests/vs/test_release_x86_cpplatest_noexcept_unrel.vcxproj b/tests/vs/test_release_x86_cpplatest_noexcept_unrel.vcxproj index 12b925e..ff062bc 100644 --- a/tests/vs/test_release_x86_cpplatest_noexcept_unrel.vcxproj +++ b/tests/vs/test_release_x86_cpplatest_noexcept_unrel.vcxproj @@ -76,10 +76,10 @@ - + NotUsing - + NotUsing diff --git a/tests/vs/test_release_x86_cpplatest_unrel.vcxproj b/tests/vs/test_release_x86_cpplatest_unrel.vcxproj index a6fd28b..20115af 100644 --- a/tests/vs/test_release_x86_cpplatest_unrel.vcxproj +++ b/tests/vs/test_release_x86_cpplatest_unrel.vcxproj @@ -76,10 +76,10 @@ - + NotUsing - + NotUsing diff --git a/tests/vs/test_release_x86_noexcept.vcxproj b/tests/vs/test_release_x86_noexcept.vcxproj index ccf22ce..0a28e9a 100644 --- a/tests/vs/test_release_x86_noexcept.vcxproj +++ b/tests/vs/test_release_x86_noexcept.vcxproj @@ -76,10 +76,10 @@ - + NotUsing - + NotUsing diff --git a/tests/vs/test_release_x86_noexcept_unrel.vcxproj b/tests/vs/test_release_x86_noexcept_unrel.vcxproj index d860d33..f9d8d6b 100644 --- a/tests/vs/test_release_x86_noexcept_unrel.vcxproj +++ b/tests/vs/test_release_x86_noexcept_unrel.vcxproj @@ -76,10 +76,10 @@ - + NotUsing - + NotUsing diff --git a/tests/vs/test_release_x86_unrel.vcxproj b/tests/vs/test_release_x86_unrel.vcxproj index 59c7fc1..f508655 100644 --- a/tests/vs/test_release_x86_unrel.vcxproj +++ b/tests/vs/test_release_x86_unrel.vcxproj @@ -76,10 +76,10 @@ - + NotUsing - + NotUsing diff --git a/toml++.vcxproj b/toml++.vcxproj index 60d80b9..a11e29b 100644 --- a/toml++.vcxproj +++ b/toml++.vcxproj @@ -36,29 +36,29 @@ - + - + - + - + - + - + - + - + @@ -67,12 +67,12 @@ - + - + - + @@ -97,6 +97,7 @@ + diff --git a/toml++.vcxproj.filters b/toml++.vcxproj.filters index 3e373ce..218e69f 100644 --- a/toml++.vcxproj.filters +++ b/toml++.vcxproj.filters @@ -7,7 +7,7 @@ include\impl - + include\impl @@ -16,7 +16,7 @@ include\impl - + include\impl @@ -25,13 +25,13 @@ include\impl - + include\impl include\impl - + include\impl @@ -46,7 +46,7 @@ include\impl - + include\impl @@ -58,7 +58,7 @@ include\impl - + include\impl @@ -103,19 +103,19 @@ include\impl - + include\impl - + include\impl - + include\impl - + include\impl - + include\impl @@ -171,6 +171,9 @@ + + tools + diff --git a/toml.hpp b/toml.hpp index 351f1a3..abf3de1 100644 --- a/toml.hpp +++ b/toml.hpp @@ -102,25 +102,18 @@ _Pragma("clang diagnostic ignored \"-Wswitch\"") \ static_assert(true) - #define TOML_DISABLE_INIT_WARNINGS \ - _Pragma("clang diagnostic ignored \"-Wmissing-field-initializers\"") \ - static_assert(true) - #define TOML_DISABLE_ARITHMETIC_WARNINGS \ _Pragma("clang diagnostic ignored \"-Wfloat-equal\"") \ _Pragma("clang diagnostic ignored \"-Wdouble-promotion\"") \ - _Pragma("clang diagnostic ignored \"-Wchar-subscripts\"") \ _Pragma("clang diagnostic ignored \"-Wshift-sign-overflow\"") \ static_assert(true) - #define TOML_DISABLE_SHADOW_WARNINGS \ - _Pragma("clang diagnostic ignored \"-Wshadow\"") \ - _Pragma("clang diagnostic ignored \"-Wshadow-field\"") \ - static_assert(true) - #define TOML_DISABLE_SPAM_WARNINGS \ _Pragma("clang diagnostic ignored \"-Wweak-vtables\"") \ _Pragma("clang diagnostic ignored \"-Wweak-template-vtables\"") \ + _Pragma("clang diagnostic ignored \"-Wdouble-promotion\"") \ + _Pragma("clang diagnostic ignored \"-Wchar-subscripts\"") \ + _Pragma("clang diagnostic ignored \"-Wmissing-field-initializers\"") \ _Pragma("clang diagnostic ignored \"-Wpadded\"") \ static_assert(true) @@ -302,23 +295,12 @@ #define TOML_DISABLE_SWITCH_WARNINGS \ _Pragma("GCC diagnostic ignored \"-Wswitch\"") \ _Pragma("GCC diagnostic ignored \"-Wswitch-enum\"") \ - _Pragma("GCC diagnostic ignored \"-Wswitch-default\"") \ - static_assert(true) - - #define TOML_DISABLE_INIT_WARNINGS \ - _Pragma("GCC diagnostic ignored \"-Wmissing-field-initializers\"") \ - _Pragma("GCC diagnostic ignored \"-Wmaybe-uninitialized\"") \ - _Pragma("GCC diagnostic ignored \"-Wuninitialized\"") \ + _Pragma("GCC diagnostic ignored \"-Wswitch-default\"") \ static_assert(true) #define TOML_DISABLE_ARITHMETIC_WARNINGS \ _Pragma("GCC diagnostic ignored \"-Wfloat-equal\"") \ _Pragma("GCC diagnostic ignored \"-Wsign-conversion\"") \ - _Pragma("GCC diagnostic ignored \"-Wchar-subscripts\"") \ - static_assert(true) - - #define TOML_DISABLE_SHADOW_WARNINGS \ - _Pragma("GCC diagnostic ignored \"-Wshadow\"") \ static_assert(true) #define TOML_DISABLE_SPAM_WARNINGS \ @@ -327,8 +309,12 @@ _Pragma("GCC diagnostic ignored \"-Wcomment\"") \ _Pragma("GCC diagnostic ignored \"-Wtype-limits\"") \ _Pragma("GCC diagnostic ignored \"-Wuseless-cast\"") \ + _Pragma("GCC diagnostic ignored \"-Wchar-subscripts\"") \ + _Pragma("GCC diagnostic ignored \"-Wsubobject-linkage\"") \ + _Pragma("GCC diagnostic ignored \"-Wmissing-field-initializers\"") \ + _Pragma("GCC diagnostic ignored \"-Wmaybe-uninitialized\"") \ _Pragma("GCC diagnostic ignored \"-Wsuggest-attribute=const\"") \ - _Pragma("GCC diagnostic ignored \"-Wsuggest-attribute=pure\"") \ + _Pragma("GCC diagnostic ignored \"-Wsuggest-attribute=pure\"") \ static_assert(true) #define TOML_POP_WARNINGS \ @@ -341,9 +327,7 @@ _Pragma("GCC diagnostic ignored \"-Wextra\"") \ _Pragma("GCC diagnostic ignored \"-Wpedantic\"") \ TOML_DISABLE_SWITCH_WARNINGS; \ - TOML_DISABLE_INIT_WARNINGS; \ TOML_DISABLE_ARITHMETIC_WARNINGS; \ - TOML_DISABLE_SHADOW_WARNINGS; \ TOML_DISABLE_SPAM_WARNINGS; \ static_assert(true) @@ -519,18 +503,12 @@ #ifndef TOML_DISABLE_SWITCH_WARNINGS #define TOML_DISABLE_SWITCH_WARNINGS static_assert(true) #endif -#ifndef TOML_DISABLE_INIT_WARNINGS - #define TOML_DISABLE_INIT_WARNINGS static_assert(true) -#endif #ifndef TOML_DISABLE_SPAM_WARNINGS #define TOML_DISABLE_SPAM_WARNINGS static_assert(true) #endif #ifndef TOML_DISABLE_ARITHMETIC_WARNINGS #define TOML_DISABLE_ARITHMETIC_WARNINGS static_assert(true) #endif -#ifndef TOML_DISABLE_SHADOW_WARNINGS - #define TOML_DISABLE_SHADOW_WARNINGS static_assert(true) -#endif #ifndef TOML_POP_WARNINGS #define TOML_POP_WARNINGS static_assert(true) #endif @@ -782,17 +760,15 @@ #define TOML_IMPL_NAMESPACE_START TOML_NAMESPACE_START { namespace impl #define TOML_IMPL_NAMESPACE_END } TOML_NAMESPACE_END #if TOML_HEADER_ONLY - #define TOML_ANON_NAMESPACE_START TOML_IMPL_NAMESPACE_START + #define TOML_ANON_NAMESPACE_START static_assert(TOML_IMPLEMENTATION); TOML_IMPL_NAMESPACE_START #define TOML_ANON_NAMESPACE_END TOML_IMPL_NAMESPACE_END #define TOML_ANON_NAMESPACE TOML_NAMESPACE::impl - #define TOML_USING_ANON_NAMESPACE using namespace TOML_ANON_NAMESPACE #define TOML_EXTERNAL_LINKAGE inline #define TOML_INTERNAL_LINKAGE inline #else - #define TOML_ANON_NAMESPACE_START namespace + #define TOML_ANON_NAMESPACE_START static_assert(TOML_IMPLEMENTATION); using namespace toml; namespace #define TOML_ANON_NAMESPACE_END static_assert(true) #define TOML_ANON_NAMESPACE - #define TOML_USING_ANON_NAMESPACE static_cast(0) #define TOML_EXTERNAL_LINKAGE #define TOML_INTERNAL_LINKAGE static #endif @@ -861,6 +837,13 @@ TOML_ENABLE_WARNINGS; // clang-format on +TOML_PUSH_WARNINGS; +#if TOML_MSVC +#pragma warning(disable : 5031) // #pragma warning(pop): likely mismatch (false-positive) +#elif TOML_CLANG && !TOML_HEADER_ONLY && TOML_IMPLEMENTATION +#pragma clang diagnostic ignored "-Wheader-hygiene" // false-positive +#endif + //******** impl/std_new.h ******************************************************************************************** TOML_DISABLE_WARNINGS; @@ -2864,6 +2847,7 @@ TOML_ENABLE_WARNINGS; TOML_PUSH_WARNINGS; TOML_DISABLE_SPAM_WARNINGS; TOML_DISABLE_SWITCH_WARNINGS; +TOML_DISABLE_ARITHMETIC_WARNINGS; TOML_NAMESPACE_START { @@ -3371,6 +3355,7 @@ TOML_POP_WARNINGS; TOML_PUSH_WARNINGS; TOML_DISABLE_SPAM_WARNINGS; TOML_DISABLE_SWITCH_WARNINGS; +TOML_DISABLE_ARITHMETIC_WARNINGS; // clang-format off @@ -6891,8 +6876,6 @@ TOML_PUSH_WARNINGS; TOML_DISABLE_SPAM_WARNINGS; TOML_DISABLE_SWITCH_WARNINGS; -TOML_DISABLE_INIT_WARNINGS; - #if defined(DOXYGEN) || !TOML_EXCEPTIONS #define TOML_PARSE_ERROR_BASE #else @@ -7680,7 +7663,7 @@ TOML_POP_WARNINGS; #if TOML_IMPLEMENTATION -//******** impl/std_string_impl.h ************************************************************************************ +//******** impl/std_string.inl *************************************************************************************** #if TOML_WINDOWS_COMPAT @@ -7773,7 +7756,7 @@ TOML_POP_WARNINGS; #endif // TOML_WINDOWS_COMPAT -//******** impl/print_to_stream_impl.h ******************************************************************************* +//******** impl/print_to_stream.inl ********************************************************************************** TOML_DISABLE_WARNINGS; #include @@ -7794,10 +7777,6 @@ TOML_DISABLE_SWITCH_WARNINGS; TOML_ANON_NAMESPACE_START { -#if !TOML_HEADER_ONLY - using namespace toml; -#endif - template inline constexpr size_t charconv_buffer_length = 0; @@ -7835,8 +7814,6 @@ TOML_ANON_NAMESPACE_START TOML_INTERNAL_LINKAGE void print_integer_to_stream(std::ostream & stream, T val, value_flags format = {}) { - using namespace toml; - if (!val) { stream.put('0'); @@ -7897,7 +7874,7 @@ TOML_ANON_NAMESPACE_START ss << std::uppercase << std::setbase(base); ss << static_cast(val); const auto str = std::move(ss).str(); - impl::print_to_stream(str, stream); + impl::print_to_stream(stream, str); } #endif @@ -7907,8 +7884,6 @@ TOML_ANON_NAMESPACE_START TOML_INTERNAL_LINKAGE void print_floating_point_to_stream(std::ostream & stream, T val, value_flags format = {}) { - using namespace toml; - switch (impl::fpclassify(val)) { case impl::fp_class::neg_inf: impl::print_to_stream(stream, "-inf"sv); break; @@ -7963,8 +7938,6 @@ TOML_ANON_NAMESPACE_START TOML_INTERNAL_LINKAGE void print_integer_leftpad_zeros(std::ostream & stream, T val, size_t min_digits) { - using namespace toml; - #if TOML_INT_CHARCONV char buf[charconv_buffer_length]; @@ -8231,7 +8204,7 @@ TOML_IMPL_NAMESPACE_END; TOML_POP_WARNINGS; -//******** impl/node_impl.h ****************************************************************************************** +//******** impl/node.inl ********************************************************************************************* TOML_PUSH_WARNINGS; TOML_DISABLE_SPAM_WARNINGS; @@ -8278,7 +8251,7 @@ TOML_NAMESPACE_END; TOML_POP_WARNINGS; -//******** impl/node_view_impl.h ************************************************************************************* +//******** impl/node_view.inl **************************************************************************************** #if TOML_EXTERN_TEMPLATES @@ -8346,7 +8319,7 @@ TOML_POP_WARNINGS; #endif // TOML_EXTERN_TEMPLATES -//******** impl/value_impl.h ***************************************************************************************** +//******** impl/value.inl ******************************************************************************************** #if TOML_EXTERN_TEMPLATES @@ -8417,7 +8390,7 @@ TOML_POP_WARNINGS; #endif // TOML_EXTERN_TEMPLATES -//******** impl/array_impl.h ***************************************************************************************** +//******** impl/array.inl ******************************************************************************************** TOML_PUSH_WARNINGS; TOML_DISABLE_SPAM_WARNINGS; @@ -8425,16 +8398,10 @@ TOML_DISABLE_SWITCH_WARNINGS; TOML_ANON_NAMESPACE_START { -#if !TOML_HEADER_ONLY - using namespace toml; -#endif - template TOML_INTERNAL_LINKAGE bool array_is_homogeneous(T & elements, node_type ntype, U & first_nonmatch) noexcept { - using namespace toml; - if (elements.empty()) { first_nonmatch = {}; @@ -8655,7 +8622,7 @@ TOML_NAMESPACE_END; TOML_POP_WARNINGS; -//******** impl/table_impl.h ***************************************************************************************** +//******** impl/table.inl ******************************************************************************************** TOML_PUSH_WARNINGS; TOML_DISABLE_SPAM_WARNINGS; @@ -8663,16 +8630,10 @@ TOML_DISABLE_SWITCH_WARNINGS; TOML_ANON_NAMESPACE_START { -#if !TOML_HEADER_ONLY - using namespace toml; -#endif - template TOML_INTERNAL_LINKAGE bool table_is_homogeneous(T & map, node_type ntype, U & first_nonmatch) noexcept { - using namespace toml; - if (map.empty()) { first_nonmatch = {}; @@ -8820,7 +8781,7 @@ TOML_NAMESPACE_END; TOML_POP_WARNINGS; -//******** impl/parser_impl.h **************************************************************************************** +//******** impl/parser.inl ******************************************************************************************* #if TOML_PARSER @@ -8844,10 +8805,6 @@ TOML_DISABLE_SWITCH_WARNINGS; TOML_ANON_NAMESPACE_START { -#if !TOML_HEADER_ONLY - using namespace toml; -#endif - template class utf8_byte_stream; @@ -8987,13 +8944,6 @@ TOML_ANON_NAMESPACE_START return bytes[3] ? std::string_view{ bytes, 4_sz } : std::string_view{ bytes }; } - TOML_NODISCARD - TOML_ATTR(pure) - constexpr operator char32_t&() noexcept - { - return value; - } - TOML_NODISCARD TOML_ATTR(pure) constexpr operator const char32_t&() const noexcept @@ -12459,7 +12409,7 @@ TOML_POP_WARNINGS; #endif // TOML_PARSER -//******** impl/formatter_impl.h ************************************************************************************* +//******** impl/formatter.inl **************************************************************************************** TOML_PUSH_WARNINGS; TOML_DISABLE_SPAM_WARNINGS; @@ -12675,11 +12625,12 @@ TOML_IMPL_NAMESPACE_END; TOML_POP_WARNINGS; -//******** impl/default_formatter_impl.h ***************************************************************************** +//******** impl/default_formatter.inl ******************************************************************************** TOML_PUSH_WARNINGS; TOML_DISABLE_SPAM_WARNINGS; TOML_DISABLE_SWITCH_WARNINGS; +TOML_DISABLE_ARITHMETIC_WARNINGS; TOML_NAMESPACE_START { @@ -13113,7 +13064,7 @@ TOML_NAMESPACE_END; TOML_POP_WARNINGS; -//******** impl/json_formatter_impl.h ******************************************************************************** +//******** impl/json_formatter.inl *********************************************************************************** TOML_PUSH_WARNINGS; TOML_DISABLE_SPAM_WARNINGS; @@ -13213,6 +13164,8 @@ TOML_POP_WARNINGS; #endif // TOML_IMPLEMENTATION +TOML_POP_WARNINGS; + // macro hygiene #if TOML_UNDEF_MACROS #undef TOML_ABI_NAMESPACE_BOOL @@ -13238,8 +13191,6 @@ TOML_POP_WARNINGS; #undef TOML_CPP #undef TOML_DISABLE_ARITHMETIC_WARNINGS #undef TOML_DISABLE_CODE_ANALYSIS_WARNINGS -#undef TOML_DISABLE_INIT_WARNINGS -#undef TOML_DISABLE_SHADOW_WARNINGS #undef TOML_DISABLE_SPAM_WARNINGS #undef TOML_DISABLE_SUGGEST_WARNINGS #undef TOML_DISABLE_SWITCH_WARNINGS @@ -13311,7 +13262,6 @@ TOML_POP_WARNINGS; #undef TOML_UINT128 #undef TOML_UNLIKELY #undef TOML_UNREACHABLE -#undef TOML_USING_ANON_NAMESPACE #endif #endif // TOMLPLUSPLUS_H diff --git a/tools/clang_format.bat b/tools/clang_format.bat new file mode 100644 index 0000000..da029f9 --- /dev/null +++ b/tools/clang_format.bat @@ -0,0 +1,33 @@ +@ECHO off +SETLOCAL enableextensions enabledelayedexpansion +PUSHD . +CD /d "%~dp0\.." + +REM -------------------------------------------------------------------------------------- +REM Runs clang format on all the non-test C++ files in the project +REM -------------------------------------------------------------------------------------- + +CALL :RunClangFormatOnDirectories ^ + include\toml++ ^ + include\toml++\impl ^ + examples + +GOTO FINISH + +:RunClangFormatOnDirectories +( + FOR %%i IN (%*) DO ( + IF EXIST "%%~i" ( + ECHO Formatting files in "%%~i" + clang-format --style=file -i "%%~i\*.cpp" >nul 2>&1 + clang-format --style=file -i "%%~i\*.h" >nul 2>&1 + clang-format --style=file -i "%%~i\*.inl" >nul 2>&1 + ) + ) + EXIT /B +) + +:FINISH +POPD +@ENDLOCAL +EXIT /B 0 diff --git a/tools/generate_single_header.py b/tools/generate_single_header.py index c87b7d8..c777462 100644 --- a/tools/generate_single_header.py +++ b/tools/generate_single_header.py @@ -15,7 +15,7 @@ from io import StringIO class Preprocessor: - __re_includes = re.compile(r'^\s*#\s*include\s+"(.+?)"', re.I | re.M) + __re_includes = re.compile(r'^\s*#\s*include\s+"(.+?)".*?$', re.I | re.M) __multiples_allowed = [ r'impl/header_start.h', r'impl/header_end.h' @@ -57,7 +57,7 @@ class Preprocessor: if self.__current_level == 1: header = utils.make_divider(relative_path, 10, pattern = r'*') - text = f'{header}\n\n{text}' + text = f'\n\n{header}\n\n{text}' self.__directory_stack.pop() return '\n\n' + text + '\n\n' @@ -102,6 +102,9 @@ def main(): toml_h = re.sub(r'([^@][({,])\n\n', r'\1\n', toml_h) # blank lines preceeding closing brackets toml_h = re.sub(r'\n\n([ \t]*[})])', r'\n\1', toml_h) + # blank lines between consecutive TOML_DISABLE_XXXXX_WARNINGS statements + toml_h = re.sub('(TOML_(?:PUSH|DISABLE_[A-Z_]+?)WARNINGS;)\n[ \t\n]*\n(TOML_DISABLE_[A-Z_]+?WARNINGS;)', r'\1\n\2', toml_h) + # ensure only one trailing newline toml_h = toml_h.strip() + '\n' # change TOML_LIB_SINGLE_HEADER to 1 diff --git a/tools/generate_windows_test_targets.py b/tools/generate_windows_test_targets.py index bc20e34..ca75ed6 100644 --- a/tools/generate_windows_test_targets.py +++ b/tools/generate_windows_test_targets.py @@ -119,10 +119,10 @@ def main(): - + NotUsing - + NotUsing