/* sqlheavy-table-cursor.c generated by valac 0.16.0, the Vala compiler
 * generated from sqlheavy-table-cursor.vala, do not modify */


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

#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))

struct _SQLHeavyTableCursorPrivate {
	SQLHeavyTable* _table;
	gint64 _offset;
	SQLHeavySortOrder _sort_order;
	gchar* _sort_column;
	gint64 current_id;
	SQLHeavyQuery* _query;
};


static gpointer sql_heavy_table_cursor_parent_class = NULL;
static SQLHeavyRecordSetIface* sql_heavy_table_cursor_sql_heavy_record_set_parent_iface = NULL;
static SQLHeavyCursorIface* sql_heavy_table_cursor_sql_heavy_cursor_parent_iface = NULL;

#define SQL_HEAVY_TABLE_CURSOR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SQL_HEAVY_TYPE_TABLE_CURSOR, SQLHeavyTableCursorPrivate))
enum  {
	SQL_HEAVY_TABLE_CURSOR_DUMMY_PROPERTY,
	SQL_HEAVY_TABLE_CURSOR_TABLE,
	SQL_HEAVY_TABLE_CURSOR_OFFSET,
	SQL_HEAVY_TABLE_CURSOR_SORT_ORDER,
	SQL_HEAVY_TABLE_CURSOR_SORT_COLUMN,
	SQL_HEAVY_TABLE_CURSOR_FIELD_COUNT
};
static SQLHeavyRecord* sql_heavy_table_cursor_real_get (SQLHeavyCursor* base, GError** error);
const gchar* sql_heavy_sqlite_errstr (gint ec);
static gboolean sql_heavy_table_cursor_move_to_internal (SQLHeavyTableCursor* self, gint64 offset);
static SQLHeavyQuery* sql_heavy_table_cursor_get_query (SQLHeavyTableCursor* self);
static void sql_heavy_table_cursor_set_offset (SQLHeavyTableCursor* self, gint64 value);
static gboolean sql_heavy_table_cursor_real_move_to (SQLHeavyCursor* base, gint64 offset, GError** error);
static gboolean sql_heavy_table_cursor_real_next (SQLHeavyRecordSet* base, GError** error);
static gboolean sql_heavy_table_cursor_real_previous (SQLHeavyCursor* base, GError** error);
static GObject * sql_heavy_table_cursor_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties);
static void sql_heavy_table_cursor_finalize (GObject* obj);
static void _vala_sql_heavy_table_cursor_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
static void _vala_sql_heavy_table_cursor_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec);


/**
     * {@inheritDoc}
     */
static SQLHeavyRecord* sql_heavy_table_cursor_real_get (SQLHeavyCursor* base, GError** error) {
	SQLHeavyTableCursor * self;
	SQLHeavyRecord* result = NULL;
	gint64 _tmp0_;
	SQLHeavyTable* _tmp3_;
	gint64 _tmp4_;
	SQLHeavyRow* _tmp5_;
	GError * _inner_error_ = NULL;
	self = (SQLHeavyTableCursor*) base;
	_tmp0_ = self->priv->current_id;
	if (_tmp0_ <= ((gint64) 0)) {
		const gchar* _tmp1_ = NULL;
		GError* _tmp2_;
		_tmp1_ = sql_heavy_sqlite_errstr (SQLITE_RANGE);
		_tmp2_ = g_error_new_literal (SQL_HEAVY_ERROR, SQL_HEAVY_ERROR_RANGE, _tmp1_);
		_inner_error_ = _tmp2_;
		if (_inner_error_->domain == SQL_HEAVY_ERROR) {
			g_propagate_error (error, _inner_error_);
			return NULL;
		} else {
			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;
		}
	}
	_tmp3_ = self->priv->_table;
	_tmp4_ = self->priv->current_id;
	_tmp5_ = sql_heavy_row_new (_tmp3_, _tmp4_);
	result = (SQLHeavyRecord*) _tmp5_;
	return result;
}


