Files
privacore-open-source-searc…/matches2.h

46 lines
993 B
C
Raw Normal View History

2013-08-02 13:12:24 -07:00
// Matt Wells, copyright Jan 2007
2016-03-08 22:14:30 +01:00
#ifndef GB_MATCHES2_H
#define GB_MATCHES2_H
2013-08-02 13:12:24 -07:00
2016-08-10 12:54:45 +02:00
#include <inttypes.h>
#include <cstring>
2016-08-10 12:54:45 +02:00
2013-08-02 13:12:24 -07:00
// use these routines for matching any of a list of substrings in the haystack.
// the Matches array is the list of substrings to match in the "haystack". this
// should be *very* fast.
class Needle {
public:
Needle(const char *string, char id, char isSection)
: m_string(string)
, m_stringSize(strlen(string))
, m_id(id)
, m_isSection(isSection) {
}
2016-04-07 17:57:16 +02:00
const char *m_string;
size_t m_stringSize;
2013-08-02 13:12:24 -07:00
char m_id;
// if m_isSection is true, getMatch() only matches if haystack
// ptr is < linkPos
char m_isSection;
};
class NeedleMatch {
public:
NeedleMatch()
: m_count(0)
, m_firstMatch(nullptr) {
}
int32_t m_count;
2013-08-02 13:12:24 -07:00
char *m_firstMatch;
};
char *getMatches2(const Needle *needles, NeedleMatch *needlesMatch, int32_t numNeedles,
char *haystack, int32_t haystackSize, char *linkPos, bool *hadPreMatch);
2013-08-02 13:12:24 -07:00
2016-03-08 22:14:30 +01:00
#endif // GB_MATCHES2_H