/* sql-operator.c generated by valac 0.56.19, the Vala compiler
 * generated from sql-operator.vala, do not modify */

/*
 * Copyright (C) 2010 Jens Georg <mail@jensge.org>.
 *
 * Author: Jens Georg <mail@jensge.org>
 *
 * This file is part of Rygel.
 *
 * Rygel is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * Rygel 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 */

#include "rygel-db.h"
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <glib-object.h>
#include <libgupnp-av/gupnp-av.h>

#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif

enum  {
	RYGEL_DATABASE_SQL_OPERATOR_0_PROPERTY,
	RYGEL_DATABASE_SQL_OPERATOR_NUM_PROPERTIES
};
static GParamSpec* rygel_database_sql_operator_properties[RYGEL_DATABASE_SQL_OPERATOR_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))

static gpointer rygel_database_sql_operator_parent_class = NULL;

static gchar* rygel_database_sql_operator_real_to_string (RygelDatabaseSqlOperator* self);
static void rygel_database_sql_operator_finalize (GObject * obj);
static GType rygel_database_sql_operator_get_type_once (void);

RygelDatabaseSqlOperator*
rygel_database_sql_operator_construct (GType object_type,
                                       const gchar* name,
                                       const gchar* arg,
                                       const gchar* collate)
{
	RygelDatabaseSqlOperator * self = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	g_return_val_if_fail (name != NULL, NULL);
	g_return_val_if_fail (arg != NULL, NULL);
	g_return_val_if_fail (collate != NULL, NULL);
	self = (RygelDatabaseSqlOperator*) g_object_new (object_type, NULL);
	_tmp0_ = g_strdup (name);
	_g_free0 (self->name);
	self->name = _tmp0_;
	_tmp1_ = g_strdup (arg);
	_g_free0 (self->arg);
	self->arg = _tmp1_;
	_tmp2_ = g_strdup (collate);
	_g_free0 (self->collate);
	self->collate = _tmp2_;
	return self;
}

RygelDatabaseSqlOperator*
rygel_database_sql_operator_new (const gchar* name,
                                 const gchar* arg,
                                 const gchar* collate)
{
	return rygel_database_sql_operator_construct (RYGEL_DATABASE_TYPE_SQL_OPERATOR, name, arg, collate);
}

RygelDatabaseSqlOperator*
rygel_database_sql_operator_construct_from_search_criteria_op (GType object_type,
                                                               GUPnPSearchCriteriaOp op,
                                                               const gchar* arg,
                                                               const gchar* collate)
{
	RygelDatabaseSqlOperator * self = NULL;
	gchar* sql = NULL;
	const gchar* _tmp6_;
	g_return_val_if_fail (arg != NULL, NULL);
	g_return_val_if_fail (collate != NULL, NULL);
	sql = NULL;
	switch (op) {
		case GUPNP_SEARCH_CRITERIA_OP_EQ:
		{
			gchar* _tmp0_;
			_tmp0_ = g_strdup ("=");
			_g_free0 (sql);
			sql = _tmp0_;
			break;
		}
		case GUPNP_SEARCH_CRITERIA_OP_NEQ:
		{
			gchar* _tmp1_;
			_tmp1_ = g_strdup ("!=");
			_g_free0 (sql);
			sql = _tmp1_;
			break;
		}
		case GUPNP_SEARCH_CRITERIA_OP_LESS:
		{
			gchar* _tmp2_;
			_tmp2_ = g_strdup ("<");
			_g_free0 (sql);
			sql = _tmp2_;
			break;
		}
		case GUPNP_SEARCH_CRITERIA_OP_LEQ:
		{
			gchar* _tmp3_;
			_tmp3_ = g_strdup ("<=");
			_g_free0 (sql);
			sql = _tmp3_;
			break;
		}
		case GUPNP_SEARCH_CRITERIA_OP_GREATER:
		{
			gchar* _tmp4_;
			_tmp4_ = g_strdup (">");
			_g_free0 (sql);
			sql = _tmp4_;
			break;
		}
		case GUPNP_SEARCH_CRITERIA_OP_GEQ:
		{
			gchar* _tmp5_;
			_tmp5_ = g_strdup (">=");
			_g_free0 (sql);
			sql = _tmp5_;
			break;
		}
		default:
		{
			g_assert_not_reached ();
		}
	}
	_tmp6_ = sql;
	self = (RygelDatabaseSqlOperator*) rygel_database_sql_operator_construct (object_type, _tmp6_, arg, collate);
	_g_free0 (sql);
	return self;
}

