fuzzy.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /* fuzzy.h
  2. *
  3. * Copyright (C) 2013 Christian Hergert <christian@hergert.me>
  4. *
  5. * This file is free software; you can redistribute it and/or modify it
  6. * under the terms of the GNU Lesser General Public License as published by
  7. * the Free Software Foundation; either version 2.1 of the License, or (at
  8. * your option) any later version.
  9. *
  10. * This file is distributed in the hope that it will be useful, but WITHOUT
  11. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
  13. * License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License along
  16. * with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #ifndef FUZZY_H
  19. #define FUZZY_H
  20. #include <glib.h>
  21. G_BEGIN_DECLS
  22. typedef struct _Fuzzy Fuzzy;
  23. typedef struct _FuzzyMatch FuzzyMatch;
  24. struct _FuzzyMatch
  25. {
  26. const gchar *key;
  27. gpointer value;
  28. gfloat score;
  29. };
  30. Fuzzy *fuzzy_new (gboolean case_sensitive);
  31. Fuzzy *fuzzy_new_with_free_func (gboolean case_sensitive,
  32. GDestroyNotify free_func);
  33. void fuzzy_set_free_func (Fuzzy *fuzzy,
  34. GDestroyNotify free_func);
  35. void fuzzy_begin_bulk_insert (Fuzzy *fuzzy);
  36. void fuzzy_end_bulk_insert (Fuzzy *fuzzy);
  37. void fuzzy_insert (Fuzzy *fuzzy,
  38. const gchar *key,
  39. gpointer value);
  40. GArray *fuzzy_match (Fuzzy *fuzzy,
  41. const gchar *needle,
  42. gsize max_matches);
  43. void fuzzy_free (Fuzzy *fuzzy);
  44. G_END_DECLS
  45. #endif /* FUZZY_H */