From a3da11a288da5993d5bc96a1647c53b6cc676f3a Mon Sep 17 00:00:00 2001 From: Mark Gillard Date: Tue, 11 Jan 2022 23:26:39 +0200 Subject: [PATCH] updated toml++ to v3 (#62) --- include/pytomlpp/pytomlpp.hpp | 3 +-- src/encoding_decoding.cpp | 22 ++++++++++++---------- third_party/tomlplusplus | 2 +- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/include/pytomlpp/pytomlpp.hpp b/include/pytomlpp/pytomlpp.hpp index 96e5b5c..b8c6eed 100644 --- a/include/pytomlpp/pytomlpp.hpp +++ b/include/pytomlpp/pytomlpp.hpp @@ -13,8 +13,7 @@ #endif // toml++ config -#define TOML_WINDOWS_COMPAT 0 -#define TOML_LARGE_FILES 1 +#define TOML_ENABLE_WINDOWS_COMPAT 0 #define TOML_HEADER_ONLY 0 #ifdef __APPLE__ #define TOML_INT_CHARCONV 0 diff --git a/src/encoding_decoding.cpp b/src/encoding_decoding.cpp index 1ee961f..ce8db70 100644 --- a/src/encoding_decoding.cpp +++ b/src/encoding_decoding.cpp @@ -20,7 +20,7 @@ py::list toml_array_to_py_list(toml::array &&a) { py::dict toml_table_to_py_dict(toml::table &&t) { py::dict result; for (auto &&[key_, val_] : std::move(t)) { - std::move(val_).visit([&, key = key_.c_str()](auto &&val) { + std::move(val_).visit([&, key = key_.str().data()](auto &&val) { if constexpr (toml::is_table) result[key] = toml_table_to_py_dict(std::move(val)); else if constexpr (toml::is_array) @@ -99,27 +99,29 @@ toml::table py_dict_to_toml_table(const py::dict &object) { bool insert_ok = true; if (py::isinstance(value)) { bool bool_value = value.cast(); - auto insert = t.insert_or_assign(key_string, bool_value); + auto insert = t.insert_or_assign(std::move(key_string), bool_value); insert_ok = insert.second; } else if (py::isinstance(value)) { int64_t int_value = value.cast(); - auto insert = t.insert_or_assign(key_string, int_value); + auto insert = t.insert_or_assign(std::move(key_string), int_value); insert_ok = insert.second; } else if (py::isinstance(value)) { double float_value = value.cast(); - auto insert = t.insert_or_assign(key_string, float_value); + auto insert = t.insert_or_assign(std::move(key_string), float_value); insert_ok = insert.second; } else if (py::isinstance(value)) { std::string string_value = value.cast(); - auto insert = t.insert_or_assign(key_string, string_value); + auto insert = t.insert_or_assign(std::move(key_string), string_value); insert_ok = insert.second; } else if (py::isinstance(value)) { toml::table table_value = py_dict_to_toml_table(value.cast()); - auto insert = t.insert_or_assign(key_string, std::move(table_value)); + auto insert = + t.insert_or_assign(std::move(key_string), std::move(table_value)); insert_ok = insert.second; } else if (py::isinstance(value)) { toml::array array_value = py_list_to_toml_array(value.cast()); - auto insert = t.insert_or_assign(key_string, std::move(array_value)); + auto insert = + t.insert_or_assign(std::move(key_string), std::move(array_value)); insert_ok = insert.second; } else if (py::isinstance(value, datetime_class)) { // Order matters here. @@ -127,15 +129,15 @@ toml::table py_dict_to_toml_table(const py::dict &object) { // isinstance(datetime_obj, date) --> true as well // so we need to test datetime first then date. toml::date_time date_time_value = value.cast(); - auto insert = t.insert_or_assign(key_string, date_time_value); + auto insert = t.insert_or_assign(std::move(key_string), date_time_value); insert_ok = insert.second; } else if (py::isinstance(value, date_class)) { toml::date date_value = value.cast(); - auto insert = t.insert_or_assign(key_string, date_value); + auto insert = t.insert_or_assign(std::move(key_string), date_value); insert_ok = insert.second; } else if (py::isinstance(value, time_class)) { toml::time time_value = value.cast(); - auto insert = t.insert_or_assign(key_string, time_value); + auto insert = t.insert_or_assign(std::move(key_string), time_value); insert_ok = insert.second; } else { std::stringstream ss; diff --git a/third_party/tomlplusplus b/third_party/tomlplusplus index 037bfdd..5c5abfd 160000 --- a/third_party/tomlplusplus +++ b/third_party/tomlplusplus @@ -1 +1 @@ -Subproject commit 037bfdd21f794d7212616d5e6f4f8baab543c472 +Subproject commit 5c5abfd8e96a0fb9ee9f57ecdba8f92fe739d869