rename QueryNew to QofQuery

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@8721 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Linas Vepstas 2003-06-25 07:38:15 +00:00
parent a81946672e
commit 8118b2fd69
23 changed files with 704 additions and 593 deletions

View File

@ -3201,8 +3201,8 @@ gboolean xaccAccountRegister (void)
{ ACCOUNT_RECONCILED_, QOF_QUERYCORE_NUMERIC, (QofQueryAccess)xaccAccountGetReconciledBalance },
{ ACCOUNT_FUTURE_MINIMUM_, QOF_QUERYCORE_NUMERIC, (QofQueryAccess)xaccAccountGetProjectedMinimumBalance },
{ ACCOUNT_TAX_RELATED, QOF_QUERYCORE_BOOLEAN, (QofQueryAccess)xaccAccountGetTaxRelated },
{ QUERY_PARAM_BOOK, GNC_ID_BOOK, (QofQueryAccess)xaccAccountGetBook },
{ QUERY_PARAM_GUID, QOF_QUERYCORE_GUID, (QofQueryAccess)xaccAccountGetGUID },
{ QOF_QUERY_PARAM_BOOK, GNC_ID_BOOK, (QofQueryAccess)xaccAccountGetBook },
{ QOF_QUERY_PARAM_GUID, QOF_QUERYCORE_GUID, (QofQueryAccess)xaccAccountGetGUID },
{ NULL },
};

View File

@ -37,15 +37,15 @@
*
*/
#ifndef XACC_BACKEND_P_H
#define XACC_BACKEND_P_H
#ifndef QOF_BACKEND_P_H
#define QOF_BACKEND_P_H
#include "config.h"
#include "Backend.h"
#include "QueryNew.h"
#include "gnc-session.h"
#include "qofbook.h"
#include "qofquery.h"
/*
* The session_begin() routine gives the backend a second initialization
@ -239,7 +239,7 @@ struct backend_s
void (*commit) (Backend *, GNCIdTypeConst, gpointer);
void (*rollback) (Backend *, GNCIdTypeConst, gpointer);
gpointer (*compile_query) (Backend *, QueryNew *);
gpointer (*compile_query) (Backend *, QofQuery *);
void (*free_query) (Backend *, gpointer);
void (*run_query) (Backend *, gpointer);
@ -300,4 +300,4 @@ Backend * xaccQofBookGetBackend (QofBook *book);
void xaccInitBackend(Backend *be);
#endif /* XACC_BACKEND_P_H */
#endif /* QOF_BACKEND_P_H */

View File

@ -16,7 +16,6 @@ libgncmod_engine_la_SOURCES = \
Group.c \
Period.c \
Query.c \
QueryNew.c \
QueryObject.c \
SchedXaction.c \
SX-book.c \
@ -44,6 +43,7 @@ libgncmod_engine_la_SOURCES = \
md5.c \
messages.c \
qofbook.c \
qofquery.c \
qofquerycore.c \
qofobject.c
@ -90,6 +90,7 @@ gncinclude_HEADERS = \
kvp-util.h \
messages.h \
qofbook.h \
qofquery.h \
qofquerycore.h \
qofobject.h
@ -100,7 +101,6 @@ noinst_HEADERS = \
GNCIdP.h \
GroupP.h \
QueryP.h \
QueryNewP.h \
QueryObjectP.h \
SchedXactionP.h \
ScrubP.h \
@ -117,6 +117,7 @@ noinst_HEADERS = \
gw-engine.h \
gw-kvp.h \
qofbook-p.h \
qofquery-p.h \
qofquerycore-p.h \
qofobject-p.h

View File

@ -457,7 +457,7 @@ gnc_book_close_period (QofBook *existing_book, Timespec calve_date,
query = xaccMallocQuery();
xaccQueryAddDateMatchTS (query, FALSE, calve_date,
TRUE, calve_date,
QUERY_AND);
QOF_QUERY_AND);
closing_book = qof_book_new();
qof_book_set_backend (closing_book, existing_book->backend);
closing_book->book_open = 'n';

View File

