GnuCash  5.6-150-g038405b370+
qofquery.h
Go to the documentation of this file.
1 /********************************************************************\
2  * qofquery.h -- find objects that match a certain expression. *
3  * *
4  * This program is free software; you can redistribute it and/or *
5  * modify it under the terms of the GNU General Public License as *
6  * published by the Free Software Foundation; either version 2 of *
7  * the License, or (at your option) any later version. *
8  * *
9  * This program is distributed in the hope that it will be useful, *
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12  * GNU General Public License for more details. *
13  * *
14  * You should have received a copy of the GNU General Public License*
15  * along with this program; if not, contact: *
16  * *
17  * Free Software Foundation Voice: +1-617-542-5942 *
18  * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
19  * Boston, MA 02110-1301, USA gnu@gnu.org *
20  * *
21 \********************************************************************/
22 
74 #ifndef QOF_QUERYNEW_H
75 #define QOF_QUERYNEW_H
76 
77 #include "guid.h"
78 #include "qofbook.h"
79 #include "qofquerycore.h"
80 
81 #ifdef __cplusplus
82 extern "C"
83 {
84 #endif
85 
86 #define QOF_MOD_QUERY "qof.query"
87 
89 typedef struct _QofQuery QofQuery;
90 
92 typedef enum
93 {
94  QOF_QUERY_AND = 1,
95  QOF_QUERY_OR,
96  QOF_QUERY_NAND,
97  QOF_QUERY_NOR,
98  QOF_QUERY_XOR
99 } QofQueryOp;
100 
102 #define QOF_QUERY_FIRST_TERM QOF_QUERY_AND
103 
105 #define QUERY_DEFAULT_SORT "QofQueryDefaultSort"
106 
108 #define QOF_PARAM_BOOK "book"
109 #define QOF_PARAM_GUID "guid"
110 
112 #define QOF_PARAM_KVP "kvp"
113 #define QOF_PARAM_ACTIVE "active"
114 #define QOF_PARAM_VERSION "version"
115 
116 /* --------------------------------------------------------- */
118 // @{
125 void qof_query_init (void);
126 void qof_query_shutdown (void);
127 // @}
128 
129 /* --------------------------------------------------------- */
131 // @{
132 
133 QofQueryParamList * qof_query_build_param_list (char const *param, ...);
134 
144 QofQuery * qof_query_create (void);
145 QofQuery * qof_query_create_for (QofIdTypeConst obj_type);
146 
148 void qof_query_destroy (QofQuery *q);
149 
153 void qof_query_search_for (QofQuery *query, QofIdTypeConst obj_type);
154 
164 void qof_query_set_book (QofQuery *q, QofBook *book);
165 
166 
191 void qof_query_add_term (QofQuery *query, QofQueryParamList *param_list,
192  QofQueryPredData *pred_data, QofQueryOp op);
193 
196  const GncGUID *guid, QofQueryOp op);
199  GList *guid_list, QofGuidMatch options,
200  QofQueryOp op);
201 
207  QofQueryParamList *param_list,
208  gboolean value,
209  QofQueryOp op);
210 
221 GList * qof_query_run (QofQuery *query);
222 
227 GList * qof_query_last_run (QofQuery *query);
228 
236 GList * qof_query_run_subquery (QofQuery *subquery,
237  const QofQuery* primary_query);
238 
242 void qof_query_clear (QofQuery *query);
243 
250 void qof_query_purge_terms (QofQuery *q, QofQueryParamList *param_list);
251 
257 
261 
263 gboolean qof_query_has_term_type (QofQuery *q, QofQueryParamList *term_param);
264 GSList * qof_query_get_term_type (QofQuery *q, QofQueryParamList *term_param);
265 
268 
281 
301 
306 
328  QofQueryParamList *primary_sort_params,
329  QofQueryParamList *secondary_sort_params,
330  QofQueryParamList *tertiary_sort_params);
331 
332 void qof_query_set_sort_options (QofQuery *q, gint prim_op, gint sec_op,
333  gint tert_op);
334 
346 void qof_query_set_sort_increasing (QofQuery *q, gboolean prim_inc,
347  gboolean sec_inc, gboolean tert_inc);
348 
349 
360 void qof_query_set_max_results (QofQuery *q, int n);
361 
368 gboolean qof_query_equal (const QofQuery *q1, const QofQuery *q2);
369 
371 /*@ dependent @*/
373 
375 GList * qof_query_get_books (QofQuery *q);
376 
377 // @}
378 /* @} */
379 #ifdef __cplusplus
380 }
381 #endif
382 
383 #endif /* QOF_QUERYNEW_H */
void qof_query_add_term(QofQuery *query, QofQueryParamList *param_list, QofQueryPredData *pred_data, QofQueryOp op)
This is the general function that adds a new Query Term to a query.
Definition: qofquery.cpp:681
void qof_query_set_sort_order(QofQuery *q, QofQueryParamList *primary_sort_params, QofQueryParamList *secondary_sort_params, QofQueryParamList *tertiary_sort_params)
When a query is run, the results are sorted before being returned.
Definition: qofquery.cpp:1249
void qof_query_purge_terms(QofQuery *q, QofQueryParamList *param_list)
Remove query terms of a particular type from q.
Definition: qofquery.cpp:705
const gchar * QofIdTypeConst
QofIdTypeConst declaration.
Definition: qofid.h:82
globally unique ID User API
QofQuery * qof_query_copy(QofQuery *q)
Make a copy of the indicated query.
Definition: qofquery.cpp:1018
gboolean qof_query_equal(const QofQuery *q1, const QofQuery *q2)
Compare two queries for equality.
Definition: qofquery.cpp:1472
void qof_query_set_sort_increasing(QofQuery *q, gboolean prim_inc, gboolean sec_inc, gboolean tert_inc)
When a query is run, the results are sorted before being returned.
Definition: qofquery.cpp:1280
GSList QofQueryParamList
A list of parameters (QofIdType) used to describe a parameter to use in a predicate or when sorting...
Definition: qofquerycore.h:151
void qof_query_set_max_results(QofQuery *q, int n)
Set the maximum number of results that should be returned.
Definition: qofquery.cpp:1289
const gchar * QofIdType
QofIdType declaration.
Definition: qofid.h:80
int qof_query_num_terms(QofQuery *q)
Return the number of terms in the canonical form of the query.
Definition: qofquery.cpp:954
API for providing core Query data types.
GList * qof_query_run_subquery(QofQuery *subquery, const QofQuery *primary_query)
Perform a subquery, return the results.
Definition: qofquery.cpp:880
void qof_query_destroy(QofQuery *q)
Frees the resources associate with a Query object.
QofGuidMatch
Definition: qofquerycore.h:109
void qof_query_init(void)
Subsystem initialization and shutdown.
Definition: qofquery.cpp:1360
void qof_query_set_book(QofQuery *q, QofBook *book)
Set the book to be searched.
QofQuery * qof_query_merge(QofQuery *q1, QofQuery *q2, QofQueryOp op)
Combine two queries together using the Boolean set (logical) operator 'op'.
Definition: qofquery.cpp:1129
QofQuery * qof_query_invert(QofQuery *q)
Make a copy of the indicated query, inverting the sense of the search.
Definition: qofquery.cpp:1050
void qof_query_clear(QofQuery *query)
Remove all query terms from query.
Definition: qofquery.cpp:905
gboolean qof_query_has_term_type(QofQuery *q, QofQueryParamList *term_param)
DOCUMENT ME !!
Definition: qofquery.cpp:964
void qof_query_add_guid_match(QofQuery *q, QofQueryParamList *param_list, const GncGUID *guid, QofQueryOp op)
DOCUMENT ME !!
Definition: qofquery.cpp:1310
Encapsulate all the information about a dataset.
GList * qof_query_last_run(QofQuery *query)
Return the results of the last query, without causing the query to be re-run.
Definition: qofquery.cpp:897
QofQueryOp
Query Term Operators, for combining Query Terms.
Definition: qofquery.h:92
GList * qof_query_run(QofQuery *query)
Perform the query, return the results.
QofIdType qof_query_get_search_for(const QofQuery *q)
Return the type of data we're querying for.
Definition: qofquery.cpp:1380
int qof_query_has_terms(QofQuery *q)
Return boolean FALSE if there are no terms in the query Can be used as a predicate to see if the quer...
Definition: qofquery.cpp:948
void qof_query_add_boolean_match(QofQuery *q, QofQueryParamList *param_list, gboolean value, QofQueryOp op)
Handy-dandy convenience routines, avoids having to create a separate predicate for boolean matches...
Definition: qofquery.cpp:1347
The type used to store guids in C.
Definition: guid.h:75
QofQuery * qof_query_create(void)
Create a new query.
Definition: qofquery.cpp:918
A Query.
Definition: qofquery.cpp:74
void qof_query_add_guid_list_match(QofQuery *q, QofQueryParamList *param_list, GList *guid_list, QofGuidMatch options, QofQueryOp op)
DOCUMENT ME !!
Definition: qofquery.cpp:1295
void qof_query_search_for(QofQuery *query, QofIdTypeConst obj_type)
Set the object type to be searched for.
Definition: qofquery.cpp:926
GList * qof_query_get_books(QofQuery *q)
Return the list of books we're using.
Definition: qofquery.cpp:1341
void qof_query_merge_in_place(QofQuery *q1, QofQuery *q2, QofQueryOp op)
Like qof_query_merge, but this will merge a copy of q2 into q1.
Definition: qofquery.cpp:1236