[libgda/libgda-vala] Added new GdaSqlExpression Class to allow GI to create GdaSqlExpr structs



commit f31aa3ceeef0886d3185476db66f9a08b4cf1f11
Author: Daniel Espinosa <esodan gmail com>
Date:   Tue May 14 18:38:06 2013 -0500

    Added new GdaSqlExpression Class to allow GI to create GdaSqlExpr structs

 libgda/gda-sql-expression-private.h |   33 +++++++++
 libgda/gda-sql-expression.c         |   57 ++++++++++++++++
 libgda/gda-sql-expression.h         |  126 +++++++++++++++++++++++++++++++++++
 3 files changed, 216 insertions(+), 0 deletions(-)
---
diff --git a/libgda/gda-sql-expression-private.h b/libgda/gda-sql-expression-private.h
new file mode 100644
index 0000000..2f2fac7
--- /dev/null
+++ b/libgda/gda-sql-expression-private.h
@@ -0,0 +1,33 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 2 -*- */
+/*
+ * libgdadata
+ * Copyright (C) Daniel Espinosa Ortiz 2011 <esodan gmail com>
+ *
+ * libgda is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * libgda is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/* inclusion guard */
+#ifndef __GDA_SQL_EXPRESSION_PRIVATE_H__
+#define __GDA_SQL_EXPRESSION_PRIVATE_H__
+
+
+void               _gda_sql_expression_set_expr       (GdaSqlExpression *expr,
+                                                    const GdaSqlExpr *e);
+const GdaSqlExpr  *_gda_sql_expression_get_expr       (GdaSqlExpression *expr);
+
+/*
+ * Method definitions.
+ */
+
+#endif /* __GDA_SQL_EXPRESSION_PRIVATE_H__ */
diff --git a/libgda/gda-sql-expression.c b/libgda/gda-sql-expression.c
new file mode 100644
index 0000000..14e883a
--- /dev/null
+++ b/libgda/gda-sql-expression.c
@@ -0,0 +1,57 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 2 -*- */
+/*
+ * libgdadata
+ * Copyright (C) Daniel Espinosa Ortiz 2011 <esodan gmail com>
+ *
+ * libgda is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * libgda is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <gda-sql-expression.h>
+#include <sql-parser/gda-statement-struct-parts.h>
+
+G_DEFINE_TYPE (GdaSqlExpression, gda_sql_expression, G_TYPE_OBJECT);
+
+#define GDA_SQL_EXPRESSION_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GDA_TYPE_SQL_EXPRESSION, 
GdaSqlExpressionPrivate))
+
+struct _GdaSqlExpressionPrivate
+{
+  GdaSqlExpr          *exp;
+  GdaSqlExpressionType type;
+};
+
+/* properties */
+enum
+{
+        PROP_0,
+        PROP_VALUE,
+        PROP_IS_IDENT,
+        PROP_EXPR_TYPE,
+        PROP_FUNCTION,
+};
+
+static void
+gda_sql_expression_class_init (GdaSqlExpressionClass *klass)
+{
+  g_type_class_add_private (klass, sizeof (GdaSqlExpressionPrivate));
+}
+
+static void
+gda_sql_expression_init (GdaSqlExpression *self)
+{
+  GdaSqlExpressionPrivate *priv;
+
+  self->priv = priv = GDA_SQL_EXPRESSION_GET_PRIVATE (self);
+
+  priv->exp = gda_sql_expr_new (NULL);
+}
diff --git a/libgda/gda-sql-expression.h b/libgda/gda-sql-expression.h
new file mode 100644
index 0000000..3e4c99b
--- /dev/null
+++ b/libgda/gda-sql-expression.h
@@ -0,0 +1,126 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 2 -*- */
+/*
+ * libgdadata
+ * Copyright (C) Daniel Espinosa Ortiz 2011 <esodan gmail com>
+ *
+ * libgda is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * libgda is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/* inclusion guard */
+#ifndef __GDA_SQL_EXPRESSION_H__
+#define __GDA_SQL_EXPRESSION_H__
+
+#include <glib-object.h>
+/*
+ * Potentially, include other headers on which this header depends.
+ */
+
+/*
+ * Type macros.
+ */
+#define GDA_TYPE_SQL_EXPRESSION                  (gda_sql_expression_get_type ())
+#define GDA_SQL_EXPRESSION(obj)                  (G_TYPE_CHECK_INSTANCE_CAST ((obj), 
GDA_TYPE_SQL_EXPRESSION, GdaSqlExpression))
+#define GDA_IS_SQL_EXPRESSION(obj)               (G_TYPE_CHECK_INSTANCE_TYPE ((obj), 
GDA_TYPE_SQL_EXPRESSION))
+#define GDA_SQL_EXPRESSION_CLASS(klass)          (G_TYPE_CHECK_CLASS_CAST ((klass), GDA_TYPE_SQL_EXPRESSION, 
GdaSqlExpressionClass))
+#define GDA_IS_SQL_EXPRESSION_CLASS(klass)       (G_TYPE_CHECK_CLASS_TYPE ((klass), GDA_TYPE_SQL_EXPRESSION))
+#define GDA_SQL_EXPRESSION_GET_CLASS(obj)        (G_TYPE_INSTANCE_GET_CLASS ((obj), GDA_TYPE_SQL_EXPRESSION, 
GdaSqlExpressionClass))
+
+typedef struct _GdaSqlExpression        GdaSqlExpression;
+typedef struct _GdaSqlExpressionClass   GdaSqlExpressionClass;
+typedef struct _GdaSqlExpressionPrivate GdaSqlExpressionPrivate;
+
+typedef enum   _GdaSqlExpressionType    GdaSqlExpressionType;
+
+enum {
+       GDA_SQL_EXPRESSION_TYPE_VALUE,
+       GDA_SQL_EXPRESSION_TYPE_VARIABLE,
+       GDA_SQL_EXPRESSION_TYPE_FUNCTION,
+       GDA_SQL_EXPRESSION_TYPE_CONDITION,
+       GDA_SQL_EXPRESSION_TYPE_SELECT,
+       GDA_SQL_EXPRESSION_TYPE_COMPOUND,
+       GDA_SQL_EXPRESSION_TYPE_CASE,
+       GDA_SQL_EXPRESSION_TYPE_CAST_AS
+}
+
+struct _GdaSqlExpression
+{
+  GObject parent_instance;
+
+  /* instance members */
+  GdaSqlExpressionPrivate *priv;
+};
+
+struct _GdaSqlExpressionClass
+{
+  GObjectClass parent_class;
+
+  /* class members */
+};
+
+/* used by GDA_TYPE_SQL_EXPRESSION */
+GType              gda_sql_expression_get_type        (void);
+GdaSqlExpression * gda_sql_expression_new             (GdaSqlExpressionType type);
+GdaSqlExpression * gda_sql_expression_new_from_string (const gchar* str);
+gchar*             gda_sql_expression_to_string       (GdaSqlExpression *expr);
+void               gda_sql_expression_check_clean     (GdaSqlExpression *expr);
+void               gda_sql_expression_take_select     (GdaSqlExpression *expr, 
+                                                    GdaSqlStatement *stm);
+
+void               gda_sql_expression_set_value       (GdaSqlExpression *expr,
+                                                    const GValue *val);
+const GValue      *gda_sql_expression_get_value       (GdaSqlExpression *expr);
+
+
+void               gda_sql_expression_set_variable_pspec (GdaSqlExpression *expr,
+                                                    const GdaSqlParamSpec *spec);
+GdaSqlParamSpec   *gda_sql_expression_get_variable_pspec (GdaSqlExpression *expr):
+
+
+void               gda_sql_expression_set_function_name  (GdaSqlExpression *expr,
+                                                    const gchar *name);
+void               gda_sql_expression_set_function_args  (GdaSqlExpression *expr,
+                                                    const GSList *args);
+
+void               gda_sql_expression_set_operator_type  (GdaSqlExpression *expr,
+                                                    GdaSqlOperatorType optype);
+void               gda_sql_expression_set_operator_operands (GdaSqlExpression *expr,
+                                                    const GSList *operands);
+
+void               gda_sql_expression_set_select      (GdaSqlExpression *expr,
+                                                    GdaSqlSelect *select);
+GdaSqlSelect      *gda_sql_expression_get_select      (GdaSqlExpression *expr);
+
+
+void               gda_sql_expression_set_compound    (GdaSqlExpression *expr,
+                                                    GdaSqlCompound *compound);
+GdaSqlCompound    *gda_sql_expression_set_compound    (GdaSqlExpression *expr);
+
+
+void               gda_sql_expression_set_case_expr   (GdaSqlExpression *expr,
+                                                    GdaSqlExpression *e);
+void               gda_sql_expression_set_case_when   (GdaSqlExpression *expr,
+                                                    const GSList *when);
+void               gda_sql_expression_set_case_then   (GdaSqlExpression *expr,
+                                                    const GSList *then);
+void               gda_sql_expression_set_case_else   (GdaSqlExpression *expr,
+                                                    const GSList *_else);
+
+
+void               gda_sql_expression_set_cast_as     (GdaSqlExpression *expr,
+                                                    const gchar *cast_as);
+/*
+ * Method definitions.
+ */
+
+#endif /* __GDA_SQL_EXPRESSION_H__ */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]