Blender V4.3
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
5#pragma once
6
8#include "BLI_map.hh"
9#include "BLI_span.hh"
10#include "BLI_string_ref.hh"
11#include "BLI_vector.hh"
12
14
42
50
59 All,
60};
61
66 protected:
69 const RecentCache *recent_cache_ = nullptr;
71
72 protected:
73 void add_impl(StringRef str, void *user_data, float weight);
75};
76
87template<typename T> class StringSearch : private StringSearchBase {
88 public:
89 StringSearch(const RecentCache *recent_cache, const MainWordsHeuristic main_words_heuristic)
90 {
91 recent_cache_ = recent_cache;
92 main_words_heuristic_ = main_words_heuristic;
93 }
94
101 void add(const StringRef str, T *user_data, const int weight = 0)
102 {
103 this->add_impl(str, (void *)user_data, weight);
104 }
105
111 {
112 Vector<void *> result = this->query_impl(query);
113 Vector<T *> result_typed = result.as_span().cast<T *>();
114 return result_typed;
115 }
116};
117
137 LinearAllocator<> &allocator,
138 Vector<StringRef, 64> &r_words,
139 Vector<int, 64> &r_word_group_ids);
140
141} // namespace blender::string_search
Span< T > as_span() const
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
local_group_size(16, 16) .push_constant(Type b
#define str(s)
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