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