RygelDatabaseSqlOperator*
rygel_database_sql_operator_new_from_search_criteria_op (GUPnPSearchCriteriaOp op,
                                                         const gchar* arg,
                                                         const gchar* collate)
{
	return rygel_database_sql_operator_construct_from_search_criteria_op (RYGEL_DATABASE_TYPE_SQL_OPERATOR, op, arg, collate);
}

static gchar*
rygel_database_sql_operator_real_to_string (RygelDatabaseSqlOperator* self)
{
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* result;
	_tmp0_ = self->arg;
	_tmp1_ = self->name;
	_tmp2_ = self->collate;
	_tmp3_ = g_strdup_printf ("(%s %s ? %s)", _tmp0_, _tmp1_, _tmp2_);
	result = _tmp3_;
	return result;
}

gchar*
rygel_database_sql_operator_to_string (RygelDatabaseSqlOperator* self)
{
	RygelDatabaseSqlOperatorClass* _klass_;
	g_return_val_if_fail (self != NULL, NULL);
	_klass_ = RYGEL_DATABASE_SQL_OPERATOR_GET_CLASS (self);
	if (_klass_->to_string) {
		return _klass_->to_string (self);
	}
	return NULL;
}

static void
rygel_database_sql_operator_class_init (RygelDatabaseSqlOperatorClass * klass,
                                        gpointer klass_data)
{
	rygel_database_sql_operator_parent_class = g_type_class_peek_parent (klass);
	((RygelDatabaseSqlOperatorClass *) klass)->to_string = (gchar* (*) (RygelDatabaseSqlOperator*)) rygel_database_sql_operator_real_to_string;
	G_OBJECT_CLASS (klass)->finalize = rygel_database_sql_operator_finalize;
}

static void
rygel_database_sql_operator_instance_init (RygelDatabaseSqlOperator * self,
                                           gpointer klass)
{
}

static void
rygel_database_sql_operator_finalize (GObject * obj)
{
	RygelDatabaseSqlOperator * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, RYGEL_DATABASE_TYPE_SQL_OPERATOR, RygelDatabaseSqlOperator);
	_g_free0 (self->name);
	_g_free0 (self->arg);
	_g_free0 (self->collate);
	G_OBJECT_CLASS (rygel_database_sql_operator_parent_class)->finalize (obj);
}

 G_GNUC_NO_INLINE static GType
rygel_database_sql_operator_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (RygelDatabaseSqlOperatorClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) rygel_database_sql_operator_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (RygelDatabaseSqlOperator), 0, (GInstanceInitFunc) rygel_database_sql_operator_instance_init, NULL };
	GType rygel_database_sql_operator_type_id;
	rygel_database_sql_operator_type_id = g_type_register_static (G_TYPE_OBJECT, "RygelDatabaseSqlOperator", &g_define_type_info, 0);
	return rygel_database_sql_operator_type_id;
}

GType
rygel_database_sql_operator_get_type (void)
{
	static volatile gsize rygel_database_sql_operator_type_id__once = 0;
	if (g_once_init_enter (&rygel_database_sql_operator_type_id__once)) {
		GType rygel_database_sql_operator_type_id;
		rygel_database_sql_operator_type_id = rygel_database_sql_operator_get_type_once ();
		g_once_init_leave (&rygel_database_sql_operator_type_id__once, rygel_database_sql_operator_type_id);
	}
	return rygel_database_sql_operator_type_id__once;
}

