GnuCash  2.6.99
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Query.h
1 /********************************************************************\
2  * Query.h : api for finding transactions *
3  * Copyright 2000 Bill Gribble <[email protected]> *
4  * Copyright 2002 Linas Vepstas <[email protected]> *
5  * *
6  * This program is free software; you can redistribute it and/or *
7  * modify it under the terms of the GNU General Public License as *
8  * published by the Free Software Foundation; either version 2 of *
9  * the License, or (at your option) any later version. *
10  * *
11  * This program is distributed in the hope that it will be useful, *
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14  * GNU General Public License for more details. *
15  * *
16  * You should have received a copy of the GNU General Public License*
17  * along with this program; if not, contact: *
18  * *
19  * Free Software Foundation Voice: +1-617-542-5942 *
20  * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
21  * Boston, MA 02110-1301, USA [email protected] *
22 \********************************************************************/
23 
24 #ifndef GNUCASH_QUERY_H
25 #define GNUCASH_QUERY_H
26 
27 #include <sys/types.h>
28 #include <time.h>
29 #include <glib.h>
30 #include "qof.h"
31 #include "Account.h"
32 
33 /*
34  * This function defines a compatibility API from the old Query API to
35  * the new Query API. Note that it is not a 100% complete equivalent.
36  * Many functions have a one-to-one mapping in the new API, but many
37  * others do not.
38  */
39 
40 typedef QofQuery Query;
41 
42 typedef enum
43 {
44  QUERY_TXN_MATCH_ALL = 1, /* match all accounts */
45  QUERY_TXN_MATCH_ANY = 2 /* match any account */
46 } query_txn_match_t;
47 
48 /* After the query has been set up, call one of these to run the query.
49  * XXX The routines below should be replaced by a query
50  * that explicitly asks for a list of the desired item.
51  *
52  * The xaccQueryGetSplits() routine returns all splits matching the
53  * query. Any given split will appear at most once in the result;
54  * however, several splits from one transaction may appear in the list.
55  * The caller MUST NOT change the GList.
56  */
57 
65 SplitList * xaccQueryGetSplitsUniqueTrans(QofQuery *q);
66 
88 TransList * xaccQueryGetTransactions(QofQuery * q, query_txn_match_t type);
89 
95 LotList * xaccQueryGetLots(QofQuery * q, query_txn_match_t type);
96 
97 /*******************************************************************
98  * match-adding API
99  *******************************************************************/
100 
101 void xaccQueryAddAccountMatch(QofQuery *, AccountList *,
102  QofGuidMatch how, QofQueryOp op);
103 
104 void xaccQueryAddAccountGUIDMatch(QofQuery *, AccountGUIDList *,
106 
107 void xaccQueryAddSingleAccountMatch(QofQuery *, Account *, QofQueryOp);
108 
109 void xaccQueryAddStringMatch (QofQuery* q, const char *matchstring,
110  gboolean case_sens, gboolean use_regexp,
111  QofQueryCompare how, QofQueryOp op,
112  const char * path, ...);
113 void
114 xaccQueryAddDescriptionMatch(QofQuery *q, const char *m, gboolean c, gboolean r,
115  QofQueryCompare how, QofQueryOp o);
116 void
117 xaccQueryAddNotesMatch(QofQuery *q, const char *m, gboolean c, gboolean r,
118  QofQueryCompare how, QofQueryOp o);
119 void
120 xaccQueryAddNumberMatch(QofQuery *q, const char *m, gboolean c, gboolean r,
121  QofQueryCompare how, QofQueryOp o);
122 void
123 xaccQueryAddActionMatch(QofQuery *q, const char *m, gboolean c, gboolean r,
124  QofQueryCompare how, QofQueryOp o);
125 void
126 xaccQueryAddMemoMatch(QofQuery *q, const char *m, gboolean c, gboolean r,
127  QofQueryCompare how, QofQueryOp o);
128 void
129 xaccQueryAddValueMatch(QofQuery *q, gnc_numeric amt, QofNumericMatch sgn,
130  QofQueryCompare how, QofQueryOp op);
131 void
132 xaccQueryAddSharePriceMatch(QofQuery *q, gnc_numeric amt, QofQueryCompare how,
133  QofQueryOp op);
134 void
135 xaccQueryAddSharesMatch(QofQuery *q, gnc_numeric amt, QofQueryCompare how,
136  QofQueryOp op);
137 void
138 xaccQueryAddBalanceMatch(QofQuery *q, QofQueryCompare bal, QofQueryOp op);
139 
140 void xaccQueryAddNumericMatch (QofQuery *q, gnc_numeric amount,
142  QofQueryOp op, const char * path, ...);
143 
153 void xaccQueryAddDateMatch(QofQuery * q, gboolean use_start,
154  int sday, int smonth, int syear,
155  gboolean use_end, int eday, int emonth, int eyear,
156  QofQueryOp op);
157 void xaccQueryAddDateMatchTS(QofQuery * q,
158  gboolean use_start, Timespec sts,
159  gboolean use_end, Timespec ets,
160  QofQueryOp op);
161 void xaccQueryAddDateMatchTT(QofQuery * q,
162  gboolean use_start, time64 stt,
163  gboolean use_end, time64 ett,
164  QofQueryOp op);
165 void xaccQueryGetDateMatchTS (QofQuery * q,
166  Timespec * sts,
167  Timespec * ets);
168 void xaccQueryGetDateMatchTT (QofQuery * q,
169  time64 * stt,
170  time64 * ett);
171 
172 void xaccQueryAddClosingTransMatch(QofQuery *q, gboolean value, QofQueryOp op);
173 
174 typedef enum
175 {
176  CLEARED_NONE = 0x0000,
177  CLEARED_NO = 0x0001,
178  CLEARED_CLEARED = 0x0002,
179  CLEARED_RECONCILED = 0x0004,
180  CLEARED_FROZEN = 0x0008,
181  CLEARED_VOIDED = 0x0010,
182  CLEARED_ALL = 0x001F
183 } cleared_match_t;
184 
185 void xaccQueryAddClearedMatch(QofQuery * q, cleared_match_t how, QofQueryOp op);
186 void xaccQueryAddGUIDMatch(QofQuery * q, const GncGUID *guid,
187  QofIdType id_type, QofQueryOp op);
188 
190 void xaccQueryAddKVPMatch(QofQuery *q, GSList *path, const KvpValue *value,
191  QofQueryCompare how, QofIdType id_type,
192  QofQueryOp op);
193 
194 /*******************************************************************
195  * compatibility interface with old QofQuery API
196  *******************************************************************/
197 time64 xaccQueryGetEarliestDateFound(QofQuery * q);
198 time64 xaccQueryGetLatestDateFound(QofQuery * q);
199 
200 #endif
GList TransList
Definition: gnc-engine.h:205
GList LotList
Definition: gnc-engine.h:201
Use a 64-bit unsigned int timespec.
Definition: gnc-date.h:299
struct _QofQuery QofQuery
Definition: qofquery.h:90
Definition: guid.h:65
const gchar * QofIdType
Definition: qofid.h:85
GList SplitList
Definition: gnc-engine.h:203
Account handling public routines.
QofGuidMatch
Definition: qofquerycore.h:110
QofQueryCompare
Definition: qofquerycore.h:55
QofQueryOp
Definition: qofquery.h:93
GList AccountList
Definition: gnc-engine.h:199
GList AccountGUIDList
Definition: gnc-engine.h:207
gint64 time64
Definition: gnc-date.h:83
QofNumericMatch
Definition: qofquerycore.h:102
struct KvpValueImpl KvpValue
Definition: kvp_frame.h:80