From db2e14f701d5e7ee989eba3fe9335cedac62fb32 Mon Sep 17 00:00:00 2001 From: Kirk Rodrigues <2454684+kirkrodrigues@users.noreply.github.com> Date: Tue, 10 Sep 2024 19:50:18 -0400 Subject: [PATCH] Rename WildcardExpressionView::m_search_string_ptr -> m_expression. --- .../core/src/clp/WildcardExpression.cpp | 30 +++++++++---------- .../core/src/clp/WildcardExpression.hpp | 20 ++++++------- 2 files changed, 24 insertions(+), 26 deletions(-) diff --git a/components/core/src/clp/WildcardExpression.cpp b/components/core/src/clp/WildcardExpression.cpp index e47e7f873..d547376af 100644 --- a/components/core/src/clp/WildcardExpression.cpp +++ b/components/core/src/clp/WildcardExpression.cpp @@ -58,7 +58,7 @@ WildcardExpressionView::WildcardExpressionView( size_t const begin_idx, size_t const end_idx ) - : m_search_string_ptr{&wildcard_expression}, + : m_expression{&wildcard_expression}, m_begin_idx{begin_idx}, m_end_idx{end_idx} { m_end_idx = std::min(m_end_idx, wildcard_expression.length()); @@ -68,13 +68,12 @@ WildcardExpressionView::WildcardExpressionView( auto WildcardExpressionView::extend_to_adjacent_greedy_wildcards() const -> WildcardExpressionView { auto extended_view = *this; bool const prev_char_is_greedy_wildcard - = m_begin_idx > 0 && m_search_string_ptr->char_is_greedy_wildcard(m_begin_idx - 1); + = m_begin_idx > 0 && m_expression->char_is_greedy_wildcard(m_begin_idx - 1); if (prev_char_is_greedy_wildcard) { extended_view.m_begin_idx--; } - bool const next_char_is_greedy_wildcard - = m_end_idx < m_search_string_ptr->length() - && m_search_string_ptr->char_is_greedy_wildcard(m_end_idx); + bool const next_char_is_greedy_wildcard = m_end_idx < m_expression->length() + && m_expression->char_is_greedy_wildcard(m_end_idx); if (next_char_is_greedy_wildcard) { ++extended_view.m_end_idx; } @@ -89,31 +88,30 @@ auto WildcardExpressionView::surrounded_by_delims_or_wildcards( has_preceding_delim = true; } else { bool const preceded_by_greedy_wildcard - = m_search_string_ptr->char_is_greedy_wildcard(m_begin_idx - 1); + = m_expression->char_is_greedy_wildcard(m_begin_idx - 1); bool const preceded_by_non_greedy_wildcard - = m_search_string_ptr->char_is_non_greedy_wildcard(m_begin_idx - 1); + = m_expression->char_is_non_greedy_wildcard(m_begin_idx - 1); bool const preceded_by_delimiter - = lexer.is_delimiter(m_search_string_ptr->get_char(m_begin_idx - 1)); + = lexer.is_delimiter(m_expression->get_char(m_begin_idx - 1)); has_preceding_delim = preceded_by_greedy_wildcard || preceded_by_non_greedy_wildcard || preceded_by_delimiter; } bool has_succeeding_delim{}; - if (m_search_string_ptr->length() == m_end_idx) { + if (m_expression->length() == m_end_idx) { has_succeeding_delim = true; } else { - bool const succeeded_by_greedy_wildcard - = m_search_string_ptr->char_is_greedy_wildcard(m_end_idx); + bool const succeeded_by_greedy_wildcard = m_expression->char_is_greedy_wildcard(m_end_idx); bool const succeeded_by_non_greedy_wildcard - = m_search_string_ptr->char_is_non_greedy_wildcard(m_end_idx); + = m_expression->char_is_non_greedy_wildcard(m_end_idx); // E.g. "foo:", where ':' is a delimiter bool const succeeded_by_unescaped_delim - = false == m_search_string_ptr->char_is_escape(m_end_idx) - && lexer.is_delimiter(m_search_string_ptr->get_char(m_end_idx)); + = false == m_expression->char_is_escape(m_end_idx) + && lexer.is_delimiter(m_expression->get_char(m_end_idx)); // E.g. "foo\\", where '\' is a delimiter bool const succeeded_by_escaped_delim - = m_search_string_ptr->char_is_escape(m_end_idx) - && lexer.is_delimiter(m_search_string_ptr->get_char(m_end_idx + 1)); + = m_expression->char_is_escape(m_end_idx) + && lexer.is_delimiter(m_expression->get_char(m_end_idx + 1)); has_succeeding_delim = succeeded_by_greedy_wildcard || succeeded_by_non_greedy_wildcard || succeeded_by_unescaped_delim || succeeded_by_escaped_delim; } diff --git a/components/core/src/clp/WildcardExpression.hpp b/components/core/src/clp/WildcardExpression.hpp index 6cebddecf..01fef1f2c 100644 --- a/components/core/src/clp/WildcardExpression.hpp +++ b/components/core/src/clp/WildcardExpression.hpp @@ -71,17 +71,17 @@ class WildcardExpressionView { [[nodiscard]] auto extend_to_adjacent_greedy_wildcards() const -> WildcardExpressionView; [[nodiscard]] auto is_greedy_wildcard() const -> bool { - return 1 == length() && m_search_string_ptr->char_is_greedy_wildcard(m_begin_idx); + return 1 == length() && m_expression->char_is_greedy_wildcard(m_begin_idx); } [[nodiscard]] auto is_non_greedy_wildcard() const -> bool { - return 1 == length() && m_search_string_ptr->char_is_non_greedy_wildcard(m_begin_idx); + return 1 == length() && m_expression->char_is_non_greedy_wildcard(m_begin_idx); } [[nodiscard]] auto starts_or_ends_with_greedy_wildcard() const -> bool { return length() > 0 - && (m_search_string_ptr->char_is_greedy_wildcard(m_begin_idx) - || m_search_string_ptr->char_is_greedy_wildcard(m_end_idx - 1)); + && (m_expression->char_is_greedy_wildcard(m_begin_idx) + || m_expression->char_is_greedy_wildcard(m_end_idx - 1)); } /** @@ -96,27 +96,27 @@ class WildcardExpressionView { [[nodiscard]] auto length() const -> size_t { return m_end_idx - m_begin_idx; } [[nodiscard]] auto char_is_greedy_wildcard(size_t const idx) const -> bool { - return m_search_string_ptr->char_is_greedy_wildcard(m_begin_idx + idx); + return m_expression->char_is_greedy_wildcard(m_begin_idx + idx); } [[nodiscard]] auto char_is_non_greedy_wildcard(size_t const idx) const -> bool { - return m_search_string_ptr->char_is_non_greedy_wildcard(m_begin_idx + idx); + return m_expression->char_is_non_greedy_wildcard(m_begin_idx + idx); } [[nodiscard]] auto char_is_escape(size_t const idx) const -> bool { - return m_search_string_ptr->char_is_escape(m_begin_idx + idx); + return m_expression->char_is_escape(m_begin_idx + idx); } [[nodiscard]] auto get_char(size_t const idx) const -> char { - return m_search_string_ptr->get_char(m_begin_idx + idx); + return m_expression->get_char(m_begin_idx + idx); } [[nodiscard]] auto get_value() const -> std::string { - return m_search_string_ptr->substr(m_begin_idx, m_end_idx - m_begin_idx); + return m_expression->substr(m_begin_idx, m_end_idx - m_begin_idx); } private: - WildcardExpression const* m_search_string_ptr; + WildcardExpression const* m_expression; size_t m_begin_idx; size_t m_end_idx; };