Refactor search queries: Introduced QSSQuery

Purpose is to seperate certain logic from SQLite and generalize it more.
Even though we only have Sqlite atm, in general the database layers
must be stupid as possible, while QSSQuery should do most of the hard work.

Fixes in Tokenizer logic.
Switched to C++17.
Este commit está contenido en:
2019-08-17 11:06:35 +02:00
padre 05a5bac22f
commit cff481a57e
Se han modificado 14 ficheros con 500 adiciones y 618 borrados

59
shared/qssquery.h Archivo normal
Ver fichero

@ -0,0 +1,59 @@
#ifndef QSSQUERY_H
#define QSSQUERY_H
#include <QString>
#include <QVector>
#include "qssgeneralexception.h"
#include "token.h"
/* Fields that can be queried or sorted */
enum QueryField
{
FILE_PATH,
FILE_MTIME,
FILE_SIZE,
CONTENT_TEXT,
CONTENT_TEXT_PAGE
};
enum SortOrder
{
ASC,
DESC
};
struct SortCondition
{
QueryField field;
SortOrder order;
};
enum QueryType
{
NOTHING = 0,
PATH_ONLY = FILTER_PATH,
CONTENT_ONLY = FILTER_CONTENT,
COMBINED = PATH_ONLY | CONTENT_ONLY
};
class QSSQuery
{
private:
/* Helper field to determine quertype as well as to quickly check what kind of filters etc.
* are being used in this query*/
int tokensMask;
QVector<Token> tokens;
QVector<SortCondition> sortConditions;
void addToken(Token t);
public:
const QVector<Token> &getTokens() const;
const QVector<SortCondition> &getSortConditions() const;
QueryType getQueryType();
int getTokensMask() const
{
return tokensMask;
}
static bool checkParanthesis(QString query);
static QSSQuery build(QString query);
};
#endif // QSSQUERY_H