/* * Copyright (C) 2012 - Juan Ferrer Toribio * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef SQL_SELECT_H #define SQL_SELECT_H #include "sql-dml.h" #define SQL_TYPE_SELECT (sql_select_get_type ()) #define SQL_SELECT(obj) (G_TYPE_CHECK_INSTANCE_CAST (obj, SQL_TYPE_SELECT, SqlSelect)) #define SQL_IS_SELECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE (obj, SQL_TYPE_SELECT)) typedef struct _SqlSelect SqlSelect; typedef struct _SqlSelectClass SqlSelectClass; typedef enum { SQL_SELECT_NONE ,SQL_SELECT_UNION_ALL ,SQL_SELECT_UNION_ANY ,SQL_SELECT_INTERSECT ,SQL_SELECT_EXCEPT ,SQL_SELECT_COUNT } SqlSelectType; /** * SqlOrderWay: * @SQL_ORDER_ASC: ascendent order * @SQL_ORDER_DESC: descendent order **/ typedef enum { SQL_ORDER_ASC ,SQL_ORDER_DESC } SqlOrderWay; /** * SqlSelect: * @expr: (element-type Sql.Expr): * @group: (element-type Sql.Expr): * @order: (element-type Sql.Expr): **/ struct _SqlSelect { SqlDml parent; gboolean distinct; GSList * expr; GSList * alias; // List of Sql.SelectAlias GSList * group; SqlExpr * having; GSList * order; guint limit_offset; guint limit_count; SqlSelectType type; SqlSelect * next; }; struct _SqlSelectClass { /* */ SqlDmlClass parent; }; GType sql_select_get_type (); SqlSelect * sql_select_new (); void sql_select_set_distinct (SqlSelect * obj, gboolean distinct); void sql_select_add_expr (SqlSelect * obj, SqlExpr * expr); void sql_select_set_alias (SqlSelect * obj, SqlExpr * expr, const gchar * alias); void sql_select_add_group (SqlSelect * obj, SqlExpr * expr); void sql_select_set_having (SqlSelect * obj, SqlExpr * expr); void sql_select_add_order (SqlSelect * obj, SqlExpr * expr, SqlOrderWay way); void sql_select_set_limit (SqlSelect * obj, guint count, guint offset); void sql_select_set_next (SqlSelect * obj, SqlSelect * next, SqlSelectType type); #endif