Class SearchRenderer

Class Documentation

class SearchRenderer

The SearcherRenderer class is used to render a search result to a html page.

Public Functions

SearchRenderer(zim::SearchResultSet srs, unsigned int start, unsigned int estimatedResultCount)

Construct a SearchRenderer from a SearchResultSet.

Parameters:
  • srs – The SearchResultSet to render.

  • start – The start offset used for the srs.

  • estimatedResultCount – The estimatedResultCount of the whole search

~SearchRenderer()
void setSearchPattern(const std::string &pattern)

Set the search pattern used to do the search

void setSearchBookQuery(const std::string &bookQuery)

Set the querystring used to select books

void setProtocolPrefix(const std::string &prefix)

Set protocol prefix.

void setSearchProtocolPrefix(const std::string &prefix)

Set search protocol prefix.

inline void setPageLength(unsigned int pageLength)

set result count per page

inline void setUserLang(const std::string &lang)

set user language

std::string getHtml(const NameMapper &mapper, const Library *library)

Generate the html page with the resutls of the search.

Parameters:
  • mapper – The NameMapper to use to do the rendering.

  • library – The Library to use to look up book details for search results. May be nullptr. In this case, bookName is not set in the rendered string.

Returns:

The html string

std::string getXml(const NameMapper &mapper, const Library *library)

Generate the xml page with the resutls of the search.

Parameters:
  • mapper – The NameMapper to use to do the rendering.

  • library – The Library to use to look up book details for search results. May be nullptr. In this case, bookName is not set in the rendered string.

Returns:

The xml string

Protected Functions

std::string renderTemplate(const std::string &tmpl_str, const NameMapper &mapper, const Library *library)
std::string beautifyInteger(const unsigned int number)

Protected Attributes

zim::SearchResultSet m_srs
std::string searchBookQuery
std::string searchPattern
std::string protocolPrefix
std::string searchProtocolPrefix
unsigned int pageLength
unsigned int estimatedResultCount
unsigned int resultStart
std::string userlang = "en"