/* database-uri-iterator.c generated by valac 0.36.6.6-c7bee, the Vala compiler
 * generated from database-uri-iterator.vala, do not modify */

/* This file is part of GNOME Games. License: GPL-3.0+.*/

#include <glib.h>
#include <glib-object.h>
#include <sqlite3.h>
#include <stdlib.h>
#include <string.h>


#define GAMES_TYPE_URI_ITERATOR (games_uri_iterator_get_type ())
#define GAMES_URI_ITERATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_URI_ITERATOR, GamesUriIterator))
#define GAMES_IS_URI_ITERATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_URI_ITERATOR))
#define GAMES_URI_ITERATOR_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GAMES_TYPE_URI_ITERATOR, GamesUriIteratorIface))

typedef struct _GamesUriIterator GamesUriIterator;
typedef struct _GamesUriIteratorIface GamesUriIteratorIface;

#define GAMES_TYPE_URI (games_uri_get_type ())
#define GAMES_URI(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_URI, GamesUri))
#define GAMES_URI_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAMES_TYPE_URI, GamesUriClass))
#define GAMES_IS_URI(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_URI))
#define GAMES_IS_URI_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAMES_TYPE_URI))
#define GAMES_URI_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAMES_TYPE_URI, GamesUriClass))

typedef struct _GamesUri GamesUri;
typedef struct _GamesUriClass GamesUriClass;

#define GAMES_TYPE_DATABASE_URI_ITERATOR (games_database_uri_iterator_get_type ())
#define GAMES_DATABASE_URI_ITERATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_DATABASE_URI_ITERATOR, GamesDatabaseUriIterator))
#define GAMES_DATABASE_URI_ITERATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAMES_TYPE_DATABASE_URI_ITERATOR, GamesDatabaseUriIteratorClass))
#define GAMES_IS_DATABASE_URI_ITERATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_DATABASE_URI_ITERATOR))
#define GAMES_IS_DATABASE_URI_ITERATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAMES_TYPE_DATABASE_URI_ITERATOR))
#define GAMES_DATABASE_URI_ITERATOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAMES_TYPE_DATABASE_URI_ITERATOR, GamesDatabaseUriIteratorClass))

typedef struct _GamesDatabaseUriIterator GamesDatabaseUriIterator;
typedef struct _GamesDatabaseUriIteratorClass GamesDatabaseUriIteratorClass;
typedef struct _GamesDatabaseUriIteratorPrivate GamesDatabaseUriIteratorPrivate;
#define _sqlite3_finalize0(var) ((var == NULL) ? NULL : (var = (sqlite3_finalize (var), NULL)))
#define _games_uri_unref0(var) ((var == NULL) ? NULL : (var = (games_uri_unref (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))

struct _GamesUriIteratorIface {
	GTypeInterface parent_iface;
	GamesUri* (*get) (GamesUriIterator* self);
	gboolean (*next) (GamesUriIterator* self);
};

struct _GamesDatabaseUriIterator {
	GObject parent_instance;
	GamesDatabaseUriIteratorPrivate * priv;
};

struct _GamesDatabaseUriIteratorClass {
	GObjectClass parent_class;
};

struct _GamesDatabaseUriIteratorPrivate {
	sqlite3_stmt* statement;
	GamesUri* uri;
};


static gpointer games_database_uri_iterator_parent_class = NULL;
static GamesUriIteratorIface * games_database_uri_iterator_games_uri_iterator_parent_iface = NULL;

gpointer games_uri_ref (gpointer instance);
void games_uri_unref (gpointer instance);
GParamSpec* games_param_spec_uri (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
void games_value_set_uri (GValue* value, gpointer v_object);
void games_value_take_uri (GValue* value, gpointer v_object);
gpointer games_value_get_uri (const GValue* value);
GType games_uri_get_type (void) G_GNUC_CONST;
GType games_uri_iterator_get_type (void) G_GNUC_CONST;
GType games_database_uri_iterator_get_type (void) G_GNUC_CONST;
#define GAMES_DATABASE_URI_ITERATOR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GAMES_TYPE_DATABASE_URI_ITERATOR, GamesDatabaseUriIteratorPrivate))
enum  {
	GAMES_DATABASE_URI_ITERATOR_0_PROPERTY
};
#define GAMES_DATABASE_URI_ITERATOR_SELECT_GAME_RESOURCE_QUERY "\n\t\tSELECT uri FROM game_resources;\n\t"
GamesDatabaseUriIterator* games_database_uri_iterator_new (sqlite3* database);
GamesDatabaseUriIterator* games_database_uri_iterator_construct (GType object_type, sqlite3* database);
sqlite3_stmt* games_database_prepare (sqlite3* database, const gchar* query, GError** error);
static GamesUri* games_database_uri_iterator_real_get (GamesUriIterator* base);
static gboolean games_database_uri_iterator_real_next (GamesUriIterator* base);
GamesUri* games_uri_new (const gchar* uri);
GamesUri* games_uri_construct (GType object_type, const gchar* uri);
static void games_database_uri_iterator_finalize (GObject * obj);


GamesDatabaseUriIterator* games_database_uri_iterator_construct (GType object_type, sqlite3* database) {
	GamesDatabaseUriIterator * self = NULL;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (database != NULL, NULL);
	self = (GamesDatabaseUriIterator*) g_object_new (object_type, NULL);
	{
		sqlite3_stmt* _tmp0_ = NULL;
		sqlite3* _tmp1_;
		sqlite3_stmt* _tmp2_;
		sqlite3_stmt* _tmp3_;
		_tmp1_ = database;
		_tmp2_ = games_database_prepare (_tmp1_, GAMES_DATABASE_URI_ITERATOR_SELECT_GAME_RESOURCE_QUERY, &_inner_error_);
		_tmp0_ = _tmp2_;
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			goto __catch5_g_error;
		}
		_tmp3_ = _tmp0_;
		_tmp0_ = NULL;
		_sqlite3_finalize0 (self->priv->statement);
		self->priv->statement = _tmp3_;
		_sqlite3_finalize0 (_tmp0_);
	}
	goto __finally5;
	__catch5_g_error:
	{
		GError* e = NULL;
		GError* _tmp4_;
		const gchar* _tmp5_;
		e = _inner_error_;
		_inner_error_ = NULL;
		_tmp4_ = e;
		_tmp5_ = _tmp4_->message;
		g_debug ("database-uri-iterator.vala:16: %s", _tmp5_);
		_g_error_free0 (e);
	}
	__finally5:
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
		g_clear_error (&_inner_error_);
		return NULL;
	}
	return self;
}


