ocarina/include/core/filter.h

54 lines
1.4 KiB
C
Raw Normal View History

/**
* Copyright 2013 (c) Anna Schumaker.
*/
#ifndef OCARINA_CORE_FILTER_H
#define OCARINA_CORE_FILTER_H
extern "C" {
#include <core/set.h>
}
#include <string>
/**
* 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:
*
* \/,;()_-~+"
*/
namespace filter {
/**
* 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.
*
* @param text The text to search for.
* @param res The results set to fill in with matching indexes.
*/
void search(const std::string &, struct set *);
/**
* Converts the input text to lowercase and returns the result.
*
* @param text The text to be converted.
* @return The lowercase form of the input text.
*/
std::string lowercase(const std::string &);
};
void filter_init();
void filter_deinit();
/* Add the input string to the index. */
void filter_add(const gchar *, unsigned int);
#endif /* OCARINA_CORE_FILTER_H */