GnuCash  5.6-150-g038405b370+
qofquerycore.h
Go to the documentation of this file.
1 /********************************************************************\
2  * qofquerycore.h -- API for providing core Query data types *
3  * Copyright (C) 2002 Derek Atkins <warlord@MIT.EDU> *
4  * *
5  * This program is free software; you can redistribute it and/or *
6  * modify it under the terms of the GNU General Public License as *
7  * published by the Free Software Foundation; either version 2 of *
8  * the License, or (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License*
16  * along with this program; if not, contact: *
17  * *
18  * Free Software Foundation Voice: +1-617-542-5942 *
19  * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
20  * Boston, MA 02110-1301, USA gnu@gnu.org *
21  * *
22 \********************************************************************/
23 
32 #ifndef QOF_QUERYCORE_H
33 #define QOF_QUERYCORE_H
34 
35 #include "gnc-numeric.h"
36 #include "gnc-date.h"
37 #include "qofclass.h"
38 
39 #ifdef __cplusplus
40 extern "C"
41 {
42 #endif
43 
49 typedef struct _QofQueryPredData QofQueryPredData;
50 
54 typedef enum
55 {
56  QOF_COMPARE_LT = 1,
57  QOF_COMPARE_LTE,
58  QOF_COMPARE_EQUAL,
59  QOF_COMPARE_GT,
60  QOF_COMPARE_GTE,
61  QOF_COMPARE_NEQ,
62  QOF_COMPARE_CONTAINS,
63  QOF_COMPARE_NCONTAINS
65 
69 /* Comparisons for QOF_TYPE_STRING */
70 typedef enum
71 {
72  QOF_STRING_MATCH_NORMAL = 1,
73  QOF_STRING_MATCH_CASEINSENSITIVE
75 
83 typedef enum
84 {
85  QOF_DATE_MATCH_NORMAL = 1,
86  QOF_DATE_MATCH_DAY
87 } QofDateMatch;
88 
101 typedef enum
102 {
103  QOF_NUMERIC_MATCH_DEBIT = 1,
104  QOF_NUMERIC_MATCH_CREDIT,
105  QOF_NUMERIC_MATCH_ANY
107 
108 /* Comparisons for QOF_TYPE_GUID */
109 typedef enum
110 {
114  QOF_GUID_MATCH_NONE,
115  QOF_GUID_MATCH_NULL,
122 } QofGuidMatch;
123 
132 typedef enum
133 {
134  QOF_CHAR_MATCH_ANY = 1,
135  QOF_CHAR_MATCH_NONE
136 } QofCharMatch;
137 
144 {
145  QofType type_name; /* QOF_TYPE_* */
146  QofQueryCompare how;
147 };
148 
151 typedef GSList QofQueryParamList;
152 
155 QofQueryPredData *qof_query_string_predicate (QofQueryCompare how,
156  const gchar *str,
157  QofStringMatch options,
158  gboolean is_regex);
159 
160 QofQueryPredData *qof_query_date_predicate (QofQueryCompare how,
161  QofDateMatch options,
162  time64 date);
163 
164 QofQueryPredData *qof_query_numeric_predicate (QofQueryCompare how,
165  QofNumericMatch options,
166  gnc_numeric value);
167 
168 QofQueryPredData *qof_query_guid_predicate (QofGuidMatch options, GList *guids);
169 QofQueryPredData *qof_query_int32_predicate (QofQueryCompare how, gint32 val);
170 QofQueryPredData *qof_query_int64_predicate (QofQueryCompare how, gint64 val);
171 QofQueryPredData *qof_query_double_predicate (QofQueryCompare how, double val);
172 QofQueryPredData *qof_query_boolean_predicate (QofQueryCompare how, gboolean val);
173 QofQueryPredData *qof_query_char_predicate (QofCharMatch options,
174  const gchar *chars);
175 QofQueryPredData *qof_query_collect_predicate (QofGuidMatch options,
176  QofCollection *coll);
177 QofQueryPredData *qof_query_choice_predicate (QofGuidMatch options, GList *guids);
178 
180 QofQueryPredData *qof_query_core_predicate_copy (const QofQueryPredData *pdata);
181 
183 void qof_query_core_predicate_free (QofQueryPredData *pdata);
184 
186 gboolean qof_query_date_predicate_get_date (const QofQueryPredData *pd, time64 *date);
187 gboolean qof_query_char_predicate_get_char (const QofQueryPredData *pd, char **chars);
188 
192 char * qof_query_core_to_string (QofType, gpointer object, QofParam *getter);
193 
198 int qof_string_number_compare_func (gpointer a, gpointer b, gint options,
199  QofParam *this_param);
200 
201 
202 #ifdef __cplusplus
203 }
204 #endif
205 
206 #endif /* QOF_QUERYCORE_H */
207 /* @} */
208 /* @} */
Date and Time handling routines.
void qof_query_core_predicate_free(QofQueryPredData *pdata)
Destroy a predicate.
const char * QofType
Type of Parameters (String, Date, Numeric, GncGUID, etc.)
Definition: qofclass.h:159
An exact-rational-number library for gnucash.
QofStringMatch
List of known core query data-types...
Definition: qofquerycore.h:70
These expect a single object and expect the QofAccessFunc returns GncGUID*.
Definition: qofquerycore.h:113
GSList QofQueryParamList
A list of parameters (QofIdType) used to describe a parameter to use in a predicate or when sorting...
Definition: qofquerycore.h:151
gboolean qof_query_date_predicate_get_date(const QofQueryPredData *pd, time64 *date)
Retrieve a predicate.
QofGuidMatch
Definition: qofquerycore.h:109
char * qof_query_core_to_string(QofType, gpointer object, QofParam *getter)
Return a printable string for a core data object.
QofQueryCompare
Standard Query comparators, for how to compare objects in a predicate.
Definition: qofquerycore.h:54
QofCharMatch
A CHAR type is for a RECNCell, Comparisons for QOF_TYPE_CHAR &#39;ANY&#39; will match any character in the st...
Definition: qofquerycore.h:132
These expect a single object and expect the QofAccessFunc function to return a GList* of GncGUID* (th...
Definition: qofquerycore.h:121
These expect a GList* of objects and calls the QofAccessFunc routine on each item in the list to obta...
Definition: qofquerycore.h:118
API for registering parameters on objects.
No extended comparisons for QOF_TYPE_INT32, QOF_TYPE_INT64, QOF_TYPE_DOUBLE, QOF_TYPE_BOOLEAN.
Definition: qofquerycore.h:143
int qof_string_number_compare_func(gpointer a, gpointer b, gint options, QofParam *this_param)
Compare two parameter(strings) as if they are numbers! the two objects, a and b, are the objects bein...
QofDateMatch
Comparisons for QOF_TYPE_DATE The QOF_DATE_MATCH_DAY comparison rounds the two time values to mid-day...
Definition: qofquerycore.h:83
gint64 time64
Most systems that are currently maintained, including Microsoft Windows, BSD-derived Unixes and Linux...
Definition: gnc-date.h:87
QofQueryPredData * qof_query_core_predicate_copy(const QofQueryPredData *pdata)
Copy a predicate.
QofNumericMatch
Comparisons for QOF_TYPE_NUMERIC, QOF_TYPE_DEBCRED.
Definition: qofquerycore.h:101