Main scan function of Hyperscan API looks like:
hs_error_t hs_scan(const hs_database_t *db,
const char *data,
unsigned int length,
unsigned int flags,
hs_scratch_t *scratch,
match_event_handler onEvent,
void *context);
Somewhere in the header file the match_event_handler
is defined as:
typedef int (*match_event_handler)(unsigned int id,
unsigned long long from,
unsigned long long to,
unsigned int flags,
void *context);
I have a class named Databag which has a member function with exact same prototype (Please note it is not static):
class Databag{
...
public:
int event_handler(unsigned int id,
unsigned long long from,
unsigned long long to,
unsigned int flags,
void *context);
...
}
I want to pass this method as argument to hyperscan, something like:
Databag the_databag;
hs_scan(db, data, length, flags, scratch, databag.event_handler, context);
Any idea how make it work? I think there should be an easy way using .* and .-> operators, something like:
int (Databag::*member_event_handler)(unsigned int id,
unsigned long long from,
unsigned long long to,
unsigned int flags,
void* context) = &Databag::event_handler;
Databag the_databag;
hs_scan(db, data, length, flags, scratch, databag.*member_event_handler, context);
And ... it failed.
How I should continue to make it working? Or is it possible at all?