1
/********************************************************************\
2
* qofquerycore.h -- API for providing core Query data types *
3
* Copyright (C) 2002 Derek Atkins <warlord@MIT.EDU> *
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. *
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. *
15
* You should have received a copy of the GNU General Public License*
16
* along with this program; if not, contact: *
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 *
22
\********************************************************************/
27
/** @file qofquerycore.h
28
@brief API for providing core Query data types
29
@author Copyright (C) 2002 Derek Atkins <warlord@MIT.EDU>
32
#ifndef QOF_QUERYCORE_H
33
#define QOF_QUERYCORE_H
35
#include "gnc-numeric.h"
37
#include "kvp_frame.h"
41
* PREDICATE DATA TYPES: All the predicate data types are rolled up into
42
* the union type PredicateData. The "type" field specifies which type
45
typedef struct _QofQueryPredData QofQueryPredData;
47
/** Standard Query comparitors, for how to compare objects in a predicate.
48
* Note that not all core types implement all comparitors
59
/** List of known core query data-types...
60
* Each core query type defines it's set of optional "comparitor qualifiers".
62
/* Comparisons for QOF_TYPE_STRING */
64
QOF_STRING_MATCH_NORMAL = 1,
65
QOF_STRING_MATCH_CASEINSENSITIVE
68
/** Comparisons for QOF_TYPE_DATE
69
* The QOF_DATE_MATCH_DAY comparison rounds the two time
70
* values to mid-day and then compares these rounded values.
71
* The QOF_DATE_MATCH_NORMAL comparison matches the time values,
76
QOF_DATE_MATCH_NORMAL = 1,
80
/** Comparisons for QOF_TYPE_NUMERIC, QOF_TYPE_DEBCRED
82
* XXX Should be deprecated, or at least wrapped up as a convenience
83
* function, this is based on the old bill gribble code, which assumed
84
* the amount was always positive, and then specified a funds-flow
85
* direction (credit, debit, or either).
87
* The point being that 'match credit' is equivalent to the compound
88
* predicate (amount >= 0) && (amount 'op' value) while the 'match
89
* debit' predicate is equivalent to (amount <= 0) && (abs(amount) 'op' value)
93
QOF_NUMERIC_MATCH_DEBIT = 1,
94
QOF_NUMERIC_MATCH_CREDIT,
98
/* Comparisons for QOF_TYPE_GUID */
100
/** These expect a single object and expect the
101
* QofAccessFunc returns GUID* */
102
QOF_GUID_MATCH_ANY = 1,
105
/** These expect a GList* of objects and calls the QofAccessFunc routine
106
* on each item in the list to obtain a GUID* for each object */
108
/** These expect a single object and expect the QofAccessFunc function
109
* to return a GList* of GUID* (the list is the property of the caller) */
110
QOF_GUID_MATCH_LIST_ANY,
113
/** A CHAR type is for a RECNCell, Comparisons for QOF_TYPE_CHAR
114
* 'ANY' will match any charagter in the string.
116
* Match 'ANY' is a convenience/performance-enhanced predicate
117
* for the compound statement (value==char1) || (value==char2) || etc.
118
* Match 'NONE' is equivalent to
119
* (value != char1) && (value != char2) && etc.
122
QOF_CHAR_MATCH_ANY = 1,
126
/** No extended comparisons for QOF_TYPE_INT32, QOF_TYPE_INT64,
127
* QOF_TYPE_DOUBLE, QOF_TYPE_BOOLEAN, QOF_TYPE_KVP
130
/** Head of Predicate Data structures. All PData must start like this. */
131
struct _QofQueryPredData {
132
QofType type_name; /* QOF_TYPE_* */
137
/** @name Core Data Type Predicates
139
QofQueryPredData *qof_query_string_predicate (QofQueryCompare how,
141
QofStringMatch options,
144
QofQueryPredData *qof_query_date_predicate (QofQueryCompare how,
145
QofDateMatch options,
148
QofQueryPredData *qof_query_numeric_predicate (QofQueryCompare how,
149
QofNumericMatch options,
152
QofQueryPredData *qof_query_guid_predicate (QofGuidMatch options, GList *guids);
153
QofQueryPredData *qof_query_int32_predicate (QofQueryCompare how, gint32 val);
154
QofQueryPredData *qof_query_int64_predicate (QofQueryCompare how, gint64 val);
155
QofQueryPredData *qof_query_double_predicate (QofQueryCompare how, double val);
156
QofQueryPredData *qof_query_boolean_predicate (QofQueryCompare how, gboolean val);
157
QofQueryPredData *qof_query_char_predicate (QofCharMatch options,
159
QofQueryPredData *qof_query_collect_predicate (QofGuidMatch options,
160
QofCollection *coll);
161
QofQueryPredData *qof_query_choice_predicate (QofGuidMatch options, GList *guids);
163
/** The qof_query_kvp_predicate() matches the object that has
164
* the value 'value' located at the path 'path'. In a certain
165
* sense, the 'path' is handled as if it were a paramter.
167
QofQueryPredData *qof_query_kvp_predicate (QofQueryCompare how,
169
const KvpValue *value);
171
/** Same predicate as above, except that 'path' is assumed to be
172
* a string containing slash-separated pathname. */
173
QofQueryPredData *qof_query_kvp_predicate_path (QofQueryCompare how,
175
const KvpValue *value);
177
/** Copy a predicate. */
178
QofQueryPredData *qof_query_core_predicate_copy (QofQueryPredData *pdata);
180
/** Destroy a predicate. */
181
void qof_query_core_predicate_free (QofQueryPredData *pdata);
183
/** Retrieve a predicate. */
184
gboolean qof_query_date_predicate_get_date (QofQueryPredData *pd, Timespec *date);
185
/** Return a printable string for a core data object. Caller needs
186
* to g_free() the returned string.
188
char * qof_query_core_to_string (QofType, gpointer object, QofParam *getter);
190
/** Compare two parameter(strings) as if they are numbers!
191
* the two objects, a and b, are the objects being compared
192
* this_param is the QofParam for this parameter in the objects
194
int qof_string_number_compare_func (gpointer a, gpointer b, gint options,
195
QofParam *this_param);
198
#endif /* QOF_QUERYCORE_H */