From 0440b6844923173a0e9a2ce270148f453bb4c843 Mon Sep 17 00:00:00 2001 From: "Dr. Patrick Urbanke" Date: Sun, 31 Aug 2025 12:02:44 +0200 Subject: [PATCH 1/3] Added a test for UUIDv4; relates to #486 --- tests/json/test_uuid.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 tests/json/test_uuid.cpp diff --git a/tests/json/test_uuid.cpp b/tests/json/test_uuid.cpp new file mode 100644 index 00000000..8c26f028 --- /dev/null +++ b/tests/json/test_uuid.cpp @@ -0,0 +1,26 @@ +#include +#include +#include +#include +#include + +#include "write_and_read.hpp" + +namespace test_uuid { + +struct Person { + rfl::Rename<"firstName", std::string> first_name; + rfl::Rename<"lastName", std::string> last_name; + rfl::UUIDv4 uuid; +}; + +TEST(json, test_uuid) { + const auto homer = Person{.first_name = "Homer", + .last_name = "Simpson", + .uuid = "f23b2a1d-b1a6-4e0d-af1b-8f0d912e255a"}; + + write_and_read( + homer, + R"({"firstName":"Homer","lastName":"Simpson","uuid":"f23b2a1d-b1a6-4e0d-af1b-8f0d912e255a"})"); +} +} // namespace test_uuid From 7ca2fcd5e44f01f8d75845dccbafdfc4a3d34ede Mon Sep 17 00:00:00 2001 From: "Dr. Patrick Urbanke" Date: Sun, 31 Aug 2025 20:49:52 +0200 Subject: [PATCH 2/3] Updated CTRE to version 3.10 --- include/rfl/thirdparty/ctre.hpp | 77 ++++++++++++++++++--------------- vcpkg | 2 +- vcpkg.json | 2 +- 3 files changed, 43 insertions(+), 38 deletions(-) diff --git a/include/rfl/thirdparty/ctre.hpp b/include/rfl/thirdparty/ctre.hpp index 096e4114..41796262 100644 --- a/include/rfl/thirdparty/ctre.hpp +++ b/include/rfl/thirdparty/ctre.hpp @@ -353,7 +353,6 @@ CTLL_EXPORT template struct fixed_string { #ifdef CTRE_STRING_IS_UTF8 size_t out{0}; for (size_t i{0}; i < N; ++i) { - if ((i == (N-1)) && (input[i] == 0)) break; length_value_t info = length_and_value_of_utf8_code_point(input[i]); switch (info.length) { case 6: @@ -383,15 +382,13 @@ CTLL_EXPORT template struct fixed_string { #else for (size_t i{0}; i < N; ++i) { content[i] = static_cast(input[i]); - if ((i == (N-1)) && (input[i] == 0)) break; real_size++; } #endif - #if __cpp_char8_t +#if defined(__cpp_char8_t) } else if constexpr (std::is_same_v) { size_t out{0}; for (size_t i{0}; i < N; ++i) { - if ((i == (N-1)) && (input[i] == 0)) break; length_value_t info = length_and_value_of_utf8_code_point(input[i]); switch (info.length) { case 6: @@ -418,7 +415,7 @@ CTLL_EXPORT template struct fixed_string { return; } } - #endif +#endif } else if constexpr (std::is_same_v) { size_t out{0}; for (size_t i{0}; i < N; ++i) { @@ -433,7 +430,6 @@ CTLL_EXPORT template struct fixed_string { } } } else { - if ((i == (N-1)) && (input[i] == 0)) break; content[out++] = info.value; } } @@ -441,7 +437,6 @@ CTLL_EXPORT template struct fixed_string { } else if constexpr (std::is_same_v || std::is_same_v) { for (size_t i{0}; i < N; ++i) { content[i] = static_cast(input[i]); - if ((i == (N-1)) && (input[i] == 0)) break; real_size++; } } @@ -1077,6 +1072,7 @@ struct pcre { struct repeat_star: ctll::action {}; struct reset_capture: ctll::action {}; struct set_combine: ctll::action {}; + struct set_empty: ctll::action {}; struct set_make: ctll::action {}; struct set_make_negative: ctll::action {}; struct set_start: ctll::action {}; @@ -1380,11 +1376,11 @@ struct pcre { static constexpr auto rule(repeat, ctll::term<'*'>) -> ctll::push; static constexpr auto rule(repeat, ctll::term<'\x7D'>) -> ctll::reject; - static constexpr auto rule(set2a, ctll::term<']'>) -> ctll::epsilon; static constexpr auto rule(set2a, ctll::term<'['>) -> ctll::push, i, range, set_start, set2b>; static constexpr auto rule(set2a, ctll::term<'\\'>) -> ctll::push; static constexpr auto rule(set2a, ctll::set<'!','$','\x28','\x29','*','+',',','.','/','0','1','2','3','4','5','6','7','8','9',':','<','=','>','?','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','\"','^','_','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','\x7B','|','\x7D'>) -> ctll::push; static constexpr auto rule(set2a, _others) -> ctll::push; + static constexpr auto rule(set2a, ctll::term<']'>) -> ctll::push; static constexpr auto rule(set2a, ctll::term<'-'>) -> ctll::reject; static constexpr auto rule(set2b, ctll::term<']'>) -> ctll::epsilon; @@ -1604,13 +1600,13 @@ template struct character { }; template struct negative_set { - template CTRE_FORCE_INLINE static constexpr bool match_char(CharT value, const flags & f) noexcept { + template CTRE_FORCE_INLINE static constexpr bool match_char([[maybe_unused]] CharT value, const flags & f) noexcept { return !(Content::match_char(value, f) || ... || false); } }; template struct set { - template CTRE_FORCE_INLINE static constexpr bool match_char(CharT value, const flags & f) noexcept { + template CTRE_FORCE_INLINE static constexpr bool match_char([[maybe_unused]] CharT value, const flags & f) noexcept { return (Content::match_char(value, f) || ... || false); } }; @@ -1618,7 +1614,7 @@ template struct set { template struct enumeration : set...> { }; template struct negate { - template CTRE_FORCE_INLINE static constexpr bool match_char(CharT value, const flags & f) noexcept { + template CTRE_FORCE_INLINE static constexpr bool match_char([[maybe_unused]] CharT value, const flags & f) noexcept { return !(Content::match_char(value, f) || ... || false); } }; @@ -2067,9 +2063,13 @@ static auto rotate(end_lookbehind_mark) -> end_lookbehind_mark; template static auto rotate(numeric_mark) -> numeric_mark; static auto rotate(any) -> any; -template static auto rotate(select) -> select; static auto rotate(empty) -> empty; +// select rotates only insides of selection, not select itself +template static auto rotate(select) { + return select{}; +} + template static auto rotate(repeat) -> decltype(ctre::convert_to_repeat(ctll::rotate(ctll::list{}))); template static auto rotate(lazy_repeat) -> decltype(ctre::convert_to_repeat(ctll::rotate(ctll::list{}))); template static auto rotate(possessive_repeat) -> decltype(ctre::convert_to_repeat(ctll::rotate(ctll::list{}))); @@ -2909,6 +2909,12 @@ template