/* Statement.c generated by valac 0.26.2, the Vala compiler
 * generated from Statement.vala, do not modify */

/*  This file is part of corebird, a Gtk+ linux Twitter client.
 *  Copyright (C) 2013 Timm Bäder
 *
 *  corebird 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.
 *
 *  corebird 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 corebird.  If not, see <http://www.gnu.org/licenses/>.
 */

#include <glib.h>
#include <glib-object.h>
#include <sqlite3.h>
#include <stdlib.h>
#include <string.h>
#include <gee.h>
#include <gobject/gvaluecollector.h>


#define SQL_TYPE_ISTATEMENT (sql_istatement_get_type ())
#define SQL_ISTATEMENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SQL_TYPE_ISTATEMENT, SqlIStatement))
#define SQL_IS_ISTATEMENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SQL_TYPE_ISTATEMENT))
#define SQL_ISTATEMENT_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), SQL_TYPE_ISTATEMENT, SqlIStatementIface))

typedef struct _SqlIStatement SqlIStatement;
typedef struct _SqlIStatementIface SqlIStatementIface;

#define SQL_TYPE_INSERT_STATEMENT (sql_insert_statement_get_type ())
#define SQL_INSERT_STATEMENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SQL_TYPE_INSERT_STATEMENT, SqlInsertStatement))
#define SQL_INSERT_STATEMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SQL_TYPE_INSERT_STATEMENT, SqlInsertStatementClass))
#define SQL_IS_INSERT_STATEMENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SQL_TYPE_INSERT_STATEMENT))
#define SQL_IS_INSERT_STATEMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SQL_TYPE_INSERT_STATEMENT))
#define SQL_INSERT_STATEMENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SQL_TYPE_INSERT_STATEMENT, SqlInsertStatementClass))

typedef struct _SqlInsertStatement SqlInsertStatement;
typedef struct _SqlInsertStatementClass SqlInsertStatementClass;
typedef struct _SqlInsertStatementPrivate SqlInsertStatementPrivate;
#define _g_string_free0(var) ((var == NULL) ? NULL : (var = (g_string_free (var, TRUE), NULL)))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _sqlite3_finalize0(var) ((var == NULL) ? NULL : (var = (sqlite3_finalize (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
typedef struct _SqlParamSpecInsertStatement SqlParamSpecInsertStatement;

struct _SqlIStatementIface {
	GTypeInterface parent_iface;
	sqlite3* (*get_db) (SqlIStatement* self);
	void (*set_db) (SqlIStatement* self, sqlite3* value);
};

typedef gboolean (*SqlSelectCallback) (gchar** vals, int vals_length1, void* user_data);
struct _SqlInsertStatement {
	GTypeInstance parent_instance;
	volatile int ref_count;
	SqlInsertStatementPrivate * priv;
};

struct _SqlInsertStatementClass {
	GTypeClass parent_class;
	void (*finalize) (SqlInsertStatement *self);
};

struct _SqlInsertStatementPrivate {
	sqlite3* _db;
	GString* query_builder;
	GeeArrayList* bindings;
	gboolean ran;
};

struct _SqlParamSpecInsertStatement {
	GParamSpec parent_instance;
};


static gpointer sql_insert_statement_parent_class = NULL;
static SqlIStatementIface* sql_insert_statement_sql_istatement_parent_iface = NULL;

