From aaa6e14fe12ad5e53957f0b7c836eda844304514 Mon Sep 17 00:00:00 2001 From: Linas Vepstas Date: Thu, 26 Jun 2003 04:30:43 +0000 Subject: [PATCH] convert QueryObject to QofQueryObject git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@8731 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/engine/Account.c | 32 ++--- src/engine/Makefile.am | 5 +- src/engine/Query.c | 2 +- src/engine/QueryCore.h | 4 +- src/engine/QueryNew.h | 3 +- src/engine/QueryObject.h | 100 ++-------------- src/engine/Transaction.c | 98 ++++++++-------- src/engine/engine-helpers.c | 16 +-- src/engine/gnc-lot.c | 14 +-- src/engine/qofbook.c | 10 +- src/engine/qofquery-p.h | 12 +- src/engine/qofquery.c | 104 ++++++++-------- src/engine/qofquerycore-p.h | 14 +-- src/engine/qofquerycore.c | 81 +++++++------ src/engine/qofquerycore.h | 15 +-- .../{QueryObjectP.h => qofqueryobject-p.h} | 17 +-- .../{QueryObject.c => qofqueryobject.c} | 29 ++--- src/engine/qofqueryobject.h | 94 +++++++++++++++ src/engine/test/test-querynew.c | 38 +++--- src/engine/xlate.pl | 111 ++++++++++-------- 20 files changed, 423 insertions(+), 376 deletions(-) rename src/engine/{QueryObjectP.h => qofqueryobject-p.h} (80%) rename src/engine/{QueryObject.c => qofqueryobject.c} (83%) create mode 100644 src/engine/qofqueryobject.h diff --git a/src/engine/Account.c b/src/engine/Account.c index b19f63f512..1b5df57377 100644 --- a/src/engine/Account.c +++ b/src/engine/Account.c @@ -46,10 +46,10 @@ #include "kvp-util-p.h" #include "messages.h" -#include "QueryObject.h" #include "qofbook.h" #include "qofbook-p.h" #include "qofobject.h" +#include "qofqueryobject.h" static short module = MOD_ACCOUNT; @@ -3189,24 +3189,24 @@ static QofObject account_object_def = { gboolean xaccAccountRegister (void) { - static QueryObjectDef params[] = { - { ACCOUNT_KVP, QOF_QUERYCORE_KVP, (QofQueryAccess)xaccAccountGetSlots }, - { ACCOUNT_NAME_, QOF_QUERYCORE_STRING, (QofQueryAccess)xaccAccountGetName }, - { ACCOUNT_CODE_, QOF_QUERYCORE_STRING, (QofQueryAccess)xaccAccountGetCode }, - { ACCOUNT_DESCRIPTION_, QOF_QUERYCORE_STRING, (QofQueryAccess)xaccAccountGetDescription }, - { ACCOUNT_NOTES_, QOF_QUERYCORE_STRING, (QofQueryAccess)xaccAccountGetNotes }, - { ACCOUNT_PRESENT_, QOF_QUERYCORE_NUMERIC, (QofQueryAccess)xaccAccountGetPresentBalance }, - { ACCOUNT_BALANCE_, QOF_QUERYCORE_NUMERIC, (QofQueryAccess)xaccAccountGetBalance }, - { ACCOUNT_CLEARED_, QOF_QUERYCORE_NUMERIC, (QofQueryAccess)xaccAccountGetClearedBalance }, - { ACCOUNT_RECONCILED_, QOF_QUERYCORE_NUMERIC, (QofQueryAccess)xaccAccountGetReconciledBalance }, - { ACCOUNT_FUTURE_MINIMUM_, QOF_QUERYCORE_NUMERIC, (QofQueryAccess)xaccAccountGetProjectedMinimumBalance }, - { ACCOUNT_TAX_RELATED, QOF_QUERYCORE_BOOLEAN, (QofQueryAccess)xaccAccountGetTaxRelated }, - { QOF_QUERY_PARAM_BOOK, GNC_ID_BOOK, (QofQueryAccess)xaccAccountGetBook }, - { QOF_QUERY_PARAM_GUID, QOF_QUERYCORE_GUID, (QofQueryAccess)xaccAccountGetGUID }, + static QofQueryObject params[] = { + { ACCOUNT_KVP, QOF_QUERYCORE_KVP, (QofAccessFunc)xaccAccountGetSlots }, + { ACCOUNT_NAME_, QOF_QUERYCORE_STRING, (QofAccessFunc)xaccAccountGetName }, + { ACCOUNT_CODE_, QOF_QUERYCORE_STRING, (QofAccessFunc)xaccAccountGetCode }, + { ACCOUNT_DESCRIPTION_, QOF_QUERYCORE_STRING, (QofAccessFunc)xaccAccountGetDescription }, + { ACCOUNT_NOTES_, QOF_QUERYCORE_STRING, (QofAccessFunc)xaccAccountGetNotes }, + { ACCOUNT_PRESENT_, QOF_QUERYCORE_NUMERIC, (QofAccessFunc)xaccAccountGetPresentBalance }, + { ACCOUNT_BALANCE_, QOF_QUERYCORE_NUMERIC, (QofAccessFunc)xaccAccountGetBalance }, + { ACCOUNT_CLEARED_, QOF_QUERYCORE_NUMERIC, (QofAccessFunc)xaccAccountGetClearedBalance }, + { ACCOUNT_RECONCILED_, QOF_QUERYCORE_NUMERIC, (QofAccessFunc)xaccAccountGetReconciledBalance }, + { ACCOUNT_FUTURE_MINIMUM_, QOF_QUERYCORE_NUMERIC, (QofAccessFunc)xaccAccountGetProjectedMinimumBalance }, + { ACCOUNT_TAX_RELATED, QOF_QUERYCORE_BOOLEAN, (QofAccessFunc)xaccAccountGetTaxRelated }, + { QOF_QUERY_PARAM_BOOK, GNC_ID_BOOK, (QofAccessFunc)xaccAccountGetBook }, + { QOF_QUERY_PARAM_GUID, QOF_QUERYCORE_GUID, (QofAccessFunc)xaccAccountGetGUID }, { NULL }, }; - gncQueryObjectRegister (GNC_ID_ACCOUNT, (QuerySort)xaccAccountOrder, params); + qof_query_object_register (GNC_ID_ACCOUNT, (QofSortFunc)xaccAccountOrder, params); return qof_object_register (&account_object_def); } diff --git a/src/engine/Makefile.am b/src/engine/Makefile.am index 609cfa4d1d..14fa562322 100644 --- a/src/engine/Makefile.am +++ b/src/engine/Makefile.am @@ -16,7 +16,6 @@ libgncmod_engine_la_SOURCES = \ Group.c \ Period.c \ Query.c \ - QueryObject.c \ SchedXaction.c \ SX-book.c \ SX-ttinfo.c \ @@ -45,6 +44,7 @@ libgncmod_engine_la_SOURCES = \ qofbook.c \ qofquery.c \ qofquerycore.c \ + qofqueryobject.c \ qofobject.c EXTRA_libgncmod_engine_la_SOURCES = iso-4217-currencies.c @@ -92,6 +92,7 @@ gncinclude_HEADERS = \ qofbook.h \ qofquery.h \ qofquerycore.h \ + qofqueryobject.h \ qofobject.h noinst_HEADERS = \ @@ -101,7 +102,6 @@ noinst_HEADERS = \ GNCIdP.h \ GroupP.h \ QueryP.h \ - QueryObjectP.h \ SchedXactionP.h \ ScrubP.h \ SX-book.h \ @@ -119,6 +119,7 @@ noinst_HEADERS = \ qofbook-p.h \ qofquery-p.h \ qofquerycore-p.h \ + qofqueryobject-p.h \ qofobject-p.h noinst_SCRIPTS = iso-currencies-to-c diff --git a/src/engine/Query.c b/src/engine/Query.c index 2624e0a162..f3ff3af00d 100644 --- a/src/engine/Query.c +++ b/src/engine/Query.c @@ -512,7 +512,7 @@ xaccQueryAddGUIDMatchGL (QofQuery *q, GList *param_list, } void -xaccQueryAddKVPMatch(Query *q, GSList *path, const kvp_value *value, +xaccQueryAddKVPMatch(QofQuery *q, GSList *path, const kvp_value *value, QofQueryCompare how, GNCIdType id_type, QofQueryOp op) { diff --git a/src/engine/QueryCore.h b/src/engine/QueryCore.h index 5ee39e205b..a3ae65628d 100644 --- a/src/engine/QueryCore.h +++ b/src/engine/QueryCore.h @@ -46,7 +46,7 @@ #define numeric_match_t QofNumericMatch #define date_match_t QofDateMatch #define string_match_t QofStringMatch - #define query_compare_t QofQueryCompare + #define query_compare_t QofCompareFunc #define gncQueryCoreInit qof_query_core_init #define gncQueryCoreShutdown qof_query_core_shutdown @@ -64,5 +64,5 @@ #define QUERYCORE_INT64 QOF_QUERYCORE_INT64 #define QUERYCORE_DOUBLE QOF_QUERYCORE_DOUBLE - #define QueryAccess QofQueryAccess + #define QueryAccess QofAccessFunc #define gncQueryCoreToString qof_query_core_to_string diff --git a/src/engine/QueryNew.h b/src/engine/QueryNew.h index 3f851a66a7..81259825b8 100644 --- a/src/engine/QueryNew.h +++ b/src/engine/QueryNew.h @@ -1,4 +1,3 @@ - #include "qofquery.h" @@ -15,7 +14,7 @@ #define QueryNew QofQuery #define QueryOp QofQueryOp #define query_new_term _QofQueryTerm - #define query_new_sort _QofQuerySort + #define query_new_sort _QofSortFunc #define gncQueryBuildParamList qof_query_build_param_list #define gncQueryCreate qof_query_create diff --git a/src/engine/QueryObject.h b/src/engine/QueryObject.h index 58847ee50c..02b6140152 100644 --- a/src/engine/QueryObject.h +++ b/src/engine/QueryObject.h @@ -1,93 +1,15 @@ -/********************************************************************\ - * QueryObject.h -- API for registering queriable 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 QueryObject.h - @brief API for registering queriable GnuCash objects - @author Copyright (C) 2002 Derek Atkins -*/ +#include "qofqueryobject.h" -#ifndef QOF_QUERYOBJECT_H -#define QOF_QUERYOBJECT_H + #define query_object_def _QofQueryObject + #define QueryObjectDef QofQueryObject + #define QuerySort QofSortFunc -#include "qofquery.h" -#include "qofquerycore.h" + #define gncQueryObjectRegister qof_query_object_register + #define gncQueryObjectParameterType qof_query_object_parameter_type + #define gncQueryObjectGetParameterGetter qof_query_object_get_parameter_getter + #define gncQueryObjectGetParameter qof_query_object_get_parameter + #define gncQueryObjectInit qof_query_object_init + #define gncQueryObjectShutdown qof_query_object_shutdown + #define gncQueryObjectDefaultSort qof_query_object_default_sort -/** This structure is for each queriable parameter in an object - * - * -- param_name is the name of the parameter. - * -- param_type is the type of the parameter, which can be either another - * object or it can be a core data type. - * -- param_getgcn is the function to actually obtain the parameter - */ -typedef struct query_object_def { - const char * param_name; - QofQueryCoreType param_type; - QofQueryAccess param_getfcn; -} QueryObjectDef; - -/** 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 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 - * argument may be NULL if there is nothing to be registered. - */ -void gncQueryObjectRegister (GNCIdTypeConst obj_name, - QuerySort default_sort_fcn, - const QueryObjectDef *params); - -/** An example: - * - * #define MY_QUERY_OBJ_MEMO "memo" - * #define MY_QUERY_OBJ_VALUE "value" - * #define MY_QUERY_OBJ_DATE "date" - * #define MY_QUERY_OBJ_ACCOUNT "account" - * #define MY_QUERY_OBJ_TRANS "trans" - * - * static QueryObjectDef myQueryObjectParams[] = { - * { MY_QUERY_OBJ_MEMO, QOF_QUERYCORE_STRING, myMemoGetter }, - * { MY_QUERY_OBJ_VALUE, QOF_QUERYCORE_NUMERIC, myValueGetter }, - * { MY_QUERY_OBJ_DATE, QOF_QUERYCORE_DATE, myDateGetter }, - * { MY_QUERY_OBJ_ACCOUNT, GNC_ID_ACCOUNT, myAccountGetter }, - * { MY_QUERY_OBJ_TRANS, GNC_ID_TRANS, myTransactionGetter }, - * NULL }; - * - * gncQueryObjectRegisterParamters ("myObjectName", myQueryObjectCompare, - * &myQueryObjectParams); - */ - -/** Return the core datatype of the specified object's parameter */ -QofQueryCoreType gncQueryObjectParameterType (GNCIdTypeConst obj_name, - const char *param_name); - -/** Return the registered Object Definition for the requested parameter */ -const QueryObjectDef * gncQueryObjectGetParameter (GNCIdTypeConst obj_name, - const char *parameter); - -/** Return the object's parameter getter function */ -QofQueryAccess gncQueryObjectGetParameterGetter (GNCIdTypeConst obj_name, - const char *parameter); - - -#endif /* QOF_QUERYOBJECT_H */ diff --git a/src/engine/Transaction.c b/src/engine/Transaction.c index e056810af9..6c750cd0c8 100644 --- a/src/engine/Transaction.c +++ b/src/engine/Transaction.c @@ -46,11 +46,11 @@ #include "gnc-lot-p.h" #include "gnc-lot.h" #include "messages.h" + #include "qofbook.h" #include "qofbook-p.h" #include "qofobject.h" - -#include "QueryObject.h" +#include "qofqueryobject.h" /* * The "force_double_entry" flag determines how @@ -3591,51 +3591,51 @@ static gpointer no_op (gpointer obj) gboolean xaccSplitRegister (void) { - static const QueryObjectDef params[] = { - { SPLIT_KVP, QOF_QUERYCORE_KVP, (QofQueryAccess)xaccSplitGetSlots }, + static const QofQueryObject params[] = { + { SPLIT_KVP, QOF_QUERYCORE_KVP, (QofAccessFunc)xaccSplitGetSlots }, { SPLIT_DATE_RECONCILED, QOF_QUERYCORE_DATE, - (QofQueryAccess)xaccSplitRetDateReconciledTS }, + (QofAccessFunc)xaccSplitRetDateReconciledTS }, { "d-share-amount", QOF_QUERYCORE_DOUBLE, - (QofQueryAccess)DxaccSplitGetShareAmount }, - { "d-share-int64", QOF_QUERYCORE_INT64, (QofQueryAccess)xaccSplitGetGUID }, - { SPLIT_BALANCE, QOF_QUERYCORE_NUMERIC, (QofQueryAccess)xaccSplitGetBalance }, + (QofAccessFunc)DxaccSplitGetShareAmount }, + { "d-share-int64", QOF_QUERYCORE_INT64, (QofAccessFunc)xaccSplitGetGUID }, + { SPLIT_BALANCE, QOF_QUERYCORE_NUMERIC, (QofAccessFunc)xaccSplitGetBalance }, { SPLIT_CLEARED_BALANCE, QOF_QUERYCORE_NUMERIC, - (QofQueryAccess)xaccSplitGetClearedBalance }, + (QofAccessFunc)xaccSplitGetClearedBalance }, { SPLIT_RECONCILED_BALANCE, QOF_QUERYCORE_NUMERIC, - (QofQueryAccess)xaccSplitGetReconciledBalance }, - { SPLIT_MEMO, QOF_QUERYCORE_STRING, (QofQueryAccess)xaccSplitGetMemo }, - { SPLIT_ACTION, QOF_QUERYCORE_STRING, (QofQueryAccess)xaccSplitGetAction }, - { SPLIT_RECONCILE, QOF_QUERYCORE_CHAR, (QofQueryAccess)xaccSplitGetReconcile }, - { SPLIT_AMOUNT, QOF_QUERYCORE_NUMERIC, (QofQueryAccess)xaccSplitGetAmount }, + (QofAccessFunc)xaccSplitGetReconciledBalance }, + { SPLIT_MEMO, QOF_QUERYCORE_STRING, (QofAccessFunc)xaccSplitGetMemo }, + { SPLIT_ACTION, QOF_QUERYCORE_STRING, (QofAccessFunc)xaccSplitGetAction }, + { SPLIT_RECONCILE, QOF_QUERYCORE_CHAR, (QofAccessFunc)xaccSplitGetReconcile }, + { SPLIT_AMOUNT, QOF_QUERYCORE_NUMERIC, (QofAccessFunc)xaccSplitGetAmount }, { SPLIT_SHARE_PRICE, QOF_QUERYCORE_NUMERIC, - (QofQueryAccess)xaccSplitGetSharePrice }, - { SPLIT_VALUE, QOF_QUERYCORE_DEBCRED, (QofQueryAccess)xaccSplitGetValue }, - { SPLIT_TYPE, QOF_QUERYCORE_STRING, (QofQueryAccess)xaccSplitGetType }, + (QofAccessFunc)xaccSplitGetSharePrice }, + { SPLIT_VALUE, QOF_QUERYCORE_DEBCRED, (QofAccessFunc)xaccSplitGetValue }, + { SPLIT_TYPE, QOF_QUERYCORE_STRING, (QofAccessFunc)xaccSplitGetType }, { SPLIT_VOIDED_AMOUNT, QOF_QUERYCORE_NUMERIC, - (QofQueryAccess)xaccSplitVoidFormerAmount }, + (QofAccessFunc)xaccSplitVoidFormerAmount }, { SPLIT_VOIDED_VALUE, QOF_QUERYCORE_NUMERIC, - (QofQueryAccess)xaccSplitVoidFormerValue }, - { SPLIT_LOT, GNC_ID_LOT, (QofQueryAccess)xaccSplitGetLot }, - { SPLIT_TRANS, GNC_ID_TRANS, (QofQueryAccess)xaccSplitGetParent }, - { SPLIT_ACCOUNT, GNC_ID_ACCOUNT, (QofQueryAccess)xaccSplitGetAccount }, + (QofAccessFunc)xaccSplitVoidFormerValue }, + { SPLIT_LOT, GNC_ID_LOT, (QofAccessFunc)xaccSplitGetLot }, + { SPLIT_TRANS, GNC_ID_TRANS, (QofAccessFunc)xaccSplitGetParent }, + { SPLIT_ACCOUNT, GNC_ID_ACCOUNT, (QofAccessFunc)xaccSplitGetAccount }, { SPLIT_ACCOUNT_GUID, QOF_QUERYCORE_GUID, split_account_guid_getter }, { 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 }, - { QOF_QUERY_PARAM_BOOK, GNC_ID_BOOK, (QofQueryAccess)xaccSplitGetBook }, - { QOF_QUERY_PARAM_GUID, QOF_QUERYCORE_GUID, (QofQueryAccess) xaccSplitGetGUID }, + { QOF_QUERY_PARAM_BOOK, GNC_ID_BOOK, (QofAccessFunc)xaccSplitGetBook }, + { QOF_QUERY_PARAM_GUID, QOF_QUERYCORE_GUID, (QofAccessFunc) xaccSplitGetGUID }, { NULL }, }; - gncQueryObjectRegister (GNC_ID_SPLIT, (QuerySort)xaccSplitDateOrder, params); - gncQueryObjectRegister (SPLIT_ACCT_FULLNAME, - (QuerySort)xaccSplitCompareAccountFullNames, + qof_query_object_register (GNC_ID_SPLIT, (QofSortFunc)xaccSplitDateOrder, params); + qof_query_object_register (SPLIT_ACCT_FULLNAME, + (QofSortFunc)xaccSplitCompareAccountFullNames, NULL); - gncQueryObjectRegister (SPLIT_CORR_ACCT_NAME, - (QuerySort)xaccSplitCompareOtherAccountFullNames, + qof_query_object_register (SPLIT_CORR_ACCT_NAME, + (QofSortFunc)xaccSplitCompareOtherAccountFullNames, NULL); - gncQueryObjectRegister (SPLIT_CORR_ACCT_CODE, - (QuerySort)xaccSplitCompareOtherAccountCodes, + qof_query_object_register (SPLIT_CORR_ACCT_CODE, + (QofSortFunc)xaccSplitCompareOtherAccountCodes, NULL); return qof_object_register (&split_object_def); @@ -3669,27 +3669,27 @@ trans_is_balanced_p (const Transaction *txn) gboolean xaccTransRegister (void) { - static QueryObjectDef params[] = { - { TRANS_KVP, QOF_QUERYCORE_KVP, (QofQueryAccess)xaccTransGetSlots }, - { TRANS_NUM, QOF_QUERYCORE_STRING, (QofQueryAccess)xaccTransGetNum }, - { TRANS_DESCRIPTION, QOF_QUERYCORE_STRING, (QofQueryAccess)xaccTransGetDescription }, - { TRANS_DATE_ENTERED, QOF_QUERYCORE_DATE, (QofQueryAccess)xaccTransRetDateEnteredTS }, - { TRANS_DATE_POSTED, QOF_QUERYCORE_DATE, (QofQueryAccess)xaccTransRetDatePostedTS }, - { TRANS_DATE_DUE, QOF_QUERYCORE_DATE, (QofQueryAccess)xaccTransRetDateDueTS }, - { TRANS_IMBALANCE, QOF_QUERYCORE_NUMERIC, (QofQueryAccess)xaccTransGetImbalance }, - { TRANS_NOTES, QOF_QUERYCORE_STRING, (QofQueryAccess)xaccTransGetNotes }, - { TRANS_IS_BALANCED, QOF_QUERYCORE_BOOLEAN, (QofQueryAccess)trans_is_balanced_p }, - { TRANS_TYPE, QOF_QUERYCORE_CHAR, (QofQueryAccess)xaccTransGetTxnType }, - { TRANS_VOID_STATUS, QOF_QUERYCORE_BOOLEAN, (QofQueryAccess)xaccTransGetVoidStatus }, - { TRANS_VOID_REASON, QOF_QUERYCORE_STRING, (QofQueryAccess)xaccTransGetVoidReason }, - { TRANS_VOID_TIME, QOF_QUERYCORE_DATE, (QofQueryAccess)xaccTransGetVoidTime }, - { TRANS_SPLITLIST, GNC_ID_SPLIT, (QofQueryAccess)xaccTransGetSplitList }, - { QOF_QUERY_PARAM_BOOK, GNC_ID_BOOK, (QofQueryAccess)xaccTransGetBook }, - { QOF_QUERY_PARAM_GUID, QOF_QUERYCORE_GUID, (QofQueryAccess)xaccTransGetGUID }, + static QofQueryObject params[] = { + { TRANS_KVP, QOF_QUERYCORE_KVP, (QofAccessFunc)xaccTransGetSlots }, + { TRANS_NUM, QOF_QUERYCORE_STRING, (QofAccessFunc)xaccTransGetNum }, + { TRANS_DESCRIPTION, QOF_QUERYCORE_STRING, (QofAccessFunc)xaccTransGetDescription }, + { TRANS_DATE_ENTERED, QOF_QUERYCORE_DATE, (QofAccessFunc)xaccTransRetDateEnteredTS }, + { TRANS_DATE_POSTED, QOF_QUERYCORE_DATE, (QofAccessFunc)xaccTransRetDatePostedTS }, + { TRANS_DATE_DUE, QOF_QUERYCORE_DATE, (QofAccessFunc)xaccTransRetDateDueTS }, + { TRANS_IMBALANCE, QOF_QUERYCORE_NUMERIC, (QofAccessFunc)xaccTransGetImbalance }, + { TRANS_NOTES, QOF_QUERYCORE_STRING, (QofAccessFunc)xaccTransGetNotes }, + { TRANS_IS_BALANCED, QOF_QUERYCORE_BOOLEAN, (QofAccessFunc)trans_is_balanced_p }, + { TRANS_TYPE, QOF_QUERYCORE_CHAR, (QofAccessFunc)xaccTransGetTxnType }, + { TRANS_VOID_STATUS, QOF_QUERYCORE_BOOLEAN, (QofAccessFunc)xaccTransGetVoidStatus }, + { TRANS_VOID_REASON, QOF_QUERYCORE_STRING, (QofAccessFunc)xaccTransGetVoidReason }, + { TRANS_VOID_TIME, QOF_QUERYCORE_DATE, (QofAccessFunc)xaccTransGetVoidTime }, + { TRANS_SPLITLIST, GNC_ID_SPLIT, (QofAccessFunc)xaccTransGetSplitList }, + { QOF_QUERY_PARAM_BOOK, GNC_ID_BOOK, (QofAccessFunc)xaccTransGetBook }, + { QOF_QUERY_PARAM_GUID, QOF_QUERYCORE_GUID, (QofAccessFunc)xaccTransGetGUID }, { NULL }, }; - gncQueryObjectRegister (GNC_ID_TRANS, (QuerySort)xaccTransOrder, params); + qof_query_object_register (GNC_ID_TRANS, (QofSortFunc)xaccTransOrder, params); return qof_object_register (&trans_object_def); } diff --git a/src/engine/engine-helpers.c b/src/engine/engine-helpers.c index 5889fe8185..fdaa861cbd 100644 --- a/src/engine/engine-helpers.c +++ b/src/engine/engine-helpers.c @@ -232,7 +232,7 @@ gnc_gw_enum_scm2val (const char *typestr, SCM enum_scm) return scm_num2int (scm, SCM_ARG1, __FUNCTION__); } -/* QofQueryCompare */ +/* QofCompareFunc */ static SCM gnc_query_compare2scm (QofQueryCompare how) @@ -937,10 +937,10 @@ gnc_queryterm2scm (QofQueryTerm_t qt) return scm_reverse (qt_scm); } -static Query * +static QofQuery * gnc_scm2query_term_query_v2 (SCM qt_scm) { - Query *q = NULL; + QofQuery *q = NULL; QofQueryPredData *pd = NULL; SCM scm; char *type = NULL; @@ -973,7 +973,7 @@ gnc_scm2query_term_query_v2 (SCM qt_scm) break; type = gh_symbol2newstr (scm, NULL); - /* QofQueryCompare */ + /* QofCompareFunc */ scm = SCM_CAR (qt_scm); qt_scm = SCM_CDR (qt_scm); if (SCM_NULLP (scm)) @@ -1164,14 +1164,14 @@ gnc_scm2query_term_query_v2 (SCM qt_scm) return q; } -static Query * +static QofQuery * gnc_scm2query_term_query_v1 (SCM query_term_scm) { gboolean ok = FALSE; char * pd_type = NULL; char * pr_type = NULL; gboolean sense = FALSE; - Query *q = NULL; + QofQuery *q = NULL; SCM scm; if (!SCM_LISTP (query_term_scm) || @@ -1626,7 +1626,7 @@ gnc_scm2query_or_terms (SCM or_terms, query_version_t vers) } static SCM -gnc_query_sort2scm (QofQuerySort_t qs) +gnc_query_sort2scm (QofSortFunc_t qs) { SCM sort_scm = SCM_EOL; GSList *path; @@ -1703,7 +1703,7 @@ gnc_query2scm (Query *q) { SCM query_scm = SCM_EOL; SCM pair; - QofQuerySort_t s1, s2, s3; + QofSortFunc_t s1, s2, s3; if (!q) return SCM_BOOL_F; diff --git a/src/engine/gnc-lot.c b/src/engine/gnc-lot.c index 0edf8354c2..a5e48bbbce 100644 --- a/src/engine/gnc-lot.c +++ b/src/engine/gnc-lot.c @@ -41,7 +41,7 @@ #include "gnc-lot-p.h" #include "Transaction.h" #include "TransactionP.h" -#include "QueryObject.h" +#include "qofqueryobject.h" #include "qofbook.h" #include "qofbook-p.h" @@ -329,15 +329,15 @@ gnc_lot_get_latest_split (GNCLot *lot) void gnc_lot_register (void) { - static const QueryObjectDef params[] = { - { 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 }, + static const QofQueryObject params[] = { + { QOF_QUERY_PARAM_BOOK, GNC_ID_BOOK, (QofAccessFunc)gnc_lot_get_book }, + { QOF_QUERY_PARAM_GUID, QOF_QUERYCORE_GUID, (QofAccessFunc)gnc_lot_get_guid }, + { LOT_IS_CLOSED, QOF_QUERYCORE_BOOLEAN, (QofAccessFunc)gnc_lot_is_closed }, + { LOT_BALANCE, QOF_QUERYCORE_NUMERIC, (QofAccessFunc)gnc_lot_get_balance }, { NULL }, }; - gncQueryObjectRegister (GNC_ID_LOT, NULL, params); + qof_query_object_register (GNC_ID_LOT, NULL, params); } /* ========================== END OF FILE ========================= */ diff --git a/src/engine/qofbook.c b/src/engine/qofbook.c index 3445f65f4f..2e59a848ec 100644 --- a/src/engine/qofbook.c +++ b/src/engine/qofbook.c @@ -42,13 +42,13 @@ #include "Backend.h" #include "BackendP.h" -#include "QueryObject.h" #include "gnc-event.h" #include "gnc-event-p.h" #include "gnc-trace.h" #include "qofbook.h" #include "qofbook-p.h" #include "qofobject-p.h" +#include "qofqueryobject.h" static short module = MOD_ENGINE; @@ -292,13 +292,13 @@ qof_book_get_counter (QofBook *book, const char *counter_name) /* gncObject function implementation and registration */ gboolean qof_book_register (void) { - static QueryObjectDef params[] = { - { QOF_BOOK_KVP, QOF_QUERYCORE_KVP, (QofQueryAccess)qof_book_get_slots }, - { QOF_QUERY_PARAM_GUID, QOF_QUERYCORE_GUID, (QofQueryAccess)qof_book_get_guid }, + static QofQueryObject params[] = { + { QOF_BOOK_KVP, QOF_QUERYCORE_KVP, (QofAccessFunc)qof_book_get_slots }, + { QOF_QUERY_PARAM_GUID, QOF_QUERYCORE_GUID, (QofAccessFunc)qof_book_get_guid }, { NULL }, }; - gncQueryObjectRegister (GNC_ID_BOOK, NULL, params); + qof_query_object_register (GNC_ID_BOOK, NULL, params); return TRUE; } diff --git a/src/engine/qofquery-p.h b/src/engine/qofquery-p.h index b9529b14ea..b7814bca25 100644 --- a/src/engine/qofquery-p.h +++ b/src/engine/qofquery-p.h @@ -27,7 +27,7 @@ #include "qofquery.h" typedef struct _QofQueryTerm *QofQueryTerm_t; -typedef struct _QofQuerySort *QofQuerySort_t; +typedef struct _QofSortFunc *QofSortFunc_t; /* Initialize/Shutdown */ void qof_query_init (void); @@ -59,11 +59,11 @@ gboolean qof_query_term_is_inverted (QofQueryTerm_t queryterm); /* This function returns the primary, secondary, and tertiary sorts. * These are part of the query and should NOT be changed! */ -void qof_query_get_sorts (QofQuery *q, QofQuerySort_t *primary, - QofQuerySort_t *secondary, QofQuerySort_t *tertiary); +void qof_query_get_sorts (QofQuery *q, QofSortFunc_t *primary, + QofSortFunc_t *secondary, QofSortFunc_t *tertiary); -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); +GSList * qof_query_sort_get_param_path (QofSortFunc_t querysort); +gint qof_query_sort_get_sort_options (QofSortFunc_t querysort); +gboolean qof_query_sort_get_increasing (QofSortFunc_t querysort); #endif /* QOF_QUERY_P_H */ diff --git a/src/engine/qofquery.c b/src/engine/qofquery.c index b8b4b9f5de..12d9271f18 100644 --- a/src/engine/qofquery.c +++ b/src/engine/qofquery.c @@ -32,7 +32,6 @@ #include "gnc-engine-util.h" #include "BackendP.h" -#include "QueryObjectP.h" #include "qofbook.h" #include "qofbook-p.h" #include "qofobject.h" @@ -40,10 +39,13 @@ #include "qofquery-p.h" #include "qofquerycore.h" #include "qofquerycore-p.h" +#include "qofqueryobject.h" +#include "qofqueryobject-p.h" static short module = MOD_QUERY; -typedef struct _QofQueryTerm { +typedef struct _QofQueryTerm +{ GSList * param_list; QofQueryPredData *pdata; gboolean invert; @@ -54,10 +56,11 @@ typedef struct _QofQueryTerm { * convert types. */ GSList * param_fcns; - QueryPredicate pred_fcn; + QofQueryPredicateFunc pred_fcn; } QofQueryTerm; -typedef struct _QofQuerySort { +typedef struct _QofSortFunc +{ GSList * param_list; gint options; gboolean increasing; @@ -69,47 +72,49 @@ typedef struct _QofQuerySort { */ gboolean use_default; GSList * param_fcns; - QuerySort obj_cmp; /* In case you are comparing objects */ - QueryCompare comp_fcn; /* When you are comparing core types */ + QofSortFunc obj_cmp; /* In case you are comparing objects */ + QofCompareFunc comp_fcn; /* When you are comparing core types */ } QofQuerySort; /* The QUERY structure */ -struct _QofQuery { +struct _QofQuery +{ /* The object type that we're searching for */ - GNCIdType search_for; + GNCIdType search_for; /* terms is a list of the OR-terms in a sum-of-products * logical expression. */ - GList * terms; + GList * terms; /* sorting and chopping is independent of the search filter */ - QofQuerySort primary_sort; - QofQuerySort secondary_sort; - QofQuerySort tertiary_sort; - QuerySort defaultSort; /* <- Computed from search_for */ + QofQuerySort primary_sort; + QofQuerySort secondary_sort; + QofQuerySort tertiary_sort; + QofSortFunc defaultSort; /* <- Computed from search_for */ /* The maximum number of results to return */ - int max_results; + int max_results; /* list of books that will be participating in the query */ - GList * books; + GList * books; /* a map of book to backend-compiled queries */ - GHashTable* be_compiled; + GHashTable* be_compiled; /* cache the results so we don't have to run the whole search * again until it's really necessary */ - int changed; + int changed; - GList * results; + GList * results; }; -typedef struct query_cb { +typedef struct _QofQueryCB +{ QofQuery * query; - GList * list; - int count; -} query_cb_t; + GList * list; + int count; +} QofQueryCB; /* initial_term will be owned by the new Query */ static void query_init (QofQuery *q, QofQueryTerm *initial_term) @@ -221,14 +226,14 @@ copy_or_terms(GList * or_terms) return g_list_reverse(or); } -static void copy_sort (QofQuerySort_t dst, const QofQuerySort_t src) +static void copy_sort (QofQuerySort *dst, const QofQuerySort *src) { memcpy (dst, src, sizeof (*dst)); dst->param_list = g_slist_copy (src->param_list); dst->param_fcns = g_slist_copy (src->param_fcns); } -static void free_sort (QofQuerySort_t s) +static void free_sort (QofQuerySort *s) { g_slist_free (s->param_list); s->param_list = NULL; @@ -271,12 +276,12 @@ static void free_members (QofQuery *q) q->results = NULL; } -static int cmp_func (QofQuerySort_t sort, QuerySort default_sort, +static int cmp_func (QofQuerySort *sort, QofSortFunc default_sort, gconstpointer a, gconstpointer b) { GSList *node; gpointer conva, convb; - QofQueryAccess get_fcn = NULL; /* to appease the compiler */ + QofAccessFunc get_fcn = NULL; /* to appease the compiler */ g_return_val_if_fail (sort, 0); g_return_val_if_fail (default_sort, 0); @@ -361,7 +366,7 @@ check_object (QofQuery *q, gpointer object) qt = (QofQueryTerm *)(and_ptr->data); if (qt->param_fcns && qt->pred_fcn) { GSList *node; - QofQueryAccess get_fcn; + QofAccessFunc get_fcn; gpointer conv_obj = object; /* iterate through the conversions */ @@ -398,9 +403,9 @@ check_object (QofQuery *q, gpointer object) * returns NULL if the first parameter is bad (and final is unchanged). */ static GSList * compile_params (GSList *param_list, GNCIdType start_obj, - QueryObjectDef const **final) + QofQueryObject const **final) { - const QueryObjectDef *objDef = NULL; + const QofQueryObject *objDef = NULL; GSList *fcns = NULL; g_return_val_if_fail (param_list, NULL); @@ -409,7 +414,7 @@ static GSList * compile_params (GSList *param_list, GNCIdType start_obj, for (; param_list; param_list = param_list->next) { GNCIdType param_name = param_list->data; - objDef = gncQueryObjectGetParameter (start_obj, param_name); + objDef = qof_query_object_get_parameter (start_obj, param_name); /* If it doesn't exist, then we've reached the end */ if (!objDef) @@ -428,9 +433,10 @@ static GSList * compile_params (GSList *param_list, GNCIdType start_obj, return (g_slist_reverse (fcns)); } -static void compile_sort (QofQuerySort_t sort, GNCIdType obj) +static void +compile_sort (QofQuerySort *sort, GNCIdType obj) { - const QueryObjectDef *resObj = NULL; + const QofQueryObject *resObj = NULL; sort->use_default = FALSE; @@ -454,7 +460,7 @@ static void compile_sort (QofQuerySort_t sort, GNCIdType obj) /* Hrm, perhaps this is an object compare, not a core compare? */ if (sort->comp_fcn == NULL) - sort->obj_cmp = gncQueryObjectDefaultSort (resObj->param_type); + sort->obj_cmp = qof_query_object_default_sort (resObj->param_type); } else if (!safe_strcmp (sort->param_list->data, QUERY_DEFAULT_SORT)) sort->use_default = TRUE; @@ -470,7 +476,7 @@ static void compile_terms (QofQuery *q) for (or_ptr = q->terms; or_ptr; or_ptr = or_ptr->next) { for (and_ptr = or_ptr->data; and_ptr; and_ptr = and_ptr->next) { QofQueryTerm *qt = and_ptr->data; - const QueryObjectDef *resObj = NULL; + const QofQueryObject *resObj = NULL; g_slist_free (qt->param_fcns); qt->param_fcns = NULL; @@ -495,7 +501,7 @@ static void compile_terms (QofQuery *q) compile_sort (&(q->secondary_sort), q->search_for); compile_sort (&(q->tertiary_sort), q->search_for); - q->defaultSort = gncQueryObjectDefaultSort (q->search_for); + q->defaultSort = qof_query_object_default_sort (q->search_for); /* Now compile the backend instances */ for (node = q->books; node; node = node->next) { @@ -512,7 +518,7 @@ static void compile_terms (QofQuery *q) static void check_item_cb (gpointer object, gpointer user_data) { - query_cb_t *ql = user_data; + QofQueryCB *ql = user_data; if (!object || !ql) return; @@ -676,7 +682,7 @@ GList * qof_query_run (QofQuery *q) /* Now run the query over all the objects and save the results */ { - query_cb_t qcb; + QofQueryCB qcb; memset (&qcb, 0, sizeof (qcb)); qcb.query = q; @@ -1172,12 +1178,12 @@ void qof_query_init (void) { PINFO("New Query Module Initialization"); qof_query_core_init (); - gncQueryObjectInit (); + qof_query_object_init (); } void qof_query_shutdown (void) { - gncQueryObjectShutdown (); + qof_query_object_shutdown (); qof_query_core_shutdown (); } @@ -1220,8 +1226,8 @@ gboolean qof_query_term_is_inverted (QofQueryTerm_t qt) return qt->invert; } -void qof_query_get_sorts (QofQuery *q, QofQuerySort_t *primary, - QofQuerySort_t *secondary, QofQuerySort_t *tertiary) +void qof_query_get_sorts (QofQuery *q, QofQuerySort **primary, + QofQuerySort **secondary, QofQuerySort **tertiary) { if (!q) return; @@ -1233,21 +1239,21 @@ void qof_query_get_sorts (QofQuery *q, QofQuerySort_t *primary, *tertiary = &(q->tertiary_sort); } -GSList * qof_query_sort_get_param_path (QofQuerySort_t qs) +GSList * qof_query_sort_get_param_path (QofQuerySort *qs) { if (!qs) return NULL; return qs->param_list; } -gint qof_query_sort_get_sort_options (QofQuerySort_t qs) +gint qof_query_sort_get_sort_options (QofQuerySort *qs) { if (!qs) return 0; return qs->options; } -gboolean qof_query_sort_get_increasing (QofQuerySort_t qs) +gboolean qof_query_sort_get_increasing (QofQuerySort *qs) { if (!qs) return FALSE; @@ -1264,7 +1270,7 @@ static gboolean gncQueryTermEqual (QofQueryTerm_t qt1, QofQueryTerm_t qt2) return qof_query_core_predicate_equal (qt1->pdata, qt2->pdata); } -static gboolean gncQuerySortEqual (QofQuerySort_t qs1, QofQuerySort_t qs2) +static gboolean gncQuerySortEqual (QofQuerySort* qs1, QofQuerySort* qs2) { if (qs1 == qs2) return TRUE; if (!qs1 || !qs2) return FALSE; @@ -1322,7 +1328,7 @@ gboolean qof_query_equal (QofQuery *q1, QofQuery *q2) /* Static prototypes */ static GList *qof_query_printSearchFor (QofQuery * query, GList * output); static GList *qof_query_printTerms (QofQuery * query, GList * output); -static GList *qof_query_printSorts (QofQuerySort_t s[], const gint numSorts, +static GList *qof_query_printSorts (QofQuerySort *s[], const gint numSorts, GList * output); static GList *qof_query_printAndTerms (GList * terms, GList * output); static gchar *qof_query_printStringForHow (QofQueryCompare how); @@ -1345,7 +1351,7 @@ qof_query_print (QofQuery * query) { GList *output; GString *str; - QofQuerySort_t s[3]; + QofQuerySort *s[3]; gint maxResults = 0, numSorts = 3; ENTER (" "); @@ -1447,7 +1453,7 @@ qof_query_printTerms (QofQuery * query, GList * output) not null. */ static GList * -qof_query_printSorts (QofQuerySort_t s[], const gint numSorts, GList * output) +qof_query_printSorts (QofQuerySort *s[], const gint numSorts, GList * output) { GSList *gsl = NULL; gint curSort; @@ -1546,7 +1552,7 @@ qof_query_printPredData (QofQueryPredData *pd) /* Get a string representation for the - QofQueryCompare enum type. + QofCompareFunc enum type. */ static gchar * qof_query_printStringForHow (QofQueryCompare how) diff --git a/src/engine/qofquerycore-p.h b/src/engine/qofquerycore-p.h index 278093343e..b18a587992 100644 --- a/src/engine/qofquerycore-p.h +++ b/src/engine/qofquerycore-p.h @@ -42,21 +42,21 @@ void qof_query_core_shutdown (void); * the Query internals), compare the object's parameter to the * predicate data */ -typedef int (*QueryPredicate) (gpointer object, - QofQueryAccess get_fcn, +typedef int (*QofQueryPredicateFunc) (gpointer object, + QofAccessFunc get_fcn, QofQueryPredData *pdata); /* A callback for how to compare two (same-type) objects based on a * common get_fcn (parameter member), using the provided comparrison * options (which are the type-specific options). */ -typedef int (*QueryCompare) (gpointer a, gpointer b, - gint compare_options, - QofQueryAccess get_fcn); +typedef int (*QofCompareFunc) (gpointer a, gpointer b, + gint compare_options, + QofAccessFunc get_fcn); /* Lookup functions */ -QueryPredicate qof_query_core_get_predicate (char const *type); -QueryCompare qof_query_core_get_compare (char const *type); +QofQueryPredicateFunc qof_query_core_get_predicate (char const *type); +QofCompareFunc qof_query_core_get_compare (char const *type); /* Compare two predicates */ gboolean qof_query_core_predicate_equal (QofQueryPredData *p1, QofQueryPredData *p2); diff --git a/src/engine/qofquerycore.c b/src/engine/qofquerycore.c index 4b7b95dce6..8b948854fb 100644 --- a/src/engine/qofquerycore.c +++ b/src/engine/qofquerycore.c @@ -39,12 +39,12 @@ typedef void (*QueryPredDataFree) (QofQueryPredData *pdata); typedef QofQueryPredData *(*QueryPredicateCopy) (QofQueryPredData *pdata); /* A function to take the object, apply the get_fcn, and return - * a printable string. Note that this QofQueryAccess function should + * a printable string. Note that this QofAccessFunc function should * be returning a type equal to this core object type. * * Note that this string MUST be freed by the caller. */ -typedef char * (*QueryToString) (gpointer object, QofQueryAccess get_fcn); +typedef char * (*QueryToString) (gpointer object, QofAccessFunc get_fcn); /* A function to test for equality of predicate data */ typedef gboolean (*QueryPredicateEqual) (QofQueryPredData *p1, @@ -55,8 +55,8 @@ typedef gboolean (*QueryPredicateEqual) (QofQueryPredData *p1, * query_predicate, predicate_copy, and predicate_data_free functions. */ static void gncQueryRegisterCoreObject (char const *type_name, - QueryPredicate pred, - QueryCompare comp, + QofQueryPredicateFunc pred, + QofCompareFunc comp, QueryPredicateCopy copy, QueryPredDataFree pd_free, QueryToString to_string, @@ -138,7 +138,7 @@ static GHashTable *predEqualTable = NULL; /* QOF_QUERYCORE_STRING */ -static int string_match_predicate (gpointer object, QofQueryAccess get_fcn, +static int string_match_predicate (gpointer object, QofAccessFunc get_fcn, QofQueryPredData *pd) { query_string_t pdata = (query_string_t) pd; @@ -177,7 +177,7 @@ static int string_match_predicate (gpointer object, QofQueryAccess get_fcn, } static int string_compare_func (gpointer a, gpointer b, gint options, - QofQueryAccess get_fcn) + QofAccessFunc get_fcn) { const char *s1, *s2; g_return_val_if_fail (a && b && get_fcn, COMPARE_ERROR); @@ -254,7 +254,7 @@ QofQueryPredData *qof_query_string_predicate (QofQueryCompare how, return ((QofQueryPredData*)pdata); } -static char * string_to_string (gpointer object, QofQueryAccess get) +static char * string_to_string (gpointer object, QofAccessFunc get) { const char *res = ((query_string_getter)get)(object); if (res) @@ -284,7 +284,7 @@ static int date_compare (Timespec ta, Timespec tb, QofDateMatch options) return 0; } -static int date_match_predicate (gpointer object, QofQueryAccess get_fcn, +static int date_match_predicate (gpointer object, QofAccessFunc get_fcn, QofQueryPredData *pd) { query_date_t pdata = (query_date_t)pd; @@ -316,7 +316,7 @@ static int date_match_predicate (gpointer object, QofQueryAccess get_fcn, } static int date_compare_func (gpointer a, gpointer b, gint options, - QofQueryAccess get_fcn) + QofAccessFunc get_fcn) { Timespec ta, tb; @@ -370,7 +370,7 @@ qof_query_date_predicate (QofQueryCompare how, return ((QofQueryPredData*)pdata); } -static char * date_to_string (gpointer object, QofQueryAccess get) +static char * date_to_string (gpointer object, QofAccessFunc get) { Timespec ts = ((query_date_getter)get)(object); @@ -382,7 +382,7 @@ static char * date_to_string (gpointer object, QofQueryAccess get) /* QOF_QUERYCORE_NUMERIC */ -static int numeric_match_predicate (gpointer object, QofQueryAccess get_fcn, +static int numeric_match_predicate (gpointer object, QofAccessFunc get_fcn, QofQueryPredData* pd) { query_numeric_t pdata = (query_numeric_t)pd; @@ -435,7 +435,7 @@ static int numeric_match_predicate (gpointer object, QofQueryAccess get_fcn, } static int numeric_compare_func (gpointer a, gpointer b, gint options, - QofQueryAccess get_fcn) + QofAccessFunc get_fcn) { gnc_numeric va, vb; @@ -486,14 +486,14 @@ qof_query_numeric_predicate (QofQueryCompare how, return ((QofQueryPredData*)pdata); } -static char * numeric_to_string (gpointer object, QofQueryAccess get) +static char * numeric_to_string (gpointer object, QofAccessFunc get) { gnc_numeric num = ((query_numeric_getter)get)(object); return g_strdup (gnc_numeric_to_string (num)); } -static char * debcred_to_string (gpointer object, QofQueryAccess get) +static char * debcred_to_string (gpointer object, QofAccessFunc get) { gnc_numeric num = ((query_numeric_getter)get)(object); @@ -502,7 +502,7 @@ static char * debcred_to_string (gpointer object, QofQueryAccess get) /* QOF_QUERYCORE_GUID */ -static int guid_match_predicate (gpointer object, QofQueryAccess get_fcn, +static int guid_match_predicate (gpointer object, QofAccessFunc get_fcn, QofQueryPredData *pd) { query_guid_t pdata = (query_guid_t)pd; @@ -662,7 +662,7 @@ qof_query_guid_predicate (QofGuidMatch options, GList *guids) /* ================================================================ */ /* QOF_QUERYCORE_INT32 */ -static int int32_match_predicate (gpointer object, QofQueryAccess get_fcn, +static int int32_match_predicate (gpointer object, QofAccessFunc get_fcn, QofQueryPredData *pd) { gint32 val; @@ -692,7 +692,7 @@ static int int32_match_predicate (gpointer object, QofQueryAccess get_fcn, } static int int32_compare_func (gpointer a, gpointer b, gint options, - QofQueryAccess get_fcn) + QofAccessFunc get_fcn) { gint32 v1, v2; g_return_val_if_fail (a && b && get_fcn, COMPARE_ERROR); @@ -739,7 +739,7 @@ qof_query_int32_predicate (QofQueryCompare how, gint32 val) return ((QofQueryPredData*)pdata); } -static char * int32_to_string (gpointer object, QofQueryAccess get) +static char * int32_to_string (gpointer object, QofAccessFunc get) { gint32 num = ((query_int32_getter)get)(object); @@ -749,7 +749,7 @@ static char * int32_to_string (gpointer object, QofQueryAccess get) /* ================================================================ */ /* QOF_QUERYCORE_INT64 */ -static int int64_match_predicate (gpointer object, QofQueryAccess get_fcn, +static int int64_match_predicate (gpointer object, QofAccessFunc get_fcn, QofQueryPredData *pd) { gint64 val; @@ -779,7 +779,7 @@ static int int64_match_predicate (gpointer object, QofQueryAccess get_fcn, } static int int64_compare_func (gpointer a, gpointer b, gint options, - QofQueryAccess get_fcn) + QofAccessFunc get_fcn) { gint64 v1, v2; g_return_val_if_fail (a && b && get_fcn, COMPARE_ERROR); @@ -826,7 +826,7 @@ qof_query_int64_predicate (QofQueryCompare how, gint64 val) return ((QofQueryPredData*)pdata); } -static char * int64_to_string (gpointer object, QofQueryAccess get) +static char * int64_to_string (gpointer object, QofAccessFunc get) { gint64 num = ((query_int64_getter)get)(object); @@ -836,7 +836,7 @@ static char * int64_to_string (gpointer object, QofQueryAccess get) /* ================================================================ */ /* QOF_QUERYCORE_DOUBLE */ -static int double_match_predicate (gpointer object, QofQueryAccess get_fcn, +static int double_match_predicate (gpointer object, QofAccessFunc get_fcn, QofQueryPredData *pd) { double val; @@ -866,7 +866,7 @@ static int double_match_predicate (gpointer object, QofQueryAccess get_fcn, } static int double_compare_func (gpointer a, gpointer b, gint options, - QofQueryAccess get_fcn) + QofAccessFunc get_fcn) { double v1, v2; g_return_val_if_fail (a && b && get_fcn, COMPARE_ERROR); @@ -913,7 +913,7 @@ qof_query_double_predicate (QofQueryCompare how, double val) return ((QofQueryPredData*)pdata); } -static char * double_to_string (gpointer object, QofQueryAccess get) +static char * double_to_string (gpointer object, QofAccessFunc get) { double num = ((query_double_getter)get)(object); @@ -922,7 +922,7 @@ static char * double_to_string (gpointer object, QofQueryAccess get) /* QOF_QUERYCORE_BOOLEAN */ -static int boolean_match_predicate (gpointer object, QofQueryAccess get_fcn, +static int boolean_match_predicate (gpointer object, QofAccessFunc get_fcn, QofQueryPredData *pd) { gboolean val; @@ -944,7 +944,7 @@ static int boolean_match_predicate (gpointer object, QofQueryAccess get_fcn, } static int boolean_compare_func (gpointer a, gpointer b, gint options, - QofQueryAccess get_fcn) + QofAccessFunc get_fcn) { gboolean va, vb; g_return_val_if_fail (a && b && get_fcn, COMPARE_ERROR); @@ -992,7 +992,7 @@ qof_query_boolean_predicate (QofQueryCompare how, gboolean val) return ((QofQueryPredData*)pdata); } -static char * boolean_to_string (gpointer object, QofQueryAccess get) +static char * boolean_to_string (gpointer object, QofAccessFunc get) { gboolean num = ((query_boolean_getter)get)(object); @@ -1001,7 +1001,7 @@ static char * boolean_to_string (gpointer object, QofQueryAccess get) /* QOF_QUERYCORE_CHAR */ -static int char_match_predicate (gpointer object, QofQueryAccess get_fcn, +static int char_match_predicate (gpointer object, QofAccessFunc get_fcn, QofQueryPredData *pd) { char c; @@ -1025,7 +1025,7 @@ static int char_match_predicate (gpointer object, QofQueryAccess get_fcn, } static int char_compare_func (gpointer a, gpointer b, gint options, - QofQueryAccess get_fcn) + QofAccessFunc get_fcn) { char va, vb; g_return_val_if_fail (a && b && get_fcn, COMPARE_ERROR); @@ -1073,7 +1073,7 @@ qof_query_char_predicate (QofCharMatch options, const char *chars) return ((QofQueryPredData*)pdata); } -static char * char_to_string (gpointer object, QofQueryAccess get) +static char * char_to_string (gpointer object, QofAccessFunc get) { char num = ((query_char_getter)get)(object); @@ -1082,7 +1082,7 @@ static char * char_to_string (gpointer object, QofQueryAccess get) /* QOF_QUERYCORE_KVP */ -static int kvp_match_predicate (gpointer object, QofQueryAccess get_fcn, +static int kvp_match_predicate (gpointer object, QofAccessFunc get_fcn, QofQueryPredData *pd) { int compare; @@ -1195,8 +1195,8 @@ static void init_tables (void) unsigned int i; struct { char const *name; - QueryPredicate pred; - QueryCompare comp; + QofQueryPredicateFunc pred; + QofCompareFunc comp; QueryPredicateCopy copy; QueryPredDataFree pd_free; QueryToString toString; @@ -1263,8 +1263,8 @@ static QueryPredDataFree gncQueryCoreGetPredFree (char const *type) } static void gncQueryRegisterCoreObject (char const *core_name, - QueryPredicate pred, - QueryCompare comp, + QofQueryPredicateFunc pred, + QofCompareFunc comp, QueryPredicateCopy copy, QueryPredDataFree pd_free, QueryToString toString, @@ -1325,19 +1325,22 @@ void qof_query_core_shutdown (void) g_hash_table_destroy (predEqualTable); } -QueryPredicate qof_query_core_get_predicate (char const *type) +QofQueryPredicateFunc +qof_query_core_get_predicate (char const *type) { g_return_val_if_fail (type, NULL); return g_hash_table_lookup (predTable, type); } -QueryCompare qof_query_core_get_compare (char const *type) +QofCompareFunc +qof_query_core_get_compare (char const *type) { g_return_val_if_fail (type, NULL); return g_hash_table_lookup (cmpTable, type); } -void qof_query_core_predicate_free (QofQueryPredData *pdata) +void +qof_query_core_predicate_free (QofQueryPredData *pdata) { QueryPredDataFree free_fcn; @@ -1361,7 +1364,7 @@ qof_query_core_predicate_copy (QofQueryPredData *pdata) } char * qof_query_core_to_string (char const *type, gpointer object, - QofQueryAccess get) + QofAccessFunc get) { QueryToString toString; diff --git a/src/engine/qofquerycore.h b/src/engine/qofquerycore.h index 67be71b656..43c19c72b5 100644 --- a/src/engine/qofquerycore.h +++ b/src/engine/qofquerycore.h @@ -40,14 +40,14 @@ typedef const char * QofQueryCoreType; typedef struct _QofQueryPredData QofQueryPredData; -/** The QofQueryAccess type defines an arbitrary function pointer +/** The QofAccessFunc type defines an arbitrary function pointer * for access functions. This is needed because C doesn't have * templates, so we just cast a lot. Real functions must be of * the form: * * function (object_type *obj); */ -typedef gpointer (*QofQueryAccess)(gpointer); +typedef gpointer (*QofAccessFunc)(gpointer); /** Standard Query comparitors, for how to compare objects in a predicate. * Note that not all core types implement all comparitors @@ -86,14 +86,15 @@ typedef enum { #define QOF_QUERYCORE_GUID "guid" typedef enum { - /* These expect a single object and expect the QofQueryAccess returns GUID* */ + /** These expect a single object and expect the + * QofAccessFunc returns GUID* */ QOF_GUID_MATCH_ANY = 1, QOF_GUID_MATCH_NONE, QOF_GUID_MATCH_NULL, - /* These expect a GList* of objects and calls the QofQueryAccess routine + /** These expect a GList* of objects and calls the QofAccessFunc routine * on each item in the list to obtain a GUID* for each object */ QOF_GUID_MATCH_ALL, - /* These expect a single object and expect the QofQueryAccess function + /** These expect a single object and expect the QofAccessFunc function * to return a GList* of GUID* (the list is the property of the caller) */ QOF_GUID_MATCH_LIST_ANY, } QofGuidMatch; @@ -114,7 +115,7 @@ typedef enum { /** Head of Predicate Data structures. All PData must start like this. */ struct _QofQueryPredData { QofQueryCoreType type_name; /* QUERYCORE_* */ - QofQueryCompare how; + QofQueryCompare how; }; @@ -147,6 +148,6 @@ void qof_query_core_predicate_free (QofQueryPredData *pdata); * to g_free() the returned string. */ char * qof_query_core_to_string (char const *type, gpointer object, - QofQueryAccess fcn); + QofAccessFunc fcn); #endif /* QOF_QUERYCORE_H */ diff --git a/src/engine/QueryObjectP.h b/src/engine/qofqueryobject-p.h similarity index 80% rename from src/engine/QueryObjectP.h rename to src/engine/qofqueryobject-p.h index 5b6b4d4cfe..2d17521d3f 100644 --- a/src/engine/QueryObjectP.h +++ b/src/engine/qofqueryobject-p.h @@ -1,5 +1,5 @@ /********************************************************************\ - * QueryObjectP.h -- Private API for registering queriable objects * + * qofqueryobject-p.h -- Private API for registering queriable objects * * Copyright (C) 2002 Derek Atkins * * * * This program is free software; you can redistribute it and/or * @@ -21,14 +21,15 @@ * * \********************************************************************/ -#ifndef GNC_QUERYOBJECTP_H -#define GNC_QUERYOBJECTP_H +#ifndef QOF_QUERYOBJECTP_H +#define QOF_QUERYOBJECTP_H -#include "QueryObject.h" +#include "GNCId.h" +#include "qofqueryobject.h" -void gncQueryObjectInit(void); -void gncQueryObjectShutdown (void); +void qof_query_object_init(void); +void qof_query_object_shutdown (void); -QuerySort gncQueryObjectDefaultSort (GNCIdTypeConst obj_name); +QofSortFunc qof_query_object_default_sort (GNCIdTypeConst obj_name); -#endif /* GNC_QUERYOBJECTP_H */ +#endif /* QOF_QUERYOBJECTP_H */ diff --git a/src/engine/QueryObject.c b/src/engine/qofqueryobject.c similarity index 83% rename from src/engine/QueryObject.c rename to src/engine/qofqueryobject.c index 506911d172..45ff0722f4 100644 --- a/src/engine/QueryObject.c +++ b/src/engine/qofqueryobject.c @@ -26,7 +26,7 @@ #include #include "gnc-engine-util.h" -#include "QueryObjectP.h" +#include "qofqueryobject-p.h" #include "qofquery.h" static short module = MOD_QUERY; @@ -44,9 +44,9 @@ static gboolean clear_table (gpointer key, gpointer value, gpointer user_data) /********************************************************************/ /* PUBLISHED API FUNCTIONS */ -void gncQueryObjectRegister (GNCIdTypeConst obj_name, - QuerySort default_sort_function, - const QueryObjectDef *params) +void qof_query_object_register (GNCIdTypeConst obj_name, + QofSortFunc default_sort_function, + const QofQueryObject *params) { int i; @@ -72,7 +72,7 @@ void gncQueryObjectRegister (GNCIdTypeConst obj_name, } } -void gncQueryObjectInit(void) +void qof_query_object_init(void) { if (initialized) return; initialized = TRUE; @@ -81,7 +81,7 @@ void gncQueryObjectInit(void) sortTable = g_hash_table_new (g_str_hash, g_str_equal); } -void gncQueryObjectShutdown (void) +void qof_query_object_shutdown (void) { if (!initialized) return; initialized = FALSE; @@ -92,7 +92,7 @@ void gncQueryObjectShutdown (void) } -const QueryObjectDef * gncQueryObjectGetParameter (GNCIdTypeConst obj_name, +const QofQueryObject * qof_query_object_get_parameter (GNCIdTypeConst obj_name, const char *parameter) { GHashTable *ht; @@ -108,35 +108,36 @@ const QueryObjectDef * gncQueryObjectGetParameter (GNCIdTypeConst obj_name, return (g_hash_table_lookup (ht, parameter)); } -QofQueryAccess gncQueryObjectGetParameterGetter (GNCIdTypeConst obj_name, +QofAccessFunc qof_query_object_get_parameter_getter (GNCIdTypeConst obj_name, const char *parameter) { - const QueryObjectDef *obj; + const QofQueryObject *obj; g_return_val_if_fail (obj_name, NULL); g_return_val_if_fail (parameter, NULL); - obj = gncQueryObjectGetParameter (obj_name, parameter); + obj = qof_query_object_get_parameter (obj_name, parameter); if (obj) return obj->param_getfcn; return NULL; } -QofQueryCoreType gncQueryObjectParameterType (GNCIdTypeConst obj_name, +QofQueryCoreType qof_query_object_parameter_type (GNCIdTypeConst obj_name, const char *param_name) { - const QueryObjectDef *obj; + const QofQueryObject *obj; if (!obj_name || !param_name) return NULL; - obj = gncQueryObjectGetParameter (obj_name, param_name); + obj = qof_query_object_get_parameter (obj_name, param_name); if (!obj) return NULL; return (obj->param_type); } -QuerySort gncQueryObjectDefaultSort (GNCIdTypeConst obj_name) +QofSortFunc +qof_query_object_default_sort (GNCIdTypeConst obj_name) { if (!obj_name) return NULL; return g_hash_table_lookup (sortTable, obj_name); diff --git a/src/engine/qofqueryobject.h b/src/engine/qofqueryobject.h new file mode 100644 index 0000000000..166c217492 --- /dev/null +++ b/src/engine/qofqueryobject.h @@ -0,0 +1,94 @@ +/********************************************************************\ + * qofqueryobject.h -- API for registering queriable 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 qofqueryobject.h + @brief API for registering queriable objects + @author Copyright (C) 2002 Derek Atkins +*/ + +#ifndef QOF_QUERYOBJECT_H +#define QOF_QUERYOBJECT_H + +#include "qofquery.h" +#include "qofquerycore.h" + +/** This structure is for each queriable parameter in an object + * + * -- param_name is the name of the parameter. + * -- param_type is the type of the parameter, which can be either another + * object or it can be a core data type. + * -- param_getgcn is the function to actually obtain the parameter + */ +typedef struct _QofQueryObject +{ + const char * param_name; + QofQueryCoreType param_type; + QofAccessFunc param_getfcn; +} QofQueryObject; + +/** This function is the default sort function for a particular object type */ +typedef int (*QofSortFunc)(gpointer, gpointer); + +/** 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 + * argument may be NULL if there is nothing to be registered. + */ +void qof_query_object_register (GNCIdTypeConst obj_name, + QofSortFunc default_sort_fcn, + const QofQueryObject *params); + +/** An example: + * + * #define MY_QUERY_OBJ_MEMO "memo" + * #define MY_QUERY_OBJ_VALUE "value" + * #define MY_QUERY_OBJ_DATE "date" + * #define MY_QUERY_OBJ_ACCOUNT "account" + * #define MY_QUERY_OBJ_TRANS "trans" + * + * static QofQueryObject myQueryObjectParams[] = { + * { MY_QUERY_OBJ_MEMO, QOF_QUERYCORE_STRING, myMemoGetter }, + * { MY_QUERY_OBJ_VALUE, QOF_QUERYCORE_NUMERIC, myValueGetter }, + * { MY_QUERY_OBJ_DATE, QOF_QUERYCORE_DATE, myDateGetter }, + * { MY_QUERY_OBJ_ACCOUNT, GNC_ID_ACCOUNT, myAccountGetter }, + * { MY_QUERY_OBJ_TRANS, GNC_ID_TRANS, myTransactionGetter }, + * NULL }; + * + * qof_query_object_registerParamters ("myObjectName", myQueryObjectCompare, + * &myQueryObjectParams); + */ + +/** Return the core datatype of the specified object's parameter */ +QofQueryCoreType qof_query_object_parameter_type (GNCIdTypeConst obj_name, + const char *param_name); + +/** Return the registered Object Definition for the requested parameter */ +const QofQueryObject * qof_query_object_get_parameter (GNCIdTypeConst obj_name, + const char *parameter); + +/** Return the object's parameter getter function */ +QofAccessFunc qof_query_object_get_parameter_getter (GNCIdTypeConst obj_name, + const char *parameter); + + +#endif /* QOF_QUERYOBJECT_H */ diff --git a/src/engine/test/test-querynew.c b/src/engine/test/test-querynew.c index ac08636713..4c4943fbb9 100644 --- a/src/engine/test/test-querynew.c +++ b/src/engine/test/test-querynew.c @@ -6,10 +6,10 @@ #include "gnc-engine-util.h" #include "messages.h" -#include "QueryObjectP.h" #include "qofquery.h" #include "qofquerycore.h" #include "qofquerycore-p.h" +#include "qofqueryobject-p.h" #include "test-stuff.h" @@ -30,39 +30,39 @@ static int test_core_param (gpointer a) static void test_query_object (void) { - static QueryObjectDef params[] = { - { TEST_PARAM, TEST_CORE, (QofQueryAccess)test_core_param }, + static QofQueryObject params[] = { + { TEST_PARAM, TEST_CORE, (QofAccessFunc)test_core_param }, { NULL }, }; fprintf (stderr, "\tTesting the QueryObject interface. \n" "\tYou may see some \"** CRITICAL **\" messages, which you can safely ignore\n"); - gncQueryObjectRegister (TEST_MODULE_NAME, (QuerySort)test_sort, params); + qof_query_object_register (TEST_MODULE_NAME, (QofSortFunc)test_sort, params); - do_test (gncQueryObjectGetParameter (TEST_MODULE_NAME, TEST_PARAM) - == ¶ms[0], "gncQueryObjectGetParameter"); - do_test (gncQueryObjectGetParameter (NULL, NULL) == NULL, + do_test (qof_query_object_get_parameter (TEST_MODULE_NAME, TEST_PARAM) + == ¶ms[0], "qof_query_object_get_parameter"); + do_test (qof_query_object_get_parameter (NULL, NULL) == NULL, "gncQueryObjectGetParamter (NULL, NULL)"); - do_test (gncQueryObjectGetParameter (TEST_MODULE_NAME, NULL) == NULL, + do_test (qof_query_object_get_parameter (TEST_MODULE_NAME, NULL) == NULL, "gncQueryObjectGetParamter (TEST_MODULE_NAME, NULL)"); - do_test (gncQueryObjectGetParameter (TEST_MODULE_NAME, BAD_PARAM) == NULL, + do_test (qof_query_object_get_parameter (TEST_MODULE_NAME, BAD_PARAM) == NULL, "gncQueryObjectGetParamter (TEST_MODULE_NAME, BAD_PARAM)"); - do_test (gncQueryObjectGetParameter (NULL, TEST_PARAM) == NULL, + do_test (qof_query_object_get_parameter (NULL, TEST_PARAM) == NULL, "gncQueryObjectGetParamter (NULL, TEST_PARAM)"); - do_test (gncQueryObjectGetParameterGetter (TEST_MODULE_NAME, TEST_PARAM) - == (QofQueryAccess)test_core_param, - "gncQueryObjectGetParameterGetter"); + do_test (qof_query_object_get_parameter_getter (TEST_MODULE_NAME, TEST_PARAM) + == (QofAccessFunc)test_core_param, + "qof_query_object_get_parameter_getter"); - do_test (safe_strcmp (gncQueryObjectParameterType (TEST_MODULE_NAME, + do_test (safe_strcmp (qof_query_object_parameter_type (TEST_MODULE_NAME, TEST_PARAM), - TEST_CORE) == 0, "gncQueryObjectParameterType"); + TEST_CORE) == 0, "qof_query_object_parameter_type"); - do_test (gncQueryObjectDefaultSort (TEST_MODULE_NAME) == test_sort, - "gncQueryObjectDefaultSort"); - do_test (gncQueryObjectDefaultSort (NULL) == NULL, - "gncQueryObjectDefaultSort (NULL)"); + do_test (qof_query_object_default_sort (TEST_MODULE_NAME) == test_sort, + "qof_query_object_default_sort"); + do_test (qof_query_object_default_sort (NULL) == NULL, + "qof_query_object_default_sort (NULL)"); } static void test_query_core (void) diff --git a/src/engine/xlate.pl b/src/engine/xlate.pl index 088abf35c3..635066f370 100755 --- a/src/engine/xlate.pl +++ b/src/engine/xlate.pl @@ -99,54 +99,73 @@ foreach (@files) # 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/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/gncQueryBuildParamList/qof_query_build_param_list/g; + # s/gncQueryCreate/qof_query_create/g; + # s/gncQueryCreateFor/qof_query_create_for/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/gncQueryMerge/qof_query_merge/g; + # s/gncQueryMergeInPlace/qof_query_merges_ins_place/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; + + # s/query_object_def/_QofQueryObject/g; + # s/QueryObjectDef/QofQueryObject/g; + # s/QuerySort/QofQuerySort/g; + + # s/gncQueryObjectRegister/qof_query_object_register/g; + # s/gncQueryObjectParameterType/qof_query_object_parameter_type/g; + # s/gncQueryObjectGetParameterGetter/qof_query_object_get_parameter_getter/g; + # s/gncQueryObjectGetParameter/qof_query_object_get_parameter/g; + # s/gncQueryObjectInit/qof_query_object_init/g; + # s/gncQueryObjectShutdown/qof_query_object_shutdown/g; + # s/gncQueryObjectDefaultSort/qof_query_object_default_sort/g; + + s/QofQueryAccessFunc/QofAccessFunc/g; + s/QofQueryAccess/QofAccessFunc/g; + s/QofQueryCompareFunc/QofCompareFunc/g; + s/QofQueryCompare/QofCompareFunc/g; + s/QofQuerySortFunc/QofSortFunc/g; + s/QofQuerySort/QofSortFunc/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 $_; } close OF;