Program Listing for File search_renderer.h

Return to documentation for file (include/search_renderer.h)

/*
 * Copyright 2011 Emmanuel Engelhart <kelson@kiwix.org>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU  General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 * MA 02110-1301, USA.
 */

#ifndef KIWIX_SEARCH_RENDERER_H
#define KIWIX_SEARCH_RENDERER_H

#include <string>
#include <zim/search.h>
#include "library.h"

namespace kiwix
{

class NameMapper;
class SearchRenderer
{
 public:
  SearchRenderer(zim::SearchResultSet srs, NameMapper* mapper,
                 unsigned int start, unsigned int estimatedResultCount);

  SearchRenderer(zim::SearchResultSet srs, NameMapper* mapper, Library* library,
                 unsigned int start, unsigned int estimatedResultCount);

  ~SearchRenderer();

  void setSearchPattern(const std::string& pattern);

  void setSearchBookQuery(const std::string& bookQuery);

  void setProtocolPrefix(const std::string& prefix);

  void setSearchProtocolPrefix(const std::string& prefix);

  void setPageLength(unsigned int pageLength){
    this->pageLength  = pageLength;
  }

  std::string renderTemplate(const std::string& tmpl_str);

  std::string getHtml();

  std::string getXml();


 protected:
  std::string beautifyInteger(const unsigned int number);
  zim::SearchResultSet m_srs;
  NameMapper* mp_nameMapper;
  Library* mp_library;
  std::string searchBookQuery;
  std::string searchPattern;
  std::string protocolPrefix;
  std::string searchProtocolPrefix;
  unsigned int pageLength;
  unsigned int estimatedResultCount;
  unsigned int resultStart;
};


}

#endif