From 57e3fc0289556909c35f4673a25dff74a581ae4d Mon Sep 17 00:00:00 2001 From: tastytea Date: Sun, 28 Jul 2019 00:07:55 +0200 Subject: [PATCH] Documented search functions. --- Doxyfile | 1 + src/lib/search.hpp | 36 ++++++++++++++++++++++++++++++++++-- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/Doxyfile b/Doxyfile index 9d16336..2813b4e 100644 --- a/Doxyfile +++ b/Doxyfile @@ -24,3 +24,4 @@ BUILTIN_STL_SUPPORT = YES VERBATIM_HEADERS = YES INLINE_SOURCES = YES SEARCHENGINE = YES +SHOW_FILES = YES diff --git a/src/lib/search.hpp b/src/lib/search.hpp index 32a1be0..e1761e1 100644 --- a/src/lib/search.hpp +++ b/src/lib/search.hpp @@ -21,20 +21,52 @@ #include #include "sqlite.hpp" +//! @file + namespace remwharead { using std::vector; using std::string; + /*! + * @brief Split expression in subexpressions. + * + * First it splits at `OR` or `||`, then it splits the subexpressions at + * `AND` or `&&`. The first vector contains all tags before the first `OR`. + * + * @return Vector of `OR`-vectors of `AND`-tags. + */ const vector> parse_expression(string expression); + + //! Convert str to lowercase. Works with unicode. const string to_lowercase(const string &str); - //! Seach database entries for tags. + /*! + * @brief Search in tags of database entries. + * + * Only matches whole tags, *Pill* does not match *Pillow*. + * + * @param entries Vector of Database::entry to search. + * @param expression Search expression. + * @param is_re Is it a regular expression? + * + * @return Vector of matching Database::entry. + */ const vector search_tags(const vector &entries, string expression, const bool is_re); - //! Search tags, title, description and full text. + /*! + * @brief Search in full text of database entries. + * + * Searches in tags, title, description and full text. + * + * @param entries Vector of Database::entry to search. + * @param expression Search expression. + * @param is_re Is it a regular expression? + * + * @return Vector of matching Database::entry. + */ const vector search_all(const vector &entries, string expression, const bool is_re);