looqs/shared/token.h
Albert S a6ddcef0c0 shared: LooqsQuery: Fix logic of implicit AND booleans. Add 'limit:' support
Add implicit AND booleans at the end.

This fixes a number of issues in LooqsQuery:

(1) A query like a b c p:(something) would fail, because
a b c get merged into one word. This happens at the end.

lonewords are special and do not become a token immediatly. So previous
logic to add implicit ANDs does not apply.

(2) Negations were also broken with lonewords.

(3) The TokenType enum fields were too narrow to be useful for the bitmask

Independent of that, add support for 'limit:'
2022-06-05 14:39:57 +02:00

50 lines
631 B
C++

#ifndef TOKEN_H
#define TOKEN_H
#include <QString>
enum TokenType
{
WORD = 8,
NEGATION = 16,
BOOL = 32,
BOOL_AND,
BOOL_OR,
GROUP = 64,
BRACKET_OPEN,
BRACKET_CLOSE,
SORT = 128,
FILTER_PATH = 256,
FILTER_PATH_MTIME,
FILTER_PATH_CONTAINS,
FILTER_PATH_SIZE,
FILTER_PATH_ENDS,
FILTER_PATH_STARTS,
FILTER_CONTENT = 512,
FILTER_CONTENT_CONTAINS,
FILTER_CONTENT_PAGE,
LIMIT = 1024
};
class Token
{
public:
Token()
{
}
Token(TokenType type)
{
this->type = type;
}
Token(TokenType type, QString value)
{
this->type = type;
this->value = value;
}
TokenType type;
QString value;
};
#endif // TOKEN_H