/* * 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 . */ #include "sql-delete.h" /** * SECTION: sql-delete * @Short_description: the equivalent of the DELETE statement in SQL. * @Title: SqlDelete * * The #SqlDelete represents a deletion statement. **/ G_DEFINE_TYPE (SqlDelete, sql_delete, SQL_TYPE_DML); SqlDelete * sql_delete_new () { return g_object_new (SQL_TYPE_DELETE, NULL); } //+++++++++++++++++++++++++++++++++++++++++++++++++++ Private static void sql_delete_render (SqlDelete * obj, SqlRender * render) { sql_render_add_token (render, "DELETE"); sql_render_add_object (render, obj->table); if (SQL_DML (obj)->target) { sql_render_add_list (render, T, "FROM", SQL_DML (obj)->target, ","); sql_render_add_item (render, F, "WHERE", SQL_DML (obj)->where); } } //+++++++++++++++++++++++++++++++++++++++++++++++++++ Public void sql_delete_add_table (SqlDelete * obj, SqlTable * table) { g_return_if_fail (SQL_IS_DELETE (obj)); g_return_if_fail (SQL_IS_TABLE (table)); obj->table = g_slist_append (obj->table, g_object_ref_sink (table)); } //+++++++++++++++++++++++++++++++++++++++++++++++++++ Class static void sql_delete_init (SqlDelete * obj) { obj->table = NULL; } static void sql_delete_finalize (SqlDelete * obj) { g_slist_free_full (obj->table, g_object_unref); G_OBJECT_CLASS (sql_delete_parent_class)->finalize (G_OBJECT (obj)); } static void sql_delete_class_init (SqlDeleteClass * klass) { G_OBJECT_CLASS (klass)->finalize = (GObjectFinalizeFunc) sql_delete_finalize; SQL_OBJECT_CLASS (klass)->render = (SqlRenderFunc) sql_delete_render; }