Blender V5.0
BLI_string_search.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#pragma once
10
12#include "BLI_map.hh"
13#include "BLI_span.hh"
14#include "BLI_string_ref.hh"
15#include "BLI_vector.hh"
16
18
46
54
65
79
90template<typename T> class StringSearch : private StringSearchBase {
91 public:
92 StringSearch(const RecentCache *recent_cache, const MainWordsHeuristic main_words_heuristic)
93 {
94 recent_cache_ = recent_cache;
95 main_words_heuristic_ = main_words_heuristic;
96 }
97
104 void add(const StringRef str, T *user_data, const int weight = 0)
105 {
106 this->add_impl(str, (void *)user_data, weight);
107 }
108
114 {
115 Vector<void *> result = this->query_impl(query);
116 Vector<T *> result_typed = result.as_span().cast<T *>();
117 return result_typed;
118 }
119};
120
140 LinearAllocator<> &allocator,
141 Vector<StringRef, 64> &r_words,
142 Vector<int, 64> &r_word_group_ids);
143
144} // namespace blender::string_search
void add_impl(StringRef str, void *user_data, float weight)
Vector< void * > query_impl(StringRef query) const
StringSearch(const RecentCache *recent_cache, const MainWordsHeuristic main_words_heuristic)
void add(const StringRef str, T *user_data, const int weight=0)
Vector< T * > query(const StringRef query) const
#define str(s)
#define T
int get_fuzzy_match_errors(StringRef query, StringRef full)
int damerau_levenshtein_distance(StringRef a, StringRef b)
void extract_normalized_words(StringRef str, LinearAllocator<> &allocator, Vector< StringRef, 64 > &r_words, Vector< int, 64 > &r_word_group_ids)
Map< std::string, int > logical_time_by_str