GType sql_istatement_get_type (void) G_GNUC_CONST;
sqlite3* sql_istatement_get_db (SqlIStatement* self);
void sql_istatement_set_db (SqlIStatement* self, sqlite3* value);
gpointer sql_insert_statement_ref (gpointer instance);
void sql_insert_statement_unref (gpointer instance);
GParamSpec* sql_param_spec_insert_statement (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
void sql_value_set_insert_statement (GValue* value, gpointer v_object);
void sql_value_take_insert_statement (GValue* value, gpointer v_object);
gpointer sql_value_get_insert_statement (const GValue* value);
GType sql_insert_statement_get_type (void) G_GNUC_CONST;
#define SQL_INSERT_STATEMENT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SQL_TYPE_INSERT_STATEMENT, SqlInsertStatementPrivate))
enum  {
	SQL_INSERT_STATEMENT_DUMMY_PROPERTY
};
SqlInsertStatement* sql_insert_statement_new (const gchar* table_name, gboolean replace);
SqlInsertStatement* sql_insert_statement_construct (GType object_type, const gchar* table_name, gboolean replace);
gint64 sql_insert_statement_run (SqlInsertStatement* self);
SqlInsertStatement* sql_insert_statement_val (SqlInsertStatement* self, const gchar* col_name, const gchar* col_value);
SqlInsertStatement* sql_insert_statement_vali (SqlInsertStatement* self, const gchar* col_name, gint col_value);
SqlInsertStatement* sql_insert_statement_vali64 (SqlInsertStatement* self, const gchar* col_name, gint64 col_value);
SqlInsertStatement* sql_insert_statement_valb (SqlInsertStatement* self, const gchar* col_name, gboolean col_value);
static void sql_insert_statement_finalize (SqlInsertStatement* obj);


sqlite3* sql_istatement_get_db (SqlIStatement* self) {
	g_return_val_if_fail (SQL_IS_ISTATEMENT (self), NULL);
	return SQL_ISTATEMENT_GET_INTERFACE (self)->get_db (self);
}


void sql_istatement_set_db (SqlIStatement* self, sqlite3* value) {
	g_return_if_fail (SQL_IS_ISTATEMENT (self));
	SQL_ISTATEMENT_GET_INTERFACE (self)->set_db (self, value);
}


static void sql_istatement_base_init (SqlIStatementIface * iface) {
	static gboolean initialized = FALSE;
	if (!initialized) {
		initialized = TRUE;
	}
}


GType sql_istatement_get_type (void) {
	static volatile gsize sql_istatement_type_id__volatile = 0;
	if (g_once_init_enter (&sql_istatement_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (SqlIStatementIface), (GBaseInitFunc) sql_istatement_base_init, (GBaseFinalizeFunc) NULL, (GClassInitFunc) NULL, (GClassFinalizeFunc) NULL, NULL, 0, 0, (GInstanceInitFunc) NULL, NULL };
		GType sql_istatement_type_id;
		sql_istatement_type_id = g_type_register_static (G_TYPE_INTERFACE, "SqlIStatement", &g_define_type_info, 0);
		g_once_init_leave (&sql_istatement_type_id__volatile, sql_istatement_type_id);
	}
	return sql_istatement_type_id__volatile;
}


SqlInsertStatement* sql_insert_statement_construct (GType object_type, const gchar* table_name, gboolean replace) {
	SqlInsertStatement* self = NULL;
	gboolean _tmp0_ = FALSE;
	GString* _tmp3_ = NULL;
	const gchar* _tmp4_ = NULL;
	GString* _tmp5_ = NULL;
	g_return_val_if_fail (table_name != NULL, NULL);
	self = (SqlInsertStatement*) g_type_create_instance (object_type);
	_tmp0_ = replace;
	if (_tmp0_) {
		GString* _tmp1_ = NULL;
		_tmp1_ = self->priv->query_builder;
		g_string_append (_tmp1_, "INSERT OR REPLACE INTO `");
	} else {
		GString* _tmp2_ = NULL;
		_tmp2_ = self->priv->query_builder;
		g_string_append (_tmp2_, "INSERT INTO `");
	}
	_tmp3_ = self->priv->query_builder;
	_tmp4_ = table_name;
	_tmp5_ = g_string_append (_tmp3_, _tmp4_);
	g_string_append (_tmp5_, "` (");
	return self;
}


SqlInsertStatement* sql_insert_statement_new (const gchar* table_name, gboolean replace) {
	return sql_insert_statement_construct (SQL_TYPE_INSERT_STATEMENT, table_name, replace);
}


gint64 sql_insert_statement_run (SqlInsertStatement* self) {
	gint64 result = 0LL;
	GString* _tmp0_ = NULL;
	GString* _tmp1_ = NULL;
	GString* _tmp9_ = NULL;
	sqlite3_stmt* stmt = NULL;
	gint ok = 0;
	sqlite3* _tmp10_ = NULL;
	sqlite3* _tmp11_ = NULL;
	GString* _tmp12_ = NULL;
	const gchar* _tmp13_ = NULL;
	sqlite3_stmt* _tmp14_ = NULL;
	gint _tmp15_ = 0;
	gint _tmp16_ = 0;
	sqlite3_stmt* _tmp32_ = NULL;
	gint _tmp33_ = 0;
	gint _tmp34_ = 0;
	sqlite3* _tmp57_ = NULL;
	sqlite3* _tmp58_ = NULL;
	gint64 _tmp59_ = 0LL;
	g_return_val_if_fail (SQL_IS_INSERT_STATEMENT (self), 0LL);
	_tmp0_ = self->priv->query_builder;
	g_string_append (_tmp0_, ") VALUES (");
	_tmp1_ = self->priv->query_builder;
	g_string_append (_tmp1_, "?");
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp2_ = FALSE;
			_tmp2_ = TRUE;
			while (TRUE) {
				gint _tmp4_ = 0;
				GeeArrayList* _tmp5_ = NULL;
				gint _tmp6_ = 0;
				gint _tmp7_ = 0;
				GString* _tmp8_ = NULL;
				if (!_tmp2_) {
					gint _tmp3_ = 0;
					_tmp3_ = i;
					i = _tmp3_ + 1;
				}
				_tmp2_ = FALSE;
				_tmp4_ = i;
				_tmp5_ = self->priv->bindings;
				_tmp6_ = gee_abstract_collection_get_size (G_TYPE_CHECK_INSTANCE_CAST (_tmp5_, GEE_TYPE_COLLECTION, GeeCollection));
				_tmp7_ = _tmp6_;
				if (!(_tmp4_ < (_tmp7_ - 1))) {
					break;
				}
				_tmp8_ = self->priv->query_builder;
				g_string_append (_tmp8_, ",?");
			}
		}
	}
	_tmp9_ = self->priv->query_builder;
	g_string_append (_tmp9_, ");");
	_tmp10_ = sql_istatement_get_db (G_TYPE_CHECK_INSTANCE_CAST (self, SQL_TYPE_ISTATEMENT, SqlIStatement));
	_tmp11_ = _tmp10_;
	_tmp12_ = self->priv->query_builder;
	_tmp13_ = _tmp12_->str;
	_tmp15_ = sqlite3_prepare_v2 (_tmp11_, _tmp13_, -1, &_tmp14_, NULL);
	_sqlite3_finalize0 (stmt);
	stmt = _tmp14_;
	ok = _tmp15_;
	_tmp16_ = ok;
	if (_tmp16_ != SQLITE_OK) {
		sqlite3* _tmp17_ = NULL;
		sqlite3* _tmp18_ = NULL;
		const gchar* _tmp19_ = NULL;
		_tmp17_ = sql_istatement_get_db (G_TYPE_CHECK_INSTANCE_CAST (self, SQL_TYPE_ISTATEMENT, SqlIStatement));
		_tmp18_ = _tmp17_;
		_tmp19_ = sqlite3_errmsg (_tmp18_);
		g_critical ("Statement.vala:53: %s", _tmp19_);
		result = (gint64) (-1);
		_sqlite3_finalize0 (stmt);
		return result;
	}
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp20_ = FALSE;
			_tmp20_ = TRUE;
			while (TRUE) {
				gint _tmp22_ = 0;
				GeeArrayList* _tmp23_ = NULL;
				gint _tmp24_ = 0;
				gint _tmp25_ = 0;
				sqlite3_stmt* _tmp26_ = NULL;
				gint _tmp27_ = 0;
				GeeArrayList* _tmp28_ = NULL;
				gint _tmp29_ = 0;
				gpointer _tmp30_ = NULL;
				GDestroyNotify _tmp31_ = NULL;
				if (!_tmp20_) {
					gint _tmp21_ = 0;
					_tmp21_ = i;
					i = _tmp21_ + 1;
				}
				_tmp20_ = FALSE;
				_tmp22_ = i;
				_tmp23_ = self->priv->bindings;
				_tmp24_ = gee_abstract_collection_get_size (G_TYPE_CHECK_INSTANCE_CAST (_tmp23_, GEE_TYPE_COLLECTION, GeeCollection));
				_tmp25_ = _tmp24_;
				if (!(_tmp22_ < _tmp25_)) {
					break;
				}
				_tmp26_ = stmt;
				_tmp27_ = i;
				_tmp28_ = self->priv->bindings;
				_tmp29_ = i;
				_tmp30_ = gee_abstract_list_get (G_TYPE_CHECK_INSTANCE_CAST (_tmp28_, GEE_TYPE_ABSTRACT_LIST, GeeAbstractList), _tmp29_);
				_tmp31_ = g_free;
				sqlite3_bind_text (_tmp26_, _tmp27_ + 1, (gchar*) _tmp30_, -1, _tmp31_);
			}
		}
	}
	_tmp32_ = stmt;
	_tmp33_ = sqlite3_step (_tmp32_);
	ok = _tmp33_;
	_tmp34_ = ok;
	if (_tmp34_ != SQLITE_DONE) {
		sqlite3* _tmp35_ = NULL;
		sqlite3* _tmp36_ = NULL;
		const gchar* _tmp37_ = NULL;
		GString* err_msg = NULL;
		GString* _tmp38_ = NULL;
		GString* _tmp39_ = NULL;
		sqlite3_stmt* _tmp40_ = NULL;
		const gchar* _tmp41_ = NULL;
		GString* _tmp42_ = NULL;
		GString* _tmp55_ = NULL;
		const gchar* _tmp56_ = NULL;
		_tmp35_ = sql_istatement_get_db (G_TYPE_CHECK_INSTANCE_CAST (self, SQL_TYPE_ISTATEMENT, SqlIStatement));
		_tmp36_ = _tmp35_;
		_tmp37_ = sqlite3_errmsg (_tmp36_);
		g_critical ("Statement.vala:62: %s", _tmp37_);
		_tmp38_ = g_string_new ("");
		err_msg = _tmp38_;
		_tmp39_ = err_msg;
		_tmp40_ = stmt;
		_tmp41_ = sqlite3_sql (_tmp40_);
		_tmp42_ = g_string_append (_tmp39_, _tmp41_);
		g_string_append (_tmp42_, " --- ");
		{
			gint i = 0;
			i = 0;
			{
				gboolean _tmp43_ = FALSE;
				_tmp43_ = TRUE;
				while (TRUE) {
					gint _tmp45_ = 0;
					GeeArrayList* _tmp46_ = NULL;
					gint _tmp47_ = 0;
					gint _tmp48_ = 0;
					GString* _tmp49_ = NULL;
					GeeArrayList* _tmp50_ = NULL;
					gint _tmp51_ = 0;
					gpointer _tmp52_ = NULL;
					gchar* _tmp53_ = NULL;
					GString* _tmp54_ = NULL;
					if (!_tmp43_) {
						gint _tmp44_ = 0;
						_tmp44_ = i;
						i = _tmp44_ + 1;
					}
					_tmp43_ = FALSE;
					_tmp45_ = i;
					_tmp46_ = self->priv->bindings;
					_tmp47_ = gee_abstract_collection_get_size (G_TYPE_CHECK_INSTANCE_CAST (_tmp46_, GEE_TYPE_COLLECTION, GeeCollection));
					_tmp48_ = _tmp47_;
					if (!(_tmp45_ < _tmp48_)) {
						break;
					}
					_tmp49_ = err_msg;
					_tmp50_ = self->priv->bindings;
					_tmp51_ = i;
					_tmp52_ = gee_abstract_list_get (G_TYPE_CHECK_INSTANCE_CAST (_tmp50_, GEE_TYPE_ABSTRACT_LIST, GeeAbstractList), _tmp51_);
					_tmp53_ = (gchar*) _tmp52_;
					_tmp54_ = g_string_append (_tmp49_, _tmp53_);
					g_string_append (_tmp54_, ", ");
					_g_free0 (_tmp53_);
				}
			}
		}
		_tmp55_ = err_msg;
		_tmp56_ = _tmp55_->str;
		g_critical ("Statement.vala:68: %s", _tmp56_);
		_g_string_free0 (err_msg);
	}
	self->priv->ran = TRUE;
	_tmp57_ = sql_istatement_get_db (G_TYPE_CHECK_INSTANCE_CAST (self, SQL_TYPE_ISTATEMENT, SqlIStatement));
	_tmp58_ = _tmp57_;
	_tmp59_ = sqlite3_last_insert_rowid (_tmp58_);
	result = _tmp59_;
	_sqlite3_finalize0 (stmt);
	return result;
}


