integrate new query parser

This commit is contained in:
djcb
2017-10-24 22:57:57 +03:00
parent b75f9f508b
commit 5e9cafea59
17 changed files with 373 additions and 979 deletions

View File

@ -1,5 +1,5 @@
/*
** Copyright (C) 2008-2013 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
** Copyright (C) 2008-2017 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
@ -43,7 +43,7 @@ typedef struct _MuQuery MuQuery;
* when the instance is no longer needed, use mu_query_destroy
* to free it
*/
MuQuery *mu_query_new (MuStore *store, GError **err)
MuQuery* mu_query_new (MuStore *store, GError **err)
G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
/**
@ -53,7 +53,6 @@ MuQuery *mu_query_new (MuStore *store, GError **err)
*/
void mu_query_destroy (MuQuery *self);
/**
* get a version string for the database
*
@ -65,16 +64,14 @@ char* mu_query_version (MuQuery *store)
G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
enum _MuQueryFlags {
MU_QUERY_FLAG_NONE = 0,
typedef enum {
MU_QUERY_FLAG_NONE = 0 << 0, /**< no flags */
MU_QUERY_FLAG_DESCENDING = 1 << 0, /**< sort z->a */
MU_QUERY_FLAG_SKIP_UNREADABLE = 1 << 1, /**< skip unreadable msgs */
MU_QUERY_FLAG_SKIP_DUPS = 1 << 2, /**< skip duplicate msgs */
MU_QUERY_FLAG_INCLUDE_RELATED = 1 << 3, /**< include related msgs */
MU_QUERY_FLAG_THREADS = 1 << 4 /**< calculate threading info */
};
typedef int MuQueryFlags;
} MuQueryFlags;
/**
* run a Xapian query; for the syntax, please refer to the mu-find
@ -94,15 +91,30 @@ typedef int MuQueryFlags;
* @return a MuMsgIter instance you can iterate over, or NULL in
* case of error
*/
MuMsgIter* mu_query_run (MuQuery *self, const char* expr, MuMsgFieldId sortfieldid, int maxnum,
MuMsgIter* mu_query_run (MuQuery *self, const char* expr,
MuMsgFieldId sortfieldid, int maxnum,
MuQueryFlags flags, GError **err)
G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
/**
* get Xapian's internal string representation of the query
*
* @param self a MuQuery instance
* @param searchexpr a xapian search expression
* @param warn print warnings to stderr
* @param err receives error information (if there is any); if
* function returns non-NULL, err will _not_be set. err can be NULL
*
* @return the string representation of the xapian query, or NULL in case of
* error; free the returned value with g_free
*/
char* mu_query_internal (MuQuery *self, const char *searchexpr,
gboolean warn, GError **err)
G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
/**
* get a string representation of the Xapian search query
* get Xapian's internal string representation of the query
*
* @param self a MuQuery instance
* @param searchexpr a xapian search expression
@ -112,18 +124,10 @@ MuMsgIter* mu_query_run (MuQuery *self, const char* expr, MuMsgFieldId sortfield
* @return the string representation of the xapian query, or NULL in case of
* error; free the returned value with g_free
*/
char* mu_query_as_string (MuQuery *self, const char* searchexpr, GError **err)
char* mu_query_internal_xapian (MuQuery *self, const char* searchexpr,
GError **err)
G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
/**
* pre-process the query; this function is useful mainly for debugging mu
*
* @param query a query string
*
* @return a pre-processed query, free it with g_free
*/
char* mu_query_preprocess (const char *query, GError **err)
G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
G_END_DECLS