1 /* gom-filter.h
2  *
3  * Copyright (C) 2011 Christian Hergert <chris@dronelabs.com>
4  *
5  * This file is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This file 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 GNU
13  * Lesser 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, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef GOM_FILTER_H
20 #define GOM_FILTER_H
21 
22 #include <glib-object.h>
23 
24 G_BEGIN_DECLS
25 
26 #define GOM_TYPE_FILTER            (gom_filter_get_type())
27 #define GOM_TYPE_FILTER_MODE       (gom_filter_mode_get_type())
28 #define GOM_FILTER(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GOM_TYPE_FILTER, GomFilter))
29 #define GOM_FILTER_CONST(obj)      (G_TYPE_CHECK_INSTANCE_CAST ((obj), GOM_TYPE_FILTER, GomFilter const))
30 #define GOM_FILTER_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass),  GOM_TYPE_FILTER, GomFilterClass))
31 #define GOM_IS_FILTER(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GOM_TYPE_FILTER))
32 #define GOM_IS_FILTER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),  GOM_TYPE_FILTER))
33 #define GOM_FILTER_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj),  GOM_TYPE_FILTER, GomFilterClass))
34 
35 enum _GomFilterMode
36 {
37    GOM_FILTER_SQL = 1,
38    GOM_FILTER_OR,
39    GOM_FILTER_AND,
40    GOM_FILTER_EQ,
41    GOM_FILTER_NEQ,
42    GOM_FILTER_GT,
43    GOM_FILTER_GTE,
44    GOM_FILTER_LT,
45    GOM_FILTER_LTE,
46    GOM_FILTER_LIKE,
47    GOM_FILTER_GLOB,
48    GOM_FILTER_IS_NULL,
49    GOM_FILTER_IS_NOT_NULL
50 };
51 
52 typedef struct _GomFilter        GomFilter;
53 typedef struct _GomFilterClass   GomFilterClass;
54 typedef struct _GomFilterPrivate GomFilterPrivate;
55 typedef enum   _GomFilterMode    GomFilterMode;
56 
57 struct _GomFilter
58 {
59    GObject parent;
60 
61    /*< private >*/
62    GomFilterPrivate *priv;
63 };
64 
65 struct _GomFilterClass
66 {
67    GObjectClass parent_class;
68 };
69 
70 GType        gom_filter_mode_get_type (void) G_GNUC_CONST;
71 GType        gom_filter_get_type      (void) G_GNUC_CONST;
72 gchar       *gom_filter_get_sql         (GomFilter     *filter,
73                                          GHashTable    *table_map);
74 GArray      *gom_filter_get_values      (GomFilter     *filter);
75 GomFilter   *gom_filter_new_sql         (const gchar   *sql,
76                                          const GArray  *values);
77 GomFilter   *gom_filter_new_or          (GomFilter     *left,
78                                          GomFilter     *right);
79 GomFilter   *gom_filter_new_or_full     (GomFilter     *first,
80                                          ...);
81 GomFilter   *gom_filter_new_or_fullv    (GomFilter    **filter_array);
82 GomFilter   *gom_filter_new_and         (GomFilter     *left,
83                                          GomFilter     *right);
84 GomFilter   *gom_filter_new_and_full    (GomFilter     *first,
85                                          ...);
86 GomFilter   *gom_filter_new_and_fullv   (GomFilter    **filter_array);
87 GomFilter   *gom_filter_new_eq          (GType          resource_type,
88                                          const gchar   *property_name,
89                                          const GValue  *value);
90 GomFilter   *gom_filter_new_neq         (GType          resource_type,
91                                          const gchar   *property_name,
92                                          const GValue  *value);
93 GomFilter   *gom_filter_new_gt          (GType          resource_type,
94                                          const gchar   *property_name,
95                                          const GValue  *value);
96 GomFilter   *gom_filter_new_gte         (GType          resource_type,
97                                          const gchar   *property_name,
98                                          const GValue  *value);
99 GomFilter   *gom_filter_new_lt          (GType          resource_type,
100                                          const gchar   *property_name,
101                                          const GValue  *value);
102 GomFilter   *gom_filter_new_lte         (GType          resource_type,
103                                          const gchar   *property_name,
104                                          const GValue  *value);
105 GomFilter   *gom_filter_new_like        (GType          resource_type,
106                                          const gchar   *property_name,
107                                          const GValue  *value);
108 GomFilter   *gom_filter_new_glob        (GType          resource_type,
109                                          const gchar   *property_name,
110                                          const GValue  *value);
111 GomFilter   *gom_filter_new_is_null     (GType          resource_type,
112                                          const gchar   *property_name);
113 GomFilter   *gom_filter_new_is_not_null (GType          resource_type,
114                                          const gchar   *property_name);
115 
116 G_END_DECLS
117 
118 #endif /* GOM_FILTER_H */
119