forked from gigablast/open-source-search-engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Highlight.h
86 lines (69 loc) · 2.28 KB
/
Highlight.h
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
83
84
85
// Matt Wells, copyright Jul 2001
// . highlights the terms in Query "q" in "xml" and puts results in m_buf
#include "Words.h"
#include "Query.h"
#include "Matches.h"
#include "Xml.h"
#include "Url.h"
#ifndef _HIGHLIGHT_H_
#define _HIGHLIGHT_H_
class Highlight {
public:
// . content is an html/xml doc
// . we highlight Query "q" in "xml" as best as we can
// . store highlighted text into "buf"
// . return length stored into "buf"
int32_t set ( //char *buf ,
//int32_t bufLen ,
SafeBuf *sb,
char *content ,
int32_t contentLen ,
char docLangId ,
Query *q ,
bool doStemming ,
bool useAnchors , // = false ,
const char *baseUrl , // = NULL ,
const char *frontTag , // = NULL ,
const char *backTag , // = NULL ,
int32_t fieldCode , // = 0 ,
int32_t niceness ) ;
int32_t set ( //char *buf ,
//int32_t bufLen ,
SafeBuf *sb ,
Words *words ,
Matches *matches ,
bool doStemming ,
bool useAnchors = false ,
const char *baseUrl = NULL ,
const char *frontTag = NULL ,
const char *backTag = NULL ,
int32_t fieldCode = 0 ,
Query *q = NULL ) ;
int32_t getNumMatches() { return m_numMatches; }
private:
bool highlightWords ( Words *words , Matches *m , Query *q=NULL );
// null terminate and store the highlighted content in m_buf
//char *m_buf ;
//int32_t m_bufLen;
//char *m_bufPtr;
//char *m_bufEnd;
class SafeBuf *m_sb;
//Words m_words;
Matches m_matches;
//Xml *m_xml;
const char *m_frontTag;
const char *m_backTag;
int32_t m_frontTagLen;
int32_t m_backTagLen;
bool m_doStemming;
bool m_useAnchors; // click and scroll technology for cached pages
//int32_t m_anchorCounts [ MAX_QUERY_TERMS ];
const char *m_baseUrl;
int32_t m_numMatches;
// so we don't repeat the same buf overflow error msg a gazillion times
bool m_didErrMsg;
// . field code of the text excerpt to highlight
// . only query terms with this fieldCode will be highlighted
int32_t m_fieldCode;
};
#endif