MatchSet updates
This commit is contained in:
parent
3a0a7e494d
commit
b100c035a0
@ -140,8 +140,8 @@ void Token::process()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
MatchSet::MatchSet(const char * data, int * ovector, int ovec_size)
|
MatchSet::MatchSet(pcre * re, const char * data, int * ovector, int ovec_size)
|
||||||
: m_data(data), m_ovector(ovector), m_ovec_size(ovec_size)
|
: m_re(re), m_data(data), m_ovector(ovector), m_ovec_size(ovec_size)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,7 +161,15 @@ std::string MatchSet::operator[](int index)
|
|||||||
|
|
||||||
std::string MatchSet::operator[](const std::string & index)
|
std::string MatchSet::operator[](const std::string & index)
|
||||||
{
|
{
|
||||||
/* FIXME */
|
int idx = pcre_get_stringnumber(m_re, index.c_str());
|
||||||
|
if (idx > 0 && idx < (m_ovec_size / 3))
|
||||||
|
{
|
||||||
|
if (m_ovector[idx] >= 0 && m_ovector[idx + 1] >= 0)
|
||||||
|
{
|
||||||
|
return string(m_data, m_ovector[idx],
|
||||||
|
m_ovector[idx + 1] - m_ovector[idx]);
|
||||||
|
}
|
||||||
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
#ifndef IMBECILE_PARSER_HEADER
|
#ifndef IMBECILE_PARSER_HEADER
|
||||||
#define IMBECILE_PARSER_HEADER
|
#define IMBECILE_PARSER_HEADER
|
||||||
|
|
||||||
|
#include <pcre.h>
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@ -124,11 +126,12 @@ class I_CLASSNAME
|
|||||||
class MatchSet
|
class MatchSet
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MatchSet(const char * data, int * ovector, int ovec_size);
|
MatchSet(pcre * re, const char * data, int * ovector, int ovec_size);
|
||||||
std::string operator[](int index);
|
std::string operator[](int index);
|
||||||
std::string operator[](const std::string & index);
|
std::string operator[](const std::string & index);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
pcre * m_re;
|
||||||
const char * m_data;
|
const char * m_data;
|
||||||
int * m_ovector;
|
int * m_ovector;
|
||||||
int m_ovec_size;
|
int m_ovec_size;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user