GamesDatabaseUriIterator* games_database_uri_iterator_new (sqlite3* database) {
	return games_database_uri_iterator_construct (GAMES_TYPE_DATABASE_URI_ITERATOR, database);
}


static gpointer _games_uri_ref0 (gpointer self) {
	return self ? games_uri_ref (self) : NULL;
}


static GamesUri* games_database_uri_iterator_real_get (GamesUriIterator* base) {
	GamesDatabaseUriIterator * self;
	GamesUri* result = NULL;
	GamesUri* _tmp0_;
	GamesUri* _tmp1_;
	self = (GamesDatabaseUriIterator*) base;
	_tmp0_ = self->priv->uri;
	_tmp1_ = _games_uri_ref0 (_tmp0_);
	result = _tmp1_;
	return result;
}


static gboolean games_database_uri_iterator_real_next (GamesUriIterator* base) {
	GamesDatabaseUriIterator * self;
	gboolean result = FALSE;
	sqlite3_stmt* _tmp0_;
	sqlite3_stmt* _tmp1_;
	gint _tmp2_;
	sqlite3_stmt* _tmp3_;
	const gchar* _tmp4_;
	GamesUri* _tmp5_;
	self = (GamesDatabaseUriIterator*) base;
	_tmp0_ = self->priv->statement;
	if (_tmp0_ == NULL) {
		result = FALSE;
		return result;
	}
	_tmp1_ = self->priv->statement;
	_tmp2_ = sqlite3_step (_tmp1_);
	if (_tmp2_ != SQLITE_ROW) {
		result = FALSE;
		return result;
	}
	_tmp3_ = self->priv->statement;
	_tmp4_ = sqlite3_column_text (_tmp3_, 0);
	_tmp5_ = games_uri_new (_tmp4_);
	_games_uri_unref0 (self->priv->uri);
	self->priv->uri = _tmp5_;
	result = TRUE;
	return result;
}


static void games_database_uri_iterator_class_init (GamesDatabaseUriIteratorClass * klass) {
	games_database_uri_iterator_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (GamesDatabaseUriIteratorPrivate));
	G_OBJECT_CLASS (klass)->finalize = games_database_uri_iterator_finalize;
}


static void games_database_uri_iterator_games_uri_iterator_interface_init (GamesUriIteratorIface * iface) {
	games_database_uri_iterator_games_uri_iterator_parent_iface = g_type_interface_peek_parent (iface);
	iface->get = (GamesUri* (*) (GamesUriIterator *)) games_database_uri_iterator_real_get;
	iface->next = (gboolean (*) (GamesUriIterator *)) games_database_uri_iterator_real_next;
}


static void games_database_uri_iterator_instance_init (GamesDatabaseUriIterator * self) {
	self->priv = GAMES_DATABASE_URI_ITERATOR_GET_PRIVATE (self);
}


static void games_database_uri_iterator_finalize (GObject * obj) {
	GamesDatabaseUriIterator * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GAMES_TYPE_DATABASE_URI_ITERATOR, GamesDatabaseUriIterator);
	_sqlite3_finalize0 (self->priv->statement);
	_games_uri_unref0 (self->priv->uri);
	G_OBJECT_CLASS (games_database_uri_iterator_parent_class)->finalize (obj);
}


GType games_database_uri_iterator_get_type (void) {
	static volatile gsize games_database_uri_iterator_type_id__volatile = 0;
	if (g_once_init_enter (&games_database_uri_iterator_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (GamesDatabaseUriIteratorClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) games_database_uri_iterator_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GamesDatabaseUriIterator), 0, (GInstanceInitFunc) games_database_uri_iterator_instance_init, NULL };
		static const GInterfaceInfo games_uri_iterator_info = { (GInterfaceInitFunc) games_database_uri_iterator_games_uri_iterator_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
		GType games_database_uri_iterator_type_id;
		games_database_uri_iterator_type_id = g_type_register_static (G_TYPE_OBJECT, "GamesDatabaseUriIterator", &g_define_type_info, 0);
		g_type_add_interface_static (games_database_uri_iterator_type_id, GAMES_TYPE_URI_ITERATOR, &games_uri_iterator_info);
		g_once_init_leave (&games_database_uri_iterator_type_id__volatile, games_database_uri_iterator_type_id);
	}
	return games_database_uri_iterator_type_id__volatile;
}