static gpointer _sql_insert_statement_ref0 (gpointer self) {
	return self ? sql_insert_statement_ref (self) : NULL;
}


SqlInsertStatement* sql_insert_statement_val (SqlInsertStatement* self, const gchar* col_name, const gchar* col_value) {
	SqlInsertStatement* result = NULL;
	GeeArrayList* _tmp0_ = NULL;
	gint _tmp1_ = 0;
	gint _tmp2_ = 0;
	GString* _tmp4_ = NULL;
	GString* _tmp5_ = NULL;
	const gchar* _tmp6_ = NULL;
	GString* _tmp7_ = NULL;
	GeeArrayList* _tmp8_ = NULL;
	const gchar* _tmp9_ = NULL;
	SqlInsertStatement* _tmp10_ = NULL;
	g_return_val_if_fail (SQL_IS_INSERT_STATEMENT (self), NULL);
	g_return_val_if_fail (col_name != NULL, NULL);
	g_return_val_if_fail (col_value != NULL, NULL);
	_tmp0_ = self->priv->bindings;
	_tmp1_ = gee_abstract_collection_get_size (G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, GEE_TYPE_COLLECTION, GeeCollection));
	_tmp2_ = _tmp1_;
	if (_tmp2_ > 0) {
		GString* _tmp3_ = NULL;
		_tmp3_ = self->priv->query_builder;
		g_string_append (_tmp3_, ", ");
	}
	_tmp4_ = self->priv->query_builder;
	_tmp5_ = g_string_append (_tmp4_, "`");
	_tmp6_ = col_name;
	_tmp7_ = g_string_append (_tmp5_, _tmp6_);
	g_string_append (_tmp7_, "`");
	_tmp8_ = self->priv->bindings;
	_tmp9_ = col_value;
	gee_abstract_collection_add (G_TYPE_CHECK_INSTANCE_CAST (_tmp8_, GEE_TYPE_ABSTRACT_COLLECTION, GeeAbstractCollection), _tmp9_);
	_tmp10_ = _sql_insert_statement_ref0 (self);
	result = _tmp10_;
	return result;
}