static gpointer _g_object_ref0 (gpointer self) {
	return self ? g_object_ref (self) : NULL;
}


static gboolean sql_heavy_table_cursor_move_to_internal (SQLHeavyTableCursor* self, gint64 offset) {
	gboolean result = FALSE;
	gint64 id;
	gint64 _tmp16_;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (self != NULL, FALSE);
	id = (gint64) (-1);
	{
		SQLHeavyQuery* _tmp0_;
		SQLHeavyQuery* _tmp1_;
		SQLHeavyQuery* _tmp2_;
		SQLHeavyQuery* q;
		SQLHeavyQuery* _tmp3_;
		gint64 _tmp4_;
		SQLHeavyQuery* _tmp5_;
		SQLHeavyQueryResult* _tmp6_ = NULL;
		SQLHeavyQueryResult* res;
		gint64 _tmp7_ = 0LL;
		SQLHeavyQueryResult* _tmp8_;
		gboolean _tmp9_;
		gboolean _tmp10_;
		gint64 _tmp13_;
		_tmp0_ = sql_heavy_table_cursor_get_query (self);
		_tmp1_ = _tmp0_;
		_tmp2_ = _g_object_ref0 (_tmp1_);
		q = _tmp2_;
		_tmp3_ = q;
		_tmp4_ = offset;
		sql_heavy_query_set_int64 (_tmp3_, ":offset", _tmp4_, &_inner_error_);
		if (_inner_error_ != NULL) {
			_g_object_unref0 (q);
			if (_inner_error_->domain == SQL_HEAVY_ERROR) {
				goto __catch40_sql_heavy_error;
			}
			_g_object_unref0 (q);
			g_critical ("file %s: line %d: unexpected 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 FALSE;
		}
		_tmp5_ = q;
		_tmp6_ = sql_heavy_query_execute (_tmp5_, NULL, &_inner_error_, NULL);
		res = _tmp6_;
		if (_inner_error_ != NULL) {
			_g_object_unref0 (q);
			if (_inner_error_->domain == SQL_HEAVY_ERROR) {
				goto __catch40_sql_heavy_error;
			}
			_g_object_unref0 (q);
			g_critical ("file %s: line %d: unexpected 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 FALSE;
		}
		_tmp8_ = res;
		_tmp9_ = sql_heavy_query_result_get_finished (_tmp8_);
		_tmp10_ = _tmp9_;
		if (_tmp10_) {
			_tmp7_ = (gint64) (-1);
		} else {
			SQLHeavyQueryResult* _tmp11_;
			gint64 _tmp12_ = 0LL;
			_tmp11_ = res;
			_tmp12_ = sql_heavy_record_fetch_int64 ((SQLHeavyRecord*) _tmp11_, 0, &_inner_error_);
			_tmp7_ = _tmp12_;
			if (_inner_error_ != NULL) {
				_g_object_unref0 (res);
				_g_object_unref0 (q);
				if (_inner_error_->domain == SQL_HEAVY_ERROR) {
					goto __catch40_sql_heavy_error;
				}
				_g_object_unref0 (res);
				_g_object_unref0 (q);
				g_critical ("file %s: line %d: unexpected 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 FALSE;
			}
		}
		_tmp13_ = _tmp7_;
		id = _tmp13_;
		_g_object_unref0 (res);
		_g_object_unref0 (q);
	}
	goto __finally40;
	__catch40_sql_heavy_error:
	{
		GError* e = NULL;
		GError* _tmp14_;
		const gchar* _tmp15_;
		e = _inner_error_;
		_inner_error_ = NULL;
		_tmp14_ = e;
		_tmp15_ = _tmp14_->message;
		g_critical ("sqlheavy-table-cursor.vala:67: Unable to move cursor: %s", _tmp15_);
		result = FALSE;
		_g_error_free0 (e);
		return result;
	}
	__finally40:
	if (_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 FALSE;
	}
	_tmp16_ = id;
	if (_tmp16_ > ((gint64) 0)) {
		gint64 _tmp17_;
		gint64 _tmp18_;
		gint64 _tmp19_;
		_tmp17_ = offset;
		g_debug ("sqlheavy-table-cursor.vala:72: Offset: %lld", _tmp17_);
		_tmp18_ = id;
		self->priv->current_id = _tmp18_;
		_tmp19_ = offset;
		sql_heavy_table_cursor_set_offset (self, _tmp19_);
		result = TRUE;
		return result;
	} else {
		result = FALSE;
		return result;
	}
}


/**
     * {@inheritDoc}
     */
static gboolean sql_heavy_table_cursor_real_move_to (SQLHeavyCursor* base, gint64 offset, GError** error) {
	SQLHeavyTableCursor * self;
	gboolean result = FALSE;
	gint64 _tmp0_;
	gboolean _tmp1_ = FALSE;
	GError * _inner_error_ = NULL;
	self = (SQLHeavyTableCursor*) base;
	_tmp0_ = offset;
	_tmp1_ = sql_heavy_table_cursor_move_to_internal (self, _tmp0_);
	if (!_tmp1_) {
		const gchar* _tmp2_ = NULL;
		GError* _tmp3_;
		_tmp2_ = sql_heavy_sqlite_errstr (SQLITE_RANGE);
		_tmp3_ = g_error_new_literal (SQL_HEAVY_ERROR, SQL_HEAVY_ERROR_RANGE, _tmp2_);
		_inner_error_ = _tmp3_;
		if (_inner_error_->domain == SQL_HEAVY_ERROR) {
			g_propagate_error (error, _inner_error_);
			return FALSE;
		} else {
			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 FALSE;
		}
	}
	result = TRUE;
	return result;
}


/**
     * {@inheritDoc}
     */
static gboolean sql_heavy_table_cursor_real_next (SQLHeavyRecordSet* base, GError** error) {
	SQLHeavyTableCursor * self;
	gboolean result = FALSE;
	gint64 _tmp0_;
	gboolean _tmp1_ = FALSE;
	self = (SQLHeavyTableCursor*) base;
	_tmp0_ = self->priv->_offset;
	_tmp1_ = sql_heavy_table_cursor_move_to_internal (self, _tmp0_ + 1);
	result = _tmp1_;
	return result;
}


/**
     * {@inheritDoc}
     */
static gboolean sql_heavy_table_cursor_real_previous (SQLHeavyCursor* base, GError** error) {
	SQLHeavyTableCursor * self;
	gboolean result = FALSE;
	gint64 _tmp0_;
	gboolean _tmp1_ = FALSE;
	self = (SQLHeavyTableCursor*) base;
	_tmp0_ = self->priv->_offset;
	_tmp1_ = sql_heavy_table_cursor_move_to_internal (self, _tmp0_ - 1);
	result = _tmp1_;
	return result;
}


/**
     * Create a new cursor for the table
     *
     * @param table the table to create the cursor for
     */
SQLHeavyTableCursor* sql_heavy_table_cursor_construct (GType object_type, SQLHeavyTable* table) {
	SQLHeavyTableCursor * self = NULL;
	SQLHeavyTable* _tmp0_;
	g_return_val_if_fail (table != NULL, NULL);
	_tmp0_ = table;
	self = (SQLHeavyTableCursor*) g_object_new (object_type, "table", _tmp0_, NULL);
	return self;
}


SQLHeavyTableCursor* sql_heavy_table_cursor_new (SQLHeavyTable* table) {
	return sql_heavy_table_cursor_construct (SQL_HEAVY_TYPE_TABLE_CURSOR, table);
}


SQLHeavyTable* sql_heavy_table_cursor_get_table (SQLHeavyTableCursor* self) {
	SQLHeavyTable* result;
	SQLHeavyTable* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_table;
	result = _tmp0_;
	return result;
}


static void sql_heavy_table_cursor_set_table (SQLHeavyTableCursor* self, SQLHeavyTable* value) {
	SQLHeavyTable* _tmp0_;
	SQLHeavyTable* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	_tmp1_ = _g_object_ref0 (_tmp0_);
	_g_object_unref0 (self->priv->_table);
	self->priv->_table = _tmp1_;
	g_object_notify ((GObject *) self, "table");
}


gint64 sql_heavy_table_cursor_get_offset (SQLHeavyTableCursor* self) {
	gint64 result;
	gint64 _tmp0_;
	g_return_val_if_fail (self != NULL, 0LL);
	_tmp0_ = self->priv->_offset;
	result = _tmp0_;
	return result;
}


static void sql_heavy_table_cursor_set_offset (SQLHeavyTableCursor* self, gint64 value) {
	gint64 _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	self->priv->_offset = _tmp0_;
	g_object_notify ((GObject *) self, "offset");
}


SQLHeavySortOrder sql_heavy_table_cursor_get_sort_order (SQLHeavyTableCursor* self) {
	SQLHeavySortOrder result;
	SQLHeavySortOrder _tmp0_;
	g_return_val_if_fail (self != NULL, 0);
	_tmp0_ = self->priv->_sort_order;
	result = _tmp0_;
	return result;
}


void sql_heavy_table_cursor_set_sort_order (SQLHeavyTableCursor* self, SQLHeavySortOrder value) {
	SQLHeavySortOrder _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	self->priv->_sort_order = _tmp0_;
	g_object_notify ((GObject *) self, "sort-order");
}


const gchar* sql_heavy_table_cursor_get_sort_column (SQLHeavyTableCursor* self) {
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_sort_column;
	result = _tmp0_;
	return result;
}


void sql_heavy_table_cursor_set_sort_column (SQLHeavyTableCursor* self, const gchar* value) {
	const gchar* _tmp0_;
	gchar* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	_tmp1_ = g_strdup (_tmp0_);
	_g_free0 (self->priv->_sort_column);
	self->priv->_sort_column = _tmp1_;
	g_object_notify ((GObject *) self, "sort-column");
}


gint sql_heavy_table_cursor_get_field_count (SQLHeavyTableCursor* self) {
	gint result;
	SQLHeavyTable* _tmp0_;
	gint _tmp1_;
	gint _tmp2_;
	g_return_val_if_fail (self != NULL, 0);
	_tmp0_ = self->priv->_table;
	_tmp1_ = sql_heavy_table_get_field_count (_tmp0_);
	_tmp2_ = _tmp1_;
	result = _tmp2_;
	return result;
}


static SQLHeavyQuery* sql_heavy_table_cursor_get_query (SQLHeavyTableCursor* self) {
	SQLHeavyQuery* result;
	SQLHeavyQuery* _tmp0_;
	SQLHeavyQuery* _tmp32_;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_query;
	if (_tmp0_ == NULL) {
		{
			const gchar* _tmp1_ = NULL;
			SQLHeavySortOrder _tmp2_;
			SQLHeavyTable* _tmp3_;
			SQLHeavyQueryable* _tmp4_;
			SQLHeavyQueryable* _tmp5_;
			SQLHeavyTable* _tmp6_;
			const gchar* _tmp7_;
			const gchar* _tmp8_;
			gchar* _tmp9_ = NULL;
			gchar* _tmp10_;
			gchar* _tmp11_;
			gchar* _tmp12_;
			gchar* _tmp13_;
			gchar* _tmp14_;
			const gchar* _tmp15_;
			gchar* _tmp16_ = NULL;
			gchar* _tmp17_;
			gchar* _tmp18_;
			gchar* _tmp19_;
			gchar* _tmp20_;
			gchar* _tmp21_;
			const gchar* _tmp22_;
			gchar* _tmp23_;
			gchar* _tmp24_;
			gchar* _tmp25_;
			gchar* _tmp26_;
			SQLHeavyQuery* _tmp27_ = NULL;
			SQLHeavyQuery* _tmp28_;
			SQLHeavyQuery* _tmp29_;
			_tmp2_ = self->priv->_sort_order;
			if (_tmp2_ == SQL_HEAVY_SORT_ORDER_ASCENDING) {
				_tmp1_ = "ASC";
			} else {
				_tmp1_ = "DESC";
			}
			_tmp3_ = self->priv->_table;
			_tmp4_ = sql_heavy_table_get_queryable (_tmp3_);
			_tmp5_ = _tmp4_;
			_tmp6_ = self->priv->_table;
			_tmp7_ = sql_heavy_table_get_name (_tmp6_);
			_tmp8_ = _tmp7_;
			_tmp9_ = sql_heavy_escape_string (_tmp8_);
			_tmp10_ = _tmp9_;
			_tmp11_ = g_strconcat ("SELECT `ROWID` FROM `", _tmp10_, NULL);
			_tmp12_ = _tmp11_;
			_tmp13_ = g_strconcat (_tmp12_, "` ORDER BY `", NULL);
			_tmp14_ = _tmp13_;
			_tmp15_ = self->priv->_sort_column;
			_tmp16_ = sql_heavy_escape_string (_tmp15_);
			_tmp17_ = _tmp16_;
			_tmp18_ = g_strconcat (_tmp14_, _tmp17_, NULL);
			_tmp19_ = _tmp18_;
			_tmp20_ = g_strconcat (_tmp19_, "` ", NULL);
			_tmp21_ = _tmp20_;
			_tmp22_ = _tmp1_;
			_tmp23_ = g_strconcat (_tmp21_, _tmp22_, NULL);
			_tmp24_ = _tmp23_;
			_tmp25_ = g_strconcat (_tmp24_, " LIMIT 1 OFFSET :offset;", NULL);
			_tmp26_ = _tmp25_;
			_tmp27_ = sql_heavy_queryable_prepare (_tmp5_, _tmp26_, &_inner_error_);
			_tmp28_ = _tmp27_;
			_g_free0 (_tmp26_);
			_g_free0 (_tmp24_);
			_g_free0 (_tmp21_);
			_g_free0 (_tmp19_);
			_g_free0 (_tmp17_);
			_g_free0 (_tmp14_);
			_g_free0 (_tmp12_);
			_g_free0 (_tmp10_);
			_tmp29_ = _tmp28_;
			if (_inner_error_ != NULL) {
				if (_inner_error_->domain == SQL_HEAVY_ERROR) {
					goto __catch41_sql_heavy_error;
				}
				g_critical ("file %s: line %d: unexpected 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;
			}
			_g_object_unref0 (self->priv->_query);
			self->priv->_query = _tmp29_;
		}
		goto __finally41;
		__catch41_sql_heavy_error:
		{
			GError* e = NULL;
			GError* _tmp30_;
			const gchar* _tmp31_;
			e = _inner_error_;
			_inner_error_ = NULL;
			_tmp30_ = e;
			_tmp31_ = _tmp30_->message;
			g_critical ("sqlheavy-table-cursor.vala:40: Unable to create table cursor: %s", _tmp31_);
			_g_error_free0 (e);
		}
		__finally41:
		if (_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;
		}
	}
	_tmp32_ = self->priv->_query;
	result = _tmp32_;
	return result;
}


static GObject * sql_heavy_table_cursor_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) {
	GObject * obj;
	GObjectClass * parent_class;
	SQLHeavyTableCursor * self;
	GError * _inner_error_ = NULL;
	parent_class = G_OBJECT_CLASS (sql_heavy_table_cursor_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = SQL_HEAVY_TABLE_CURSOR (obj);
	{
		sql_heavy_record_set_next ((SQLHeavyRecordSet*) self, &_inner_error_);
		if (_inner_error_ != NULL) {
			if (_inner_error_->domain == SQL_HEAVY_ERROR) {
				goto __catch42_sql_heavy_error;
			}
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
			g_clear_error (&_inner_error_);
		}
	}
	goto __finally42;
	__catch42_sql_heavy_error:
	{
		GError* e = NULL;
		GError* _tmp0_;
		const gchar* _tmp1_;
		e = _inner_error_;
		_inner_error_ = NULL;
		_tmp0_ = e;
		_tmp1_ = _tmp0_->message;
		g_critical ("sqlheavy-table-cursor.vala:109: Unable to create table cursor: %s", _tmp1_);
		_g_error_free0 (e);
	}
	__finally42:
	if (_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 obj;
}


static void sql_heavy_table_cursor_class_init (SQLHeavyTableCursorClass * klass) {
	sql_heavy_table_cursor_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (SQLHeavyTableCursorPrivate));
	G_OBJECT_CLASS (klass)->get_property = _vala_sql_heavy_table_cursor_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_sql_heavy_table_cursor_set_property;
	G_OBJECT_CLASS (klass)->constructor = sql_heavy_table_cursor_constructor;
	G_OBJECT_CLASS (klass)->finalize = sql_heavy_table_cursor_finalize;
	/**
	     * The table
	     */
	g_object_class_install_property (G_OBJECT_CLASS (klass), SQL_HEAVY_TABLE_CURSOR_TABLE, g_param_spec_object ("table", "table", "table", SQL_HEAVY_TYPE_TABLE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	/**
	     * The current offset
	     */
	g_object_class_install_property (G_OBJECT_CLASS (klass), SQL_HEAVY_TABLE_CURSOR_OFFSET, g_param_spec_int64 ("offset", "offset", "offset", G_MININT64, G_MAXINT64, (gint64) 0, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
	/**
	     * The order to sort the result set in
	     */
	g_object_class_install_property (G_OBJECT_CLASS (klass), SQL_HEAVY_TABLE_CURSOR_SORT_ORDER, g_param_spec_enum ("sort-order", "sort-order", "sort-order", SQL_HEAVY_TYPE_SORT_ORDER, SQL_HEAVY_SORT_ORDER_ASCENDING, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
	/**
	     * The column to sort the result set by
	     */
	g_object_class_install_property (G_OBJECT_CLASS (klass), SQL_HEAVY_TABLE_CURSOR_SORT_COLUMN, g_param_spec_string ("sort-column", "sort-column", "sort-column", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
	/**
	     * {@inheritDoc}
	     */
	g_object_class_install_property (G_OBJECT_CLASS (klass), SQL_HEAVY_TABLE_CURSOR_FIELD_COUNT, g_param_spec_int ("field-count", "field-count", "field-count", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
}


static void sql_heavy_table_cursor_sql_heavy_record_set_interface_init (SQLHeavyRecordSetIface * iface) {
	sql_heavy_table_cursor_sql_heavy_record_set_parent_iface = g_type_interface_peek_parent (iface);
	iface->next = (gboolean (*)(SQLHeavyRecordSet*, GError**)) sql_heavy_table_cursor_real_next;
}


static void sql_heavy_table_cursor_sql_heavy_cursor_interface_init (SQLHeavyCursorIface * iface) {
	sql_heavy_table_cursor_sql_heavy_cursor_parent_iface = g_type_interface_peek_parent (iface);
	iface->get = (SQLHeavyRecord* (*)(SQLHeavyCursor*, GError**)) sql_heavy_table_cursor_real_get;
	iface->move_to = (gboolean (*)(SQLHeavyCursor*, gint64, GError**)) sql_heavy_table_cursor_real_move_to;
	iface->previous = (gboolean (*)(SQLHeavyCursor*, GError**)) sql_heavy_table_cursor_real_previous;
}


static void sql_heavy_table_cursor_instance_init (SQLHeavyTableCursor * self) {
	gchar* _tmp0_;
	self->priv = SQL_HEAVY_TABLE_CURSOR_GET_PRIVATE (self);
	self->priv->_offset = (gint64) 0;
	self->priv->_sort_order = SQL_HEAVY_SORT_ORDER_ASCENDING;
	_tmp0_ = g_strdup ("ROWID");
	self->priv->_sort_column = _tmp0_;
	self->priv->current_id = (gint64) (-1);
	self->priv->_query = NULL;
}


static void sql_heavy_table_cursor_finalize (GObject* obj) {
	SQLHeavyTableCursor * self;
	self = SQL_HEAVY_TABLE_CURSOR (obj);
	_g_object_unref0 (self->priv->_table);
	_g_free0 (self->priv->_sort_column);
	_g_object_unref0 (self->priv->_query);
	G_OBJECT_CLASS (sql_heavy_table_cursor_parent_class)->finalize (obj);
}


/**
   * Cursor for use with a {@link Table}
   */
GType sql_heavy_table_cursor_get_type (void) {
	static volatile gsize sql_heavy_table_cursor_type_id__volatile = 0;
	if (g_once_init_enter (&sql_heavy_table_cursor_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (SQLHeavyTableCursorClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) sql_heavy_table_cursor_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (SQLHeavyTableCursor), 0, (GInstanceInitFunc) sql_heavy_table_cursor_instance_init, NULL };
		static const GInterfaceInfo sql_heavy_record_set_info = { (GInterfaceInitFunc) sql_heavy_table_cursor_sql_heavy_record_set_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
		static const GInterfaceInfo sql_heavy_cursor_info = { (GInterfaceInitFunc) sql_heavy_table_cursor_sql_heavy_cursor_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
		GType sql_heavy_table_cursor_type_id;
		sql_heavy_table_cursor_type_id = g_type_register_static (G_TYPE_OBJECT, "SQLHeavyTableCursor", &g_define_type_info, 0);
		g_type_add_interface_static (sql_heavy_table_cursor_type_id, SQL_HEAVY_TYPE_RECORD_SET, &sql_heavy_record_set_info);
		g_type_add_interface_static (sql_heavy_table_cursor_type_id, SQL_HEAVY_TYPE_CURSOR, &sql_heavy_cursor_info);
		g_once_init_leave (&sql_heavy_table_cursor_type_id__volatile, sql_heavy_table_cursor_type_id);
	}
	return sql_heavy_table_cursor_type_id__volatile;
}


static void _vala_sql_heavy_table_cursor_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
	SQLHeavyTableCursor * self;
	self = SQL_HEAVY_TABLE_CURSOR (object);
	switch (property_id) {
		case SQL_HEAVY_TABLE_CURSOR_TABLE:
		g_value_set_object (value, sql_heavy_table_cursor_get_table (self));
		break;
		case SQL_HEAVY_TABLE_CURSOR_OFFSET:
		g_value_set_int64 (value, sql_heavy_table_cursor_get_offset (self));
		break;
		case SQL_HEAVY_TABLE_CURSOR_SORT_ORDER:
		g_value_set_enum (value, sql_heavy_table_cursor_get_sort_order (self));
		break;
		case SQL_HEAVY_TABLE_CURSOR_SORT_COLUMN:
		g_value_set_string (value, sql_heavy_table_cursor_get_sort_column (self));
		break;
		case SQL_HEAVY_TABLE_CURSOR_FIELD_COUNT:
		g_value_set_int (value, sql_heavy_table_cursor_get_field_count (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}


static void _vala_sql_heavy_table_cursor_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
	SQLHeavyTableCursor * self;
	self = SQL_HEAVY_TABLE_CURSOR (object);
	switch (property_id) {
		case SQL_HEAVY_TABLE_CURSOR_TABLE:
		sql_heavy_table_cursor_set_table (self, g_value_get_object (value));
		break;
		case SQL_HEAVY_TABLE_CURSOR_OFFSET:
		sql_heavy_table_cursor_set_offset (self, g_value_get_int64 (value));
		break;
		case SQL_HEAVY_TABLE_CURSOR_SORT_ORDER:
		sql_heavy_table_cursor_set_sort_order (self, g_value_get_enum (value));
		break;
		case SQL_HEAVY_TABLE_CURSOR_SORT_COLUMN:
		sql_heavy_table_cursor_set_sort_column (self, g_value_get_string (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}



