#include "CLucene/StdHeader.h" #include "TokenList.h" #include "CLucene/util/VoidMap.h" #include "CLucene/util/VoidList.h" #include "QueryToken.h" namespace lucene{ namespace queryParser{ TokenList::TokenList() { } TokenList::~TokenList(){ tokens.setDoDelete(DELETE_TYPE_DELETE); tokens.clear(); } void TokenList::Add(QueryToken* token) { tokens.push_front(token); } void TokenList::Push(QueryToken* token) { tokens.push_back(token); } QueryToken& TokenList::Peek() { /* DSR:CL_BUG: Sometimes code internal to CLucene 0.8.11 called Peek() ** when this->tokens was empty, resulting in an invalid memory operation ** (i.e., accessing tokens[-1]). For example, ** QueryParser::parse("!", ..., ...) triggered this bug. */ if (Count() == 0) { _THROWC("TokenList::Peek called when Count() == 0"); } return *tokens[tokens.size()-1]; } QueryToken& TokenList::Extract() { QueryToken& token = Peek(); tokens.pop_back(); return token; } int_t TokenList::Count() { return tokens.size(); } }}