/* * 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-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 void sql_target_set_alias (SqlTarget * obj, const gchar * alias) { g_return_if_fail (SQL_IS_TARGET (obj)); g_free (obj->alias); obj->alias = g_strdup (alias); } //+++++++++++++++++++++++++++++++++++++++++++++++++++ Properties enum { PROP_ALIAS = 1 }; static void sql_target_set_property (SqlTarget * obj, guint id, const GValue * value, GParamSpec * pspec) { switch (id) { case PROP_ALIAS: sql_target_set_alias (obj, g_value_get_string (value)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, id, pspec); } } static void sql_target_get_property (SqlTarget * obj, guint id, GValue * value, GParamSpec * pspec) { switch (id) { case PROP_ALIAS: g_value_set_string (value, obj->alias); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, id, pspec); } } //+++++++++++++++++++++++++++++++++++++++++++++++++++ Class static void sql_target_init (SqlTarget * obj) { obj->alias = NULL; } static void sql_target_finalize (SqlTarget * obj) { g_free (obj->alias); G_OBJECT_CLASS (sql_target_parent_class)->finalize (G_OBJECT (obj)); } 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") ,NULL ,G_PARAM_READWRITE )); }