qofquerycore-p.h

00001 /********************************************************************\
00002  * qofquerycore-p.h -- Private API for providing core Query data types *
00003  * Copyright (C) 2002 Derek Atkins <warlord@MIT.EDU>                *
00004  *                                                                  *
00005  * This program is free software; you can redistribute it and/or    *
00006  * modify it under the terms of the GNU General Public License as   *
00007  * published by the Free Software Foundation; either version 2 of   *
00008  * the License, or (at your option) any later version.              *
00009  *                                                                  *
00010  * This program is distributed in the hope that it will be useful,  *
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
00013  * GNU General Public License for more details.                     *
00014  *                                                                  *
00015  * You should have received a copy of the GNU General Public License*
00016  * along with this program; if not, contact:                        *
00017  *                                                                  *
00018  * Free Software Foundation           Voice:  +1-617-542-5942       *
00019  * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
00020  * Boston, MA  02110-1301,  USA       gnu@gnu.org                   *
00021  *                                                                  *
00022 \********************************************************************/
00023 
00024 #ifndef QOF_QUERYCOREP_H
00025 #define QOF_QUERYCOREP_H
00026 
00027 #include <sys/types.h>
00028 #include <time.h>
00029 #include <regex.h>
00030 #include <string.h>
00031 
00032 #include "qofquerycore.h"
00033 
00034 /* Initalize the Query Core registry and install the default type handlers */
00035 void qof_query_core_init(void);
00036 void qof_query_core_shutdown (void);
00037 
00038 /* 
00039  * An arbitrary Query Predicate.  Given the object and the
00040  * particular parameter get-function (obtained from the registry by
00041  * the Query internals), compare the object's parameter to the
00042  * predicate data.
00043  */
00044 typedef gint (*QofQueryPredicateFunc) (gpointer object,
00045                                QofParam *getter,
00046                                QofQueryPredData *pdata);
00047 
00048 /* A callback for how to compare two (same-type) objects based on a
00049  * common getter (parameter member), using the provided comparison
00050  * options (which are the type-specific options).
00051  */
00052 typedef gint (*QofCompareFunc) (gpointer a, gpointer b,
00053                               gint compare_options,
00054                               QofParam *getter);
00055 
00056 /* Lookup functions */
00057 QofQueryPredicateFunc qof_query_core_get_predicate (gchar const *type);
00058 QofCompareFunc qof_query_core_get_compare (gchar const *type);
00059 
00060 /* Compare two predicates */
00061 gboolean qof_query_core_predicate_equal (QofQueryPredData *p1, QofQueryPredData *p2);
00062 
00063 /* Predicate Data Structures:
00064  *
00065  * These are defined such that you can cast between these types and
00066  * a QofQueryPredData.
00067  *
00068  * Note that these are provided for READ ONLY PURPOSES.  You should NEVER
00069  * write into these structures, change them, or use them to create a
00070  * Query.
00071  */
00072 
00073 typedef struct {
00074   QofQueryPredData      pd;
00075   QofStringMatch        options;
00076   gboolean              is_regex;
00077   gchar *               matchstring;
00078   regex_t               compiled;
00079 } query_string_def, *query_string_t;
00080 
00081 typedef struct {
00082   QofQueryPredData      pd;
00083   QofDateMatch  options;
00084   Timespec      date;
00085 } query_date_def, *query_date_t;
00086 
00087 typedef struct {
00088   QofQueryPredData      pd;
00089   QofNumericMatch       options;
00090   gnc_numeric           amount;
00091 } query_numeric_def, *query_numeric_t;
00092 
00093 typedef struct {
00094   QofQueryPredData      pd;
00095   QofGuidMatch  options;
00096   GList *       guids;
00097 } query_guid_def, *query_guid_t;
00098 
00099 typedef struct {
00100   QofQueryPredData      pd;
00101   gint32        val;
00102 } query_int32_def, *query_int32_t;
00103 
00104 typedef struct {
00105   QofQueryPredData      pd;
00106   gint64        val;
00107 } query_int64_def, *query_int64_t;
00108 
00109 typedef struct {
00110   QofQueryPredData      pd;
00111   double        val;
00112 } query_double_def, *query_double_t;
00113 
00114 typedef struct {
00115   QofQueryPredData      pd;
00116   gboolean      val;
00117 } query_boolean_def, *query_boolean_t;
00118 
00119 typedef struct {
00120   QofQueryPredData      pd;
00121   QofCharMatch  options;
00122   gchar *       char_list;
00123 } query_char_def, *query_char_t;
00124 
00125 typedef struct {
00126   QofQueryPredData      pd;
00127   GSList *      path;
00128   KvpValue *    value;
00129 } query_kvp_def, *query_kvp_t;
00130 
00131 typedef struct {
00132         QofQueryPredData pd;
00133         QofGuidMatch  options;
00134         QofCollection *coll;
00135         GList *guids;
00136 } query_coll_def, *query_coll_t;
00137 
00138 typedef struct {
00139         QofQueryPredData pd;
00140         QofGuidMatch options;
00141         const GUID *guid;
00142         GList * guids;
00143 } query_choice_def, *query_choice_t;
00144 
00145 #endif /* QOF_QUERYCOREP_H */

Generated on Fri May 12 17:57:20 2006 for QOF by  doxygen 1.4.4