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