diff --git a/include/rfl/PatternValidator.hpp b/include/rfl/PatternValidator.hpp index c5b77992..ef18ee63 100644 --- a/include/rfl/PatternValidator.hpp +++ b/include/rfl/PatternValidator.hpp @@ -23,7 +23,8 @@ struct PatternValidator { using Regex = Literal<_regex>; static Result validate(const std::string& _str) noexcept { - if (ctre::match<_regex.arr_>(_str)) { + if (ctre::match{ + ctll::construct_from_pointer, _regex.arr_.data()}>(_str)) { return _str; } else { std::stringstream stream; diff --git a/include/rfl/internal/StringLiteral.hpp b/include/rfl/internal/StringLiteral.hpp index 57f6861f..c4cc88c9 100644 --- a/include/rfl/internal/StringLiteral.hpp +++ b/include/rfl/internal/StringLiteral.hpp @@ -30,6 +30,8 @@ struct StringLiteral { return std::string_view(std::data(arr_), N - 1); } + static constexpr size_t length = N - 1; + std::array arr_{}; }; 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