SqlInsertStatement* sql_insert_statement_vali (SqlInsertStatement* self, const gchar* col_name, gint col_value) {
	SqlInsertStatement* result = NULL;
	const gchar* _tmp0_ = NULL;
	gint _tmp1_ = 0;
	gchar* _tmp2_ = NULL;
	gchar* _tmp3_ = NULL;
	SqlInsertStatement* _tmp4_ = NULL;
	SqlInsertStatement* _tmp5_ = NULL;
	g_return_val_if_fail (SQL_IS_INSERT_STATEMENT (self), NULL);
	g_return_val_if_fail (col_name != NULL, NULL);
	_tmp0_ = col_name;
	_tmp1_ = col_value;
	_tmp2_ = g_strdup_printf ("%i", _tmp1_);
	_tmp3_ = _tmp2_;
	_tmp4_ = sql_insert_statement_val (self, _tmp0_, _tmp3_);
	_tmp5_ = _tmp4_;
	_g_free0 (_tmp3_);
	result = _tmp5_;
	return result;
}


SqlInsertStatement* sql_insert_statement_vali64 (SqlInsertStatement* self, const gchar* col_name, gint64 col_value) {
	SqlInsertStatement* result = NULL;
	const gchar* _tmp0_ = NULL;
	gint64 _tmp1_ = 0LL;
	gchar* _tmp2_ = NULL;
	gchar* _tmp3_ = NULL;
	SqlInsertStatement* _tmp4_ = NULL;
	SqlInsertStatement* _tmp5_ = NULL;
	g_return_val_if_fail (SQL_IS_INSERT_STATEMENT (self), NULL);
	g_return_val_if_fail (col_name != NULL, NULL);
	_tmp0_ = col_name;
	_tmp1_ = col_value;
	_tmp2_ = g_strdup_printf ("%" G_GINT64_FORMAT, _tmp1_);
	_tmp3_ = _tmp2_;
	_tmp4_ = sql_insert_statement_val (self, _tmp0_, _tmp3_);
	_tmp5_ = _tmp4_;
	_g_free0 (_tmp3_);
	result = _tmp5_;
	return result;
}


