2013-10-11 23:07:35 +00:00
|
|
|
/*
|
|
|
|
* 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 <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "sql-multi-stmt.h"
|
|
|
|
|
|
|
|
/**
|
|
|
|
* SECTION: sql-multi-stmt
|
|
|
|
* @Short_description: the equivalent multiple statements separated by semicolon.
|
|
|
|
* @Title: SqlMultiStmt
|
|
|
|
*
|
|
|
|
* The #SqlMultiStmt represents multiple SQL statements separated by semicolon.
|
|
|
|
**/
|
|
|
|
G_DEFINE_TYPE (SqlMultiStmt, sql_multi_stmt, SQL_TYPE_STMT);
|
|
|
|
|
|
|
|
SqlMultiStmt * sql_multi_stmt_new ()
|
|
|
|
{
|
|
|
|
return g_object_new (SQL_TYPE_MULTI_STMT, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Private
|
|
|
|
|
|
|
|
static void sql_multi_stmt_render (SqlMultiStmt * obj, SqlRender * render)
|
|
|
|
{
|
2013-10-14 12:08:06 +00:00
|
|
|
sql_render_add_list (render, T, NULL, obj->stmt, ";");
|
2013-10-11 23:07:35 +00:00
|
|
|
}
|
|
|
|
|
2013-10-14 12:08:06 +00:00
|
|
|
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Public
|
2013-10-11 23:07:35 +00:00
|
|
|
|
2013-10-14 12:08:06 +00:00
|
|
|
void sql_multi_stmt_add_stmt (SqlMultiStmt * obj, SqlStmt * stmt)
|
2013-10-11 23:07:35 +00:00
|
|
|
{
|
2013-10-14 12:08:06 +00:00
|
|
|
g_return_if_fail (SQL_IS_MULTI_STMT (obj));
|
|
|
|
g_return_if_fail (SQL_IS_STMT (stmt));
|
2013-10-11 23:07:35 +00:00
|
|
|
|
2013-10-14 12:08:06 +00:00
|
|
|
obj->stmt = g_slist_append (obj->stmt, g_object_ref_sink (stmt));
|
2013-10-11 23:07:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Class
|
|
|
|
|
|
|
|
static void sql_multi_stmt_init (SqlMultiStmt * obj)
|
|
|
|
{
|
2013-10-14 12:08:06 +00:00
|
|
|
obj->stmt = NULL;
|
2013-10-11 23:07:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void sql_multi_stmt_finalize (SqlMultiStmt * obj)
|
|
|
|
{
|
2013-10-14 12:08:06 +00:00
|
|
|
g_slist_free_full (obj->stmt, g_object_unref);
|
2013-10-11 23:07:35 +00:00
|
|
|
G_OBJECT_CLASS (sql_multi_stmt_parent_class)->finalize (G_OBJECT (obj));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void sql_multi_stmt_class_init (SqlMultiStmtClass * klass)
|
|
|
|
{
|
2013-10-14 12:08:06 +00:00
|
|
|
G_OBJECT_CLASS (klass)->finalize = (GObjectFinalizeFunc) sql_multi_stmt_finalize;
|
2013-10-11 23:07:35 +00:00
|
|
|
SQL_OBJECT_CLASS (klass)->render = (SqlRenderFunc) sql_multi_stmt_render;
|
|
|
|
}
|