mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
convert QueryObject to QofQueryObject
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@8731 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
@@ -46,10 +46,10 @@
|
|||||||
#include "kvp-util-p.h"
|
#include "kvp-util-p.h"
|
||||||
#include "messages.h"
|
#include "messages.h"
|
||||||
|
|
||||||
#include "QueryObject.h"
|
|
||||||
#include "qofbook.h"
|
#include "qofbook.h"
|
||||||
#include "qofbook-p.h"
|
#include "qofbook-p.h"
|
||||||
#include "qofobject.h"
|
#include "qofobject.h"
|
||||||
|
#include "qofqueryobject.h"
|
||||||
|
|
||||||
static short module = MOD_ACCOUNT;
|
static short module = MOD_ACCOUNT;
|
||||||
|
|
||||||
@@ -3189,24 +3189,24 @@ static QofObject account_object_def = {
|
|||||||
|
|
||||||
gboolean xaccAccountRegister (void)
|
gboolean xaccAccountRegister (void)
|
||||||
{
|
{
|
||||||
static QueryObjectDef params[] = {
|
static QofQueryObject params[] = {
|
||||||
{ ACCOUNT_KVP, QOF_QUERYCORE_KVP, (QofQueryAccess)xaccAccountGetSlots },
|
{ ACCOUNT_KVP, QOF_QUERYCORE_KVP, (QofAccessFunc)xaccAccountGetSlots },
|
||||||
{ ACCOUNT_NAME_, QOF_QUERYCORE_STRING, (QofQueryAccess)xaccAccountGetName },
|
{ ACCOUNT_NAME_, QOF_QUERYCORE_STRING, (QofAccessFunc)xaccAccountGetName },
|
||||||
{ ACCOUNT_CODE_, QOF_QUERYCORE_STRING, (QofQueryAccess)xaccAccountGetCode },
|
{ ACCOUNT_CODE_, QOF_QUERYCORE_STRING, (QofAccessFunc)xaccAccountGetCode },
|
||||||
{ ACCOUNT_DESCRIPTION_, QOF_QUERYCORE_STRING, (QofQueryAccess)xaccAccountGetDescription },
|
{ ACCOUNT_DESCRIPTION_, QOF_QUERYCORE_STRING, (QofAccessFunc)xaccAccountGetDescription },
|
||||||
{ ACCOUNT_NOTES_, QOF_QUERYCORE_STRING, (QofQueryAccess)xaccAccountGetNotes },
|
{ ACCOUNT_NOTES_, QOF_QUERYCORE_STRING, (QofAccessFunc)xaccAccountGetNotes },
|
||||||
{ ACCOUNT_PRESENT_, QOF_QUERYCORE_NUMERIC, (QofQueryAccess)xaccAccountGetPresentBalance },
|
{ ACCOUNT_PRESENT_, QOF_QUERYCORE_NUMERIC, (QofAccessFunc)xaccAccountGetPresentBalance },
|
||||||
{ ACCOUNT_BALANCE_, QOF_QUERYCORE_NUMERIC, (QofQueryAccess)xaccAccountGetBalance },
|
{ ACCOUNT_BALANCE_, QOF_QUERYCORE_NUMERIC, (QofAccessFunc)xaccAccountGetBalance },
|
||||||
{ ACCOUNT_CLEARED_, QOF_QUERYCORE_NUMERIC, (QofQueryAccess)xaccAccountGetClearedBalance },
|
{ ACCOUNT_CLEARED_, QOF_QUERYCORE_NUMERIC, (QofAccessFunc)xaccAccountGetClearedBalance },
|
||||||
{ ACCOUNT_RECONCILED_, QOF_QUERYCORE_NUMERIC, (QofQueryAccess)xaccAccountGetReconciledBalance },
|
{ ACCOUNT_RECONCILED_, QOF_QUERYCORE_NUMERIC, (QofAccessFunc)xaccAccountGetReconciledBalance },
|
||||||
{ ACCOUNT_FUTURE_MINIMUM_, QOF_QUERYCORE_NUMERIC, (QofQueryAccess)xaccAccountGetProjectedMinimumBalance },
|
{ ACCOUNT_FUTURE_MINIMUM_, QOF_QUERYCORE_NUMERIC, (QofAccessFunc)xaccAccountGetProjectedMinimumBalance },
|
||||||
{ ACCOUNT_TAX_RELATED, QOF_QUERYCORE_BOOLEAN, (QofQueryAccess)xaccAccountGetTaxRelated },
|
{ ACCOUNT_TAX_RELATED, QOF_QUERYCORE_BOOLEAN, (QofAccessFunc)xaccAccountGetTaxRelated },
|
||||||
{ QOF_QUERY_PARAM_BOOK, GNC_ID_BOOK, (QofQueryAccess)xaccAccountGetBook },
|
{ QOF_QUERY_PARAM_BOOK, GNC_ID_BOOK, (QofAccessFunc)xaccAccountGetBook },
|
||||||
{ QOF_QUERY_PARAM_GUID, QOF_QUERYCORE_GUID, (QofQueryAccess)xaccAccountGetGUID },
|
{ QOF_QUERY_PARAM_GUID, QOF_QUERYCORE_GUID, (QofAccessFunc)xaccAccountGetGUID },
|
||||||
{ NULL },
|
{ 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);
|
return qof_object_register (&account_object_def);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ libgncmod_engine_la_SOURCES = \
|
|||||||
Group.c \
|
Group.c \
|
||||||
Period.c \
|
Period.c \
|
||||||
Query.c \
|
Query.c \
|
||||||
QueryObject.c \
|
|
||||||
SchedXaction.c \
|
SchedXaction.c \
|
||||||
SX-book.c \
|
SX-book.c \
|
||||||
SX-ttinfo.c \
|
SX-ttinfo.c \
|
||||||
@@ -45,6 +44,7 @@ libgncmod_engine_la_SOURCES = \
|
|||||||
qofbook.c \
|
qofbook.c \
|
||||||
qofquery.c \
|
qofquery.c \
|
||||||
qofquerycore.c \
|
qofquerycore.c \
|
||||||
|
qofqueryobject.c \
|
||||||
qofobject.c
|
qofobject.c
|
||||||
|
|
||||||
EXTRA_libgncmod_engine_la_SOURCES = iso-4217-currencies.c
|
EXTRA_libgncmod_engine_la_SOURCES = iso-4217-currencies.c
|
||||||
@@ -92,6 +92,7 @@ gncinclude_HEADERS = \
|
|||||||
qofbook.h \
|
qofbook.h \
|
||||||
qofquery.h \
|
qofquery.h \
|
||||||
qofquerycore.h \
|
qofquerycore.h \
|
||||||
|
qofqueryobject.h \
|
||||||
qofobject.h
|
qofobject.h
|
||||||
|
|
||||||
noinst_HEADERS = \
|
noinst_HEADERS = \
|
||||||
@@ -101,7 +102,6 @@ noinst_HEADERS = \
|
|||||||
GNCIdP.h \
|
GNCIdP.h \
|
||||||
GroupP.h \
|
GroupP.h \
|
||||||
QueryP.h \
|
QueryP.h \
|
||||||
QueryObjectP.h \
|
|
||||||
SchedXactionP.h \
|
SchedXactionP.h \
|
||||||
ScrubP.h \
|
ScrubP.h \
|
||||||
SX-book.h \
|
SX-book.h \
|
||||||
@@ -119,6 +119,7 @@ noinst_HEADERS = \
|
|||||||
qofbook-p.h \
|
qofbook-p.h \
|
||||||
qofquery-p.h \
|
qofquery-p.h \
|
||||||
qofquerycore-p.h \
|
qofquerycore-p.h \
|
||||||
|
qofqueryobject-p.h \
|
||||||
qofobject-p.h
|
qofobject-p.h
|
||||||
|
|
||||||
noinst_SCRIPTS = iso-currencies-to-c
|
noinst_SCRIPTS = iso-currencies-to-c
|
||||||
|
|||||||
@@ -512,7 +512,7 @@ xaccQueryAddGUIDMatchGL (QofQuery *q, GList *param_list,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
xaccQueryAddKVPMatch(Query *q, GSList *path, const kvp_value *value,
|
xaccQueryAddKVPMatch(QofQuery *q, GSList *path, const kvp_value *value,
|
||||||
QofQueryCompare how, GNCIdType id_type,
|
QofQueryCompare how, GNCIdType id_type,
|
||||||
QofQueryOp op)
|
QofQueryOp op)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -46,7 +46,7 @@
|
|||||||
#define numeric_match_t QofNumericMatch
|
#define numeric_match_t QofNumericMatch
|
||||||
#define date_match_t QofDateMatch
|
#define date_match_t QofDateMatch
|
||||||
#define string_match_t QofStringMatch
|
#define string_match_t QofStringMatch
|
||||||
#define query_compare_t QofQueryCompare
|
#define query_compare_t QofCompareFunc
|
||||||
|
|
||||||
#define gncQueryCoreInit qof_query_core_init
|
#define gncQueryCoreInit qof_query_core_init
|
||||||
#define gncQueryCoreShutdown qof_query_core_shutdown
|
#define gncQueryCoreShutdown qof_query_core_shutdown
|
||||||
@@ -64,5 +64,5 @@
|
|||||||
#define QUERYCORE_INT64 QOF_QUERYCORE_INT64
|
#define QUERYCORE_INT64 QOF_QUERYCORE_INT64
|
||||||
#define QUERYCORE_DOUBLE QOF_QUERYCORE_DOUBLE
|
#define QUERYCORE_DOUBLE QOF_QUERYCORE_DOUBLE
|
||||||
|
|
||||||
#define QueryAccess QofQueryAccess
|
#define QueryAccess QofAccessFunc
|
||||||
#define gncQueryCoreToString qof_query_core_to_string
|
#define gncQueryCoreToString qof_query_core_to_string
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
#include "qofquery.h"
|
#include "qofquery.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -15,7 +14,7 @@
|
|||||||
#define QueryNew QofQuery
|
#define QueryNew QofQuery
|
||||||
#define QueryOp QofQueryOp
|
#define QueryOp QofQueryOp
|
||||||
#define query_new_term _QofQueryTerm
|
#define query_new_term _QofQueryTerm
|
||||||
#define query_new_sort _QofQuerySort
|
#define query_new_sort _QofSortFunc
|
||||||
|
|
||||||
#define gncQueryBuildParamList qof_query_build_param_list
|
#define gncQueryBuildParamList qof_query_build_param_list
|
||||||
#define gncQueryCreate qof_query_create
|
#define gncQueryCreate qof_query_create
|
||||||
|
|||||||
@@ -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
|
#include "qofqueryobject.h"
|
||||||
@brief API for registering queriable GnuCash objects
|
|
||||||
@author Copyright (C) 2002 Derek Atkins <warlord@MIT.EDU>
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef QOF_QUERYOBJECT_H
|
#define query_object_def _QofQueryObject
|
||||||
#define QOF_QUERYOBJECT_H
|
#define QueryObjectDef QofQueryObject
|
||||||
|
#define QuerySort QofSortFunc
|
||||||
|
|
||||||
#include "qofquery.h"
|
#define gncQueryObjectRegister qof_query_object_register
|
||||||
#include "qofquerycore.h"
|
#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 */
|
|
||||||
|
|||||||
@@ -46,11 +46,11 @@
|
|||||||
#include "gnc-lot-p.h"
|
#include "gnc-lot-p.h"
|
||||||
#include "gnc-lot.h"
|
#include "gnc-lot.h"
|
||||||
#include "messages.h"
|
#include "messages.h"
|
||||||
|
|
||||||
#include "qofbook.h"
|
#include "qofbook.h"
|
||||||
#include "qofbook-p.h"
|
#include "qofbook-p.h"
|
||||||
#include "qofobject.h"
|
#include "qofobject.h"
|
||||||
|
#include "qofqueryobject.h"
|
||||||
#include "QueryObject.h"
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The "force_double_entry" flag determines how
|
* The "force_double_entry" flag determines how
|
||||||
@@ -3591,51 +3591,51 @@ static gpointer no_op (gpointer obj)
|
|||||||
|
|
||||||
gboolean xaccSplitRegister (void)
|
gboolean xaccSplitRegister (void)
|
||||||
{
|
{
|
||||||
static const QueryObjectDef params[] = {
|
static const QofQueryObject params[] = {
|
||||||
{ SPLIT_KVP, QOF_QUERYCORE_KVP, (QofQueryAccess)xaccSplitGetSlots },
|
{ SPLIT_KVP, QOF_QUERYCORE_KVP, (QofAccessFunc)xaccSplitGetSlots },
|
||||||
{ SPLIT_DATE_RECONCILED, QOF_QUERYCORE_DATE,
|
{ SPLIT_DATE_RECONCILED, QOF_QUERYCORE_DATE,
|
||||||
(QofQueryAccess)xaccSplitRetDateReconciledTS },
|
(QofAccessFunc)xaccSplitRetDateReconciledTS },
|
||||||
{ "d-share-amount", QOF_QUERYCORE_DOUBLE,
|
{ "d-share-amount", QOF_QUERYCORE_DOUBLE,
|
||||||
(QofQueryAccess)DxaccSplitGetShareAmount },
|
(QofAccessFunc)DxaccSplitGetShareAmount },
|
||||||
{ "d-share-int64", QOF_QUERYCORE_INT64, (QofQueryAccess)xaccSplitGetGUID },
|
{ "d-share-int64", QOF_QUERYCORE_INT64, (QofAccessFunc)xaccSplitGetGUID },
|
||||||
{ SPLIT_BALANCE, QOF_QUERYCORE_NUMERIC, (QofQueryAccess)xaccSplitGetBalance },
|
{ SPLIT_BALANCE, QOF_QUERYCORE_NUMERIC, (QofAccessFunc)xaccSplitGetBalance },
|
||||||
{ SPLIT_CLEARED_BALANCE, QOF_QUERYCORE_NUMERIC,
|
{ SPLIT_CLEARED_BALANCE, QOF_QUERYCORE_NUMERIC,
|
||||||
(QofQueryAccess)xaccSplitGetClearedBalance },
|
(QofAccessFunc)xaccSplitGetClearedBalance },
|
||||||
{ SPLIT_RECONCILED_BALANCE, QOF_QUERYCORE_NUMERIC,
|
{ SPLIT_RECONCILED_BALANCE, QOF_QUERYCORE_NUMERIC,
|
||||||
(QofQueryAccess)xaccSplitGetReconciledBalance },
|
(QofAccessFunc)xaccSplitGetReconciledBalance },
|
||||||
{ SPLIT_MEMO, QOF_QUERYCORE_STRING, (QofQueryAccess)xaccSplitGetMemo },
|
{ SPLIT_MEMO, QOF_QUERYCORE_STRING, (QofAccessFunc)xaccSplitGetMemo },
|
||||||
{ SPLIT_ACTION, QOF_QUERYCORE_STRING, (QofQueryAccess)xaccSplitGetAction },
|
{ SPLIT_ACTION, QOF_QUERYCORE_STRING, (QofAccessFunc)xaccSplitGetAction },
|
||||||
{ SPLIT_RECONCILE, QOF_QUERYCORE_CHAR, (QofQueryAccess)xaccSplitGetReconcile },
|
{ SPLIT_RECONCILE, QOF_QUERYCORE_CHAR, (QofAccessFunc)xaccSplitGetReconcile },
|
||||||
{ SPLIT_AMOUNT, QOF_QUERYCORE_NUMERIC, (QofQueryAccess)xaccSplitGetAmount },
|
{ SPLIT_AMOUNT, QOF_QUERYCORE_NUMERIC, (QofAccessFunc)xaccSplitGetAmount },
|
||||||
{ SPLIT_SHARE_PRICE, QOF_QUERYCORE_NUMERIC,
|
{ SPLIT_SHARE_PRICE, QOF_QUERYCORE_NUMERIC,
|
||||||
(QofQueryAccess)xaccSplitGetSharePrice },
|
(QofAccessFunc)xaccSplitGetSharePrice },
|
||||||
{ SPLIT_VALUE, QOF_QUERYCORE_DEBCRED, (QofQueryAccess)xaccSplitGetValue },
|
{ SPLIT_VALUE, QOF_QUERYCORE_DEBCRED, (QofAccessFunc)xaccSplitGetValue },
|
||||||
{ SPLIT_TYPE, QOF_QUERYCORE_STRING, (QofQueryAccess)xaccSplitGetType },
|
{ SPLIT_TYPE, QOF_QUERYCORE_STRING, (QofAccessFunc)xaccSplitGetType },
|
||||||
{ SPLIT_VOIDED_AMOUNT, QOF_QUERYCORE_NUMERIC,
|
{ SPLIT_VOIDED_AMOUNT, QOF_QUERYCORE_NUMERIC,
|
||||||
(QofQueryAccess)xaccSplitVoidFormerAmount },
|
(QofAccessFunc)xaccSplitVoidFormerAmount },
|
||||||
{ SPLIT_VOIDED_VALUE, QOF_QUERYCORE_NUMERIC,
|
{ SPLIT_VOIDED_VALUE, QOF_QUERYCORE_NUMERIC,
|
||||||
(QofQueryAccess)xaccSplitVoidFormerValue },
|
(QofAccessFunc)xaccSplitVoidFormerValue },
|
||||||
{ SPLIT_LOT, GNC_ID_LOT, (QofQueryAccess)xaccSplitGetLot },
|
{ SPLIT_LOT, GNC_ID_LOT, (QofAccessFunc)xaccSplitGetLot },
|
||||||
{ SPLIT_TRANS, GNC_ID_TRANS, (QofQueryAccess)xaccSplitGetParent },
|
{ SPLIT_TRANS, GNC_ID_TRANS, (QofAccessFunc)xaccSplitGetParent },
|
||||||
{ SPLIT_ACCOUNT, GNC_ID_ACCOUNT, (QofQueryAccess)xaccSplitGetAccount },
|
{ SPLIT_ACCOUNT, GNC_ID_ACCOUNT, (QofAccessFunc)xaccSplitGetAccount },
|
||||||
{ SPLIT_ACCOUNT_GUID, QOF_QUERYCORE_GUID, split_account_guid_getter },
|
{ SPLIT_ACCOUNT_GUID, QOF_QUERYCORE_GUID, split_account_guid_getter },
|
||||||
{ SPLIT_ACCT_FULLNAME, SPLIT_ACCT_FULLNAME, no_op },
|
{ SPLIT_ACCT_FULLNAME, SPLIT_ACCT_FULLNAME, no_op },
|
||||||
{ SPLIT_CORR_ACCT_NAME, SPLIT_CORR_ACCT_NAME, no_op },
|
{ SPLIT_CORR_ACCT_NAME, SPLIT_CORR_ACCT_NAME, no_op },
|
||||||
{ SPLIT_CORR_ACCT_CODE, SPLIT_CORR_ACCT_CODE, no_op },
|
{ SPLIT_CORR_ACCT_CODE, SPLIT_CORR_ACCT_CODE, no_op },
|
||||||
{ QOF_QUERY_PARAM_BOOK, GNC_ID_BOOK, (QofQueryAccess)xaccSplitGetBook },
|
{ QOF_QUERY_PARAM_BOOK, GNC_ID_BOOK, (QofAccessFunc)xaccSplitGetBook },
|
||||||
{ QOF_QUERY_PARAM_GUID, QOF_QUERYCORE_GUID, (QofQueryAccess) xaccSplitGetGUID },
|
{ QOF_QUERY_PARAM_GUID, QOF_QUERYCORE_GUID, (QofAccessFunc) xaccSplitGetGUID },
|
||||||
{ NULL },
|
{ NULL },
|
||||||
};
|
};
|
||||||
|
|
||||||
gncQueryObjectRegister (GNC_ID_SPLIT, (QuerySort)xaccSplitDateOrder, params);
|
qof_query_object_register (GNC_ID_SPLIT, (QofSortFunc)xaccSplitDateOrder, params);
|
||||||
gncQueryObjectRegister (SPLIT_ACCT_FULLNAME,
|
qof_query_object_register (SPLIT_ACCT_FULLNAME,
|
||||||
(QuerySort)xaccSplitCompareAccountFullNames,
|
(QofSortFunc)xaccSplitCompareAccountFullNames,
|
||||||
NULL);
|
NULL);
|
||||||
gncQueryObjectRegister (SPLIT_CORR_ACCT_NAME,
|
qof_query_object_register (SPLIT_CORR_ACCT_NAME,
|
||||||
(QuerySort)xaccSplitCompareOtherAccountFullNames,
|
(QofSortFunc)xaccSplitCompareOtherAccountFullNames,
|
||||||
NULL);
|
NULL);
|
||||||
gncQueryObjectRegister (SPLIT_CORR_ACCT_CODE,
|
qof_query_object_register (SPLIT_CORR_ACCT_CODE,
|
||||||
(QuerySort)xaccSplitCompareOtherAccountCodes,
|
(QofSortFunc)xaccSplitCompareOtherAccountCodes,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
return qof_object_register (&split_object_def);
|
return qof_object_register (&split_object_def);
|
||||||
@@ -3669,27 +3669,27 @@ trans_is_balanced_p (const Transaction *txn)
|
|||||||
|
|
||||||
gboolean xaccTransRegister (void)
|
gboolean xaccTransRegister (void)
|
||||||
{
|
{
|
||||||
static QueryObjectDef params[] = {
|
static QofQueryObject params[] = {
|
||||||
{ TRANS_KVP, QOF_QUERYCORE_KVP, (QofQueryAccess)xaccTransGetSlots },
|
{ TRANS_KVP, QOF_QUERYCORE_KVP, (QofAccessFunc)xaccTransGetSlots },
|
||||||
{ TRANS_NUM, QOF_QUERYCORE_STRING, (QofQueryAccess)xaccTransGetNum },
|
{ TRANS_NUM, QOF_QUERYCORE_STRING, (QofAccessFunc)xaccTransGetNum },
|
||||||
{ TRANS_DESCRIPTION, QOF_QUERYCORE_STRING, (QofQueryAccess)xaccTransGetDescription },
|
{ TRANS_DESCRIPTION, QOF_QUERYCORE_STRING, (QofAccessFunc)xaccTransGetDescription },
|
||||||
{ TRANS_DATE_ENTERED, QOF_QUERYCORE_DATE, (QofQueryAccess)xaccTransRetDateEnteredTS },
|
{ TRANS_DATE_ENTERED, QOF_QUERYCORE_DATE, (QofAccessFunc)xaccTransRetDateEnteredTS },
|
||||||
{ TRANS_DATE_POSTED, QOF_QUERYCORE_DATE, (QofQueryAccess)xaccTransRetDatePostedTS },
|
{ TRANS_DATE_POSTED, QOF_QUERYCORE_DATE, (QofAccessFunc)xaccTransRetDatePostedTS },
|
||||||
{ TRANS_DATE_DUE, QOF_QUERYCORE_DATE, (QofQueryAccess)xaccTransRetDateDueTS },
|
{ TRANS_DATE_DUE, QOF_QUERYCORE_DATE, (QofAccessFunc)xaccTransRetDateDueTS },
|
||||||
{ TRANS_IMBALANCE, QOF_QUERYCORE_NUMERIC, (QofQueryAccess)xaccTransGetImbalance },
|
{ TRANS_IMBALANCE, QOF_QUERYCORE_NUMERIC, (QofAccessFunc)xaccTransGetImbalance },
|
||||||
{ TRANS_NOTES, QOF_QUERYCORE_STRING, (QofQueryAccess)xaccTransGetNotes },
|
{ TRANS_NOTES, QOF_QUERYCORE_STRING, (QofAccessFunc)xaccTransGetNotes },
|
||||||
{ TRANS_IS_BALANCED, QOF_QUERYCORE_BOOLEAN, (QofQueryAccess)trans_is_balanced_p },
|
{ TRANS_IS_BALANCED, QOF_QUERYCORE_BOOLEAN, (QofAccessFunc)trans_is_balanced_p },
|
||||||
{ TRANS_TYPE, QOF_QUERYCORE_CHAR, (QofQueryAccess)xaccTransGetTxnType },
|
{ TRANS_TYPE, QOF_QUERYCORE_CHAR, (QofAccessFunc)xaccTransGetTxnType },
|
||||||
{ TRANS_VOID_STATUS, QOF_QUERYCORE_BOOLEAN, (QofQueryAccess)xaccTransGetVoidStatus },
|
{ TRANS_VOID_STATUS, QOF_QUERYCORE_BOOLEAN, (QofAccessFunc)xaccTransGetVoidStatus },
|
||||||
{ TRANS_VOID_REASON, QOF_QUERYCORE_STRING, (QofQueryAccess)xaccTransGetVoidReason },
|
{ TRANS_VOID_REASON, QOF_QUERYCORE_STRING, (QofAccessFunc)xaccTransGetVoidReason },
|
||||||
{ TRANS_VOID_TIME, QOF_QUERYCORE_DATE, (QofQueryAccess)xaccTransGetVoidTime },
|
{ TRANS_VOID_TIME, QOF_QUERYCORE_DATE, (QofAccessFunc)xaccTransGetVoidTime },
|
||||||
{ TRANS_SPLITLIST, GNC_ID_SPLIT, (QofQueryAccess)xaccTransGetSplitList },
|
{ TRANS_SPLITLIST, GNC_ID_SPLIT, (QofAccessFunc)xaccTransGetSplitList },
|
||||||
{ QOF_QUERY_PARAM_BOOK, GNC_ID_BOOK, (QofQueryAccess)xaccTransGetBook },
|
{ QOF_QUERY_PARAM_BOOK, GNC_ID_BOOK, (QofAccessFunc)xaccTransGetBook },
|
||||||
{ QOF_QUERY_PARAM_GUID, QOF_QUERYCORE_GUID, (QofQueryAccess)xaccTransGetGUID },
|
{ QOF_QUERY_PARAM_GUID, QOF_QUERYCORE_GUID, (QofAccessFunc)xaccTransGetGUID },
|
||||||
{ NULL },
|
{ 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);
|
return qof_object_register (&trans_object_def);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -232,7 +232,7 @@ gnc_gw_enum_scm2val (const char *typestr, SCM enum_scm)
|
|||||||
return scm_num2int (scm, SCM_ARG1, __FUNCTION__);
|
return scm_num2int (scm, SCM_ARG1, __FUNCTION__);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* QofQueryCompare */
|
/* QofCompareFunc */
|
||||||
|
|
||||||
static SCM
|
static SCM
|
||||||
gnc_query_compare2scm (QofQueryCompare how)
|
gnc_query_compare2scm (QofQueryCompare how)
|
||||||
@@ -937,10 +937,10 @@ gnc_queryterm2scm (QofQueryTerm_t qt)
|
|||||||
return scm_reverse (qt_scm);
|
return scm_reverse (qt_scm);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Query *
|
static QofQuery *
|
||||||
gnc_scm2query_term_query_v2 (SCM qt_scm)
|
gnc_scm2query_term_query_v2 (SCM qt_scm)
|
||||||
{
|
{
|
||||||
Query *q = NULL;
|
QofQuery *q = NULL;
|
||||||
QofQueryPredData *pd = NULL;
|
QofQueryPredData *pd = NULL;
|
||||||
SCM scm;
|
SCM scm;
|
||||||
char *type = NULL;
|
char *type = NULL;
|
||||||
@@ -973,7 +973,7 @@ gnc_scm2query_term_query_v2 (SCM qt_scm)
|
|||||||
break;
|
break;
|
||||||
type = gh_symbol2newstr (scm, NULL);
|
type = gh_symbol2newstr (scm, NULL);
|
||||||
|
|
||||||
/* QofQueryCompare */
|
/* QofCompareFunc */
|
||||||
scm = SCM_CAR (qt_scm);
|
scm = SCM_CAR (qt_scm);
|
||||||
qt_scm = SCM_CDR (qt_scm);
|
qt_scm = SCM_CDR (qt_scm);
|
||||||
if (SCM_NULLP (scm))
|
if (SCM_NULLP (scm))
|
||||||
@@ -1164,14 +1164,14 @@ gnc_scm2query_term_query_v2 (SCM qt_scm)
|
|||||||
return q;
|
return q;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Query *
|
static QofQuery *
|
||||||
gnc_scm2query_term_query_v1 (SCM query_term_scm)
|
gnc_scm2query_term_query_v1 (SCM query_term_scm)
|
||||||
{
|
{
|
||||||
gboolean ok = FALSE;
|
gboolean ok = FALSE;
|
||||||
char * pd_type = NULL;
|
char * pd_type = NULL;
|
||||||
char * pr_type = NULL;
|
char * pr_type = NULL;
|
||||||
gboolean sense = FALSE;
|
gboolean sense = FALSE;
|
||||||
Query *q = NULL;
|
QofQuery *q = NULL;
|
||||||
SCM scm;
|
SCM scm;
|
||||||
|
|
||||||
if (!SCM_LISTP (query_term_scm) ||
|
if (!SCM_LISTP (query_term_scm) ||
|
||||||
@@ -1626,7 +1626,7 @@ gnc_scm2query_or_terms (SCM or_terms, query_version_t vers)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static SCM
|
static SCM
|
||||||
gnc_query_sort2scm (QofQuerySort_t qs)
|
gnc_query_sort2scm (QofSortFunc_t qs)
|
||||||
{
|
{
|
||||||
SCM sort_scm = SCM_EOL;
|
SCM sort_scm = SCM_EOL;
|
||||||
GSList *path;
|
GSList *path;
|
||||||
@@ -1703,7 +1703,7 @@ gnc_query2scm (Query *q)
|
|||||||
{
|
{
|
||||||
SCM query_scm = SCM_EOL;
|
SCM query_scm = SCM_EOL;
|
||||||
SCM pair;
|
SCM pair;
|
||||||
QofQuerySort_t s1, s2, s3;
|
QofSortFunc_t s1, s2, s3;
|
||||||
|
|
||||||
if (!q) return SCM_BOOL_F;
|
if (!q) return SCM_BOOL_F;
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,7 @@
|
|||||||
#include "gnc-lot-p.h"
|
#include "gnc-lot-p.h"
|
||||||
#include "Transaction.h"
|
#include "Transaction.h"
|
||||||
#include "TransactionP.h"
|
#include "TransactionP.h"
|
||||||
#include "QueryObject.h"
|
#include "qofqueryobject.h"
|
||||||
#include "qofbook.h"
|
#include "qofbook.h"
|
||||||
#include "qofbook-p.h"
|
#include "qofbook-p.h"
|
||||||
|
|
||||||
@@ -329,15 +329,15 @@ gnc_lot_get_latest_split (GNCLot *lot)
|
|||||||
|
|
||||||
void gnc_lot_register (void)
|
void gnc_lot_register (void)
|
||||||
{
|
{
|
||||||
static const QueryObjectDef params[] = {
|
static const QofQueryObject params[] = {
|
||||||
{ QOF_QUERY_PARAM_BOOK, GNC_ID_BOOK, (QofQueryAccess)gnc_lot_get_book },
|
{ QOF_QUERY_PARAM_BOOK, GNC_ID_BOOK, (QofAccessFunc)gnc_lot_get_book },
|
||||||
{ QOF_QUERY_PARAM_GUID, QOF_QUERYCORE_GUID, (QofQueryAccess)gnc_lot_get_guid },
|
{ QOF_QUERY_PARAM_GUID, QOF_QUERYCORE_GUID, (QofAccessFunc)gnc_lot_get_guid },
|
||||||
{ LOT_IS_CLOSED, QOF_QUERYCORE_BOOLEAN, (QofQueryAccess)gnc_lot_is_closed },
|
{ LOT_IS_CLOSED, QOF_QUERYCORE_BOOLEAN, (QofAccessFunc)gnc_lot_is_closed },
|
||||||
{ LOT_BALANCE, QOF_QUERYCORE_NUMERIC, (QofQueryAccess)gnc_lot_get_balance },
|
{ LOT_BALANCE, QOF_QUERYCORE_NUMERIC, (QofAccessFunc)gnc_lot_get_balance },
|
||||||
{ NULL },
|
{ NULL },
|
||||||
};
|
};
|
||||||
|
|
||||||
gncQueryObjectRegister (GNC_ID_LOT, NULL, params);
|
qof_query_object_register (GNC_ID_LOT, NULL, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ========================== END OF FILE ========================= */
|
/* ========================== END OF FILE ========================= */
|
||||||
|
|||||||
@@ -42,13 +42,13 @@
|
|||||||
|
|
||||||
#include "Backend.h"
|
#include "Backend.h"
|
||||||
#include "BackendP.h"
|
#include "BackendP.h"
|
||||||
#include "QueryObject.h"
|
|
||||||
#include "gnc-event.h"
|
#include "gnc-event.h"
|
||||||
#include "gnc-event-p.h"
|
#include "gnc-event-p.h"
|
||||||
#include "gnc-trace.h"
|
#include "gnc-trace.h"
|
||||||
#include "qofbook.h"
|
#include "qofbook.h"
|
||||||
#include "qofbook-p.h"
|
#include "qofbook-p.h"
|
||||||
#include "qofobject-p.h"
|
#include "qofobject-p.h"
|
||||||
|
#include "qofqueryobject.h"
|
||||||
|
|
||||||
static short module = MOD_ENGINE;
|
static short module = MOD_ENGINE;
|
||||||
|
|
||||||
@@ -292,13 +292,13 @@ qof_book_get_counter (QofBook *book, const char *counter_name)
|
|||||||
/* gncObject function implementation and registration */
|
/* gncObject function implementation and registration */
|
||||||
gboolean qof_book_register (void)
|
gboolean qof_book_register (void)
|
||||||
{
|
{
|
||||||
static QueryObjectDef params[] = {
|
static QofQueryObject params[] = {
|
||||||
{ QOF_BOOK_KVP, QOF_QUERYCORE_KVP, (QofQueryAccess)qof_book_get_slots },
|
{ QOF_BOOK_KVP, QOF_QUERYCORE_KVP, (QofAccessFunc)qof_book_get_slots },
|
||||||
{ QOF_QUERY_PARAM_GUID, QOF_QUERYCORE_GUID, (QofQueryAccess)qof_book_get_guid },
|
{ QOF_QUERY_PARAM_GUID, QOF_QUERYCORE_GUID, (QofAccessFunc)qof_book_get_guid },
|
||||||
{ NULL },
|
{ NULL },
|
||||||
};
|
};
|
||||||
|
|
||||||
gncQueryObjectRegister (GNC_ID_BOOK, NULL, params);
|
qof_query_object_register (GNC_ID_BOOK, NULL, params);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
#include "qofquery.h"
|
#include "qofquery.h"
|
||||||
|
|
||||||
typedef struct _QofQueryTerm *QofQueryTerm_t;
|
typedef struct _QofQueryTerm *QofQueryTerm_t;
|
||||||
typedef struct _QofQuerySort *QofQuerySort_t;
|
typedef struct _QofSortFunc *QofSortFunc_t;
|
||||||
|
|
||||||
/* Initialize/Shutdown */
|
/* Initialize/Shutdown */
|
||||||
void qof_query_init (void);
|
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.
|
/* This function returns the primary, secondary, and tertiary sorts.
|
||||||
* These are part of the query and should NOT be changed!
|
* These are part of the query and should NOT be changed!
|
||||||
*/
|
*/
|
||||||
void qof_query_get_sorts (QofQuery *q, QofQuerySort_t *primary,
|
void qof_query_get_sorts (QofQuery *q, QofSortFunc_t *primary,
|
||||||
QofQuerySort_t *secondary, QofQuerySort_t *tertiary);
|
QofSortFunc_t *secondary, QofSortFunc_t *tertiary);
|
||||||
|
|
||||||
GSList * qof_query_sort_get_param_path (QofQuerySort_t querysort);
|
GSList * qof_query_sort_get_param_path (QofSortFunc_t querysort);
|
||||||
gint qof_query_sort_get_sort_options (QofQuerySort_t querysort);
|
gint qof_query_sort_get_sort_options (QofSortFunc_t querysort);
|
||||||
gboolean qof_query_sort_get_increasing (QofQuerySort_t querysort);
|
gboolean qof_query_sort_get_increasing (QofSortFunc_t querysort);
|
||||||
|
|
||||||
#endif /* QOF_QUERY_P_H */
|
#endif /* QOF_QUERY_P_H */
|
||||||
|
|||||||
@@ -32,7 +32,6 @@
|
|||||||
#include "gnc-engine-util.h"
|
#include "gnc-engine-util.h"
|
||||||
#include "BackendP.h"
|
#include "BackendP.h"
|
||||||
|
|
||||||
#include "QueryObjectP.h"
|
|
||||||
#include "qofbook.h"
|
#include "qofbook.h"
|
||||||
#include "qofbook-p.h"
|
#include "qofbook-p.h"
|
||||||
#include "qofobject.h"
|
#include "qofobject.h"
|
||||||
@@ -40,10 +39,13 @@
|
|||||||
#include "qofquery-p.h"
|
#include "qofquery-p.h"
|
||||||
#include "qofquerycore.h"
|
#include "qofquerycore.h"
|
||||||
#include "qofquerycore-p.h"
|
#include "qofquerycore-p.h"
|
||||||
|
#include "qofqueryobject.h"
|
||||||
|
#include "qofqueryobject-p.h"
|
||||||
|
|
||||||
static short module = MOD_QUERY;
|
static short module = MOD_QUERY;
|
||||||
|
|
||||||
typedef struct _QofQueryTerm {
|
typedef struct _QofQueryTerm
|
||||||
|
{
|
||||||
GSList * param_list;
|
GSList * param_list;
|
||||||
QofQueryPredData *pdata;
|
QofQueryPredData *pdata;
|
||||||
gboolean invert;
|
gboolean invert;
|
||||||
@@ -54,10 +56,11 @@ typedef struct _QofQueryTerm {
|
|||||||
* convert types.
|
* convert types.
|
||||||
*/
|
*/
|
||||||
GSList * param_fcns;
|
GSList * param_fcns;
|
||||||
QueryPredicate pred_fcn;
|
QofQueryPredicateFunc pred_fcn;
|
||||||
} QofQueryTerm;
|
} QofQueryTerm;
|
||||||
|
|
||||||
typedef struct _QofQuerySort {
|
typedef struct _QofSortFunc
|
||||||
|
{
|
||||||
GSList * param_list;
|
GSList * param_list;
|
||||||
gint options;
|
gint options;
|
||||||
gboolean increasing;
|
gboolean increasing;
|
||||||
@@ -69,47 +72,49 @@ typedef struct _QofQuerySort {
|
|||||||
*/
|
*/
|
||||||
gboolean use_default;
|
gboolean use_default;
|
||||||
GSList * param_fcns;
|
GSList * param_fcns;
|
||||||
QuerySort obj_cmp; /* In case you are comparing objects */
|
QofSortFunc obj_cmp; /* In case you are comparing objects */
|
||||||
QueryCompare comp_fcn; /* When you are comparing core types */
|
QofCompareFunc comp_fcn; /* When you are comparing core types */
|
||||||
} QofQuerySort;
|
} QofQuerySort;
|
||||||
|
|
||||||
/* The QUERY structure */
|
/* The QUERY structure */
|
||||||
struct _QofQuery {
|
struct _QofQuery
|
||||||
|
{
|
||||||
/* The object type that we're searching for */
|
/* 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
|
/* terms is a list of the OR-terms in a sum-of-products
|
||||||
* logical expression. */
|
* logical expression. */
|
||||||
GList * terms;
|
GList * terms;
|
||||||
|
|
||||||
/* sorting and chopping is independent of the search filter */
|
/* sorting and chopping is independent of the search filter */
|
||||||
|
|
||||||
QofQuerySort primary_sort;
|
QofQuerySort primary_sort;
|
||||||
QofQuerySort secondary_sort;
|
QofQuerySort secondary_sort;
|
||||||
QofQuerySort tertiary_sort;
|
QofQuerySort tertiary_sort;
|
||||||
QuerySort defaultSort; /* <- Computed from search_for */
|
QofSortFunc defaultSort; /* <- Computed from search_for */
|
||||||
|
|
||||||
/* The maximum number of results to return */
|
/* The maximum number of results to return */
|
||||||
int max_results;
|
int max_results;
|
||||||
|
|
||||||
/* list of books that will be participating in the query */
|
/* list of books that will be participating in the query */
|
||||||
GList * books;
|
GList * books;
|
||||||
|
|
||||||
/* a map of book to backend-compiled queries */
|
/* 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
|
/* cache the results so we don't have to run the whole search
|
||||||
* again until it's really necessary */
|
* again until it's really necessary */
|
||||||
int changed;
|
int changed;
|
||||||
|
|
||||||
GList * results;
|
GList * results;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct query_cb {
|
typedef struct _QofQueryCB
|
||||||
|
{
|
||||||
QofQuery * query;
|
QofQuery * query;
|
||||||
GList * list;
|
GList * list;
|
||||||
int count;
|
int count;
|
||||||
} query_cb_t;
|
} QofQueryCB;
|
||||||
|
|
||||||
/* initial_term will be owned by the new Query */
|
/* initial_term will be owned by the new Query */
|
||||||
static void query_init (QofQuery *q, QofQueryTerm *initial_term)
|
static void query_init (QofQuery *q, QofQueryTerm *initial_term)
|
||||||
@@ -221,14 +226,14 @@ copy_or_terms(GList * or_terms)
|
|||||||
return g_list_reverse(or);
|
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));
|
memcpy (dst, src, sizeof (*dst));
|
||||||
dst->param_list = g_slist_copy (src->param_list);
|
dst->param_list = g_slist_copy (src->param_list);
|
||||||
dst->param_fcns = g_slist_copy (src->param_fcns);
|
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);
|
g_slist_free (s->param_list);
|
||||||
s->param_list = NULL;
|
s->param_list = NULL;
|
||||||
@@ -271,12 +276,12 @@ static void free_members (QofQuery *q)
|
|||||||
q->results = NULL;
|
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)
|
gconstpointer a, gconstpointer b)
|
||||||
{
|
{
|
||||||
GSList *node;
|
GSList *node;
|
||||||
gpointer conva, convb;
|
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 (sort, 0);
|
||||||
g_return_val_if_fail (default_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);
|
qt = (QofQueryTerm *)(and_ptr->data);
|
||||||
if (qt->param_fcns && qt->pred_fcn) {
|
if (qt->param_fcns && qt->pred_fcn) {
|
||||||
GSList *node;
|
GSList *node;
|
||||||
QofQueryAccess get_fcn;
|
QofAccessFunc get_fcn;
|
||||||
gpointer conv_obj = object;
|
gpointer conv_obj = object;
|
||||||
|
|
||||||
/* iterate through the conversions */
|
/* 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).
|
* returns NULL if the first parameter is bad (and final is unchanged).
|
||||||
*/
|
*/
|
||||||
static GSList * compile_params (GSList *param_list, GNCIdType start_obj,
|
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;
|
GSList *fcns = NULL;
|
||||||
|
|
||||||
g_return_val_if_fail (param_list, 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) {
|
for (; param_list; param_list = param_list->next) {
|
||||||
GNCIdType param_name = param_list->data;
|
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 it doesn't exist, then we've reached the end */
|
||||||
if (!objDef)
|
if (!objDef)
|
||||||
@@ -428,9 +433,10 @@ static GSList * compile_params (GSList *param_list, GNCIdType start_obj,
|
|||||||
return (g_slist_reverse (fcns));
|
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;
|
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? */
|
/* Hrm, perhaps this is an object compare, not a core compare? */
|
||||||
if (sort->comp_fcn == NULL)
|
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))
|
} else if (!safe_strcmp (sort->param_list->data, QUERY_DEFAULT_SORT))
|
||||||
sort->use_default = TRUE;
|
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 (or_ptr = q->terms; or_ptr; or_ptr = or_ptr->next) {
|
||||||
for (and_ptr = or_ptr->data; and_ptr; and_ptr = and_ptr->next) {
|
for (and_ptr = or_ptr->data; and_ptr; and_ptr = and_ptr->next) {
|
||||||
QofQueryTerm *qt = and_ptr->data;
|
QofQueryTerm *qt = and_ptr->data;
|
||||||
const QueryObjectDef *resObj = NULL;
|
const QofQueryObject *resObj = NULL;
|
||||||
|
|
||||||
g_slist_free (qt->param_fcns);
|
g_slist_free (qt->param_fcns);
|
||||||
qt->param_fcns = NULL;
|
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->secondary_sort), q->search_for);
|
||||||
compile_sort (&(q->tertiary_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 */
|
/* Now compile the backend instances */
|
||||||
for (node = q->books; node; node = node->next) {
|
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)
|
static void check_item_cb (gpointer object, gpointer user_data)
|
||||||
{
|
{
|
||||||
query_cb_t *ql = user_data;
|
QofQueryCB *ql = user_data;
|
||||||
|
|
||||||
if (!object || !ql) return;
|
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 */
|
/* Now run the query over all the objects and save the results */
|
||||||
{
|
{
|
||||||
query_cb_t qcb;
|
QofQueryCB qcb;
|
||||||
|
|
||||||
memset (&qcb, 0, sizeof (qcb));
|
memset (&qcb, 0, sizeof (qcb));
|
||||||
qcb.query = q;
|
qcb.query = q;
|
||||||
@@ -1172,12 +1178,12 @@ void qof_query_init (void)
|
|||||||
{
|
{
|
||||||
PINFO("New Query Module Initialization");
|
PINFO("New Query Module Initialization");
|
||||||
qof_query_core_init ();
|
qof_query_core_init ();
|
||||||
gncQueryObjectInit ();
|
qof_query_object_init ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void qof_query_shutdown (void)
|
void qof_query_shutdown (void)
|
||||||
{
|
{
|
||||||
gncQueryObjectShutdown ();
|
qof_query_object_shutdown ();
|
||||||
qof_query_core_shutdown ();
|
qof_query_core_shutdown ();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1220,8 +1226,8 @@ gboolean qof_query_term_is_inverted (QofQueryTerm_t qt)
|
|||||||
return qt->invert;
|
return qt->invert;
|
||||||
}
|
}
|
||||||
|
|
||||||
void qof_query_get_sorts (QofQuery *q, QofQuerySort_t *primary,
|
void qof_query_get_sorts (QofQuery *q, QofQuerySort **primary,
|
||||||
QofQuerySort_t *secondary, QofQuerySort_t *tertiary)
|
QofQuerySort **secondary, QofQuerySort **tertiary)
|
||||||
{
|
{
|
||||||
if (!q)
|
if (!q)
|
||||||
return;
|
return;
|
||||||
@@ -1233,21 +1239,21 @@ void qof_query_get_sorts (QofQuery *q, QofQuerySort_t *primary,
|
|||||||
*tertiary = &(q->tertiary_sort);
|
*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)
|
if (!qs)
|
||||||
return NULL;
|
return NULL;
|
||||||
return qs->param_list;
|
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)
|
if (!qs)
|
||||||
return 0;
|
return 0;
|
||||||
return qs->options;
|
return qs->options;
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean qof_query_sort_get_increasing (QofQuerySort_t qs)
|
gboolean qof_query_sort_get_increasing (QofQuerySort *qs)
|
||||||
{
|
{
|
||||||
if (!qs)
|
if (!qs)
|
||||||
return FALSE;
|
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);
|
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 TRUE;
|
||||||
if (!qs1 || !qs2) return FALSE;
|
if (!qs1 || !qs2) return FALSE;
|
||||||
@@ -1322,7 +1328,7 @@ gboolean qof_query_equal (QofQuery *q1, QofQuery *q2)
|
|||||||
/* Static prototypes */
|
/* Static prototypes */
|
||||||
static GList *qof_query_printSearchFor (QofQuery * query, GList * output);
|
static GList *qof_query_printSearchFor (QofQuery * query, GList * output);
|
||||||
static GList *qof_query_printTerms (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);
|
GList * output);
|
||||||
static GList *qof_query_printAndTerms (GList * terms, GList * output);
|
static GList *qof_query_printAndTerms (GList * terms, GList * output);
|
||||||
static gchar *qof_query_printStringForHow (QofQueryCompare how);
|
static gchar *qof_query_printStringForHow (QofQueryCompare how);
|
||||||
@@ -1345,7 +1351,7 @@ qof_query_print (QofQuery * query)
|
|||||||
{
|
{
|
||||||
GList *output;
|
GList *output;
|
||||||
GString *str;
|
GString *str;
|
||||||
QofQuerySort_t s[3];
|
QofQuerySort *s[3];
|
||||||
gint maxResults = 0, numSorts = 3;
|
gint maxResults = 0, numSorts = 3;
|
||||||
|
|
||||||
ENTER (" ");
|
ENTER (" ");
|
||||||
@@ -1447,7 +1453,7 @@ qof_query_printTerms (QofQuery * query, GList * output)
|
|||||||
not null.
|
not null.
|
||||||
*/
|
*/
|
||||||
static GList *
|
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;
|
GSList *gsl = NULL;
|
||||||
gint curSort;
|
gint curSort;
|
||||||
@@ -1546,7 +1552,7 @@ qof_query_printPredData (QofQueryPredData *pd)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
Get a string representation for the
|
Get a string representation for the
|
||||||
QofQueryCompare enum type.
|
QofCompareFunc enum type.
|
||||||
*/
|
*/
|
||||||
static gchar *
|
static gchar *
|
||||||
qof_query_printStringForHow (QofQueryCompare how)
|
qof_query_printStringForHow (QofQueryCompare how)
|
||||||
|
|||||||
@@ -42,21 +42,21 @@ void qof_query_core_shutdown (void);
|
|||||||
* the Query internals), compare the object's parameter to the
|
* the Query internals), compare the object's parameter to the
|
||||||
* predicate data
|
* predicate data
|
||||||
*/
|
*/
|
||||||
typedef int (*QueryPredicate) (gpointer object,
|
typedef int (*QofQueryPredicateFunc) (gpointer object,
|
||||||
QofQueryAccess get_fcn,
|
QofAccessFunc get_fcn,
|
||||||
QofQueryPredData *pdata);
|
QofQueryPredData *pdata);
|
||||||
|
|
||||||
/* A callback for how to compare two (same-type) objects based on a
|
/* A callback for how to compare two (same-type) objects based on a
|
||||||
* common get_fcn (parameter member), using the provided comparrison
|
* common get_fcn (parameter member), using the provided comparrison
|
||||||
* options (which are the type-specific options).
|
* options (which are the type-specific options).
|
||||||
*/
|
*/
|
||||||
typedef int (*QueryCompare) (gpointer a, gpointer b,
|
typedef int (*QofCompareFunc) (gpointer a, gpointer b,
|
||||||
gint compare_options,
|
gint compare_options,
|
||||||
QofQueryAccess get_fcn);
|
QofAccessFunc get_fcn);
|
||||||
|
|
||||||
/* Lookup functions */
|
/* Lookup functions */
|
||||||
QueryPredicate qof_query_core_get_predicate (char const *type);
|
QofQueryPredicateFunc qof_query_core_get_predicate (char const *type);
|
||||||
QueryCompare qof_query_core_get_compare (char const *type);
|
QofCompareFunc qof_query_core_get_compare (char const *type);
|
||||||
|
|
||||||
/* Compare two predicates */
|
/* Compare two predicates */
|
||||||
gboolean qof_query_core_predicate_equal (QofQueryPredData *p1, QofQueryPredData *p2);
|
gboolean qof_query_core_predicate_equal (QofQueryPredData *p1, QofQueryPredData *p2);
|
||||||
|
|||||||
@@ -39,12 +39,12 @@ typedef void (*QueryPredDataFree) (QofQueryPredData *pdata);
|
|||||||
typedef QofQueryPredData *(*QueryPredicateCopy) (QofQueryPredData *pdata);
|
typedef QofQueryPredData *(*QueryPredicateCopy) (QofQueryPredData *pdata);
|
||||||
|
|
||||||
/* A function to take the object, apply the get_fcn, and return
|
/* 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.
|
* be returning a type equal to this core object type.
|
||||||
*
|
*
|
||||||
* Note that this string MUST be freed by the caller.
|
* 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 */
|
/* A function to test for equality of predicate data */
|
||||||
typedef gboolean (*QueryPredicateEqual) (QofQueryPredData *p1,
|
typedef gboolean (*QueryPredicateEqual) (QofQueryPredData *p1,
|
||||||
@@ -55,8 +55,8 @@ typedef gboolean (*QueryPredicateEqual) (QofQueryPredData *p1,
|
|||||||
* query_predicate, predicate_copy, and predicate_data_free functions.
|
* query_predicate, predicate_copy, and predicate_data_free functions.
|
||||||
*/
|
*/
|
||||||
static void gncQueryRegisterCoreObject (char const *type_name,
|
static void gncQueryRegisterCoreObject (char const *type_name,
|
||||||
QueryPredicate pred,
|
QofQueryPredicateFunc pred,
|
||||||
QueryCompare comp,
|
QofCompareFunc comp,
|
||||||
QueryPredicateCopy copy,
|
QueryPredicateCopy copy,
|
||||||
QueryPredDataFree pd_free,
|
QueryPredDataFree pd_free,
|
||||||
QueryToString to_string,
|
QueryToString to_string,
|
||||||
@@ -138,7 +138,7 @@ static GHashTable *predEqualTable = NULL;
|
|||||||
|
|
||||||
/* QOF_QUERYCORE_STRING */
|
/* 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)
|
QofQueryPredData *pd)
|
||||||
{
|
{
|
||||||
query_string_t pdata = (query_string_t) 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,
|
static int string_compare_func (gpointer a, gpointer b, gint options,
|
||||||
QofQueryAccess get_fcn)
|
QofAccessFunc get_fcn)
|
||||||
{
|
{
|
||||||
const char *s1, *s2;
|
const char *s1, *s2;
|
||||||
g_return_val_if_fail (a && b && get_fcn, COMPARE_ERROR);
|
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);
|
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);
|
const char *res = ((query_string_getter)get)(object);
|
||||||
if (res)
|
if (res)
|
||||||
@@ -284,7 +284,7 @@ static int date_compare (Timespec ta, Timespec tb, QofDateMatch options)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int date_match_predicate (gpointer object, QofQueryAccess get_fcn,
|
static int date_match_predicate (gpointer object, QofAccessFunc get_fcn,
|
||||||
QofQueryPredData *pd)
|
QofQueryPredData *pd)
|
||||||
{
|
{
|
||||||
query_date_t pdata = (query_date_t)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,
|
static int date_compare_func (gpointer a, gpointer b, gint options,
|
||||||
QofQueryAccess get_fcn)
|
QofAccessFunc get_fcn)
|
||||||
{
|
{
|
||||||
Timespec ta, tb;
|
Timespec ta, tb;
|
||||||
|
|
||||||
@@ -370,7 +370,7 @@ qof_query_date_predicate (QofQueryCompare how,
|
|||||||
return ((QofQueryPredData*)pdata);
|
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);
|
Timespec ts = ((query_date_getter)get)(object);
|
||||||
|
|
||||||
@@ -382,7 +382,7 @@ static char * date_to_string (gpointer object, QofQueryAccess get)
|
|||||||
|
|
||||||
/* QOF_QUERYCORE_NUMERIC */
|
/* 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)
|
QofQueryPredData* pd)
|
||||||
{
|
{
|
||||||
query_numeric_t pdata = (query_numeric_t)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,
|
static int numeric_compare_func (gpointer a, gpointer b, gint options,
|
||||||
QofQueryAccess get_fcn)
|
QofAccessFunc get_fcn)
|
||||||
{
|
{
|
||||||
gnc_numeric va, vb;
|
gnc_numeric va, vb;
|
||||||
|
|
||||||
@@ -486,14 +486,14 @@ qof_query_numeric_predicate (QofQueryCompare how,
|
|||||||
return ((QofQueryPredData*)pdata);
|
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);
|
gnc_numeric num = ((query_numeric_getter)get)(object);
|
||||||
|
|
||||||
return g_strdup (gnc_numeric_to_string (num));
|
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);
|
gnc_numeric num = ((query_numeric_getter)get)(object);
|
||||||
|
|
||||||
@@ -502,7 +502,7 @@ static char * debcred_to_string (gpointer object, QofQueryAccess get)
|
|||||||
|
|
||||||
/* QOF_QUERYCORE_GUID */
|
/* 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)
|
QofQueryPredData *pd)
|
||||||
{
|
{
|
||||||
query_guid_t pdata = (query_guid_t)pd;
|
query_guid_t pdata = (query_guid_t)pd;
|
||||||
@@ -662,7 +662,7 @@ qof_query_guid_predicate (QofGuidMatch options, GList *guids)
|
|||||||
/* ================================================================ */
|
/* ================================================================ */
|
||||||
/* QOF_QUERYCORE_INT32 */
|
/* 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)
|
QofQueryPredData *pd)
|
||||||
{
|
{
|
||||||
gint32 val;
|
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,
|
static int int32_compare_func (gpointer a, gpointer b, gint options,
|
||||||
QofQueryAccess get_fcn)
|
QofAccessFunc get_fcn)
|
||||||
{
|
{
|
||||||
gint32 v1, v2;
|
gint32 v1, v2;
|
||||||
g_return_val_if_fail (a && b && get_fcn, COMPARE_ERROR);
|
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);
|
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);
|
gint32 num = ((query_int32_getter)get)(object);
|
||||||
|
|
||||||
@@ -749,7 +749,7 @@ static char * int32_to_string (gpointer object, QofQueryAccess get)
|
|||||||
/* ================================================================ */
|
/* ================================================================ */
|
||||||
/* QOF_QUERYCORE_INT64 */
|
/* 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)
|
QofQueryPredData *pd)
|
||||||
{
|
{
|
||||||
gint64 val;
|
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,
|
static int int64_compare_func (gpointer a, gpointer b, gint options,
|
||||||
QofQueryAccess get_fcn)
|
QofAccessFunc get_fcn)
|
||||||
{
|
{
|
||||||
gint64 v1, v2;
|
gint64 v1, v2;
|
||||||
g_return_val_if_fail (a && b && get_fcn, COMPARE_ERROR);
|
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);
|
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);
|
gint64 num = ((query_int64_getter)get)(object);
|
||||||
|
|
||||||
@@ -836,7 +836,7 @@ static char * int64_to_string (gpointer object, QofQueryAccess get)
|
|||||||
/* ================================================================ */
|
/* ================================================================ */
|
||||||
/* QOF_QUERYCORE_DOUBLE */
|
/* 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)
|
QofQueryPredData *pd)
|
||||||
{
|
{
|
||||||
double val;
|
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,
|
static int double_compare_func (gpointer a, gpointer b, gint options,
|
||||||
QofQueryAccess get_fcn)
|
QofAccessFunc get_fcn)
|
||||||
{
|
{
|
||||||
double v1, v2;
|
double v1, v2;
|
||||||
g_return_val_if_fail (a && b && get_fcn, COMPARE_ERROR);
|
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);
|
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);
|
double num = ((query_double_getter)get)(object);
|
||||||
|
|
||||||
@@ -922,7 +922,7 @@ static char * double_to_string (gpointer object, QofQueryAccess get)
|
|||||||
|
|
||||||
/* QOF_QUERYCORE_BOOLEAN */
|
/* 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)
|
QofQueryPredData *pd)
|
||||||
{
|
{
|
||||||
gboolean val;
|
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,
|
static int boolean_compare_func (gpointer a, gpointer b, gint options,
|
||||||
QofQueryAccess get_fcn)
|
QofAccessFunc get_fcn)
|
||||||
{
|
{
|
||||||
gboolean va, vb;
|
gboolean va, vb;
|
||||||
g_return_val_if_fail (a && b && get_fcn, COMPARE_ERROR);
|
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);
|
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);
|
gboolean num = ((query_boolean_getter)get)(object);
|
||||||
|
|
||||||
@@ -1001,7 +1001,7 @@ static char * boolean_to_string (gpointer object, QofQueryAccess get)
|
|||||||
|
|
||||||
/* QOF_QUERYCORE_CHAR */
|
/* 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)
|
QofQueryPredData *pd)
|
||||||
{
|
{
|
||||||
char c;
|
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,
|
static int char_compare_func (gpointer a, gpointer b, gint options,
|
||||||
QofQueryAccess get_fcn)
|
QofAccessFunc get_fcn)
|
||||||
{
|
{
|
||||||
char va, vb;
|
char va, vb;
|
||||||
g_return_val_if_fail (a && b && get_fcn, COMPARE_ERROR);
|
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);
|
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);
|
char num = ((query_char_getter)get)(object);
|
||||||
|
|
||||||
@@ -1082,7 +1082,7 @@ static char * char_to_string (gpointer object, QofQueryAccess get)
|
|||||||
|
|
||||||
/* QOF_QUERYCORE_KVP */
|
/* 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)
|
QofQueryPredData *pd)
|
||||||
{
|
{
|
||||||
int compare;
|
int compare;
|
||||||
@@ -1195,8 +1195,8 @@ static void init_tables (void)
|
|||||||
unsigned int i;
|
unsigned int i;
|
||||||
struct {
|
struct {
|
||||||
char const *name;
|
char const *name;
|
||||||
QueryPredicate pred;
|
QofQueryPredicateFunc pred;
|
||||||
QueryCompare comp;
|
QofCompareFunc comp;
|
||||||
QueryPredicateCopy copy;
|
QueryPredicateCopy copy;
|
||||||
QueryPredDataFree pd_free;
|
QueryPredDataFree pd_free;
|
||||||
QueryToString toString;
|
QueryToString toString;
|
||||||
@@ -1263,8 +1263,8 @@ static QueryPredDataFree gncQueryCoreGetPredFree (char const *type)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void gncQueryRegisterCoreObject (char const *core_name,
|
static void gncQueryRegisterCoreObject (char const *core_name,
|
||||||
QueryPredicate pred,
|
QofQueryPredicateFunc pred,
|
||||||
QueryCompare comp,
|
QofCompareFunc comp,
|
||||||
QueryPredicateCopy copy,
|
QueryPredicateCopy copy,
|
||||||
QueryPredDataFree pd_free,
|
QueryPredDataFree pd_free,
|
||||||
QueryToString toString,
|
QueryToString toString,
|
||||||
@@ -1325,19 +1325,22 @@ void qof_query_core_shutdown (void)
|
|||||||
g_hash_table_destroy (predEqualTable);
|
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);
|
g_return_val_if_fail (type, NULL);
|
||||||
return g_hash_table_lookup (predTable, type);
|
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);
|
g_return_val_if_fail (type, NULL);
|
||||||
return g_hash_table_lookup (cmpTable, type);
|
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;
|
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,
|
char * qof_query_core_to_string (char const *type, gpointer object,
|
||||||
QofQueryAccess get)
|
QofAccessFunc get)
|
||||||
{
|
{
|
||||||
QueryToString toString;
|
QueryToString toString;
|
||||||
|
|
||||||
|
|||||||
@@ -40,14 +40,14 @@ typedef const char * QofQueryCoreType;
|
|||||||
|
|
||||||
typedef struct _QofQueryPredData QofQueryPredData;
|
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
|
* for access functions. This is needed because C doesn't have
|
||||||
* templates, so we just cast a lot. Real functions must be of
|
* templates, so we just cast a lot. Real functions must be of
|
||||||
* the form:
|
* the form:
|
||||||
*
|
*
|
||||||
* <param_type> function (object_type *obj);
|
* <param_type> function (object_type *obj);
|
||||||
*/
|
*/
|
||||||
typedef gpointer (*QofQueryAccess)(gpointer);
|
typedef gpointer (*QofAccessFunc)(gpointer);
|
||||||
|
|
||||||
/** Standard Query comparitors, for how to compare objects in a predicate.
|
/** Standard Query comparitors, for how to compare objects in a predicate.
|
||||||
* Note that not all core types implement all comparitors
|
* Note that not all core types implement all comparitors
|
||||||
@@ -86,14 +86,15 @@ typedef enum {
|
|||||||
|
|
||||||
#define QOF_QUERYCORE_GUID "guid"
|
#define QOF_QUERYCORE_GUID "guid"
|
||||||
typedef enum {
|
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_ANY = 1,
|
||||||
QOF_GUID_MATCH_NONE,
|
QOF_GUID_MATCH_NONE,
|
||||||
QOF_GUID_MATCH_NULL,
|
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 */
|
* on each item in the list to obtain a GUID* for each object */
|
||||||
QOF_GUID_MATCH_ALL,
|
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) */
|
* to return a GList* of GUID* (the list is the property of the caller) */
|
||||||
QOF_GUID_MATCH_LIST_ANY,
|
QOF_GUID_MATCH_LIST_ANY,
|
||||||
} QofGuidMatch;
|
} QofGuidMatch;
|
||||||
@@ -114,7 +115,7 @@ typedef enum {
|
|||||||
/** Head of Predicate Data structures. All PData must start like this. */
|
/** Head of Predicate Data structures. All PData must start like this. */
|
||||||
struct _QofQueryPredData {
|
struct _QofQueryPredData {
|
||||||
QofQueryCoreType type_name; /* QUERYCORE_* */
|
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.
|
* to g_free() the returned string.
|
||||||
*/
|
*/
|
||||||
char * qof_query_core_to_string (char const *type, gpointer object,
|
char * qof_query_core_to_string (char const *type, gpointer object,
|
||||||
QofQueryAccess fcn);
|
QofAccessFunc fcn);
|
||||||
|
|
||||||
#endif /* QOF_QUERYCORE_H */
|
#endif /* QOF_QUERYCORE_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 <warlord@MIT.EDU> *
|
* Copyright (C) 2002 Derek Atkins <warlord@MIT.EDU> *
|
||||||
* *
|
* *
|
||||||
* This program is free software; you can redistribute it and/or *
|
* This program is free software; you can redistribute it and/or *
|
||||||
@@ -21,14 +21,15 @@
|
|||||||
* *
|
* *
|
||||||
\********************************************************************/
|
\********************************************************************/
|
||||||
|
|
||||||
#ifndef GNC_QUERYOBJECTP_H
|
#ifndef QOF_QUERYOBJECTP_H
|
||||||
#define GNC_QUERYOBJECTP_H
|
#define QOF_QUERYOBJECTP_H
|
||||||
|
|
||||||
#include "QueryObject.h"
|
#include "GNCId.h"
|
||||||
|
#include "qofqueryobject.h"
|
||||||
|
|
||||||
void gncQueryObjectInit(void);
|
void qof_query_object_init(void);
|
||||||
void gncQueryObjectShutdown (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 */
|
||||||
@@ -26,7 +26,7 @@
|
|||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
|
||||||
#include "gnc-engine-util.h"
|
#include "gnc-engine-util.h"
|
||||||
#include "QueryObjectP.h"
|
#include "qofqueryobject-p.h"
|
||||||
#include "qofquery.h"
|
#include "qofquery.h"
|
||||||
|
|
||||||
static short module = MOD_QUERY;
|
static short module = MOD_QUERY;
|
||||||
@@ -44,9 +44,9 @@ static gboolean clear_table (gpointer key, gpointer value, gpointer user_data)
|
|||||||
/********************************************************************/
|
/********************************************************************/
|
||||||
/* PUBLISHED API FUNCTIONS */
|
/* PUBLISHED API FUNCTIONS */
|
||||||
|
|
||||||
void gncQueryObjectRegister (GNCIdTypeConst obj_name,
|
void qof_query_object_register (GNCIdTypeConst obj_name,
|
||||||
QuerySort default_sort_function,
|
QofSortFunc default_sort_function,
|
||||||
const QueryObjectDef *params)
|
const QofQueryObject *params)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@@ -72,7 +72,7 @@ void gncQueryObjectRegister (GNCIdTypeConst obj_name,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gncQueryObjectInit(void)
|
void qof_query_object_init(void)
|
||||||
{
|
{
|
||||||
if (initialized) return;
|
if (initialized) return;
|
||||||
initialized = TRUE;
|
initialized = TRUE;
|
||||||
@@ -81,7 +81,7 @@ void gncQueryObjectInit(void)
|
|||||||
sortTable = g_hash_table_new (g_str_hash, g_str_equal);
|
sortTable = g_hash_table_new (g_str_hash, g_str_equal);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gncQueryObjectShutdown (void)
|
void qof_query_object_shutdown (void)
|
||||||
{
|
{
|
||||||
if (!initialized) return;
|
if (!initialized) return;
|
||||||
initialized = FALSE;
|
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)
|
const char *parameter)
|
||||||
{
|
{
|
||||||
GHashTable *ht;
|
GHashTable *ht;
|
||||||
@@ -108,35 +108,36 @@ const QueryObjectDef * gncQueryObjectGetParameter (GNCIdTypeConst obj_name,
|
|||||||
return (g_hash_table_lookup (ht, parameter));
|
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 char *parameter)
|
||||||
{
|
{
|
||||||
const QueryObjectDef *obj;
|
const QofQueryObject *obj;
|
||||||
|
|
||||||
g_return_val_if_fail (obj_name, NULL);
|
g_return_val_if_fail (obj_name, NULL);
|
||||||
g_return_val_if_fail (parameter, NULL);
|
g_return_val_if_fail (parameter, NULL);
|
||||||
|
|
||||||
obj = gncQueryObjectGetParameter (obj_name, parameter);
|
obj = qof_query_object_get_parameter (obj_name, parameter);
|
||||||
if (obj)
|
if (obj)
|
||||||
return obj->param_getfcn;
|
return obj->param_getfcn;
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
QofQueryCoreType gncQueryObjectParameterType (GNCIdTypeConst obj_name,
|
QofQueryCoreType qof_query_object_parameter_type (GNCIdTypeConst obj_name,
|
||||||
const char *param_name)
|
const char *param_name)
|
||||||
{
|
{
|
||||||
const QueryObjectDef *obj;
|
const QofQueryObject *obj;
|
||||||
|
|
||||||
if (!obj_name || !param_name) return NULL;
|
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;
|
if (!obj) return NULL;
|
||||||
|
|
||||||
return (obj->param_type);
|
return (obj->param_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
QuerySort gncQueryObjectDefaultSort (GNCIdTypeConst obj_name)
|
QofSortFunc
|
||||||
|
qof_query_object_default_sort (GNCIdTypeConst obj_name)
|
||||||
{
|
{
|
||||||
if (!obj_name) return NULL;
|
if (!obj_name) return NULL;
|
||||||
return g_hash_table_lookup (sortTable, obj_name);
|
return g_hash_table_lookup (sortTable, obj_name);
|
||||||
94
src/engine/qofqueryobject.h
Normal file
94
src/engine/qofqueryobject.h
Normal file
@@ -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 <warlord@MIT.EDU>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#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 */
|
||||||
@@ -6,10 +6,10 @@
|
|||||||
#include "gnc-engine-util.h"
|
#include "gnc-engine-util.h"
|
||||||
#include "messages.h"
|
#include "messages.h"
|
||||||
|
|
||||||
#include "QueryObjectP.h"
|
|
||||||
#include "qofquery.h"
|
#include "qofquery.h"
|
||||||
#include "qofquerycore.h"
|
#include "qofquerycore.h"
|
||||||
#include "qofquerycore-p.h"
|
#include "qofquerycore-p.h"
|
||||||
|
#include "qofqueryobject-p.h"
|
||||||
|
|
||||||
#include "test-stuff.h"
|
#include "test-stuff.h"
|
||||||
|
|
||||||
@@ -30,39 +30,39 @@ static int test_core_param (gpointer a)
|
|||||||
|
|
||||||
static void test_query_object (void)
|
static void test_query_object (void)
|
||||||
{
|
{
|
||||||
static QueryObjectDef params[] = {
|
static QofQueryObject params[] = {
|
||||||
{ TEST_PARAM, TEST_CORE, (QofQueryAccess)test_core_param },
|
{ TEST_PARAM, TEST_CORE, (QofAccessFunc)test_core_param },
|
||||||
{ NULL },
|
{ NULL },
|
||||||
};
|
};
|
||||||
|
|
||||||
fprintf (stderr, "\tTesting the QueryObject interface. \n"
|
fprintf (stderr, "\tTesting the QueryObject interface. \n"
|
||||||
"\tYou may see some \"** CRITICAL **\" messages, which you can safely ignore\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)
|
do_test (qof_query_object_get_parameter (TEST_MODULE_NAME, TEST_PARAM)
|
||||||
== ¶ms[0], "gncQueryObjectGetParameter");
|
== ¶ms[0], "qof_query_object_get_parameter");
|
||||||
do_test (gncQueryObjectGetParameter (NULL, NULL) == NULL,
|
do_test (qof_query_object_get_parameter (NULL, NULL) == NULL,
|
||||||
"gncQueryObjectGetParamter (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)");
|
"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)");
|
"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)");
|
"gncQueryObjectGetParamter (NULL, TEST_PARAM)");
|
||||||
|
|
||||||
do_test (gncQueryObjectGetParameterGetter (TEST_MODULE_NAME, TEST_PARAM)
|
do_test (qof_query_object_get_parameter_getter (TEST_MODULE_NAME, TEST_PARAM)
|
||||||
== (QofQueryAccess)test_core_param,
|
== (QofAccessFunc)test_core_param,
|
||||||
"gncQueryObjectGetParameterGetter");
|
"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_PARAM),
|
||||||
TEST_CORE) == 0, "gncQueryObjectParameterType");
|
TEST_CORE) == 0, "qof_query_object_parameter_type");
|
||||||
|
|
||||||
do_test (gncQueryObjectDefaultSort (TEST_MODULE_NAME) == test_sort,
|
do_test (qof_query_object_default_sort (TEST_MODULE_NAME) == test_sort,
|
||||||
"gncQueryObjectDefaultSort");
|
"qof_query_object_default_sort");
|
||||||
do_test (gncQueryObjectDefaultSort (NULL) == NULL,
|
do_test (qof_query_object_default_sort (NULL) == NULL,
|
||||||
"gncQueryObjectDefaultSort (NULL)");
|
"qof_query_object_default_sort (NULL)");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_query_core (void)
|
static void test_query_core (void)
|
||||||
|
|||||||
@@ -99,54 +99,73 @@ foreach (@files)
|
|||||||
# s/QUERY_PARAM_GUID/QOF_QUERY_PARAM_GUID/g;
|
# s/QUERY_PARAM_GUID/QOF_QUERY_PARAM_GUID/g;
|
||||||
# s/QUERY_PARAM_ACTIVE/QOF_QUERY_PARAM_ACTIVE/g;
|
# s/QUERY_PARAM_ACTIVE/QOF_QUERY_PARAM_ACTIVE/g;
|
||||||
|
|
||||||
s/querynew_s/_QofQuery/g;
|
# s/querynew_s/_QofQuery/g;
|
||||||
s/QueryNew/QofQuery/g;
|
# s/QueryNew/QofQuery/g;
|
||||||
s/QueryOp/QofQueryOp/g;
|
# s/QueryOp/QofQueryOp/g;
|
||||||
s/query_new_term/_QofQueryTerm/g;
|
# s/query_new_term/_QofQueryTerm/g;
|
||||||
s/query_new_sort/_QofQuerySort/g;
|
# s/query_new_sort/_QofQuerySort/g;
|
||||||
|
|
||||||
s/gncQueryBuildParamList/qof_query_build_param_list/g;
|
# s/gncQueryBuildParamList/qof_query_build_param_list/g;
|
||||||
s/gncQueryCreateFor/qof_query_create_for/g;
|
# s/gncQueryCreate/qof_query_create/g;
|
||||||
s/gncQueryCreate/qof_query_create/g;
|
# s/gncQueryCreateFor/qof_query_create_for/g;
|
||||||
s/gncQueryDestroy/qof_query_destroy/g;
|
# s/gncQueryDestroy/qof_query_destroy/g;
|
||||||
s/gncQuerySearchFor/qof_query_search_for/g;
|
# s/gncQuerySearchFor/qof_query_search_for/g;
|
||||||
s/gncQuerySetBook/qof_query_set_book/g;
|
# s/gncQuerySetBook/qof_query_set_book/g;
|
||||||
s/gncQueryAddTerm/qof_query_add_term/g;
|
# s/gncQueryAddTerm/qof_query_add_term/g;
|
||||||
s/gncQueryAddGUIDMatch/qof_query_add_guid_match/g;
|
# s/gncQueryAddGUIDMatch/qof_query_add_guid_match/g;
|
||||||
s/gncQueryAddGUIDListMatch/qof_query_add_guid_list_match/g;
|
# s/gncQueryAddGUIDListMatch/qof_query_add_guid_list_match/g;
|
||||||
s/gncQueryAddBooleanMatch/qof_query_add_boolean_match/g;
|
# s/gncQueryAddBooleanMatch/qof_query_add_boolean_match/g;
|
||||||
s/gncQueryRun/qof_query_run/g;
|
# s/gncQueryRun/qof_query_run/g;
|
||||||
s/gncQueryLastRun/qof_query_last_run/g;
|
# s/gncQueryLastRun/qof_query_last_run/g;
|
||||||
s/gncQueryClear/qof_query_clear/g;
|
# s/gncQueryClear/qof_query_clear/g;
|
||||||
s/gncQueryPurgeTerms/qof_query_purge_terms/g;
|
# s/gncQueryPurgeTerms/qof_query_purge_terms/g;
|
||||||
s/gncQueryHasTerms/qof_query_has_terms/g;
|
# s/gncQueryHasTerms/qof_query_has_terms/g;
|
||||||
s/gncQueryNumTerms/qof_query_num_terms/g;
|
# s/gncQueryNumTerms/qof_query_num_terms/g;
|
||||||
s/gncQueryHasTermType/qof_query_has_term_type/g;
|
# s/gncQueryHasTermType/qof_query_has_term_type/g;
|
||||||
s/gncQueryCopy/qof_query_copy/g;
|
# s/gncQueryCopy/qof_query_copy/g;
|
||||||
s/gncQueryInvert/qof_query_invert/g;
|
# s/gncQueryInvert/qof_query_invert/g;
|
||||||
s/gncQueryMergeInPlace/qof_query_merges_ins_place/g;
|
# s/gncQueryMerge/qof_query_merge/g;
|
||||||
s/gncQueryMerge/qof_query_merge/g;
|
# s/gncQueryMergeInPlace/qof_query_merges_ins_place/g;
|
||||||
s/gncQuerySetSortOrder/qof_query_set_sort_order/g;
|
# s/gncQuerySetSortOrder/qof_query_set_sort_order/g;
|
||||||
s/gncQuerySetSortOptions/qof_query_set_sort_options/g;
|
# s/gncQuerySetSortOptions/qof_query_set_sort_options/g;
|
||||||
s/gncQuerySetSortIncreasing/qof_query_set_sort_increasing/g;
|
# s/gncQuerySetSortIncreasing/qof_query_set_sort_increasing/g;
|
||||||
s/gncQuerySetMaxResults/qof_query_set_max_results/g;
|
# s/gncQuerySetMaxResults/qof_query_set_max_results/g;
|
||||||
s/gncQueryEqual/qof_query_equal/g;
|
# s/gncQueryEqual/qof_query_equal/g;
|
||||||
s/gncQueryPrint/qof_query_print/g;
|
# s/gncQueryPrint/qof_query_print/g;
|
||||||
s/gncQueryGetSearchFor/qof_query_get_search_for/g;
|
# s/gncQueryGetSearchFor/qof_query_get_search_for/g;
|
||||||
s/gncQueryGetBooks/qof_query_get_books/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 $_;
|
print OF $_;
|
||||||
}
|
}
|
||||||
close OF;
|
close OF;
|
||||||
|
|||||||
Reference in New Issue
Block a user