diff options
author | Campbell Barton <ideasman42@gmail.com> | 2021-12-09 12:01:44 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2021-12-09 12:01:44 +0300 |
commit | 9e365069afe156f33fadfad9705e1325f894cd54 (patch) | |
tree | 78373044d029feb51f987b45208e0c1a36958625 /source/blender/blenlib/BLI_string_search.h | |
parent | d8b42751625c915113b64f5a2d9c72f19f009fee (diff) |
Cleanup: move public doc-strings into headers for 'blenlib'
- Added space below non doc-string comments to make it clear
these aren't comments for the symbols directly below them.
- Use doxy sections for some headers.
- Minor improvements to doc-strings.
Ref T92709
Diffstat (limited to 'source/blender/blenlib/BLI_string_search.h')
-rw-r--r-- | source/blender/blenlib/BLI_string_search.h | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_string_search.h b/source/blender/blenlib/BLI_string_search.h index 8057e5b75cb..b846a4d3c39 100644 --- a/source/blender/blenlib/BLI_string_search.h +++ b/source/blender/blenlib/BLI_string_search.h @@ -23,7 +23,16 @@ extern "C" { typedef struct StringSearch StringSearch; StringSearch *BLI_string_search_new(void); +/** + * Add a new possible result to the search. + * The caller keeps ownership of all parameters. + */ void BLI_string_search_add(StringSearch *search, const char *str, void *user_data); +/** + * Filter and sort all previously added search items. + * Returns an array containing the filtered user data. + * The caller has to free the returned array. + */ int BLI_string_search_query(StringSearch *search, const char *query, void ***r_data); void BLI_string_search_free(StringSearch *search); @@ -40,8 +49,24 @@ void BLI_string_search_free(StringSearch *search); namespace blender::string_search { +/** + * Computes the cost of transforming string a into b. The cost/distance is the minimal number of + * operations that need to be executed. Valid operations are deletion, insertion, substitution and + * transposition. + * + * This function is utf8 aware in the sense that it works at the level of individual code points + * (1-4 bytes long) instead of on individual bytes. + */ int damerau_levenshtein_distance(StringRef a, StringRef b); +/** + * Returns -1 when this is no reasonably good match. + * Otherwise returns the number of errors in the match. + */ int get_fuzzy_match_errors(StringRef query, StringRef full); +/** + * Splits a string into words and normalizes them (currently that just means converting to lower + * case). The returned strings are allocated in the given allocator. + */ void extract_normalized_words(StringRef str, LinearAllocator<> &allocator, Vector<StringRef, 64> &r_words); |