From 5315034afe82c607da990ad22a62e32eb8f87b7f Mon Sep 17 00:00:00 2001 From: Maneesh P M Date: Thu, 13 May 2021 11:38:11 +0530 Subject: [PATCH] Introduce `SuggestionItem` class This is a helper class that allows to create and manage individual suggestion item and their data. --- include/reader.h | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/include/reader.h b/include/reader.h index 94c108f9d..395da4ee9 100644 --- a/include/reader.h +++ b/include/reader.h @@ -37,6 +37,41 @@ using namespace std; namespace kiwix { +/** + * The SuggestionItem is a helper class that contains the info about a single + * suggestion item. + */ + +class SuggestionItem +{ + // Functions + private: + // Create a sugggestion item. + explicit SuggestionItem(std::string title, std::string normalizedTitle, + std::string path, std::string snippet = "") : + title(title), + normalizedTitle(normalizedTitle), + path(path), + snippet(snippet) {} + + public: + const std::string getTitle() {return title;} + const std::string getNormalizedTitle() {return normalizedTitle;} + const std::string getPath() {return path;} + const std::string getSnippet() {return snippet;} + + const bool hasSnippet() {return !snippet.empty();} + + // Data + private: + std::string title; + std::string normalizedTitle; + std::string path; + std::string snippet; + + friend class Reader; +}; + /** * The Reader class is the class who allow to get an entry content from a zim * file.