Files

47 lines
1.0 KiB
C
Raw Permalink Normal View History

2013-08-02 13:12:24 -07:00
// Matt Wells, copyright Jul 2001
// . highlights the terms in Query "q" in "xml" and puts results in m_buf
2016-03-08 22:14:30 +01:00
#ifndef GB_HIGHLIGHT_H
#define GB_HIGHLIGHT_H
2016-08-09 21:09:25 +02:00
#include <inttypes.h>
#include <stddef.h>
class Query;
class SafeBuf;
class Words;
class Matches;
2013-08-02 13:12:24 -07:00
class Highlight {
2016-03-06 23:51:15 +01:00
public:
2013-08-02 13:12:24 -07:00
// . 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( SafeBuf *sb, const char *content, int32_t contentLen, Query *q, const char *frontTag,
2016-09-23 02:53:33 +02:00
const char *backTag );
2016-05-24 17:03:41 +02:00
int32_t set( SafeBuf *sb, const Words *words, const Matches *matches, const char *frontTag = NULL,
const char *backTag = NULL, const Query *q = NULL );
2013-08-02 13:12:24 -07:00
2014-11-10 14:45:11 -08:00
int32_t getNumMatches() { return m_numMatches; }
2013-08-02 13:12:24 -07:00
private:
2016-05-24 17:03:41 +02:00
bool highlightWords ( const Words *words, const Matches *m, const Query *q=NULL );
2013-08-02 13:12:24 -07:00
class SafeBuf *m_sb;
2013-08-02 13:12:24 -07:00
const char *m_frontTag;
const char *m_backTag;
2014-11-10 14:45:11 -08:00
int32_t m_frontTagLen;
int32_t m_backTagLen;
2013-08-02 13:12:24 -07:00
2014-11-10 14:45:11 -08:00
int32_t m_numMatches;
2013-08-02 13:12:24 -07:00
};
2016-03-08 22:14:30 +01:00
#endif // GB_HIGHLIGHT_H
2013-08-02 13:12:24 -07:00