This repository has been archived on 2024-07-15. You can view files and clone it, but cannot push or open issues or pull requests.
hedera/sql/sql-multi-stmt.c

104 lines
2.8 KiB
C
Raw Normal View History

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);
SqlObject * sql_multi_stmt_new ()
2013-10-11 23:07:35 +00:00
{
return g_object_new (SQL_TYPE_MULTI_STMT, NULL);
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Private
static void sql_multi_stmt_render (SqlMultiStmt * obj, SqlRender * render)
{
sql_render_add_list (render, TRUE, NULL, obj->stmts, ";");
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Properties
enum
{
PROP_STMTS = 1
};
static void sql_mutli_stmt_set_property (SqlMultiStmt * obj, guint id,
const GValue * value, GParamSpec * pspec)
{
switch (id)
{
case PROP_STMTS:
sql_object_remove (obj, obj->stmts);
obj->stmts = sql_object_add (obj, g_value_get_object (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, id, pspec);
}
}
static void sql_mutli_stmt_get_property (SqlMultiStmt * obj, guint id,
GValue * value, GParamSpec * pspec)
{
switch (id)
{
case PROP_STMTS:
g_value_set_object (value, obj->stmts);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, id, pspec);
}
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Class
static void sql_multi_stmt_init (SqlMultiStmt * obj)
{
obj->stmts = NULL;
}
static void sql_multi_stmt_finalize (SqlMultiStmt * obj)
{
sql_object_remove (obj, obj->stmts);
G_OBJECT_CLASS (sql_multi_stmt_parent_class)->finalize (G_OBJECT (obj));
}
static void sql_multi_stmt_class_init (SqlMultiStmtClass * klass)
{
GObjectClass * k = G_OBJECT_CLASS (klass);
k->finalize = (GObjectFinalizeFunc) sql_multi_stmt_finalize;
k->set_property = (GObjectSetPropertyFunc) sql_mutli_stmt_set_property;
k->get_property = (GObjectGetPropertyFunc) sql_mutli_stmt_get_property;
SQL_OBJECT_CLASS (klass)->render = (SqlRenderFunc) sql_multi_stmt_render;
g_object_class_install_property (k, PROP_STMTS,
sql_param_list ("stmts"
,("Statements")
,("The list of statements")
2013-10-11 23:07:35 +00:00
,SQL_TYPE_STMT
,G_PARAM_READWRITE | G_PARAM_CONSTRUCT
));
}