GnuCash 2.4.99
qofquery.h
Go to the documentation of this file.
00001 /********************************************************************\
00002  * qofquery.h -- find objects that match a certain expression.      *
00003  *                                                                  *
00004  * This program is free software; you can redistribute it and/or    *
00005  * modify it under the terms of the GNU General Public License as   *
00006  * published by the Free Software Foundation; either version 2 of   *
00007  * the License, or (at your option) any later version.              *
00008  *                                                                  *
00009  * This program is distributed in the hope that it will be useful,  *
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
00012  * GNU General Public License for more details.                     *
00013  *                                                                  *
00014  * You should have received a copy of the GNU General Public License*
00015  * along with this program; if not, contact:                        *
00016  *                                                                  *
00017  * Free Software Foundation           Voice:  +1-617-542-5942       *
00018  * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
00019  * Boston, MA  02110-1301,  USA       gnu@gnu.org                   *
00020  *                                                                  *
00021 \********************************************************************/
00022 
00074 #ifndef QOF_QUERYNEW_H
00075 #define QOF_QUERYNEW_H
00076 
00077 #include "guid.h"
00078 #include "qofbook.h"
00079 #include "qofquerycore.h"
00080 #include "qofchoice.h"
00081 
00082 #define QOF_MOD_QUERY "qof.query"
00083 
00085 typedef struct _QofQuery QofQuery;
00086 
00088 typedef enum
00089 {
00090     QOF_QUERY_AND = 1,
00091     QOF_QUERY_OR,
00092     QOF_QUERY_NAND,
00093     QOF_QUERY_NOR,
00094     QOF_QUERY_XOR
00095 } QofQueryOp;
00096 
00098 #define QOF_QUERY_FIRST_TERM QOF_QUERY_AND
00099 
00101 #define QUERY_DEFAULT_SORT      "QofQueryDefaultSort"
00102 
00104 #define QOF_PARAM_BOOK    "book"
00105 #define QOF_PARAM_GUID    "guid"
00106 
00108 #define QOF_PARAM_KVP     "kvp"
00109 #define QOF_PARAM_ACTIVE  "active"
00110 #define QOF_PARAM_VERSION "version"
00111 
00112 /* --------------------------------------------------------- */
00114 // @{
00121 void qof_query_init (void);
00122 void qof_query_shutdown (void);
00123 // @}
00124 
00125 /* --------------------------------------------------------- */
00127 // @{
00128 
00129 QofQueryParamList * qof_query_build_param_list (char const *param, ...);
00130 
00140 QofQuery * qof_query_create (void);
00141 QofQuery * qof_query_create_for (QofIdTypeConst obj_type);
00142 
00144 void qof_query_destroy (QofQuery *q);
00145 
00149 void qof_query_search_for (QofQuery *query, QofIdTypeConst obj_type);
00150 
00160 void qof_query_set_book (QofQuery *q, QofBook *book);
00161 
00162 
00187 void qof_query_add_term (QofQuery *query, QofQueryParamList *param_list,
00188                          QofQueryPredData *pred_data, QofQueryOp op);
00189 
00191 void qof_query_add_guid_match (QofQuery *q, QofQueryParamList *param_list,
00192                                const GncGUID *guid, QofQueryOp op);
00194 void qof_query_add_guid_list_match (QofQuery *q, QofQueryParamList *param_list,
00195                                     GList *guid_list, QofGuidMatch options,
00196                                     QofQueryOp op);
00197 
00202 void qof_query_add_boolean_match (QofQuery *q,
00203                                   QofQueryParamList *param_list,
00204                                   gboolean value,
00205                                   QofQueryOp op);
00206 
00217 GList * qof_query_run (QofQuery *query);
00218 
00223 GList * qof_query_last_run (QofQuery *query);
00224 
00232 GList * qof_query_run_subquery (QofQuery *subquery,
00233                                 const QofQuery* primary_query);
00234 
00238 void qof_query_clear (QofQuery *query);
00239 
00246 void qof_query_purge_terms (QofQuery *q, QofQueryParamList *param_list);
00247 
00252 int qof_query_has_terms (QofQuery *q);
00253 
00256 int qof_query_num_terms (QofQuery *q);
00257 
00259 gboolean qof_query_has_term_type (QofQuery *q, QofQueryParamList *term_param);
00260 GSList * qof_query_get_term_type (QofQuery *q, QofQueryParamList *term_param);
00261 
00263 QofQuery * qof_query_copy (QofQuery *q);
00264 
00276 QofQuery * qof_query_invert(QofQuery *q);
00277 
00296 QofQuery * qof_query_merge(QofQuery *q1, QofQuery *q2, QofQueryOp op);
00297 
00301 void qof_query_merge_in_place(QofQuery *q1, QofQuery *q2, QofQueryOp op);
00302 
00323 void qof_query_set_sort_order (QofQuery *q,
00324                                QofQueryParamList *primary_sort_params,
00325                                QofQueryParamList *secondary_sort_params,
00326                                QofQueryParamList *tertiary_sort_params);
00327 
00328 void qof_query_set_sort_options (QofQuery *q, gint prim_op, gint sec_op,
00329                                  gint tert_op);
00330 
00342 void qof_query_set_sort_increasing (QofQuery *q, gboolean prim_inc,
00343                                     gboolean sec_inc, gboolean tert_inc);
00344 
00345 
00356 void qof_query_set_max_results (QofQuery *q, int n);
00357 
00364 gboolean qof_query_equal (const QofQuery *q1, const QofQuery *q2);
00365 
00372 void qof_query_print (QofQuery *query);
00373 
00375 /*@ dependent @*/
00376 QofIdType qof_query_get_search_for (const QofQuery *q);
00377 
00379 GList * qof_query_get_books (QofQuery *q);
00380 
00381 // @}
00382 /* @} */
00383 #endif /* QOF_QUERYNEW_H */
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines