2014-09-16 08:09:27 -04:00
|
|
|
/**
|
2013-08-25 10:33:48 -04:00
|
|
|
* Copyright 2013 (c) Anna Schumaker.
|
|
|
|
*/
|
2014-06-21 09:37:47 -04:00
|
|
|
#ifndef OCARINA_CORE_FILTER_H
|
|
|
|
#define OCARINA_CORE_FILTER_H
|
2013-08-25 10:33:48 -04:00
|
|
|
|
2015-10-21 15:57:21 -04:00
|
|
|
extern "C" {
|
|
|
|
#include <core/set.h>
|
|
|
|
}
|
|
|
|
|
2013-08-25 10:33:48 -04:00
|
|
|
#include <string>
|
|
|
|
|
2014-09-16 08:09:27 -04:00
|
|
|
/**
|
2014-11-08 11:25:13 -05:00
|
|
|
* The filter layer is used to find a subset of songs based on an input
|
|
|
|
* string. Since this layer does text processing, it also provides a
|
|
|
|
* functions for converting strings to lowercase.
|
|
|
|
*
|
|
|
|
* The text processing is mostly interested in alphanumeric characters, so
|
|
|
|
* any special characters included in the input text will be stripped out.
|
|
|
|
* Tabs, spaces and the following characters are used to delimit words:
|
|
|
|
*
|
|
|
|
* \/,;()_-~+"
|
2014-09-16 08:09:27 -04:00
|
|
|
*/
|
2013-08-25 10:33:48 -04:00
|
|
|
namespace filter {
|
|
|
|
|
2014-09-16 08:09:27 -04:00
|
|
|
/**
|
2014-11-08 11:25:13 -05:00
|
|
|
* Break the input text into lowercase words and search the Index
|
|
|
|
* for matches. The results set should be filled out with the
|
|
|
|
* intersection of the IndexEntry for each word. If any word does
|
|
|
|
* not appear in the index, then the result set should be empty.
|
2014-09-16 08:09:27 -04:00
|
|
|
*
|
|
|
|
* @param text The text to search for.
|
2014-11-08 11:25:13 -05:00
|
|
|
* @param res The results set to fill in with matching indexes.
|
2014-09-16 08:09:27 -04:00
|
|
|
*/
|
2015-10-21 15:57:21 -04:00
|
|
|
void search(const std::string &, struct set *);
|
2014-09-16 08:09:27 -04:00
|
|
|
|
|
|
|
/**
|
2014-11-08 11:25:13 -05:00
|
|
|
* Converts the input text to lowercase and returns the result.
|
2014-09-16 08:09:27 -04:00
|
|
|
*
|
2014-11-08 11:25:13 -05:00
|
|
|
* @param text The text to be converted.
|
|
|
|
* @return The lowercase form of the input text.
|
2014-09-16 08:09:27 -04:00
|
|
|
*/
|
2014-03-15 20:44:07 -04:00
|
|
|
std::string lowercase(const std::string &);
|
2013-08-25 10:33:48 -04:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2015-09-29 16:25:16 -04:00
|
|
|
void filter_init();
|
|
|
|
void filter_deinit();
|
|
|
|
|
2015-11-10 09:36:38 -05:00
|
|
|
/* Add the input string to the index. */
|
|
|
|
void filter_add(const gchar *, unsigned int);
|
|
|
|
|
2014-06-21 09:37:47 -04:00
|
|
|
#endif /* OCARINA_CORE_FILTER_H */
|