SqlInsertStatement* sql_insert_statement_valb (SqlInsertStatement* self, const gchar* col_name, gboolean col_value) {
	SqlInsertStatement* result = NULL;
	const gchar* _tmp0_ = NULL;
	gboolean _tmp1_ = FALSE;
	const gchar* _tmp2_ = NULL;
	SqlInsertStatement* _tmp3_ = NULL;
	g_return_val_if_fail (SQL_IS_INSERT_STATEMENT (self), NULL);
	g_return_val_if_fail (col_name != NULL, NULL);
	_tmp1_ = col_value;
	if (_tmp1_) {
		_tmp0_ = "1";
	} else {
		_tmp0_ = "0";
	}
	_tmp2_ = col_name;
	_tmp3_ = sql_insert_statement_val (self, _tmp2_, _tmp0_);
	result = _tmp3_;
	return result;
}


static sqlite3* sql_insert_statement_real_get_db (SqlIStatement* base) {
	sqlite3* result;
	SqlInsertStatement* self;
	sqlite3* _tmp0_ = NULL;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, SQL_TYPE_INSERT_STATEMENT, SqlInsertStatement);
	_tmp0_ = self->priv->_db;
	result = _tmp0_;
	return result;
}


static void sql_insert_statement_real_set_db (SqlIStatement* base, sqlite3* value) {
	SqlInsertStatement* self;
	sqlite3* _tmp0_ = NULL;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, SQL_TYPE_INSERT_STATEMENT, SqlInsertStatement);
	_tmp0_ = value;
	self->priv->_db = _tmp0_;
}


