|
|
|
@ -235,7 +235,7 @@ CSMFilter::Token CSMFilter::Parser::getNextToken()
|
|
|
|
|
return Token (Token::Type_None);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
boost::shared_ptr<CSMFilter::Node> CSMFilter::Parser::parseImp (bool allowEmpty, bool ignoreOneShot)
|
|
|
|
|
std::shared_ptr<CSMFilter::Node> CSMFilter::Parser::parseImp (bool allowEmpty, bool ignoreOneShot)
|
|
|
|
|
{
|
|
|
|
|
if (Token token = getNextToken())
|
|
|
|
|
{
|
|
|
|
@ -247,11 +247,11 @@ boost::shared_ptr<CSMFilter::Node> CSMFilter::Parser::parseImp (bool allowEmpty,
|
|
|
|
|
{
|
|
|
|
|
case Token::Type_Keyword_True:
|
|
|
|
|
|
|
|
|
|
return boost::shared_ptr<CSMFilter::Node> (new BooleanNode (true));
|
|
|
|
|
return std::shared_ptr<CSMFilter::Node> (new BooleanNode (true));
|
|
|
|
|
|
|
|
|
|
case Token::Type_Keyword_False:
|
|
|
|
|
|
|
|
|
|
return boost::shared_ptr<CSMFilter::Node> (new BooleanNode (false));
|
|
|
|
|
return std::shared_ptr<CSMFilter::Node> (new BooleanNode (false));
|
|
|
|
|
|
|
|
|
|
case Token::Type_Keyword_And:
|
|
|
|
|
case Token::Type_Keyword_Or:
|
|
|
|
@ -260,12 +260,12 @@ boost::shared_ptr<CSMFilter::Node> CSMFilter::Parser::parseImp (bool allowEmpty,
|
|
|
|
|
|
|
|
|
|
case Token::Type_Keyword_Not:
|
|
|
|
|
{
|
|
|
|
|
boost::shared_ptr<CSMFilter::Node> node = parseImp();
|
|
|
|
|
std::shared_ptr<CSMFilter::Node> node = parseImp();
|
|
|
|
|
|
|
|
|
|
if (mError)
|
|
|
|
|
return boost::shared_ptr<Node>();
|
|
|
|
|
return std::shared_ptr<Node>();
|
|
|
|
|
|
|
|
|
|
return boost::shared_ptr<CSMFilter::Node> (new NotNode (node));
|
|
|
|
|
return std::shared_ptr<CSMFilter::Node> (new NotNode (node));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case Token::Type_Keyword_Text:
|
|
|
|
@ -281,7 +281,7 @@ boost::shared_ptr<CSMFilter::Node> CSMFilter::Parser::parseImp (bool allowEmpty,
|
|
|
|
|
if (!allowEmpty)
|
|
|
|
|
error();
|
|
|
|
|
|
|
|
|
|
return boost::shared_ptr<Node>();
|
|
|
|
|
return std::shared_ptr<Node>();
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
|
@ -289,27 +289,27 @@ boost::shared_ptr<CSMFilter::Node> CSMFilter::Parser::parseImp (bool allowEmpty,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return boost::shared_ptr<Node>();
|
|
|
|
|
return std::shared_ptr<Node>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
boost::shared_ptr<CSMFilter::Node> CSMFilter::Parser::parseNAry (const Token& keyword)
|
|
|
|
|
std::shared_ptr<CSMFilter::Node> CSMFilter::Parser::parseNAry (const Token& keyword)
|
|
|
|
|
{
|
|
|
|
|
std::vector<boost::shared_ptr<Node> > nodes;
|
|
|
|
|
std::vector<std::shared_ptr<Node> > nodes;
|
|
|
|
|
|
|
|
|
|
Token token = getNextToken();
|
|
|
|
|
|
|
|
|
|
if (token.mType!=Token::Type_Open)
|
|
|
|
|
{
|
|
|
|
|
error();
|
|
|
|
|
return boost::shared_ptr<Node>();
|
|
|
|
|
return std::shared_ptr<Node>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
|
{
|
|
|
|
|
boost::shared_ptr<Node> node = parseImp();
|
|
|
|
|
std::shared_ptr<Node> node = parseImp();
|
|
|
|
|
|
|
|
|
|
if (mError)
|
|
|
|
|
return boost::shared_ptr<Node>();
|
|
|
|
|
return std::shared_ptr<Node>();
|
|
|
|
|
|
|
|
|
|
nodes.push_back (node);
|
|
|
|
|
|
|
|
|
@ -318,7 +318,7 @@ boost::shared_ptr<CSMFilter::Node> CSMFilter::Parser::parseNAry (const Token& ke
|
|
|
|
|
if (!token || (token.mType!=Token::Type_Close && token.mType!=Token::Type_Comma))
|
|
|
|
|
{
|
|
|
|
|
error();
|
|
|
|
|
return boost::shared_ptr<Node>();
|
|
|
|
|
return std::shared_ptr<Node>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (token.mType==Token::Type_Close)
|
|
|
|
@ -328,31 +328,31 @@ boost::shared_ptr<CSMFilter::Node> CSMFilter::Parser::parseNAry (const Token& ke
|
|
|
|
|
if (nodes.empty())
|
|
|
|
|
{
|
|
|
|
|
error();
|
|
|
|
|
return boost::shared_ptr<Node>();
|
|
|
|
|
return std::shared_ptr<Node>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch (keyword.mType)
|
|
|
|
|
{
|
|
|
|
|
case Token::Type_Keyword_And: return boost::shared_ptr<CSMFilter::Node> (new AndNode (nodes));
|
|
|
|
|
case Token::Type_Keyword_Or: return boost::shared_ptr<CSMFilter::Node> (new OrNode (nodes));
|
|
|
|
|
default: error(); return boost::shared_ptr<Node>();
|
|
|
|
|
case Token::Type_Keyword_And: return std::shared_ptr<CSMFilter::Node> (new AndNode (nodes));
|
|
|
|
|
case Token::Type_Keyword_Or: return std::shared_ptr<CSMFilter::Node> (new OrNode (nodes));
|
|
|
|
|
default: error(); return std::shared_ptr<Node>();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
boost::shared_ptr<CSMFilter::Node> CSMFilter::Parser::parseText()
|
|
|
|
|
std::shared_ptr<CSMFilter::Node> CSMFilter::Parser::parseText()
|
|
|
|
|
{
|
|
|
|
|
Token token = getNextToken();
|
|
|
|
|
|
|
|
|
|
if (token.mType!=Token::Type_Open)
|
|
|
|
|
{
|
|
|
|
|
error();
|
|
|
|
|
return boost::shared_ptr<Node>();
|
|
|
|
|
return std::shared_ptr<Node>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
token = getNextToken();
|
|
|
|
|
|
|
|
|
|
if (!token)
|
|
|
|
|
return boost::shared_ptr<Node>();
|
|
|
|
|
return std::shared_ptr<Node>();
|
|
|
|
|
|
|
|
|
|
// parse column ID
|
|
|
|
|
int columnId = -1;
|
|
|
|
@ -370,7 +370,7 @@ boost::shared_ptr<CSMFilter::Node> CSMFilter::Parser::parseText()
|
|
|
|
|
if (columnId<0)
|
|
|
|
|
{
|
|
|
|
|
error();
|
|
|
|
|
return boost::shared_ptr<Node>();
|
|
|
|
|
return std::shared_ptr<Node>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
token = getNextToken();
|
|
|
|
@ -378,7 +378,7 @@ boost::shared_ptr<CSMFilter::Node> CSMFilter::Parser::parseText()
|
|
|
|
|
if (token.mType!=Token::Type_Comma)
|
|
|
|
|
{
|
|
|
|
|
error();
|
|
|
|
|
return boost::shared_ptr<Node>();
|
|
|
|
|
return std::shared_ptr<Node>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// parse text pattern
|
|
|
|
@ -387,7 +387,7 @@ boost::shared_ptr<CSMFilter::Node> CSMFilter::Parser::parseText()
|
|
|
|
|
if (!token.isString())
|
|
|
|
|
{
|
|
|
|
|
error();
|
|
|
|
|
return boost::shared_ptr<Node>();
|
|
|
|
|
return std::shared_ptr<Node>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::string text = token.mString;
|
|
|
|
@ -397,26 +397,26 @@ boost::shared_ptr<CSMFilter::Node> CSMFilter::Parser::parseText()
|
|
|
|
|
if (token.mType!=Token::Type_Close)
|
|
|
|
|
{
|
|
|
|
|
error();
|
|
|
|
|
return boost::shared_ptr<Node>();
|
|
|
|
|
return std::shared_ptr<Node>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return boost::shared_ptr<Node> (new TextNode (columnId, text));
|
|
|
|
|
return std::shared_ptr<Node> (new TextNode (columnId, text));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
boost::shared_ptr<CSMFilter::Node> CSMFilter::Parser::parseValue()
|
|
|
|
|
std::shared_ptr<CSMFilter::Node> CSMFilter::Parser::parseValue()
|
|
|
|
|
{
|
|
|
|
|
Token token = getNextToken();
|
|
|
|
|
|
|
|
|
|
if (token.mType!=Token::Type_Open)
|
|
|
|
|
{
|
|
|
|
|
error();
|
|
|
|
|
return boost::shared_ptr<Node>();
|
|
|
|
|
return std::shared_ptr<Node>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
token = getNextToken();
|
|
|
|
|
|
|
|
|
|
if (!token)
|
|
|
|
|
return boost::shared_ptr<Node>();
|
|
|
|
|
return std::shared_ptr<Node>();
|
|
|
|
|
|
|
|
|
|
// parse column ID
|
|
|
|
|
int columnId = -1;
|
|
|
|
@ -434,7 +434,7 @@ boost::shared_ptr<CSMFilter::Node> CSMFilter::Parser::parseValue()
|
|
|
|
|
if (columnId<0)
|
|
|
|
|
{
|
|
|
|
|
error();
|
|
|
|
|
return boost::shared_ptr<Node>();
|
|
|
|
|
return std::shared_ptr<Node>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
token = getNextToken();
|
|
|
|
@ -442,7 +442,7 @@ boost::shared_ptr<CSMFilter::Node> CSMFilter::Parser::parseValue()
|
|
|
|
|
if (token.mType!=Token::Type_Comma)
|
|
|
|
|
{
|
|
|
|
|
error();
|
|
|
|
|
return boost::shared_ptr<Node>();
|
|
|
|
|
return std::shared_ptr<Node>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// parse value
|
|
|
|
@ -467,7 +467,7 @@ boost::shared_ptr<CSMFilter::Node> CSMFilter::Parser::parseValue()
|
|
|
|
|
else if (token.mType!=Token::Type_CloseSquare && token.mType!=Token::Type_Open)
|
|
|
|
|
{
|
|
|
|
|
error();
|
|
|
|
|
return boost::shared_ptr<Node>();
|
|
|
|
|
return std::shared_ptr<Node>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
token = getNextToken();
|
|
|
|
@ -481,7 +481,7 @@ boost::shared_ptr<CSMFilter::Node> CSMFilter::Parser::parseValue()
|
|
|
|
|
if (token.mType!=Token::Type_Comma)
|
|
|
|
|
{
|
|
|
|
|
error();
|
|
|
|
|
return boost::shared_ptr<Node>();
|
|
|
|
|
return std::shared_ptr<Node>();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (token.mType==Token::Type_Comma)
|
|
|
|
@ -491,7 +491,7 @@ boost::shared_ptr<CSMFilter::Node> CSMFilter::Parser::parseValue()
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
error();
|
|
|
|
|
return boost::shared_ptr<Node>();
|
|
|
|
|
return std::shared_ptr<Node>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
token = getNextToken();
|
|
|
|
@ -513,7 +513,7 @@ boost::shared_ptr<CSMFilter::Node> CSMFilter::Parser::parseValue()
|
|
|
|
|
else if (token.mType!=Token::Type_OpenSquare && token.mType!=Token::Type_Close)
|
|
|
|
|
{
|
|
|
|
|
error();
|
|
|
|
|
return boost::shared_ptr<Node>();
|
|
|
|
|
return std::shared_ptr<Node>();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -522,10 +522,10 @@ boost::shared_ptr<CSMFilter::Node> CSMFilter::Parser::parseValue()
|
|
|
|
|
if (token.mType!=Token::Type_Close)
|
|
|
|
|
{
|
|
|
|
|
error();
|
|
|
|
|
return boost::shared_ptr<Node>();
|
|
|
|
|
return std::shared_ptr<Node>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return boost::shared_ptr<Node> (new ValueNode (columnId, lowerType, upperType, lower, upper));
|
|
|
|
|
return std::shared_ptr<Node> (new ValueNode (columnId, lowerType, upperType, lower, upper));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CSMFilter::Parser::error()
|
|
|
|
@ -556,7 +556,7 @@ bool CSMFilter::Parser::parse (const std::string& filter, bool allowPredefined)
|
|
|
|
|
}
|
|
|
|
|
else if (!allowPredefined || token==Token (Token::Type_OneShot))
|
|
|
|
|
{
|
|
|
|
|
boost::shared_ptr<Node> node = parseImp (true, token!=Token (Token::Type_OneShot));
|
|
|
|
|
std::shared_ptr<Node> node = parseImp (true, token!=Token (Token::Type_OneShot));
|
|
|
|
|
|
|
|
|
|
if (mError)
|
|
|
|
|
return false;
|
|
|
|
@ -612,7 +612,7 @@ bool CSMFilter::Parser::parse (const std::string& filter, bool allowPredefined)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
boost::shared_ptr<CSMFilter::Node> CSMFilter::Parser::getFilter() const
|
|
|
|
|
std::shared_ptr<CSMFilter::Node> CSMFilter::Parser::getFilter() const
|
|
|
|
|
{
|
|
|
|
|
if (mError)
|
|
|
|
|
throw std::logic_error ("No filter available");
|
|
|
|
|