added MatchSet class; Token::process()

This commit is contained in:
Josh Holtrop 2010-05-19 13:43:06 -04:00
parent c0e88f5c6f
commit 3a0a7e494d
2 changed files with 46 additions and 1 deletions

View File

@ -136,6 +136,35 @@ refptr<Node> Node::operator[](const std::string & index)
: NULL;
}
void Token::process()
{
}
MatchSet::MatchSet(const char * data, int * ovector, int ovec_size)
: m_data(data), m_ovector(ovector), m_ovec_size(ovec_size)
{
}
std::string MatchSet::operator[](int index)
{
if (0 <= index && index < (m_ovec_size / 3))
{
int idx = 2 * index;
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 "";
}
std::string MatchSet::operator[](const std::string & index)
{
/* FIXME */
return "";
}
#ifdef I_NAMESPACE
};
#endif

View File

@ -121,6 +121,20 @@ class I_CLASSNAME
const char * m_errstr;
};
class MatchSet
{
public:
MatchSet(const char * data, int * ovector, int ovec_size);
std::string operator[](int index);
std::string operator[](const std::string & index);
protected:
const char * m_data;
int * m_ovector;
int m_ovec_size;
};
typedef refptr<MatchSet> MatchSetRef;
class Node
{
public:
@ -131,14 +145,16 @@ class Node
std::map< std::string, refptr<Node> > m_named_children;
std::vector< refptr<Node> > m_indexed_children;
};
typedef refptr<Node> NodeRef;
class Token : public Node
{
public:
virtual void process();
protected:
};
typedef refptr<Token> TokenRef;
#ifdef I_NAMESPACE
};