File: SherlockParser.h

package info (click to toggle)
pinot 1.23-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,608 kB
  • sloc: cpp: 41,870; makefile: 611; xml: 416; sh: 336
file content (82 lines) | stat: -rw-r--r-- 2,534 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/*
 *  Copyright 2005-2009 Fabrice Colin
 *
 *  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 2 of the License, or
 *  (at your option) 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

#ifndef _SHERLOCK_PARSER_H
#define _SHERLOCK_PARSER_H

#include <pthread.h>
#include <string>
#include <vector>

#include "Document.h"
#include "PluginParsers.h"

/// Parses output of Sherlock-based search engines.
class SherlockResponseParser : public ResponseParserInterface
{
	public:
		SherlockResponseParser();
		virtual ~SherlockResponseParser();

		/// Parses the response; false if not all could be parsed.
		virtual bool parse(const Document *pResponseDoc, std::vector<DocumentInfo> &resultsList,
			unsigned int &totalResults, unsigned int &firstResultIndex,
			std::string &charset) const;

		std::string m_resultListStart;
		std::string m_resultListEnd;
		std::string m_resultItemStart;
		std::string m_resultItemEnd;
		std::string m_resultTitleStart;
		std::string m_resultTitleEnd;
		std::string m_resultLinkStart;
		std::string m_resultLinkEnd;
		std::string m_resultExtractStart;
		std::string m_resultExtractEnd;
		bool m_skipLocal;

	private:
		SherlockResponseParser(const SherlockResponseParser &other);
		SherlockResponseParser& operator=(const SherlockResponseParser& other);

};

/** A parser for Sherlock plugin files.
  * See http://developer.apple.com/technotes/tn/tn1141.html
  * and http://mycroft.mozdev.org/deepdocs/deepdocs.html
  */
class SherlockParser : public PluginParserInterface
{
	public:
		SherlockParser(const std::string &fileName);
		virtual ~SherlockParser();

		/// Parses the plugin and returns a response parser.
		virtual ResponseParserInterface *parse(SearchPluginProperties &properties,
			bool minimal = false);

	protected:
		static pthread_mutex_t m_mutex;

	private:
		SherlockParser(const SherlockParser &other);
		SherlockParser& operator=(const SherlockParser& other);

};

#endif // _SHERLOCK_PARSER_H