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

117 lines
2.9 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-target.h"
/**
* SECTION: sql-target
* @Short_description: any target for an SQL statement
* @Title: SqlTarget
*
* A target that can be used as such in any SQL statement (here represented by
* the #SqlStmt class).
**/
G_DEFINE_ABSTRACT_TYPE (SqlTarget, sql_target, SQL_TYPE_OBJECT);
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Public
/**
* sql_target_set_alias:
* @self: the #SqlTargetClass
* @alias: the target alias
**/
void sql_target_set_alias (SqlTarget * self, const gchar * alias)
{
g_return_if_fail (SQL_IS_TARGET (self));
g_free (self->alias);
self->alias = g_strdup (alias);
}
/**
* sql_target_get_alias:
* @self: the #SqlTargetClass
**/
const gchar * sql_target_get_alias (SqlTarget * self)
2013-10-11 23:07:35 +00:00
{
g_return_if_fail (SQL_IS_TARGET (self));
2013-10-11 23:07:35 +00:00
return self->alias;
2013-10-11 23:07:35 +00:00
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Properties
enum
{
PROP_ALIAS = 1
};
static void sql_target_set_property (SqlTarget * self, guint id,
2013-10-11 23:07:35 +00:00
const GValue * value, GParamSpec * pspec)
{
switch (id)
{
case PROP_ALIAS:
sql_target_set_alias (self, g_value_get_string (value));
2013-10-11 23:07:35 +00:00
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (self, id, pspec);
2013-10-11 23:07:35 +00:00
}
}
static void sql_target_get_property (SqlTarget * self, guint id,
2013-10-11 23:07:35 +00:00
GValue * value, GParamSpec * pspec)
{
switch (id)
{
case PROP_ALIAS:
g_value_set_string (value, self->alias);
2013-10-11 23:07:35 +00:00
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (self, id, pspec);
2013-10-11 23:07:35 +00:00
}
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Class
static void sql_target_init (SqlTarget * self)
2013-10-11 23:07:35 +00:00
{
self->alias = NULL;
2013-10-11 23:07:35 +00:00
}
static void sql_target_finalize (SqlTarget * self)
2013-10-11 23:07:35 +00:00
{
g_free (self->alias);
G_OBJECT_CLASS (sql_target_parent_class)->finalize (G_OBJECT (self));
2013-10-11 23:07:35 +00:00
}
static void sql_target_class_init (SqlTargetClass * k)
{
GObjectClass * klass = G_OBJECT_CLASS (k);
klass->finalize = (GObjectFinalizeFunc) sql_target_finalize;
klass->set_property = (GObjectSetPropertyFunc) sql_target_set_property;
klass->get_property = (GObjectGetPropertyFunc) sql_target_get_property;
g_object_class_install_property (klass, PROP_ALIAS,
g_param_spec_string ("alias"
,("Alias")
,("The alias for the target")
2013-10-11 23:07:35 +00:00
,NULL
,G_PARAM_READWRITE
));
}