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-set.c

109 lines
2.8 KiB
C

/*
* 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-set.h"
/**
* SECTION: sql-set
* @Short_description: represents any set used in SQL.
* @Title: SqlSet
**/
G_DEFINE_TYPE (SqlSet, sql_set, SQL_TYPE_EXPR);
SqlObject * sql_set_new ()
{
return g_object_new (SQL_TYPE_SET, NULL);
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Private
static void sql_set_render (SqlSet * obj, SqlRender * render)
{
/* if (obj)
sql_render_add_object (render, obj);
else
sql_render_add_token (render, "DEFAULT");
*/
sql_render_append (render, "(");
sql_render_add_list (render, FALSE, NULL, obj->exprs, ",");
sql_render_append (render, ")");
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Properties
enum
{
PROP_EXPRS = 1
};
static void sql_set_set_property (SqlSet * obj, guint id,
const GValue * value, GParamSpec * pspec)
{
switch (id)
{
case PROP_EXPRS:
sql_object_remove (obj, obj->exprs);
obj->exprs = sql_object_add (obj, g_value_get_object (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, id, pspec);
}
}
static void sql_set_get_property (SqlSet * obj, guint id,
GValue * value, GParamSpec * pspec)
{
switch (id)
{
case PROP_EXPRS:
g_value_set_object (value, obj->exprs);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, id, pspec);
}
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Class
static void sql_set_init (SqlSet * obj)
{
obj->exprs = NULL;
}
static void sql_set_finalize (SqlSet * obj)
{
sql_object_remove (obj, obj->exprs);
G_OBJECT_CLASS (sql_set_parent_class)->finalize (G_OBJECT (obj));
}
static void sql_set_class_init (SqlSetClass * klass)
{
GObjectClass * k = G_OBJECT_CLASS (klass);
k->finalize = (GObjectFinalizeFunc) sql_set_finalize;
k->set_property = (GObjectSetPropertyFunc) sql_set_set_property;
k->get_property = (GObjectGetPropertyFunc) sql_set_get_property;
SQL_OBJECT_CLASS (klass)->render = (SqlRenderFunc) sql_set_render;
g_object_class_install_property (k, PROP_EXPRS,
sql_param_list ("exprs"
,"Expressions"
,"The list of expressions"
,SQL_TYPE_EXPR
,G_PARAM_READWRITE | G_PARAM_CONSTRUCT
));
}