Skip to content

Improvement suggestion to support OOP #17

@lafrank

Description

@lafrank

In an OOP environment the GlobalMatch callback functionality is very restrictive.

Would it be possible to implement a base callback class with a callback virtual function to later build upon this class, ?
I tried below but I have difficulties with syntax since I am not much experienced with c++.

Could ypu please help to fix below - or suggest something similar - and if works it might be a good candidate for an MR.

In regexp.h :

class GlobalMatchClass;

typedef void (*GlobalMatchClassCallback) (GlobalMatchClass::*matchcallback)(const char* match,  const unsigned int length,  const MatchState& ms);  

typedef class GlobalMatchClass
{
public:
  virtual void matchcallback(const char* match, const unsigned int length, const MatchState& ms);
} GlobalMatchClass;

In regexp.cpp:

unsigned int MatchState::GlobalMatchCM(const char* pattern, GlobalMatchClassCallback f)
{
  // Same as MatchState::GlobalMatch, probably invocation of f must be different
}

void GlobalMatchClass::matchcallback(const char* match, const unsigned int length, const MatchState& ms) {}

The code above is not correct, has either syntactical or semantical issues, I am not quite sure what is wrong.

Appreciate your help in advance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions