From 8f63db0411b456e1a5b05b8a9ee7fe0f7c983a73 Mon Sep 17 00:00:00 2001 From: Derek Atkins Date: Fri, 28 Jun 2002 04:20:46 +0000 Subject: [PATCH] create xaccQueryAddGUIDMatchGL() and wrap it. This is a special function that takes a GUID (instead of a const GUID *) and a GList (instead of a GSList) and performs an gncQueryAddGUIDMatch(). Add Lots to the query infrastructure, so we can add Lot-based lookups and queries. Add SPLIT_LOT parameter and wrap it. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@7041 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/engine/Query.c | 16 ++++++++++++++++ src/engine/Query.h | 2 ++ src/engine/Transaction.c | 1 + src/engine/Transaction.h | 1 + src/engine/gnc-engine.c | 2 ++ src/engine/gnc-lot-p.h | 3 +++ src/engine/gnc-lot.c | 12 ++++++++++++ src/engine/gw-engine-spec.scm | 10 ++++++++++ 8 files changed, 47 insertions(+) diff --git a/src/engine/Query.c b/src/engine/Query.c index f8d3142917..a8ce5c728e 100644 --- a/src/engine/Query.c +++ b/src/engine/Query.c @@ -514,6 +514,22 @@ xaccQueryAddGUIDMatch(Query * q, const GUID *guid, gncQueryAddGUIDMatch (q, param_list, guid, op); } +void +xaccQueryAddGUIDMatchGL (QueryNew *q, GList *param_list, + GUID guid, QueryOp op) +{ + GSList *params = NULL; + GList *node; + + for (node = param_list; node; node = node->next) + params = g_slist_prepend (params, node->data); + + params = g_slist_reverse (params); + g_list_free (param_list); + + gncQueryAddGUIDMatch (q, params, &guid, op); +} + void xaccQueryAddKVPMatch(Query *q, GSList *path, const kvp_value *value, query_compare_t how, GNCIdType id_type, diff --git a/src/engine/Query.h b/src/engine/Query.h index 1335a5fc50..29e02a5841 100644 --- a/src/engine/Query.h +++ b/src/engine/Query.h @@ -202,6 +202,8 @@ typedef enum { void xaccQueryAddClearedMatch(Query * q, cleared_match_t how, QueryOp op); void xaccQueryAddGUIDMatch(Query * q, const GUID *guid, GNCIdType id_type, QueryOp op); +void xaccQueryAddGUIDMatchGL (QueryNew *q, GList *param_list, + GUID guid, QueryOp op); /* given kvp value is on right side of comparison */ void xaccQueryAddKVPMatch(Query *q, GSList *path, const kvp_value *value, diff --git a/src/engine/Transaction.c b/src/engine/Transaction.c index 3470d491db..160a79ae0a 100644 --- a/src/engine/Transaction.c +++ b/src/engine/Transaction.c @@ -3206,6 +3206,7 @@ gboolean xaccSplitRegister (void) (QueryAccess)xaccSplitVoidFormerAmount }, { SPLIT_VOIDED_VALUE, QUERYCORE_NUMERIC, (QueryAccess)xaccSplitVoidFormerValue }, + { SPLIT_LOT, GNC_ID_LOT, (QueryAccess)xaccSplitGetLot }, { SPLIT_TRANS, GNC_ID_TRANS, (QueryAccess)xaccSplitGetParent }, { SPLIT_ACCOUNT, GNC_ID_ACCOUNT, (QueryAccess)xaccSplitGetAccount }, { SPLIT_ACCOUNT_GUID, QUERYCORE_GUID, split_account_guid_getter }, diff --git a/src/engine/Transaction.h b/src/engine/Transaction.h index 6bf7fe7570..02f9399664 100644 --- a/src/engine/Transaction.h +++ b/src/engine/Transaction.h @@ -536,6 +536,7 @@ Timespec xaccTransGetVoidTime(Transaction *tr); #define SPLIT_TYPE "type" #define SPLIT_VOIDED_AMOUNT "voided-amount" #define SPLIT_VOIDED_VALUE "voided-value" +#define SPLIT_LOT "lot" #define SPLIT_TRANS "trans" #define SPLIT_ACCOUNT "account" #define SPLIT_ACCOUNT_GUID "account-guid" /* for guid_match_all */ diff --git a/src/engine/gnc-engine.c b/src/engine/gnc-engine.c index 3e040159e9..8d4d2c9ec3 100644 --- a/src/engine/gnc-engine.c +++ b/src/engine/gnc-engine.c @@ -33,6 +33,7 @@ #include "TransactionP.h" #include "AccountP.h" #include "gnc-book-p.h" +#include "gnc-lot-p.h" static GList * engine_init_hooks = NULL; static int engine_is_initialized = 0; @@ -84,6 +85,7 @@ gnc_engine_init(int argc, char ** argv) xaccTransRegister (); xaccAccountRegister (); gnc_book_register (); + gnc_lot_register (); /* call any engine hooks */ for (cur = engine_init_hooks; cur; cur = cur->next) diff --git a/src/engine/gnc-lot-p.h b/src/engine/gnc-lot-p.h index 3d2d295be4..0ec101ac9e 100644 --- a/src/engine/gnc-lot-p.h +++ b/src/engine/gnc-lot-p.h @@ -67,5 +67,8 @@ struct gnc_lot_struct void gnc_lot_set_guid(GNCLot *lot, GUID guid); +/* Register with the Query engine */ +void gnc_lot_register (void); + #endif /* GNC_LOT_P_H */ diff --git a/src/engine/gnc-lot.c b/src/engine/gnc-lot.c index 9e97cf90d9..b11c83378f 100644 --- a/src/engine/gnc-lot.c +++ b/src/engine/gnc-lot.c @@ -42,6 +42,7 @@ #include "gnc-lot-p.h" #include "Transaction.h" #include "TransactionP.h" +#include "QueryObject.h" /* This static indicates the debugging module that this .o belongs to. */ static short module = MOD_LOT; @@ -261,4 +262,15 @@ gnc_lot_remove_split (GNCLot *lot, Split *split) } } +void gnc_lot_register (void) +{ + static const QueryObjectDef params[] = { + { QUERY_PARAM_BOOK, GNC_ID_BOOK, (QueryAccess)gnc_lot_get_book }, + { QUERY_PARAM_GUID, QUERYCORE_GUID, (QueryAccess)gnc_lot_get_guid }, + { NULL }, + }; + + gncQueryObjectRegister (GNC_ID_LOT, NULL, params); +} + /* ========================== END OF FILE ========================= */ diff --git a/src/engine/gw-engine-spec.scm b/src/engine/gw-engine-spec.scm index 14075c29fe..77e714b7ca 100644 --- a/src/engine/gw-engine-spec.scm +++ b/src/engine/gw-engine-spec.scm @@ -264,6 +264,7 @@ ; Definitions for query parameter names ; (gw:wrap-value ws 'gnc:query-default-sort ' "QUERY_DEFAULT_SORT") +(gw:wrap-value ws 'gnc:split-lot ' "SPLIT_LOT") (gw:wrap-value ws 'gnc:split-trans ' "SPLIT_TRANS") (gw:wrap-value ws 'gnc:split-account ' "SPLIT_ACCOUNT") (gw:wrap-value ws 'gnc:split-value ' "SPLIT_VALUE") @@ -1880,6 +1881,15 @@ of having a parent transaction with which one is working...") '(( q) ( cleared-how) ( how)) "match splits against the cleared state.") +(gw:wrap-function + ws + 'gnc:query-add-guid-match + ' + "xaccQueryAddGUIDMatchGL" + '(( q) ((gw:glist-of callee-owned) param_path) + ( guid) ( how)) + "Add a GUID match against the specified param_path") + (gw:wrap-function ws 'gnc:query-set-sort-order