@ -224,7 +224,7 @@ xaccQueryGetLots (Query * q, query_txn_match_t runtype)
void
xaccQueryAddAccountMatch(Query *q, AccountList *acct_list,
QofGuidMatch how, QueryOp op)
QofGuidMatch how, QofQueryOp op)
{
GList *list = NULL;
@ -252,7 +252,7 @@ xaccQueryAddAccountMatch(Query *q, AccountList *acct_list,
void
xaccQueryAddAccountGUIDMatch(Query *q, AccountGUIDList *guid_list,
QofGuidMatch how, QueryOp op)
QofGuidMatch how, QofQueryOp op)
{
QofQueryPredData *pred_data;
GSList *param_list = NULL;
@ -266,21 +266,21 @@ xaccQueryAddAccountGUIDMatch(Query *q, AccountGUIDList *guid_list,
switch (how) {
case QOF_GUID_MATCH_ANY:
case QOF_GUID_MATCH_NONE:
param_list = gncQueryBuildParamList (SPLIT_ACCOUNT, QUERY_PARAM_GUID, NULL);
param_list = qof_query_build_param_list (SPLIT_ACCOUNT, QOF_QUERY_PARAM_GUID, NULL);
break;
case QOF_GUID_MATCH_ALL:
param_list = gncQueryBuildParamList (SPLIT_TRANS, TRANS_SPLITLIST,
param_list = qof_query_build_param_list (SPLIT_TRANS, TRANS_SPLITLIST,
SPLIT_ACCOUNT_GUID, NULL);
break;
default:
PERR ("Invalid match type: %d", how);
}
gncQueryAddTerm (q, param_list, pred_data, op);
qof_query_add_term (q, param_list, pred_data, op);
}
void
xaccQueryAddSingleAccountMatch(Query *q, Account *acc, QueryOp op)
xaccQueryAddSingleAccountMatch(Query *q, Account *acc, QofQueryOp op)
{
GList *list;
const GUID *guid;
@ -298,7 +298,7 @@ xaccQueryAddSingleAccountMatch(Query *q, Account *acc, QueryOp op)
void
xaccQueryAddStringMatch (Query* q, const char *matchstring,
int case_sens, int use_regexp, QueryOp op,
int case_sens, int use_regexp, QofQueryOp op,
const char * path, ...)
{
QofQueryPredData *pred_data;
@ -319,12 +319,12 @@ xaccQueryAddStringMatch (Query* q, const char *matchstring,
param_list = build_param_list_internal (path, ap);
va_end (ap);
gncQueryAddTerm (q, param_list, pred_data, op);
qof_query_add_term (q, param_list, pred_data, op);
}
void
xaccQueryAddNumericMatch (Query *q, gnc_numeric amount, QofNumericMatch sign,
QofQueryCompare how, QueryOp op,
QofQueryCompare how, QofQueryOp op,
const char * path, ...)
{
QofQueryPredData *pred_data;
@ -342,7 +342,7 @@ xaccQueryAddNumericMatch (Query *q, gnc_numeric amount, QofNumericMatch sign,
param_list = build_param_list_internal (path, ap);
va_end (ap);
gncQueryAddTerm (q, param_list, pred_data, op);
qof_query_add_term (q, param_list, pred_data, op);
}
/* The DateMatch queries match transactions whose posted date
@ -358,7 +358,7 @@ void
xaccQueryAddDateMatchTS (Query * q,
int use_start, Timespec sts,
int use_end, Timespec ets,
QueryOp op)
QofQueryOp op)
{
Query *tmp_q = NULL;
QofQueryPredData *pred_data;
@ -367,32 +367,32 @@ xaccQueryAddDateMatchTS (Query * q,
if (!q || (!use_start && !use_end))
return;
tmp_q = gncQueryCreate ();
tmp_q = qof_query_create ();
if (use_start) {
pred_data = qof_query_date_predicate (QOF_COMPARE_GTE, QOF_DATE_MATCH_NORMAL, sts);
if (!pred_data) {
gncQueryDestroy (tmp_q);
qof_query_destroy (tmp_q);
return;
}
param_list = gncQueryBuildParamList (SPLIT_TRANS, TRANS_DATE_POSTED, NULL);
gncQueryAddTerm (tmp_q, param_list, pred_data, QUERY_AND);
param_list = qof_query_build_param_list (SPLIT_TRANS, TRANS_DATE_POSTED, NULL);
qof_query_add_term (tmp_q, param_list, pred_data, QOF_QUERY_AND);
}
if (use_end) {
pred_data = qof_query_date_predicate (QOF_COMPARE_LTE, QOF_DATE_MATCH_NORMAL, ets);
if (!pred_data) {
gncQueryDestroy (tmp_q);
qof_query_destroy (tmp_q);
return;
}
param_list = gncQueryBuildParamList (SPLIT_TRANS, TRANS_DATE_POSTED, NULL);
gncQueryAddTerm (tmp_q, param_list, pred_data, QUERY_AND);
param_list = qof_query_build_param_list (SPLIT_TRANS, TRANS_DATE_POSTED, NULL);
qof_query_add_term (tmp_q, param_list, pred_data, QOF_QUERY_AND);
}
gncQueryMergeInPlace (q, tmp_q, op);
gncQueryDestroy (tmp_q);
qof_query_merge_in_place (q, tmp_q, op);
qof_query_destroy (tmp_q);
}
/********************************************************************
@ -404,7 +404,7 @@ void
xaccQueryAddDateMatch(Query * q,
int use_start, int sday, int smonth, int syear,
int use_end, int eday, int emonth, int eyear,
QueryOp op)
QofQueryOp op)
{
/* gcc -O3 will auto-inline this function, avoiding a call overhead */
xaccQueryAddDateMatchTS (q, use_start,
@ -425,7 +425,7 @@ xaccQueryAddDateMatchTT(Query * q,
time_t stt,
int use_end,
time_t ett,
QueryOp op)
QofQueryOp op)
{
Timespec sts;
Timespec ets;
@ -443,7 +443,7 @@ xaccQueryAddDateMatchTT(Query * q,
}
void
xaccQueryAddClearedMatch(Query * q, cleared_match_t how, QueryOp op)
xaccQueryAddClearedMatch(Query * q, cleared_match_t how, QofQueryOp op)
{
QofQueryPredData *pred_data;
GSList *param_list;
@ -469,14 +469,14 @@ xaccQueryAddClearedMatch(Query * q, cleared_match_t how, QueryOp op)
if (!pred_data)
return;
param_list = gncQueryBuildParamList (SPLIT_RECONCILE, NULL);
param_list = qof_query_build_param_list (SPLIT_RECONCILE, NULL);
gncQueryAddTerm (q, param_list, pred_data, op);
qof_query_add_term (q, param_list, pred_data, op);
}
void
xaccQueryAddGUIDMatch(Query * q, const GUID *guid,
GNCIdType id_type, QueryOp op)
GNCIdType id_type, QofQueryOp op)
{
GSList *param_list = NULL;
@ -484,20 +484,20 @@ xaccQueryAddGUIDMatch(Query * q, const GUID *guid,
return;
if (!safe_strcmp (id_type, GNC_ID_SPLIT))
param_list = gncQueryBuildParamList (QUERY_PARAM_GUID, NULL);
param_list = qof_query_build_param_list (QOF_QUERY_PARAM_GUID, NULL);
else if (!safe_strcmp (id_type, GNC_ID_TRANS))
param_list = gncQueryBuildParamList (SPLIT_TRANS, QUERY_PARAM_GUID, NULL);
param_list = qof_query_build_param_list (SPLIT_TRANS, QOF_QUERY_PARAM_GUID, NULL);
else if (!safe_strcmp (id_type, GNC_ID_ACCOUNT))
param_list = gncQueryBuildParamList (SPLIT_ACCOUNT, QUERY_PARAM_GUID, NULL);
param_list = qof_query_build_param_list (SPLIT_ACCOUNT, QOF_QUERY_PARAM_GUID, NULL);
else
PERR ("Invalid match type: %s", id_type);
gncQueryAddGUIDMatch (q, param_list, guid, op);
qof_query_add_guid_match (q, param_list, guid, op);
}
void
xaccQueryAddGUIDMatchGL (QueryNew *q, GList *param_list,
GUID guid, QueryOp op)
xaccQueryAddGUIDMatchGL (QofQuery *q, GList *param_list,
GUID guid, QofQueryOp op)
{
GSList *params = NULL;
GList *node;
@ -508,13 +508,13 @@ xaccQueryAddGUIDMatchGL (QueryNew *q, GList *param_list,
params = g_slist_reverse (params);
g_list_free (param_list);
gncQueryAddGUIDMatch (q, params, &guid, op);
qof_query_add_guid_match (q, params, &guid, op);
}
void
xaccQueryAddKVPMatch(Query *q, GSList *path, const kvp_value *value,
QofQueryCompare how, GNCIdType id_type,
QueryOp op)
QofQueryOp op)
{
GSList *param_list = NULL;
QofQueryPredData *pred_data;
@ -527,15 +527,15 @@ xaccQueryAddKVPMatch(Query *q, GSList *path, const kvp_value *value,
return;
if (!safe_strcmp (id_type, GNC_ID_SPLIT))
param_list = gncQueryBuildParamList (SPLIT_KVP, NULL);
param_list = qof_query_build_param_list (SPLIT_KVP, NULL);
else if (!safe_strcmp (id_type, GNC_ID_TRANS))
param_list = gncQueryBuildParamList (SPLIT_TRANS, TRANS_KVP, NULL);
param_list = qof_query_build_param_list (SPLIT_TRANS, TRANS_KVP, NULL);
else if (!safe_strcmp (id_type, GNC_ID_ACCOUNT))
param_list = gncQueryBuildParamList (SPLIT_ACCOUNT, ACCOUNT_KVP, NULL);
param_list = qof_query_build_param_list (SPLIT_ACCOUNT, ACCOUNT_KVP, NULL);
else
PERR ("Invalid match type: %s", id_type);
gncQueryAddTerm (q, param_list, pred_data, op);
qof_query_add_term (q, param_list, pred_data, op);
}
/*******************************************************************
@ -550,7 +550,7 @@ xaccQueryGetEarliestDateFound(Query * q)
time_t earliest = LONG_MAX;
if (!q) return 0;
spl = gncQueryLastRun (q);
spl = qof_query_last_run (q);
if (!spl) return 0;
for(; spl; spl=spl->next) {
@ -574,7 +574,7 @@ xaccQueryGetLatestDateFound(Query * q)
time_t latest = 0;
if(!q) return 0;
spl = gncQueryLastRun (q);
spl = qof_query_last_run (q);
if(!spl) return 0;
for(; spl; spl=spl->next) {
@ -609,7 +609,7 @@ xaccQuerySetSortOrder(Query *q, GList *p1, GList *p2, GList *p3)
if (p2) g_list_free (p2);
if (p3) g_list_free (p3);
gncQuerySetSortOrder (q, l1, l2, l3);
qof_query_set_sort_order (q, l1, l2, l3);
}
/* ======================== END OF FILE ======================= */

View File

@ -34,7 +34,7 @@
#include "guid.h"
#include "kvp_frame.h"
#include "QueryNew.h"
#include "qofquery.h"
#include "qofquerycore.h"
/*
@ -44,16 +44,16 @@
* others do not.
*/
typedef QueryNew Query;
typedef QofQuery Query;
#define xaccMallocQuery() gncQueryCreateFor(GNC_ID_SPLIT)
#define xaccFreeQuery gncQueryDestroy
#define xaccQueryCopy gncQueryCopy
#define xaccQuerySetBook gncQuerySetBook
#define xaccMallocQuery() qof_query_create_for(GNC_ID_SPLIT)
#define xaccFreeQuery qof_query_destroy
#define xaccQueryCopy qof_query_copy
#define xaccQuerySetBook qof_query_set_book
#define xaccQueryInvert gncQueryInvert
#define xaccQueryMerge gncQueryMerge
#define xaccQueryClear gncQueryClear
#define xaccQueryInvert qof_query_invert
#define xaccQueryMerge qof_query_merge
#define xaccQueryClear qof_query_clear
/* The xaccQueryHasTerms() routine returns the number of 'OR' terms in the query.
* The xaccQueryNumTerms() routine returns the total number of terms in the query.
@ -61,17 +61,17 @@ typedef QueryNew Query;
// void xaccQueryPurgeTerms(Query * q, pd_type_t type);
// gboolean xaccQueryHasTermType(Query * q, pd_type_t type);
#define xaccQueryHasTerms gncQueryHasTerms
#define xaccQueryNumTerms gncQueryNumTerms
// #define xaccQueryGetTerms gncQueryGetTerms
#define xaccQueryHasTerms qof_query_has_terms
#define xaccQueryNumTerms qof_query_num_terms
// #define xaccQueryGetTerms qof_query_get_terms
#define xaccQuerySetSortIncreasing gncQuerySetSortIncreasing
#define xaccQuerySetSortIncreasing qof_query_set_sort_increasing
#define xaccQuerySetMaxSplits gncQuerySetMaxResults
#define xaccQueryGetMaxSplits gncQueryGetMaxResults
#define xaccQuerySetMaxSplits qof_query_set_max_results
#define xaccQueryGetMaxSplits qof_query_get_max_results
#define xaccQueryEqual gncQueryEqual
#define xaccQueryEqual qof_query_equal
typedef enum {
QUERY_TXN_MATCH_ALL=1, /* match all accounts */
@ -114,7 +114,7 @@ typedef enum {
* matching accounts, whereas 'AND' acts as a boolean-AND
* for matching accounts. Whew. Got that?
*/
#define xaccQueryGetSplits gncQueryRun
#define xaccQueryGetSplits qof_query_run
SplitList * xaccQueryGetSplitsUniqueTrans(Query *q);
TransList * xaccQueryGetTransactions(Query * q, query_txn_match_t type);
LotList * xaccQueryGetLots(Query * q, query_txn_match_t type);
@ -124,15 +124,15 @@ LotList * xaccQueryGetLots(Query * q, query_txn_match_t type);
*******************************************************************/
void xaccQueryAddAccountMatch(Query *, AccountList *,
QofGuidMatch how, QueryOp op);
QofGuidMatch how, QofQueryOp op);
void xaccQueryAddAccountGUIDMatch(Query *, AccountGUIDList *,
QofGuidMatch, QueryOp);
QofGuidMatch, QofQueryOp);
void xaccQueryAddSingleAccountMatch(Query *, Account *, QueryOp);
void xaccQueryAddSingleAccountMatch(Query *, Account *, QofQueryOp);
void xaccQueryAddStringMatch (Query* q, const char *matchstring,
int case_sens, int use_regexp, QueryOp op,
int case_sens, int use_regexp, QofQueryOp op,
const char * path, ...);
#define xaccQueryAddDescriptionMatch(q,m,c,r,o) \
@ -150,7 +150,7 @@ void xaccQueryAddStringMatch (Query* q, const char *matchstring,
void xaccQueryAddNumericMatch (Query *q, gnc_numeric amount,
QofNumericMatch sign, QofQueryCompare how,
QueryOp op, const char * path, ...);
QofQueryOp op, const char * path, ...);
#define xaccQueryAddValueMatch(q,amt,sgn,how,op) \
xaccQueryAddNumericMatch ((q), (amt), (sgn), (how), (op), \
@ -181,15 +181,15 @@ void xaccQueryAddNumericMatch (Query *q, gnc_numeric amount,
void xaccQueryAddDateMatch(Query * q,
int use_start, int sday, int smonth, int syear,
int use_end, int eday, int emonth, int eyear,
QueryOp op);
QofQueryOp op);
void xaccQueryAddDateMatchTS(Query * q,
int use_start, Timespec sts,
int use_end, Timespec ets,
QueryOp op);
QofQueryOp op);
void xaccQueryAddDateMatchTT(Query * q,
int use_start, time_t stt,
int use_end, time_t ett,
QueryOp op);
QofQueryOp op);
typedef enum {
CLEARED_NONE = 0x0000,
CLEARED_NO = 0x0001,
@ -200,16 +200,16 @@ typedef enum {
CLEARED_ALL = 0x001F
} cleared_match_t;
void xaccQueryAddClearedMatch(Query * q, cleared_match_t how, QueryOp op);
void xaccQueryAddClearedMatch(Query * q, cleared_match_t how, QofQueryOp op);
void xaccQueryAddGUIDMatch(Query * q, const GUID *guid,
GNCIdType id_type, QueryOp op);
void xaccQueryAddGUIDMatchGL (QueryNew *q, GList *param_list,
GUID guid, QueryOp op);
GNCIdType id_type, QofQueryOp op);
void xaccQueryAddGUIDMatchGL (QofQuery *q, GList *param_list,
GUID guid, QofQueryOp op);
/* given kvp value is on right side of comparison */
void xaccQueryAddKVPMatch(Query *q, GSList *path, const kvp_value *value,
QofQueryCompare how, GNCIdType id_type,
QueryOp op);
QofQueryOp op);
void xaccQuerySetSortOrder(Query *q, GList *p1, GList *p2, GList *p3);

View File

@ -1,170 +1,49 @@
/********************************************************************\
* QueryNew.h -- API for finding Gnucash objects *
* *
* 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 the Free Software Foundation; either version 2 of *
* the License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License*
* along with this program; if not, contact: *
* *
* Free Software Foundation Voice: +1-617-542-5942 *
* 59 Temple Place - Suite 330 Fax: +1-617-542-2652 *
* Boston, MA 02111-1307, USA gnu@gnu.org *
* *
\********************************************************************/
/** @file QueryNew.h
@breif API for finding Gnucash objects
@author Copyright (C) 2002 Derek Atkins <warlord@MIT.EDU>
*/
#include "qofquery.h"
#ifndef GNC_QUERYNEW_H
#define GNC_QUERYNEW_H
#define QUERY_AND QOF_QUERY_AND
#define QUERY_OR QOF_QUERY_OR
#define QUERY_NAND QOF_QUERY_NAND
#define QUERY_NOR QOF_QUERY_NOR
#define QUERY_XOR QOF_QUERY_XOR
#define QUERY_PARAM_BOOK QOF_QUERY_PARAM_BOOK
#define QUERY_PARAM_GUID QOF_QUERY_PARAM_GUID
#define QUERY_PARAM_ACTIVE QOF_QUERY_PARAM_ACTIVE
#include "GNCId.h"
#include "qofquerycore.h"
#include "qofbook.h"
#define querynew_s _QofQuery
#define QueryNew QofQuery
#define QueryOp QofQueryOp
#define query_new_term _QofQueryTerm
#define query_new_sort _QofQuerySort
/** A Query */
typedef struct querynew_s QueryNew;
#define gncQueryBuildParamList qof_query_build_param_list
#define gncQueryCreate qof_query_create
#define gncQueryCreateFor qof_query_create_for
#define gncQueryDestroy qof_query_destroy
#define gncQuerySearchFor qof_query_search_for
#define gncQuerySetBook qof_query_set_book
#define gncQueryAddTerm qof_query_add_term
#define gncQueryAddGUIDMatch qof_query_add_guid_match
#define gncQueryAddGUIDListMatch qof_query_add_guid_list_match
#define gncQueryAddBooleanMatch qof_query_add_boolean_match
#define gncQueryRun qof_query_run
#define gncQueryLastRun qof_query_last_run
#define gncQueryClear qof_query_clear
#define gncQueryPurgeTerms qof_query_purge_terms
#define gncQueryHasTerms qof_query_has_terms
#define gncQueryNumTerms qof_query_num_terms
#define gncQueryHasTermType qof_query_has_term_type
#define gncQueryCopy qof_query_copy
#define gncQueryInvert qof_query_invert
#define gncQueryMerge qof_query_merge
#define gncQueryMergeInPlace qof_query_merge_in_place
#define gncQuerySetSortOrder qof_query_set_sort_order
#define gncQuerySetSortOptions qof_query_set_sort_options
#define gncQuerySetSortIncreasing qof_query_set_sort_increasing
#define gncQuerySetMaxResults qof_query_set_max_results
#define gncQueryEqual qof_query_equal
#define gncQueryPrint qof_query_print
#define gncQueryGetSearchFor qof_query_get_search_for
#define gncQueryGetBooks qof_query_get_books
/** Query Term Operators, for combining Query Terms */
typedef enum {
QUERY_AND=1,
QUERY_OR,
QUERY_NAND,
QUERY_NOR,
QUERY_XOR
} QueryOp;
/* First/only term is same as 'and' */
#define QUERY_FIRST_TERM QUERY_AND
/** Default sort object type */
#define QUERY_DEFAULT_SORT "GnucashQueryDefaultSortObject"
/** "Known" Object Parameters -- all objects must support these */
#define QUERY_PARAM_BOOK "book"
#define QUERY_PARAM_GUID "guid"
#define QUERY_PARAM_ACTIVE "active" /* it's ok if an object does
* not support this */
/** Basic API Functions */
GSList * gncQueryBuildParamList (char const *param, ...);
/** Create a new query. A Query MUST be set with a 'search-for' type.
* you can create and set this value in one step or two */
QueryNew * gncQueryCreate (void);
QueryNew * gncQueryCreateFor (GNCIdTypeConst obj_type);
void gncQueryDestroy (QueryNew *q);
/** Set the object type to be searched for */
void gncQuerySearchFor (QueryNew *query, GNCIdTypeConst obj_type);
/** Set the book to be searched (you can search multiple books) */
void gncQuerySetBook (QueryNew *q, QofBook *book);
/** This is the general function that adds a new Query Term to a query.
* It will find the 'obj_type' object of the search item and compare
* the 'param_list' parameter to the predicate data via the comparitor.
*
* The param_list is a recursive list of parameters. For example, you
* can say 'split->memo' by creating a list of one element, "SPLIT_MEMO".
* You can say 'split->account->name' by creating a list of two elements,
* "SPLIT_ACCOUNT" and "ACCOUNT_NAME". The list becomes the property of
* the Query.
*
* For example:
*
* acct_name_pred_data = make_string_pred_data(QOF_STRING_MATCH_CASEINSENSITIVE,
* account_name);
* param_list = make_list (SPLIT_ACCOUNT, ACCOUNT_NAME, NULL);
* gncQueryAddTerm (query, param_list, QOF_COMPARE_EQUAL,
* acct_name_pred_data, QUERY_AND);
*/
void gncQueryAddTerm (QueryNew *query, GSList *param_list,
QofQueryPredData *pred_data, QueryOp op);
void gncQueryAddGUIDMatch (QueryNew *q, GSList *param_list,
const GUID *guid, QueryOp op);
void gncQueryAddGUIDListMatch (QueryNew *q, GSList *param_list,
GList *guid_list, QofGuidMatch options,
QueryOp op);
void gncQueryAddBooleanMatch (QueryNew *q, GSList *param_list, gboolean value,
QueryOp op);
/** Run the query: */
GList * gncQueryRun (QueryNew *query);
/** Return the results of the last query, without re-running */
GList * gncQueryLastRun (QueryNew *query);
void gncQueryClear (QueryNew *query);
void gncQueryPurgeTerms (QueryNew *q, GSList *param_list);
int gncQueryHasTerms (QueryNew *q);
int gncQueryNumTerms (QueryNew *q);
gboolean gncQueryHasTermType (QueryNew *q, GSList *term_param);
QueryNew * gncQueryCopy (QueryNew *q);
QueryNew * gncQueryInvert(QueryNew *q);
/** Merges two queries together. Both queries must be compatible
* search-types. If both queries are set, they must search for the
* same object type. If only one is set, the resulting query will
* search for the set type. If neither query has the search-type set,
* the result will be unset as well.
*/
QueryNew * gncQueryMerge(QueryNew *q1, QueryNew *q2, QueryOp op);
/** Like gncQueryMerge, but this will merge q2 into q1. q2 remains
* unchanged.
*/
void gncQueryMergeInPlace(QueryNew *q1, QueryNew *q2, QueryOp op);
/** The lists become the property of the Query and will be freed
* by the query when it is destroyed.
*/
void gncQuerySetSortOrder (QueryNew *q,
GSList *primary_sort_params,
GSList *secondary_sort_params,
GSList *tertiary_sort_params);
void gncQuerySetSortOptions (QueryNew *q, gint prim_op, gint sec_op,
gint tert_op);
void gncQuerySetSortIncreasing (QueryNew *q, gboolean prim_inc,
gboolean sec_inc, gboolean tert_inc);
void gncQuerySetMaxResults (QueryNew *q, int n);
/** Compare two queries for equality. This is a simplistic
* implementation -- logical equivalences between different
* and/or trees are ignored. */
gboolean gncQueryEqual (QueryNew *q1, QueryNew *q2);
/* Print the Query in human-readable format.
* Useful for debugging and development.
*/
void gncQueryPrint (QueryNew *query);
/* Return the type of data we're querying for */
GNCIdType gncQueryGetSearchFor (QueryNew *q);
/* Return the list of books we're using */
GList * gncQueryGetBooks (QueryNew *q);
#endif /* GNC_QUERYNEW_H */

View File

@ -1,5 +1,5 @@
/********************************************************************\
* QueryObject.c -- provide Gnucash Queriable data objects *
* QueryObject.c -- provide QOF Queriable data objects *
* Copyright (C) 2002 Derek Atkins <warlord@MIT.EDU> *
* *
* This program is free software; you can redistribute it and/or *
@ -27,7 +27,7 @@
#include "gnc-engine-util.h"
#include "QueryObjectP.h"
#include "QueryNew.h"
#include "qofquery.h"
static short module = MOD_QUERY;

View File

@ -25,11 +25,11 @@
@author Copyright (C) 2002 Derek Atkins <warlord@MIT.EDU>
*/
#ifndef GNC_QUERYOBJECT_H
#define GNC_QUERYOBJECT_H
#ifndef QOF_QUERYOBJECT_H
#define QOF_QUERYOBJECT_H
#include "qofquery.h"
#include "qofquerycore.h"
#include "QueryNew.h"
/** This structure is for each queriable parameter in an object
*
@ -47,7 +47,7 @@ typedef struct query_object_def {
/** This function is the default sort function for a particular object type */
typedef int (*QuerySort)(gpointer, gpointer);
/** This function registers a new Gnucash Object with the QueryNew
/** This function registers a new Gnucash Object with the QofQuery
* subsystem. In particular it registers the set of parameters and
* converters to query the type-specific data. Both "params" and
* "converters" are NULL-terminated arrays of structures. Either
@ -90,4 +90,4 @@ QofQueryAccess gncQueryObjectGetParameterGetter (GNCIdTypeConst obj_name,
const char *parameter);
#endif /* GNC_QUERYOBJECT_H */
#endif /* QOF_QUERYOBJECT_H */

View File

@ -144,9 +144,9 @@ typedef struct {
} QueryTerm;
void xaccQueryAddMiscMatch(Query * q, Predicate p, int how, int data,
QueryOp op);
QofQueryOp op);
void xaccQueryAddPredicate (Query * q, PredicateData *pred, QueryOp op);
void xaccQueryAddPredicate (Query * q, PredicateData *pred, QofQueryOp op);
/* This is useful for network systems */
Predicate xaccQueryGetPredicate (pr_type_t term_type);

View File

@ -3622,8 +3622,8 @@ gboolean xaccSplitRegister (void)
{ SPLIT_ACCT_FULLNAME, SPLIT_ACCT_FULLNAME, no_op },
{ SPLIT_CORR_ACCT_NAME, SPLIT_CORR_ACCT_NAME, no_op },
{ SPLIT_CORR_ACCT_CODE, SPLIT_CORR_ACCT_CODE, no_op },
{ QUERY_PARAM_BOOK, GNC_ID_BOOK, (QofQueryAccess)xaccSplitGetBook },
{ QUERY_PARAM_GUID, QOF_QUERYCORE_GUID, (QofQueryAccess) xaccSplitGetGUID },
{ QOF_QUERY_PARAM_BOOK, GNC_ID_BOOK, (QofQueryAccess)xaccSplitGetBook },
{ QOF_QUERY_PARAM_GUID, QOF_QUERYCORE_GUID, (QofQueryAccess) xaccSplitGetGUID },
{ NULL },
};
@ -3684,8 +3684,8 @@ gboolean xaccTransRegister (void)
{ TRANS_VOID_REASON, QOF_QUERYCORE_STRING, (QofQueryAccess)xaccTransGetVoidReason },
{ TRANS_VOID_TIME, QOF_QUERYCORE_DATE, (QofQueryAccess)xaccTransGetVoidTime },
{ TRANS_SPLITLIST, GNC_ID_SPLIT, (QofQueryAccess)xaccTransGetSplitList },
{ QUERY_PARAM_BOOK, GNC_ID_BOOK, (QofQueryAccess)xaccTransGetBook },
{ QUERY_PARAM_GUID, QOF_QUERYCORE_GUID, (QofQueryAccess)xaccTransGetGUID },
{ QOF_QUERY_PARAM_BOOK, GNC_ID_BOOK, (QofQueryAccess)xaccTransGetBook },
{ QOF_QUERY_PARAM_GUID, QOF_QUERYCORE_GUID, (QofQueryAccess)xaccTransGetGUID },
{ NULL },
};

View File

@ -31,7 +31,6 @@
#include "Account.h"
#include "Backend.h"
#include "Group.h"
#include "QueryNewP.h"
#include "engine-helpers.h"
#include "glib-helpers.h"
#include "gnc-date.h"
@ -40,6 +39,8 @@
#include "gnc-numeric.h"
#include "guile-mappings.h"
#include "qofbook.h"
#include "qofquery.h"
#include "qofquery-p.h"
#include "qofquerycore.h"
#include "qofquerycore-p.h"
@ -863,16 +864,16 @@ gnc_scm2kvp_frame (SCM frame_scm)
}
static SCM
gnc_queryterm2scm (QueryNewTerm_t qt)
gnc_queryterm2scm (QofQueryTerm_t qt)
{
SCM qt_scm = SCM_EOL;
QofQueryPredData *pd = NULL;
qt_scm = scm_cons (gnc_query_path2scm (gncQueryTermGetParamPath (qt)),
qt_scm = scm_cons (gnc_query_path2scm (qof_query_term_get_param_path (qt)),
qt_scm);
qt_scm = scm_cons (SCM_BOOL (gncQueryTermIsInverted (qt)), qt_scm);
qt_scm = scm_cons (SCM_BOOL (qof_query_term_is_inverted (qt)), qt_scm);
pd = gncQueryTermGetPredData (qt);
pd = qof_query_term_get_pred_data (qt);
qt_scm = scm_cons (scm_str2symbol (pd->type_name), qt_scm);
qt_scm = scm_cons (gnc_query_compare2scm (pd->how), qt_scm);
@ -1146,11 +1147,11 @@ gnc_scm2query_term_query_v2 (SCM qt_scm)
} while (FALSE);
if (pd) {
q = gncQueryCreate ();
gncQueryAddTerm (q, path, pd, QUERY_OR);
q = qof_query_create ();
qof_query_add_term (q, path, pd, QOF_QUERY_OR);
if (inverted) {
Query *outq = gncQueryInvert (q);
gncQueryDestroy (q);
Query *outq = qof_query_invert (q);
qof_query_destroy (q);
q = outq;
}
} else {
@ -1245,7 +1246,7 @@ gnc_scm2query_term_query_v1 (SCM query_term_scm)
query_term_scm = SCM_CDR (query_term_scm);
end = gnc_timepair2timespec (scm);
xaccQueryAddDateMatchTS (q, use_start, start, use_end, end, QUERY_OR);
xaccQueryAddDateMatchTS (q, use_start, start, use_end, end, QOF_QUERY_OR);
ok = TRUE;
@ -1279,15 +1280,15 @@ gnc_scm2query_term_query_v1 (SCM query_term_scm)
val = double_to_gnc_numeric (amount, GNC_DENOM_AUTO, GNC_RND_ROUND);
if (!safe_strcmp (pr_type, "pr-price")) {
xaccQueryAddSharePriceMatch (q, val, how, QUERY_OR);
xaccQueryAddSharePriceMatch (q, val, how, QOF_QUERY_OR);
ok = TRUE;
} else if (!safe_strcmp (pr_type, "pr-shares")) {
xaccQueryAddSharesMatch (q, val, how, QUERY_OR);
xaccQueryAddSharesMatch (q, val, how, QOF_QUERY_OR);
ok = TRUE;
} else if (!safe_strcmp (pr_type, "pr-value")) {
xaccQueryAddValueMatch (q, val, amt_sgn, how, QUERY_OR);
xaccQueryAddValueMatch (q, val, amt_sgn, how, QOF_QUERY_OR);
ok = TRUE;
} else {
@ -1319,7 +1320,7 @@ gnc_scm2query_term_query_v1 (SCM query_term_scm)
account_guids = gnc_scm2guid_glist (scm);
xaccQueryAddAccountGUIDMatch (q, account_guids, how, QUERY_OR);
xaccQueryAddAccountGUIDMatch (q, account_guids, how, QOF_QUERY_OR);
gnc_guid_glist_free (account_guids);
@ -1356,22 +1357,22 @@ gnc_scm2query_term_query_v1 (SCM query_term_scm)
if (!safe_strcmp (pr_type, "pr-action")) {
xaccQueryAddActionMatch (q, matchstring, case_sens, use_regexp,
QUERY_OR);
QOF_QUERY_OR);
ok = TRUE;
} else if (!safe_strcmp (pr_type, "pr-desc")) {
xaccQueryAddDescriptionMatch (q, matchstring, case_sens,
use_regexp, QUERY_OR);
use_regexp, QOF_QUERY_OR);
ok = TRUE;
} else if (!safe_strcmp (pr_type, "pr-memo")) {
xaccQueryAddMemoMatch (q, matchstring, case_sens, use_regexp,
QUERY_OR);
QOF_QUERY_OR);
ok = TRUE;
} else if (!safe_strcmp (pr_type, "pr-num")) {
xaccQueryAddNumberMatch (q, matchstring, case_sens, use_regexp,
QUERY_OR);
QOF_QUERY_OR);
ok = TRUE;
} else {
@ -1389,7 +1390,7 @@ gnc_scm2query_term_query_v1 (SCM query_term_scm)
query_term_scm = SCM_CDR (query_term_scm);
how = gnc_scm2cleared_match_how (scm);
xaccQueryAddClearedMatch (q, how, QUERY_OR);
xaccQueryAddClearedMatch (q, how, QOF_QUERY_OR);
ok = TRUE;
} else if (!safe_strcmp (pd_type, "pd-balance")) {
@ -1404,7 +1405,7 @@ gnc_scm2query_term_query_v1 (SCM query_term_scm)
if (gnc_scm2balance_match_how (scm, &how) == FALSE)
break;
xaccQueryAddBalanceMatch (q, how, QUERY_OR);
xaccQueryAddBalanceMatch (q, how, QOF_QUERY_OR);
ok = TRUE;
} else if (!safe_strcmp (pd_type, "pd-guid")) {
@ -1427,7 +1428,7 @@ gnc_scm2query_term_query_v1 (SCM query_term_scm)
id_type = g_strdup (tmp);
if (tmp) free (tmp);
xaccQueryAddGUIDMatch (q, &guid, id_type, QUERY_OR);
xaccQueryAddGUIDMatch (q, &guid, id_type, QOF_QUERY_OR);
ok = TRUE;
} else if (!safe_strcmp (pd_type, "pd-kvp")) {
@ -1464,7 +1465,7 @@ gnc_scm2query_term_query_v1 (SCM query_term_scm)
query_term_scm = SCM_CDR (query_term_scm);
value = gnc_scm2kvp_value (scm);
xaccQueryAddKVPMatch (q, path, value, how, where, QUERY_OR);
xaccQueryAddKVPMatch (q, path, value, how, where, QOF_QUERY_OR);
gnc_query_path_free (path);
kvp_value_delete (value);
@ -1526,7 +1527,7 @@ gnc_query_terms2scm (GList *terms)
for (and_node = or_node->data; and_node; and_node = and_node->next)
{
QueryNewTerm_t qt = and_node->data;
QofQueryTerm_t qt = and_node->data;
SCM qt_scm;
qt_scm = gnc_queryterm2scm (qt);
@ -1568,7 +1569,7 @@ gnc_scm2query_and_terms (SCM and_terms, query_version_t vers)
if (q_and)
{
q_new = xaccQueryMerge (q, q_and, QUERY_AND);
q_new = xaccQueryMerge (q, q_and, QOF_QUERY_AND);
if (q_new)
{
@ -1610,7 +1611,7 @@ gnc_scm2query_or_terms (SCM or_terms, query_version_t vers)
if (q_or)
{
q_new = xaccQueryMerge (q, q_or, QUERY_OR);
q_new = xaccQueryMerge (q, q_or, QOF_QUERY_OR);
if (q_new)
{
@ -1625,18 +1626,18 @@ gnc_scm2query_or_terms (SCM or_terms, query_version_t vers)
}
static SCM
gnc_query_sort2scm (QueryNewSort_t qs)
gnc_query_sort2scm (QofQuerySort_t qs)
{
SCM sort_scm = SCM_EOL;
GSList *path;
path = gncQuerySortGetParamPath (qs);
path = qof_query_sort_get_param_path (qs);
if (path == NULL)
return SCM_BOOL_F;
sort_scm = scm_cons (gnc_query_path2scm (path), sort_scm);
sort_scm = scm_cons (scm_int2num (gncQuerySortGetSortOptions (qs)), sort_scm);
sort_scm = scm_cons (SCM_BOOL (gncQuerySortGetIncreasing (qs)), sort_scm);
sort_scm = scm_cons (scm_int2num (qof_query_sort_get_sort_options (qs)), sort_scm);
sort_scm = scm_cons (SCM_BOOL (qof_query_sort_get_increasing (qs)), sort_scm);
return scm_reverse (sort_scm);
}
@ -1702,22 +1703,22 @@ gnc_query2scm (Query *q)
{
SCM query_scm = SCM_EOL;
SCM pair;
QueryNewSort_t s1, s2, s3;
QofQuerySort_t s1, s2, s3;
if (!q) return SCM_BOOL_F;
/* terms */
pair = scm_cons (gnc_query_terms2scm (gncQueryGetTerms (q)), SCM_EOL);
pair = scm_cons (gnc_query_terms2scm (qof_query_get_terms (q)), SCM_EOL);
pair = scm_cons (scm_str2symbol ("terms"), pair);
query_scm = scm_cons (pair, query_scm);
/* search-for */
pair = scm_cons (scm_str2symbol (gncQueryGetSearchFor (q)), SCM_EOL);
pair = scm_cons (scm_str2symbol (qof_query_get_search_for (q)), SCM_EOL);
pair = scm_cons (scm_str2symbol ("search-for"), pair);
query_scm = scm_cons (pair, query_scm);
/* sorts... */
gncQueryGetSorts (q, &s1, &s2, &s3);
qof_query_get_sorts (q, &s1, &s2, &s3);
/* primary-sort */
pair = scm_cons (gnc_query_sort2scm (s1), SCM_EOL);
@ -1735,7 +1736,7 @@ gnc_query2scm (Query *q)
query_scm = scm_cons (pair, query_scm);
/* max results */
pair = scm_cons (scm_int2num (gncQueryGetMaxResults (q)), SCM_EOL);
pair = scm_cons (scm_int2num (qof_query_get_max_results (q)), SCM_EOL);
pair = scm_cons (scm_str2symbol ("max-results"), pair);
query_scm = scm_cons (pair, query_scm);
@ -1932,8 +1933,8 @@ gnc_scm2query_v1 (SCM query_scm)
s2 = gnc_query_sort_to_list (secondary_sort);
s3 = gnc_query_sort_to_list (tertiary_sort);
gncQuerySetSortOrder (q, s1, s2, s3);
gncQuerySetSortIncreasing (q, primary_increasing, secondary_increasing,
qof_query_set_sort_order (q, s1, s2, s3);
qof_query_set_sort_increasing (q, primary_increasing, secondary_increasing,
tertiary_increasing);
xaccQuerySetMaxSplits (q, max_splits);
@ -2052,11 +2053,11 @@ gnc_scm2query_v2 (SCM query_scm)
}
if (ok && search_for) {
gncQuerySearchFor (q, search_for);
gncQuerySetSortOrder (q, sp1, sp2, sp3);
gncQuerySetSortOptions (q, so1, so2, so3);
gncQuerySetSortIncreasing (q, si1, si2, si3);
gncQuerySetMaxResults (q, max_results);
qof_query_search_for (q, search_for);
qof_query_set_sort_order (q, sp1, sp2, sp3);
qof_query_set_sort_options (q, so1, so2, so3);
qof_query_set_sort_increasing (q, si1, si2, si3);
qof_query_set_max_results (q, max_results);
return q;
}

View File

@ -26,7 +26,6 @@
#include <glib.h>
#include "GNCIdP.h"
#include "QueryNewP.h"
#include "gnc-engine.h"
#include "gnc-engine-util.h"
@ -39,7 +38,10 @@
#include "gnc-pricedb-p.h"
#include "qofbook.h"
#include "qofbook-p.h"
#include "qofobject.h"
#include "qofobject-p.h"
#include "qofquery.h"
#include "qofquery-p.h"
static GList * engine_init_hooks = NULL;
static int engine_is_initialized = 0;
@ -82,7 +84,8 @@ gnc_engine_init(int argc, char ** argv)
xaccGUIDInit ();
qof_object_initialize ();
gncQueryNewInit ();
qof_query_init ();
qof_book_register ();
/* Now register our core types */
xaccSplitRegister ();
@ -92,7 +95,6 @@ gnc_engine_init(int argc, char ** argv)
gnc_sxtt_register ();
gnc_pricedb_register ();
gnc_commodity_table_register();
qof_book_register ();
gnc_lot_register ();
/* call any engine hooks */
@ -113,7 +115,7 @@ gnc_engine_init(int argc, char ** argv)
void
gnc_engine_shutdown (void)
{
gncQueryNewShutdown ();
qof_query_shutdown ();
gnc_engine_string_cache_destroy ();

View File

@ -330,8 +330,8 @@ gnc_lot_get_latest_split (GNCLot *lot)
void gnc_lot_register (void)
{
static const QueryObjectDef params[] = {
{ QUERY_PARAM_BOOK, GNC_ID_BOOK, (QofQueryAccess)gnc_lot_get_book },
{ QUERY_PARAM_GUID, QOF_QUERYCORE_GUID, (QofQueryAccess)gnc_lot_get_guid },
{ QOF_QUERY_PARAM_BOOK, GNC_ID_BOOK, (QofQueryAccess)gnc_lot_get_book },
{ QOF_QUERY_PARAM_GUID, QOF_QUERYCORE_GUID, (QofQueryAccess)gnc_lot_get_guid },
{ LOT_IS_CLOSED, QOF_QUERYCORE_BOOLEAN, (QofQueryAccess)gnc_lot_is_closed },
{ LOT_BALANCE, QOF_QUERYCORE_NUMERIC, (QofQueryAccess)gnc_lot_get_balance },
{ NULL },

View File

@ -119,13 +119,13 @@
(gw:enum-add-value! wt "GNC_EVENT_DESTROY" 'gnc-event-destroy)
(gw:enum-add-value! wt "GNC_EVENT_ALL" 'gnc-event-all))
(let ((wt (gw:wrap-enumeration ws '<gnc:query-op> "QueryOp")))
(let ((wt (gw:wrap-enumeration ws '<gnc:query-op> "QofQueryOp")))
(gw:enum-add-value! wt "QUERY_AND" 'query-and)
(gw:enum-add-value! wt "QUERY_OR" 'query-or)
(gw:enum-add-value! wt "QUERY_NAND" 'query-nand)
(gw:enum-add-value! wt "QUERY_NOR" 'query-nor)
(gw:enum-add-value! wt "QUERY_XOR" 'query-xor))
(gw:enum-add-value! wt "QOF_QUERY_AND" 'query-and)
(gw:enum-add-value! wt "QOF_QUERY_OR" 'query-or)
(gw:enum-add-value! wt "QOF_QUERY_NAND" 'query-nand)
(gw:enum-add-value! wt "QOF_QUERY_NOR" 'query-nor)
(gw:enum-add-value! wt "QOF_QUERY_XOR" 'query-xor))
(let ((wt (gw:wrap-enumeration ws '<gnc:query-compare-how> "QofQueryCompare")))
(gw:enum-add-value! wt "QOF_COMPARE_LT" 'query-compare-lt)
@ -1714,7 +1714,7 @@ of having a parent transaction with which one is working...")
ws
'gnc:query-create
'<gnc:Query*>
"gncQueryCreate"
"qof_query_create"
'()
"Create a new (empty) Query structure.")
@ -1722,7 +1722,7 @@ of having a parent transaction with which one is working...")
ws
'gnc:query-create-for
'<gnc:Query*>
"gncQueryCreateFor"
"qof_query_create_for"
'((<gnc:id-type> obj-type))
"Create a new (empty) Query structure to search for the supplied type.")
@ -1730,7 +1730,7 @@ of having a parent transaction with which one is working...")
ws
'gnc:query-search-for
'<gw:void>
"gncQuerySearchFor"
"qof_query_search_for"
'((<gnc:Query*> q) (<gnc:id-type> obj-type))
"Set the object-type to search for.")
@ -1778,7 +1778,7 @@ of having a parent transaction with which one is working...")
ws
'gnc:query-purge-terms
'<gw:void>
"gncQueryPurgeTerms"
"qof_query_purge_terms"
'((<gnc:Query*> q) ((gw:gslist-of <gnc:id-type> caller-owned) param-path))
"Remove query terms of a particular parameter-path.")
@ -1996,7 +1996,7 @@ of having a parent transaction with which one is working...")
ws
'gnc:query-set-max-results
'<gw:void>
"gncQuerySetMaxResults"
"qof_query_set_max_results"
'((<gnc:Query*> q) (<gw:int> n))
"Set the max number of results to be returned by a query.")

View File

@ -294,7 +294,7 @@ gboolean qof_book_register (void)
{
static QueryObjectDef params[] = {
{ QOF_BOOK_KVP, QOF_QUERYCORE_KVP, (QofQueryAccess)qof_book_get_slots },
{ QUERY_PARAM_GUID, QOF_QUERYCORE_GUID, (QofQueryAccess)qof_book_get_guid },
{ QOF_QUERY_PARAM_GUID, QOF_QUERYCORE_GUID, (QofQueryAccess)qof_book_get_guid },
{ NULL },
};

View File

@ -1,5 +1,5 @@
/********************************************************************\
* QueryNewP.h -- internal/private API for finding Gnucash objects *
* qofquery-p.h -- internal/private API for finding objects *
* Copyright (C) 2002 Derek Atkins <warlord@MIT.EDU> *
* *
* This program is free software; you can redistribute it and/or *
@ -21,20 +21,20 @@
* *
\********************************************************************/
#ifndef GNC_QUERYNEWP_H
#define GNC_QUERYNEWP_H
#ifndef QOF_QUERY_P_H
#define QOF_QUERY_P_H
#include "QueryNew.h"
#include "qofquery.h"
typedef struct query_new_term *QueryNewTerm_t;
typedef struct query_new_sort *QueryNewSort_t;
typedef struct _QofQueryTerm *QofQueryTerm_t;
typedef struct _QofQuerySort *QofQuerySort_t;
/* Initialize/Shutdown */
void gncQueryNewInit (void);
void gncQueryNewShutdown (void);
void qof_query_init (void);
void qof_query_shutdown (void);
/* Functions to get Query information */
int gncQueryGetMaxResults (QueryNew *q);
int qof_query_get_max_results (QofQuery *q);
/* Functions to get and look at QueryTerms */
@ -47,11 +47,11 @@ int gncQueryGetMaxResults (QueryNew *q);
* Note that you should NOT modify this list in any way. It belongs
* to the query.
*/
GList * gncQueryGetTerms (QueryNew *q);
GList * qof_query_get_terms (QofQuery *q);
GSList * gncQueryTermGetParamPath (QueryNewTerm_t queryterm);
QofQueryPredData *gncQueryTermGetPredData (QueryNewTerm_t queryterm);
gboolean gncQueryTermIsInverted (QueryNewTerm_t queryterm);
GSList * qof_query_term_get_param_path (QofQueryTerm_t queryterm);
QofQueryPredData *qof_query_term_get_pred_data (QofQueryTerm_t queryterm);
gboolean qof_query_term_is_inverted (QofQueryTerm_t queryterm);
/* Functions to get and look at QuerySorts */
@ -59,11 +59,11 @@ gboolean gncQueryTermIsInverted (QueryNewTerm_t queryterm);
/* This function returns the primary, secondary, and tertiary sorts.
* These are part of the query and should NOT be changed!
*/
void gncQueryGetSorts (QueryNew *q, QueryNewSort_t *primary,
QueryNewSort_t *secondary, QueryNewSort_t *tertiary);
void qof_query_get_sorts (QofQuery *q, QofQuerySort_t *primary,
QofQuerySort_t *secondary, QofQuerySort_t *tertiary);
GSList * gncQuerySortGetParamPath (QueryNewSort_t querysort);
gint gncQuerySortGetSortOptions (QueryNewSort_t querysort);
gboolean gncQuerySortGetIncreasing (QueryNewSort_t querysort);
GSList * qof_query_sort_get_param_path (QofQuerySort_t querysort);
gint qof_query_sort_get_sort_options (QofQuerySort_t querysort);
gboolean qof_query_sort_get_increasing (QofQuerySort_t querysort);
#endif /* GNC_QUERYNEWP_H */
#endif /* QOF_QUERY_P_H */

File diff suppressed because it is too large Load Diff

170
src/engine/qofquery.h Normal file
View File

@ -0,0 +1,170 @@
/********************************************************************\
* qofquery.h -- API for finding objects that can be queried *
* *
* 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 the Free Software Foundation; either version 2 of *
* the License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License*
* along with this program; if not, contact: *
* *
* Free Software Foundation Voice: +1-617-542-5942 *
* 59 Temple Place - Suite 330 Fax: +1-617-542-2652 *
* Boston, MA 02111-1307, USA gnu@gnu.org *
* *
\********************************************************************/
/** @file qofquery.h
@breif API for finding objects that can be queried
@author Copyright (C) 2002 Derek Atkins <warlord@MIT.EDU>
*/
#ifndef QOF_QUERYNEW_H
#define QOF_QUERYNEW_H
#include "GNCId.h"
#include "qofquerycore.h"
#include "qofbook.h"
/** A Query */
typedef struct _QofQuery QofQuery;
/** Query Term Operators, for combining Query Terms */
typedef enum {
QOF_QUERY_AND=1,
QOF_QUERY_OR,
QOF_QUERY_NAND,
QOF_QUERY_NOR,
QOF_QUERY_XOR
} QofQueryOp;
/* First/only term is same as 'and' */
#define QOF_QUERY_FIRST_TERM QOF_QUERY_AND
/** Default sort object type */
#define QUERY_DEFAULT_SORT "GnucashQueryDefaultSortObject"
/** "Known" Object Parameters -- all objects must support these */
#define QOF_QUERY_PARAM_BOOK "book"
#define QOF_QUERY_PARAM_GUID "guid"
#define QOF_QUERY_PARAM_ACTIVE "active" /* it's ok if an object does
* not support this */
/** Basic API Functions */
GSList * qof_query_build_param_list (char const *param, ...);
/** Create a new query. A Query MUST be set with a 'search-for' type.
* you can create and set this value in one step or two */
QofQuery * qof_query_create (void);
QofQuery * qof_query_create_for (GNCIdTypeConst obj_type);
void qof_query_destroy (QofQuery *q);
/** Set the object type to be searched for */
void qof_query_search_for (QofQuery *query, GNCIdTypeConst obj_type);
/** Set the book to be searched (you can search multiple books) */
void qof_query_set_book (QofQuery *q, QofBook *book);
/** This is the general function that adds a new Query Term to a query.
* It will find the 'obj_type' object of the search item and compare
* the 'param_list' parameter to the predicate data via the comparitor.
*
* The param_list is a recursive list of parameters. For example, you
* can say 'split->memo' by creating a list of one element, "SPLIT_MEMO".
* You can say 'split->account->name' by creating a list of two elements,
* "SPLIT_ACCOUNT" and "ACCOUNT_NAME". The list becomes the property of
* the Query.
*
* For example:
*
* acct_name_pred_data = make_string_pred_data(QOF_STRING_MATCH_CASEINSENSITIVE,
* account_name);
* param_list = make_list (SPLIT_ACCOUNT, ACCOUNT_NAME, NULL);
* qof_query_add_term (query, param_list, QOF_COMPARE_EQUAL,
* acct_name_pred_data, QOF_QUERY_AND);
*/
void qof_query_add_term (QofQuery *query, GSList *param_list,
QofQueryPredData *pred_data, QofQueryOp op);
void qof_query_add_guid_match (QofQuery *q, GSList *param_list,
const GUID *guid, QofQueryOp op);
void qof_query_add_guid_list_match (QofQuery *q, GSList *param_list,
GList *guid_list, QofGuidMatch options,
QofQueryOp op);
void qof_query_add_boolean_match (QofQuery *q, GSList *param_list, gboolean value,
QofQueryOp op);
/** Run the query: */
GList * qof_query_run (QofQuery *query);
/** Return the results of the last query, without re-running */
GList * qof_query_last_run (QofQuery *query);
void qof_query_clear (QofQuery *query);
void qof_query_purge_terms (QofQuery *q, GSList *param_list);
int qof_query_has_terms (QofQuery *q);
int qof_query_num_terms (QofQuery *q);
gboolean qof_query_has_term_type (QofQuery *q, GSList *term_param);
QofQuery * qof_query_copy (QofQuery *q);
QofQuery * qof_query_invert(QofQuery *q);
/** Merges two queries together. Both queries must be compatible
* search-types. If both queries are set, they must search for the
* same object type. If only one is set, the resulting query will
* search for the set type. If neither query has the search-type set,
* the result will be unset as well.
*/
QofQuery * qof_query_merge(QofQuery *q1, QofQuery *q2, QofQueryOp op);
/** Like qof_query_merge, but this will merge q2 into q1. q2 remains
* unchanged.
*/
void qof_query_merge_in_place(QofQuery *q1, QofQuery *q2, QofQueryOp op);
/** The lists become the property of the Query and will be freed
* by the query when it is destroyed.
*/
void qof_query_set_sort_order (QofQuery *q,
GSList *primary_sort_params,
GSList *secondary_sort_params,
GSList *tertiary_sort_params);
void qof_query_set_sort_options (QofQuery *q, gint prim_op, gint sec_op,
gint tert_op);
void qof_query_set_sort_increasing (QofQuery *q, gboolean prim_inc,
gboolean sec_inc, gboolean tert_inc);
void qof_query_set_max_results (QofQuery *q, int n);
/** Compare two queries for equality. This is a simplistic
* implementation -- logical equivalences between different
* and/or trees are ignored. */
gboolean qof_query_equal (QofQuery *q1, QofQuery *q2);
/* Print the Query in human-readable format.
* Useful for debugging and development.
*/
void qof_query_print (QofQuery *query);
/* Return the type of data we're querying for */
GNCIdType qof_query_get_search_for (QofQuery *q);
/* Return the list of books we're using */
GList * qof_query_get_books (QofQuery *q);
#endif /* QOF_QUERYNEW_H */

View File

@ -26,9 +26,9 @@
#include <glib.h>
#include "gnc-engine-util.h"
#include "qofquery.h"
#include "qofquerycore.h"
#include "qofquerycore-p.h"
#include "QueryNew.h"
static short module = MOD_QUERY;
@ -50,7 +50,7 @@ typedef char * (*QueryToString) (gpointer object, QofQueryAccess get_fcn);
typedef gboolean (*QueryPredicateEqual) (QofQueryPredData *p1,
QofQueryPredData *p2);
/* This function registers a new Core Object with the QueryNew
/* This function registers a new Core Object with the QofQuery
* subsystem. It maps the "core_name" object to the given
* query_predicate, predicate_copy, and predicate_data_free functions.
*/

View File

@ -1233,10 +1233,10 @@ free_random_guids(GList *guids)
g_list_free (guids);
}
static QueryOp
static QofQueryOp
get_random_queryop(void)
{
return get_random_int_in_range (1, QUERY_XOR);
return get_random_int_in_range (1, QOF_QUERY_XOR);
}
static GSList *
@ -1345,7 +1345,7 @@ set_query_sort (Query *q, sort_type_t sort_code)
g_return_if_fail (FALSE);
}
gncQuerySetSortOrder (q, p1, p2, p3);
qof_query_set_sort_order (q, p1, p2, p3);
}
Query *
@ -1640,7 +1640,7 @@ add_kvp_value_query (const char *key, kvp_value *value, gpointer data)
else
xaccQueryAddKVPMatch (kqd->q, kqd->path, value,
QOF_COMPARE_EQUAL, kqd->where,
QUERY_AND);
QOF_QUERY_AND);
node = g_slist_last (kqd->path);
kqd->path = g_slist_remove_link (kqd->path, node);
@ -1699,38 +1699,38 @@ make_trans_query (Transaction *trans, TestQueryTypes query_types)
if (query_types & SIMPLE_QT)
{
xaccQueryAddSingleAccountMatch (q, xaccSplitGetAccount (s), QUERY_AND);
xaccQueryAddSingleAccountMatch (q, xaccSplitGetAccount (s), QOF_QUERY_AND);
xaccQueryAddDescriptionMatch (q, xaccTransGetDescription (trans),
TRUE, FALSE, QUERY_AND);
TRUE, FALSE, QOF_QUERY_AND);
xaccQueryAddNumberMatch (q, xaccTransGetNum (trans),
TRUE, FALSE, QUERY_AND);
TRUE, FALSE, QOF_QUERY_AND);
xaccQueryAddActionMatch (q, xaccSplitGetAction (s),
TRUE, FALSE, QUERY_AND);
TRUE, FALSE, QOF_QUERY_AND);
n = xaccSplitGetValue (s);
xaccQueryAddValueMatch (q, n, QOF_NUMERIC_MATCH_ANY,
QOF_COMPARE_EQUAL, QUERY_AND);
QOF_COMPARE_EQUAL, QOF_QUERY_AND);
n = xaccSplitGetAmount (s);
xaccQueryAddSharesMatch (q, n, QOF_COMPARE_EQUAL, QUERY_AND);
xaccQueryAddSharesMatch (q, n, QOF_COMPARE_EQUAL, QOF_QUERY_AND);
if (include_price)
{
n = xaccSplitGetSharePrice (s);
xaccQueryAddSharePriceMatch (q, n, QOF_COMPARE_EQUAL, QUERY_AND);
xaccQueryAddSharePriceMatch (q, n, QOF_COMPARE_EQUAL, QOF_QUERY_AND);
}
{
Timespec ts;
xaccTransGetDatePostedTS (trans, &ts);
xaccQueryAddDateMatchTS (q, TRUE, ts, TRUE, ts, QUERY_AND);
xaccQueryAddDateMatchTS (q, TRUE, ts, TRUE, ts, QOF_QUERY_AND);
}
xaccQueryAddMemoMatch (q, xaccSplitGetMemo (s), TRUE, FALSE, QUERY_AND);
xaccQueryAddMemoMatch (q, xaccSplitGetMemo (s), TRUE, FALSE, QOF_QUERY_AND);
{
cleared_match_t how;
@ -1758,7 +1758,7 @@ make_trans_query (Transaction *trans, TestQueryTypes query_types)
return NULL;
}
xaccQueryAddClearedMatch (q, how, QUERY_AND);
xaccQueryAddClearedMatch (q, how, QOF_QUERY_AND);
}
}
@ -1774,7 +1774,7 @@ make_trans_query (Transaction *trans, TestQueryTypes query_types)
Split * split = node->data;
list = g_list_prepend (list, xaccSplitGetAccount (split));
}
xaccQueryAddAccountMatch (q, list, QOF_GUID_MATCH_ALL, QUERY_AND);
xaccQueryAddAccountMatch (q, list, QOF_GUID_MATCH_ALL, QOF_QUERY_AND);
g_list_free (list);
/* GUID_MATCH_NONE */
@ -1782,7 +1782,7 @@ make_trans_query (Transaction *trans, TestQueryTypes query_types)
list = g_list_prepend (list, get_random_guid ());
list = g_list_prepend (list, get_random_guid ());
list = g_list_prepend (list, get_random_guid ());
xaccQueryAddAccountGUIDMatch (q, list, QOF_GUID_MATCH_NONE, QUERY_AND);
xaccQueryAddAccountGUIDMatch (q, list, QOF_GUID_MATCH_NONE, QOF_QUERY_AND);
/* GUID_MATCH_ANY */
{
@ -1790,7 +1790,7 @@ make_trans_query (Transaction *trans, TestQueryTypes query_types)
*guid = *xaccAccountGetGUID (a);
list = g_list_prepend (list, guid);
}
xaccQueryAddAccountGUIDMatch (q, list, QOF_GUID_MATCH_ANY, QUERY_AND);
xaccQueryAddAccountGUIDMatch (q, list, QOF_GUID_MATCH_ANY, QOF_QUERY_AND);
for (node = list; node; node = node->next)
g_free (node->data);
@ -1800,13 +1800,13 @@ make_trans_query (Transaction *trans, TestQueryTypes query_types)
if (query_types & GUID_QT)
{
xaccQueryAddGUIDMatch (q, xaccSplitGetGUID (s),
GNC_ID_SPLIT, QUERY_AND);
GNC_ID_SPLIT, QOF_QUERY_AND);
xaccQueryAddGUIDMatch (q, xaccTransGetGUID (trans),
GNC_ID_TRANS, QUERY_AND);
GNC_ID_TRANS, QOF_QUERY_AND);
xaccQueryAddGUIDMatch (q, xaccAccountGetGUID (a),
GNC_ID_ACCOUNT, QUERY_AND);
GNC_ID_ACCOUNT, QOF_QUERY_AND);
}
if (query_types & SPLIT_KVP_QT)

View File

@ -7,7 +7,7 @@
#include "messages.h"
#include "QueryObjectP.h"
#include "QueryNew.h"
#include "qofquery.h"
#include "qofquerycore.h"
#include "qofquerycore-p.h"

View File

@ -76,19 +76,76 @@ foreach (@files)
# s/CHAR_MATCH_ANY/QOF_CHAR_MATCH_ANY/g;
# s/CHAR_MATCH_NONE/QOF_CHAR_MATCH_NONE/g;
s/char_match_t/QofCharMatch/g;
s/guid_match_t/QofGuidMatch/g;
s/numeric_match_t/QofNumericMatch/g;
s/date_match_t/QofDateMatch/g;
s/string_match_t/QofStringMatch/g;
s/query_compare_t/QofQueryCompare/g;
# s/char_match_t/QofCharMatch/g;
# s/guid_match_t/QofGuidMatch/g;
# s/numeric_match_t/QofNumericMatch/g;
# s/date_match_t/QofDateMatch/g;
# s/string_match_t/QofStringMatch/g;
# s/query_compare_t/QofQueryCompare/g;
s/gncQueryCoreInit/qof_query_core_init/g;
s/gncQueryCoreShutdown/qof_query_core_shutdown/g;
s/gncQueryCoreGetPredicate/qof_query_core_get_predicate/g;
s/gncQueryCoreGetCompare/qof_query_core_get_compare/g;
# s/gncQueryCoreInit/qof_query_core_init/g;
# s/gncQueryCoreShutdown/qof_query_core_shutdown/g;
# s/gncQueryCoreGetPredicate/qof_query_core_get_predicate/g;
# s/gncQueryCoreGetCompare/qof_query_core_get_compare/g;
s/gncQueryCorePredicateEqual/qof_query_core_predicate_equal/g;
# s/gncQueryCorePredicateEqual/qof_query_core_predicate_equal/g;
# s/QUERY_AND/QOF_QUERY_AND/g;
# s/QUERY_OR/QOF_QUERY_OR/g;
# s/QUERY_NAND/QOF_QUERY_NAND/g;
# s/QUERY_NOR/QOF_QUERY_NOR/g;
# s/QUERY_XOR/QOF_QUERY_XOR/g;
# s/QUERY_PARAM_BOOK/QOF_QUERY_PARAM_BOOK/g;
# s/QUERY_PARAM_GUID/QOF_QUERY_PARAM_GUID/g;
# s/QUERY_PARAM_ACTIVE/QOF_QUERY_PARAM_ACTIVE/g;
s/querynew_s/_QofQuery/g;
s/QueryNew/QofQuery/g;
s/QueryOp/QofQueryOp/g;
s/query_new_term/_QofQueryTerm/g;
s/query_new_sort/_QofQuerySort/g;
s/gncQueryBuildParamList/qof_query_build_param_list/g;
s/gncQueryCreateFor/qof_query_create_for/g;
s/gncQueryCreate/qof_query_create/g;
s/gncQueryDestroy/qof_query_destroy/g;
s/gncQuerySearchFor/qof_query_search_for/g;
s/gncQuerySetBook/qof_query_set_book/g;
s/gncQueryAddTerm/qof_query_add_term/g;
s/gncQueryAddGUIDMatch/qof_query_add_guid_match/g;
s/gncQueryAddGUIDListMatch/qof_query_add_guid_list_match/g;
s/gncQueryAddBooleanMatch/qof_query_add_boolean_match/g;
s/gncQueryRun/qof_query_run/g;
s/gncQueryLastRun/qof_query_last_run/g;
s/gncQueryClear/qof_query_clear/g;
s/gncQueryPurgeTerms/qof_query_purge_terms/g;
s/gncQueryHasTerms/qof_query_has_terms/g;
s/gncQueryNumTerms/qof_query_num_terms/g;
s/gncQueryHasTermType/qof_query_has_term_type/g;
s/gncQueryCopy/qof_query_copy/g;
s/gncQueryInvert/qof_query_invert/g;
s/gncQueryMergeInPlace/qof_query_merges_ins_place/g;
s/gncQueryMerge/qof_query_merge/g;
s/gncQuerySetSortOrder/qof_query_set_sort_order/g;
s/gncQuerySetSortOptions/qof_query_set_sort_options/g;
s/gncQuerySetSortIncreasing/qof_query_set_sort_increasing/g;
s/gncQuerySetMaxResults/qof_query_set_max_results/g;
s/gncQueryEqual/qof_query_equal/g;
s/gncQueryPrint/qof_query_print/g;
s/gncQueryGetSearchFor/qof_query_get_search_for/g;
s/gncQueryGetBooks/qof_query_get_books/g;
s/gncQueryNewInit/qof_query_new_init/g;
s/gncQueryNewShutdown/qof_query_new_shutdown/g;
s/gncQueryGetMaxResults/qof_query_get_max_results/g;
s/gncQueryGetTerms/qof_query_get_terms/g;
s/gncQueryTermGetParamPath/qof_query_term_get_param_path/g;
s/gncQueryTermGetPredData/qof_query_term_get_pred_data/g;
s/gncQueryTermIsInverted/qof_query_term_is_inverted/g;
s/gncQueryGetSorts/qof_query_get_sorts/g;
s/gncQuerySortGetParamPath/qof_query_sort_get_param_path/g;
s/gncQuerySortGetSortOptions/qof_query_sort_get_sort_options/g;
s/gncQuerySortGetIncreasing/qof_query_sort_get_increasing/g;
print OF $_;
}