TokenDefinition storing name and definition, not pcre RE
This commit is contained in:
parent
876cc5da78
commit
c1070fb021
@ -8,30 +8,20 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
TokenDefinition::TokenDefinition()
|
||||
: m_re(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
TokenDefinition::~TokenDefinition()
|
||||
{
|
||||
if (m_re != NULL)
|
||||
{
|
||||
pcre_free(m_re);
|
||||
}
|
||||
}
|
||||
|
||||
bool TokenDefinition::create(const string & name,
|
||||
const string & definition, const string & flags)
|
||||
{
|
||||
const char * errptr;
|
||||
int erroffset;
|
||||
m_re = pcre_compile(definition.c_str(), 0, &errptr, &erroffset, NULL);
|
||||
if (m_re == NULL)
|
||||
pcre * re = pcre_compile(definition.c_str(), 0, &errptr, &erroffset, NULL);
|
||||
if (re == NULL)
|
||||
{
|
||||
cerr << "Error compiling regular expression '" << definition
|
||||
<< "' at position " << erroffset << ": " << errptr << endl;
|
||||
return false;
|
||||
}
|
||||
m_name = name;
|
||||
m_definition = definition;
|
||||
pcre_free(re);
|
||||
return true;
|
||||
}
|
||||
|
@ -2,20 +2,17 @@
|
||||
#ifndef TOKENDEFINITION_H
|
||||
#define TOKENDEFINITION_H
|
||||
|
||||
#include <pcre.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
class TokenDefinition
|
||||
{
|
||||
public:
|
||||
TokenDefinition();
|
||||
~TokenDefinition();
|
||||
bool create(const std::string & name,
|
||||
const std::string & definition, const std::string & flags);
|
||||
|
||||
protected:
|
||||
pcre * m_re;
|
||||
std::string m_name;
|
||||
std::string m_definition;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user