/**************************************************************************/ /* fuzzy_search.cpp */ /**************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ /* https://godotengine.org */ /**************************************************************************/ /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ /* "Software"), to deal in the Software without restriction, including */ /* without limitation the rights to use, copy, modify, merge, publish, */ /* distribute, sublicense, and/or sell copies of the Software, and to */ /* permit persons to whom the Software is furnished to do so, subject to */ /* the following conditions: */ /* */ /* The above copyright notice and this permission notice shall be */ /* included in all copies or substantial portions of the Software. */ /* */ /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /**************************************************************************/ #include "fuzzy_search.h" constexpr float cull_factor = …; constexpr float cull_cutoff = …; const String boundary_chars = …; static bool _is_valid_interval(const Vector2i &p_interval) { … } static Vector2i _extend_interval(const Vector2i &p_a, const Vector2i &p_b) { … } static bool _is_word_boundary(const String &p_str, int p_index) { … } bool FuzzySearchToken::try_exact_match(FuzzyTokenMatch &p_match, const String &p_target, int p_offset) const { … } bool FuzzySearchToken::try_fuzzy_match(FuzzyTokenMatch &p_match, const String &p_target, int p_offset, int p_miss_budget) const { … } void FuzzyTokenMatch::add_substring(int p_substring_start, int p_substring_length) { … } bool FuzzyTokenMatch::intersects(const Vector2i &p_other_interval) const { … } bool FuzzySearchResult::can_add_token_match(const FuzzyTokenMatch &p_match) const { … } bool FuzzyTokenMatch::is_case_insensitive(const String &p_original, const String &p_adjusted) const { … } void FuzzySearchResult::score_token_match(FuzzyTokenMatch &p_match, bool p_case_insensitive) const { … } void FuzzySearchResult::maybe_apply_score_bonus() { … } void FuzzySearchResult::add_token_match(const FuzzyTokenMatch &p_match) { … } void remove_low_scores(Vector<FuzzySearchResult> &p_results, float p_cull_score) { … } void FuzzySearch::sort_and_filter(Vector<FuzzySearchResult> &p_results) const { … } void FuzzySearch::set_query(const String &p_query) { … } bool FuzzySearch::search(const String &p_target, FuzzySearchResult &p_result) const { … } void FuzzySearch::search_all(const PackedStringArray &p_targets, Vector<FuzzySearchResult> &p_results) const { … }