Add xaccQueryCopy api call.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@3346 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Dave Peticolas 2000-12-22 12:41:28 +00:00
parent 30e728d81f
commit ce09e164fc
2 changed files with 37 additions and 3 deletions

View File

@ -40,7 +40,7 @@
#include "Group.h"
#include "Query.h"
static short module = MOD_QUERY;
/* static short module = MOD_QUERY; */
/* the Query makes a subset of all splits based on 3 things:
* - an AND-OR tree of predicates which combine to make a
@ -272,8 +272,8 @@ copy_or_terms(GList * or_terms) {
* allocated it
********************************************************************/
void
xaccFreeQuery(Query * q) {
static void
xaccFreeQueryMembers(Query *q) {
GList * cur_or;
if (q == NULL)
@ -296,10 +296,43 @@ xaccFreeQuery(Query * q) {
g_list_free(q->split_list);
q->split_list = NULL;
}
void
xaccFreeQuery(Query * q) {
if (q == NULL)
return;
xaccFreeQueryMembers (q);
g_free(q);
}
Query *
xaccQueryCopy(Query *q) {
Query *copy;
if (q == NULL)
return NULL;
copy = xaccMallocQuery ();
xaccFreeQueryMembers (copy);
copy->terms = copy_or_terms (q->terms);
copy->primary_sort = q->primary_sort;
copy->secondary_sort = q->secondary_sort;
copy->tertiary_sort = q->tertiary_sort;
copy->sort_increasing = q->sort_increasing;
copy->max_splits = q->max_splits;
copy->changed = q->changed;
copy->acct_group = q->acct_group;
copy->split_list = g_list_copy (q->split_list);
return copy;
}
/********************************************************************
* xaccQueryInvert

View File

@ -172,6 +172,7 @@ typedef struct {
Query * xaccMallocQuery(void);
void xaccFreeQuery(Query *);
Query * xaccQueryCopy(Query *q);
void xaccQuerySetGroup(Query * q, AccountGroup * group);
Query * xaccQueryInvert(Query * q1);
Query * xaccQueryMerge(Query * q1, Query * q2, QueryOp op);