|
a/src/query/plaintorich.h |
|
b/src/query/plaintorich.h |
|
... |
|
... |
19 |
|
19 |
|
20 |
#include <string>
|
20 |
#include <string>
|
21 |
#include <list>
|
21 |
#include <list>
|
22 |
|
22 |
|
23 |
#include "hldata.h"
|
23 |
#include "hldata.h"
|
|
|
24 |
#include "cstr.h"
|
24 |
|
25 |
|
25 |
/**
|
26 |
/**
|
26 |
* A class for highlighting search results. Overridable methods allow
|
27 |
* A class for highlighting search results. Overridable methods allow
|
27 |
* for different styles. We can handle plain text or html input. In the latter
|
28 |
* for different styles. We can handle plain text or html input. In the latter
|
28 |
* case, we may fail to highligt term groups if they are mixed with HTML
|
29 |
* case, we may fail to highligt term groups if they are mixed with HTML
|
29 |
* tags (ex: firstterm <b>2ndterm</b>).
|
30 |
* tags (ex: firstterm <b>2ndterm</b>).
|
30 |
*/
|
31 |
*/
|
31 |
class PlainToRich {
|
32 |
class PlainToRich {
|
32 |
public:
|
33 |
public:
|
33 |
PlainToRich()
|
34 |
PlainToRich()
|
34 |
: m_inputhtml(false)
|
35 |
: m_inputhtml(false), m_eolbr(false), m_hdata(0)
|
35 |
{
|
36 |
{
|
36 |
}
|
37 |
}
|
37 |
|
38 |
|
38 |
virtual ~PlainToRich()
|
39 |
virtual ~PlainToRich()
|
39 |
{
|
40 |
{
|
|
... |
|
... |
69 |
const HighlightData& hdata,
|
70 |
const HighlightData& hdata,
|
70 |
int chunksize = 50000
|
71 |
int chunksize = 50000
|
71 |
);
|
72 |
);
|
72 |
|
73 |
|
73 |
/* Overridable output methods for headers, highlighting and marking tags */
|
74 |
/* Overridable output methods for headers, highlighting and marking tags */
|
|
|
75 |
|
74 |
virtual std::string header() {return snull;}
|
76 |
virtual std::string header()
|
75 |
virtual std::string startMatch() {return snull;}
|
77 |
{
|
|
|
78 |
return cstr_null;
|
|
|
79 |
}
|
|
|
80 |
|
|
|
81 |
/** Return match prefix (e.g.: <div class="match">).
|
|
|
82 |
@param groupidx the index into hdata.groups */
|
|
|
83 |
virtual std::string startMatch(unsigned int)
|
|
|
84 |
{
|
|
|
85 |
return cstr_null;
|
|
|
86 |
}
|
|
|
87 |
|
|
|
88 |
/** Return data for end of match area (e.g.: </div>). */
|
76 |
virtual std::string endMatch() {return snull;}
|
89 |
virtual std::string endMatch()
|
77 |
virtual std::string startAnchor(int) {return snull;}
|
90 |
{
|
78 |
virtual std::string endAnchor() {return snull;}
|
91 |
return cstr_null;
|
|
|
92 |
}
|
|
|
93 |
|
79 |
virtual std::string startChunk() {return snull;}
|
94 |
virtual std::string startChunk()
|
|
|
95 |
{
|
|
|
96 |
return cstr_null;
|
|
|
97 |
}
|
80 |
|
98 |
|
81 |
protected:
|
99 |
protected:
|
82 |
const std::string snull;
|
|
|
83 |
bool m_inputhtml;
|
100 |
bool m_inputhtml;
|
84 |
// Use <br> to break plain text lines (else caller has used a <pre> tag)
|
101 |
// Use <br> to break plain text lines (else caller has used a <pre> tag)
|
85 |
bool m_eolbr;
|
102 |
bool m_eolbr;
|
|
|
103 |
const HighlightData *m_hdata;
|
86 |
};
|
104 |
};
|
87 |
|
105 |
|
88 |
#endif /* _PLAINTORICH_H_INCLUDED_ */
|
106 |
#endif /* _PLAINTORICH_H_INCLUDED_ */
|