static void sql_value_insert_statement_init (GValue* value) {
	value->data[0].v_pointer = NULL;
}


static void sql_value_insert_statement_free_value (GValue* value) {
	if (value->data[0].v_pointer) {
		sql_insert_statement_unref (value->data[0].v_pointer);
	}
}


static void sql_value_insert_statement_copy_value (const GValue* src_value, GValue* dest_value) {
	if (src_value->data[0].v_pointer) {
		dest_value->data[0].v_pointer = sql_insert_statement_ref (src_value->data[0].v_pointer);
	} else {
		dest_value->data[0].v_pointer = NULL;
	}
}


static gpointer sql_value_insert_statement_peek_pointer (const GValue* value) {
	return value->data[0].v_pointer;
}


static gchar* sql_value_insert_statement_collect_value (GValue* value, guint n_collect_values, GTypeCValue* collect_values, guint collect_flags) {
	if (collect_values[0].v_pointer) {
		SqlInsertStatement* object;
		object = collect_values[0].v_pointer;
		if (object->parent_instance.g_class == NULL) {
			return g_strconcat ("invalid unclassed object pointer for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		} else if (!g_value_type_compatible (G_TYPE_FROM_INSTANCE (object), G_VALUE_TYPE (value))) {
			return g_strconcat ("invalid object type `", g_type_name (G_TYPE_FROM_INSTANCE (object)), "' for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		}
		value->data[0].v_pointer = sql_insert_statement_ref (object);
	} else {
		value->data[0].v_pointer = NULL;
	}
	return NULL;
}


static gchar* sql_value_insert_statement_lcopy_value (const GValue* value, guint n_collect_values, GTypeCValue* collect_values, guint collect_flags) {
	SqlInsertStatement** object_p;
	object_p = collect_values[0].v_pointer;
	if (!object_p) {
		return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
	}
	if (!value->data[0].v_pointer) {
		*object_p = NULL;
	} else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) {
		*object_p = value->data[0].v_pointer;
	} else {
		*object_p = sql_insert_statement_ref (value->data[0].v_pointer);
	}
	return NULL;
}


GParamSpec* sql_param_spec_insert_statement (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags) {
	SqlParamSpecInsertStatement* spec;
	g_return_val_if_fail (g_type_is_a (object_type, SQL_TYPE_INSERT_STATEMENT), NULL);
	spec = g_param_spec_internal (G_TYPE_PARAM_OBJECT, name, nick, blurb, flags);
	G_PARAM_SPEC (spec)->value_type = object_type;
	return G_PARAM_SPEC (spec);
}


gpointer sql_value_get_insert_statement (const GValue* value) {
	g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, SQL_TYPE_INSERT_STATEMENT), NULL);
	return value->data[0].v_pointer;
}


void sql_value_set_insert_statement (GValue* value, gpointer v_object) {
	SqlInsertStatement* old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, SQL_TYPE_INSERT_STATEMENT));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, SQL_TYPE_INSERT_STATEMENT));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
		sql_insert_statement_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		sql_insert_statement_unref (old);
	}
}


void sql_value_take_insert_statement (GValue* value, gpointer v_object) {
	SqlInsertStatement* old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, SQL_TYPE_INSERT_STATEMENT));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, SQL_TYPE_INSERT_STATEMENT));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		sql_insert_statement_unref (old);
	}
}


static void sql_insert_statement_class_init (SqlInsertStatementClass * klass) {
	sql_insert_statement_parent_class = g_type_class_peek_parent (klass);
	((SqlInsertStatementClass *) klass)->finalize = sql_insert_statement_finalize;
	g_type_class_add_private (klass, sizeof (SqlInsertStatementPrivate));
}


static void sql_insert_statement_sql_istatement_interface_init (SqlIStatementIface * iface) {
	sql_insert_statement_sql_istatement_parent_iface = g_type_interface_peek_parent (iface);
	iface->get_db = sql_insert_statement_real_get_db;
	iface->set_db = sql_insert_statement_real_set_db;
}


static void sql_insert_statement_instance_init (SqlInsertStatement * self) {
	GString* _tmp0_ = NULL;
	GeeArrayList* _tmp1_ = NULL;
	self->priv = SQL_INSERT_STATEMENT_GET_PRIVATE (self);
	_tmp0_ = g_string_new ("");
	self->priv->query_builder = _tmp0_;
	_tmp1_ = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, NULL, NULL, NULL);
	self->priv->bindings = _tmp1_;
	self->priv->ran = FALSE;
	self->ref_count = 1;
}


static void sql_insert_statement_finalize (SqlInsertStatement* obj) {
	SqlInsertStatement * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, SQL_TYPE_INSERT_STATEMENT, SqlInsertStatement);
	g_signal_handlers_destroy (self);
	_g_string_free0 (self->priv->query_builder);
	_g_object_unref0 (self->priv->bindings);
}


GType sql_insert_statement_get_type (void) {
	static volatile gsize sql_insert_statement_type_id__volatile = 0;
	if (g_once_init_enter (&sql_insert_statement_type_id__volatile)) {
		static const GTypeValueTable g_define_type_value_table = { sql_value_insert_statement_init, sql_value_insert_statement_free_value, sql_value_insert_statement_copy_value, sql_value_insert_statement_peek_pointer, "p", sql_value_insert_statement_collect_value, "p", sql_value_insert_statement_lcopy_value };
		static const GTypeInfo g_define_type_info = { sizeof (SqlInsertStatementClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) sql_insert_statement_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (SqlInsertStatement), 0, (GInstanceInitFunc) sql_insert_statement_instance_init, &g_define_type_value_table };
		static const GTypeFundamentalInfo g_define_type_fundamental_info = { (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE) };
		static const GInterfaceInfo sql_istatement_info = { (GInterfaceInitFunc) sql_insert_statement_sql_istatement_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
		GType sql_insert_statement_type_id;
		sql_insert_statement_type_id = g_type_register_fundamental (g_type_fundamental_next (), "SqlInsertStatement", &g_define_type_info, &g_define_type_fundamental_info, 0);
		g_type_add_interface_static (sql_insert_statement_type_id, SQL_TYPE_ISTATEMENT, &sql_istatement_info);
		g_once_init_leave (&sql_insert_statement_type_id__volatile, sql_insert_statement_type_id);
	}
	return sql_insert_statement_type_id__volatile;
}


gpointer sql_insert_statement_ref (gpointer instance) {
	SqlInsertStatement* self;
	self = instance;
	g_atomic_int_inc (&self->ref_count);
	return instance;
}


void sql_insert_statement_unref (gpointer instance) {
	SqlInsertStatement* self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		SQL_INSERT_STATEMENT_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}



