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

#include "qlite.h"
#include <sqlite3.h>
#include <glib-object.h>
#include <glib.h>
#include <gobject/gvaluecollector.h>
#include <stdlib.h>
#include <string.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

#define _qlite_database_unref0(var) ((var == NULL) ? NULL : (var = (qlite_database_unref (var), NULL)))

#define QLITE_STATEMENT_BUILDER_TYPE_ABSTRACT_FIELD (qlite_statement_builder_abstract_field_get_type ())
#define QLITE_STATEMENT_BUILDER_ABSTRACT_FIELD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), QLITE_STATEMENT_BUILDER_TYPE_ABSTRACT_FIELD, QliteStatementBuilderAbstractField))
#define QLITE_STATEMENT_BUILDER_ABSTRACT_FIELD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), QLITE_STATEMENT_BUILDER_TYPE_ABSTRACT_FIELD, QliteStatementBuilderAbstractFieldClass))
#define QLITE_STATEMENT_BUILDER_IS_ABSTRACT_FIELD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), QLITE_STATEMENT_BUILDER_TYPE_ABSTRACT_FIELD))
#define QLITE_STATEMENT_BUILDER_IS_ABSTRACT_FIELD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), QLITE_STATEMENT_BUILDER_TYPE_ABSTRACT_FIELD))
#define QLITE_STATEMENT_BUILDER_ABSTRACT_FIELD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), QLITE_STATEMENT_BUILDER_TYPE_ABSTRACT_FIELD, QliteStatementBuilderAbstractFieldClass))

typedef struct _QliteStatementBuilderAbstractField QliteStatementBuilderAbstractField;
typedef struct _QliteStatementBuilderAbstractFieldClass QliteStatementBuilderAbstractFieldClass;
typedef struct _QliteStatementBuilderAbstractFieldPrivate QliteStatementBuilderAbstractFieldPrivate;
#define _qlite_column_unref0(var) ((var == NULL) ? NULL : (var = (qlite_column_unref (var), NULL)))
typedef struct _QliteStatementBuilderParamSpecAbstractField QliteStatementBuilderParamSpecAbstractField;

#define QLITE_STATEMENT_BUILDER_TYPE_FIELD (qlite_statement_builder_field_get_type ())
#define QLITE_STATEMENT_BUILDER_FIELD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), QLITE_STATEMENT_BUILDER_TYPE_FIELD, QliteStatementBuilderField))
#define QLITE_STATEMENT_BUILDER_FIELD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), QLITE_STATEMENT_BUILDER_TYPE_FIELD, QliteStatementBuilderFieldClass))
#define QLITE_STATEMENT_BUILDER_IS_FIELD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), QLITE_STATEMENT_BUILDER_TYPE_FIELD))
#define QLITE_STATEMENT_BUILDER_IS_FIELD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), QLITE_STATEMENT_BUILDER_TYPE_FIELD))
#define QLITE_STATEMENT_BUILDER_FIELD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), QLITE_STATEMENT_BUILDER_TYPE_FIELD, QliteStatementBuilderFieldClass))

typedef struct _QliteStatementBuilderField QliteStatementBuilderField;
typedef struct _QliteStatementBuilderFieldClass QliteStatementBuilderFieldClass;
typedef struct _QliteStatementBuilderFieldPrivate QliteStatementBuilderFieldPrivate;

#define QLITE_STATEMENT_BUILDER_TYPE_NULL_FIELD (qlite_statement_builder_null_field_get_type ())
#define QLITE_STATEMENT_BUILDER_NULL_FIELD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), QLITE_STATEMENT_BUILDER_TYPE_NULL_FIELD, QliteStatementBuilderNullField))
#define QLITE_STATEMENT_BUILDER_NULL_FIELD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), QLITE_STATEMENT_BUILDER_TYPE_NULL_FIELD, QliteStatementBuilderNullFieldClass))
#define QLITE_STATEMENT_BUILDER_IS_NULL_FIELD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), QLITE_STATEMENT_BUILDER_TYPE_NULL_FIELD))
#define QLITE_STATEMENT_BUILDER_IS_NULL_FIELD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), QLITE_STATEMENT_BUILDER_TYPE_NULL_FIELD))
#define QLITE_STATEMENT_BUILDER_NULL_FIELD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), QLITE_STATEMENT_BUILDER_TYPE_NULL_FIELD, QliteStatementBuilderNullFieldClass))

typedef struct _QliteStatementBuilderNullField QliteStatementBuilderNullField;
typedef struct _QliteStatementBuilderNullFieldClass QliteStatementBuilderNullFieldClass;
typedef struct _QliteStatementBuilderNullFieldPrivate QliteStatementBuilderNullFieldPrivate;

#define QLITE_STATEMENT_BUILDER_TYPE_STRING_FIELD (qlite_statement_builder_string_field_get_type ())
#define QLITE_STATEMENT_BUILDER_STRING_FIELD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), QLITE_STATEMENT_BUILDER_TYPE_STRING_FIELD, QliteStatementBuilderStringField))
#define QLITE_STATEMENT_BUILDER_STRING_FIELD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), QLITE_STATEMENT_BUILDER_TYPE_STRING_FIELD, QliteStatementBuilderStringFieldClass))
#define QLITE_STATEMENT_BUILDER_IS_STRING_FIELD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), QLITE_STATEMENT_BUILDER_TYPE_STRING_FIELD))
#define QLITE_STATEMENT_BUILDER_IS_STRING_FIELD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), QLITE_STATEMENT_BUILDER_TYPE_STRING_FIELD))
#define QLITE_STATEMENT_BUILDER_STRING_FIELD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), QLITE_STATEMENT_BUILDER_TYPE_STRING_FIELD, QliteStatementBuilderStringFieldClass))

typedef struct _QliteStatementBuilderStringField QliteStatementBuilderStringField;
typedef struct _QliteStatementBuilderStringFieldClass QliteStatementBuilderStringFieldClass;
typedef struct _QliteStatementBuilderStringFieldPrivate QliteStatementBuilderStringFieldPrivate;
typedef struct _QliteParamSpecStatementBuilder QliteParamSpecStatementBuilder;

struct _QliteStatementBuilderAbstractField {
	GTypeInstance parent_instance;
	volatile int ref_count;
	QliteStatementBuilderAbstractFieldPrivate * priv;
	gpointer value;
	QliteColumn* column;
};

struct _QliteStatementBuilderAbstractFieldClass {
	GTypeClass parent_class;
	void (*finalize) (QliteStatementBuilderAbstractField *self);
	void (*bind) (QliteStatementBuilderAbstractField* self, sqlite3_stmt* stmt, gint index);
};

struct _QliteStatementBuilderAbstractFieldPrivate {
	GType t_type;
	GBoxedCopyFunc t_dup_func;
	GDestroyNotify t_destroy_func;
};

struct _QliteStatementBuilderParamSpecAbstractField {
	GParamSpec parent_instance;
};

struct _QliteStatementBuilderField {
	QliteStatementBuilderAbstractField parent_instance;
	QliteStatementBuilderFieldPrivate * priv;
};

struct _QliteStatementBuilderFieldClass {
	QliteStatementBuilderAbstractFieldClass parent_class;
};

struct _QliteStatementBuilderFieldPrivate {
	GType t_type;
	GBoxedCopyFunc t_dup_func;
	GDestroyNotify t_destroy_func;
};

struct _QliteStatementBuilderNullField {
	QliteStatementBuilderAbstractField parent_instance;
	QliteStatementBuilderNullFieldPrivate * priv;
};

struct _QliteStatementBuilderNullFieldClass {
	QliteStatementBuilderAbstractFieldClass parent_class;
};

struct _QliteStatementBuilderNullFieldPrivate {
	GType t_type;
	GBoxedCopyFunc t_dup_func;
	GDestroyNotify t_destroy_func;
};

struct _QliteStatementBuilderStringField {
	QliteStatementBuilderAbstractField parent_instance;
	QliteStatementBuilderStringFieldPrivate * priv;
};

struct _QliteStatementBuilderStringFieldClass {
	QliteStatementBuilderAbstractFieldClass parent_class;
};

struct _QliteParamSpecStatementBuilder {
	GParamSpec parent_instance;
};

static gpointer qlite_statement_builder_parent_class = NULL;
static gint QliteStatementBuilderAbstractField_private_offset;
static gpointer qlite_statement_builder_abstract_field_parent_class = NULL;
static gint QliteStatementBuilderField_private_offset;
static gpointer qlite_statement_builder_field_parent_class = NULL;
static gint QliteStatementBuilderNullField_private_offset;
static gpointer qlite_statement_builder_null_field_parent_class = NULL;
static gpointer qlite_statement_builder_string_field_parent_class = NULL;

VALA_EXTERN sqlite3_stmt* qlite_statement_builder_prepare (QliteStatementBuilder* self);
VALA_EXTERN QliteStatementBuilder* qlite_statement_builder_construct (GType object_type,
                                                          QliteDatabase* db);
static sqlite3_stmt* qlite_statement_builder_real_prepare (QliteStatementBuilder* self);
VALA_EXTERN gpointer qlite_statement_builder_abstract_field_ref (gpointer instance);
VALA_EXTERN void qlite_statement_builder_abstract_field_unref (gpointer instance);
VALA_EXTERN GParamSpec* qlite_statement_builder_param_spec_abstract_field (const gchar* name,
                                                               const gchar* nick,
                                                               const gchar* blurb,
                                                               GType object_type,
                                                               GParamFlags flags);
VALA_EXTERN void qlite_statement_builder_value_set_abstract_field (GValue* value,
                                                       gpointer v_object);
VALA_EXTERN void qlite_statement_builder_value_take_abstract_field (GValue* value,
                                                        gpointer v_object);
VALA_EXTERN gpointer qlite_statement_builder_value_get_abstract_field (const GValue* value);
VALA_EXTERN GType qlite_statement_builder_abstract_field_get_type (void) G_GNUC_CONST ;
VALA_EXTERN void qlite_statement_builder_abstract_field_bind (QliteStatementBuilderAbstractField* self,
                                                  sqlite3_stmt* stmt,
                                                  gint index);
static QliteStatementBuilderAbstractField* qlite_statement_builder_abstract_field_construct (GType object_type,
                                                                                      GType t_type,
                                                                                      GBoxedCopyFunc t_dup_func,
                                                                                      GDestroyNotify t_destroy_func,
                                                                                      gconstpointer value);
static void qlite_statement_builder_abstract_field_real_bind (QliteStatementBuilderAbstractField* self,
                                                       sqlite3_stmt* stmt,
                                                       gint index);
static void qlite_statement_builder_abstract_field_finalize (QliteStatementBuilderAbstractField * obj);
static GType qlite_statement_builder_abstract_field_get_type_once (void);
VALA_EXTERN GType qlite_statement_builder_field_get_type (void) G_GNUC_CONST ;
VALA_EXTERN QliteStatementBuilderField* qlite_statement_builder_field_new (GType t_type,
                                                               GBoxedCopyFunc t_dup_func,
                                                               GDestroyNotify t_destroy_func,
                                                               QliteColumn* column,
                                                               gconstpointer value);
VALA_EXTERN QliteStatementBuilderField* qlite_statement_builder_field_construct (GType object_type,
                                                                     GType t_type,
                                                                     GBoxedCopyFunc t_dup_func,
                                                                     GDestroyNotify t_destroy_func,
                                                                     QliteColumn* column,
                                                                     gconstpointer value);
static void qlite_statement_builder_field_real_bind (QliteStatementBuilderAbstractField* base,
                                              sqlite3_stmt* stmt,
                                              gint index);
VALA_EXTERN void qlite_column_bind (QliteColumn* self,
                        sqlite3_stmt* stmt,
                        gint index,
                        gconstpointer value);
static GType qlite_statement_builder_field_get_type_once (void);
VALA_EXTERN GType qlite_statement_builder_null_field_get_type (void) G_GNUC_CONST ;
VALA_EXTERN QliteStatementBuilderNullField* qlite_statement_builder_null_field_new (GType t_type,
                                                                        GBoxedCopyFunc t_dup_func,
                                                                        GDestroyNotify t_destroy_func,
                                                                        QliteColumn* column);
VALA_EXTERN QliteStatementBuilderNullField* qlite_statement_builder_null_field_construct (GType object_type,
                                                                              GType t_type,
                                                                              GBoxedCopyFunc t_dup_func,
                                                                              GDestroyNotify t_destroy_func,
                                                                              QliteColumn* column);
static void qlite_statement_builder_null_field_real_bind (QliteStatementBuilderAbstractField* base,
                                                   sqlite3_stmt* stmt,
                                                   gint index);
static GType qlite_statement_builder_null_field_get_type_once (void);
VALA_EXTERN GType qlite_statement_builder_string_field_get_type (void) G_GNUC_CONST ;
VALA_EXTERN QliteStatementBuilderStringField* qlite_statement_builder_string_field_new (const gchar* value);
VALA_EXTERN QliteStatementBuilderStringField* qlite_statement_builder_string_field_construct (GType object_type,
                                                                                  const gchar* value);
static void qlite_statement_builder_string_field_real_bind (QliteStatementBuilderAbstractField* base,
                                                     sqlite3_stmt* stmt,
                                                     gint index);
static GType qlite_statement_builder_string_field_get_type_once (void);
static void qlite_statement_builder_finalize (QliteStatementBuilder * obj);
static GType qlite_statement_builder_get_type_once (void);

static gpointer
_qlite_database_ref0 (gpointer self)
{
	return self ? qlite_database_ref (self) : NULL;
}

QliteStatementBuilder*
qlite_statement_builder_construct (GType object_type,
                                   QliteDatabase* db)
{
	QliteStatementBuilder* self = NULL;
	QliteDatabase* _tmp0_;
	g_return_val_if_fail (db != NULL, NULL);
	self = (QliteStatementBuilder*) g_type_create_instance (object_type);
	_tmp0_ = _qlite_database_ref0 (db);
	_qlite_database_unref0 (self->db);
	self->db = _tmp0_;
	return self;
}

static sqlite3_stmt*
qlite_statement_builder_real_prepare (QliteStatementBuilder* self)
{
	g_critical ("Type `%s' does not implement abstract method `qlite_statement_builder_prepare'", g_type_name (G_TYPE_FROM_INSTANCE (self)));
	return NULL;
}

sqlite3_stmt*
qlite_statement_builder_prepare (QliteStatementBuilder* self)
{
	QliteStatementBuilderClass* _klass_;
	g_return_val_if_fail (self != NULL, NULL);
	_klass_ = QLITE_STATEMENT_BUILDER_GET_CLASS (self);
	if (_klass_->prepare) {
		return _klass_->prepare (self);
	}
	return NULL;
}

static inline gpointer
qlite_statement_builder_abstract_field_get_instance_private (QliteStatementBuilderAbstractField* self)
{
	return G_STRUCT_MEMBER_P (self, QliteStatementBuilderAbstractField_private_offset);
}

static QliteStatementBuilderAbstractField*
qlite_statement_builder_abstract_field_construct (GType object_type,
                                                  GType t_type,
                                                  GBoxedCopyFunc t_dup_func,
                                                  GDestroyNotify t_destroy_func,
                                                  gconstpointer value)
{
	QliteStatementBuilderAbstractField* self = NULL;
	gpointer _tmp0_;
	self = (QliteStatementBuilderAbstractField*) g_type_create_instance (object_type);
	self->priv->t_type = t_type;
	self->priv->t_dup_func = t_dup_func;
	self->priv->t_destroy_func = t_destroy_func;
	_tmp0_ = ((value != NULL) && (t_dup_func != NULL)) ? t_dup_func ((gpointer) value) : ((gpointer) value);
	((self->value == NULL) || (t_destroy_func == NULL)) ? NULL : (self->value = (t_destroy_func (self->value), NULL));
	self->value = _tmp0_;
	return self;
}

static void
qlite_statement_builder_abstract_field_real_bind (QliteStatementBuilderAbstractField* self,
                                                  sqlite3_stmt* stmt,
                                                  gint index)
{
	g_critical ("Type `%s' does not implement abstract method `qlite_statement_builder_abstract_field_bind'", g_type_name (G_TYPE_FROM_INSTANCE (self)));
	return;
}

void
qlite_statement_builder_abstract_field_bind (QliteStatementBuilderAbstractField* self,
                                             sqlite3_stmt* stmt,
                                             gint index)
{
	QliteStatementBuilderAbstractFieldClass* _klass_;
	g_return_if_fail (self != NULL);
	_klass_ = QLITE_STATEMENT_BUILDER_ABSTRACT_FIELD_GET_CLASS (self);
	if (_klass_->bind) {
		_klass_->bind (self, stmt, index);
	}
}

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

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

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

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

static gchar*
qlite_statement_builder_value_abstract_field_collect_value (GValue* value,
                                                            guint n_collect_values,
                                                            GTypeCValue* collect_values,
                                                            guint collect_flags)
{
	if (collect_values[0].v_pointer) {
		QliteStatementBuilderAbstractField * 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 = qlite_statement_builder_abstract_field_ref (object);
	} else {
		value->data[0].v_pointer = NULL;
	}
	return NULL;
}

static gchar*
qlite_statement_builder_value_abstract_field_lcopy_value (const GValue* value,
                                                          guint n_collect_values,
                                                          GTypeCValue* collect_values,
                                                          guint collect_flags)
{
	QliteStatementBuilderAbstractField ** 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 = qlite_statement_builder_abstract_field_ref (value->data[0].v_pointer);
	}
	return NULL;
}

GParamSpec*
qlite_statement_builder_param_spec_abstract_field (const gchar* name,
                                                   const gchar* nick,
                                                   const gchar* blurb,
                                                   GType object_type,
                                                   GParamFlags flags)
{
	QliteStatementBuilderParamSpecAbstractField* spec;
	g_return_val_if_fail (g_type_is_a (object_type, QLITE_STATEMENT_BUILDER_TYPE_ABSTRACT_FIELD), 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
qlite_statement_builder_value_get_abstract_field (const GValue* value)
{
	g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, QLITE_STATEMENT_BUILDER_TYPE_ABSTRACT_FIELD), NULL);
	return value->data[0].v_pointer;
}

void
qlite_statement_builder_value_set_abstract_field (GValue* value,
                                                  gpointer v_object)
{
	QliteStatementBuilderAbstractField * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, QLITE_STATEMENT_BUILDER_TYPE_ABSTRACT_FIELD));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, QLITE_STATEMENT_BUILDER_TYPE_ABSTRACT_FIELD));
		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;
		qlite_statement_builder_abstract_field_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		qlite_statement_builder_abstract_field_unref (old);
	}
}

void
qlite_statement_builder_value_take_abstract_field (GValue* value,
                                                   gpointer v_object)
{
	QliteStatementBuilderAbstractField * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, QLITE_STATEMENT_BUILDER_TYPE_ABSTRACT_FIELD));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, QLITE_STATEMENT_BUILDER_TYPE_ABSTRACT_FIELD));
		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) {
		qlite_statement_builder_abstract_field_unref (old);
	}
}

static void
qlite_statement_builder_abstract_field_class_init (QliteStatementBuilderAbstractFieldClass * klass,
                                                   gpointer klass_data)
{
	qlite_statement_builder_abstract_field_parent_class = g_type_class_peek_parent (klass);
	((QliteStatementBuilderAbstractFieldClass *) klass)->finalize = qlite_statement_builder_abstract_field_finalize;
	g_type_class_adjust_private_offset (klass, &QliteStatementBuilderAbstractField_private_offset);
	((QliteStatementBuilderAbstractFieldClass *) klass)->bind = (void (*) (QliteStatementBuilderAbstractField*, sqlite3_stmt*, gint)) qlite_statement_builder_abstract_field_real_bind;
}

static void
qlite_statement_builder_abstract_field_instance_init (QliteStatementBuilderAbstractField * self,
                                                      gpointer klass)
{
	self->priv = qlite_statement_builder_abstract_field_get_instance_private (self);
	self->ref_count = 1;
}

static void
qlite_statement_builder_abstract_field_finalize (QliteStatementBuilderAbstractField * obj)
{
	QliteStatementBuilderAbstractField * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, QLITE_STATEMENT_BUILDER_TYPE_ABSTRACT_FIELD, QliteStatementBuilderAbstractField);
	g_signal_handlers_destroy (self);
	((self->value == NULL) || (self->priv->t_destroy_func == NULL)) ? NULL : (self->value = (self->priv->t_destroy_func (self->value), NULL));
	_qlite_column_unref0 (self->column);
}

static GType
qlite_statement_builder_abstract_field_get_type_once (void)
{
	static const GTypeValueTable g_define_type_value_table = { qlite_statement_builder_value_abstract_field_init, qlite_statement_builder_value_abstract_field_free_value, qlite_statement_builder_value_abstract_field_copy_value, qlite_statement_builder_value_abstract_field_peek_pointer, "p", qlite_statement_builder_value_abstract_field_collect_value, "p", qlite_statement_builder_value_abstract_field_lcopy_value };
	static const GTypeInfo g_define_type_info = { sizeof (QliteStatementBuilderAbstractFieldClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) qlite_statement_builder_abstract_field_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (QliteStatementBuilderAbstractField), 0, (GInstanceInitFunc) qlite_statement_builder_abstract_field_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) };
	GType qlite_statement_builder_abstract_field_type_id;
	qlite_statement_builder_abstract_field_type_id = g_type_register_fundamental (g_type_fundamental_next (), "QliteStatementBuilderAbstractField", &g_define_type_info, &g_define_type_fundamental_info, G_TYPE_FLAG_ABSTRACT);
	QliteStatementBuilderAbstractField_private_offset = g_type_add_instance_private (qlite_statement_builder_abstract_field_type_id, sizeof (QliteStatementBuilderAbstractFieldPrivate));
	return qlite_statement_builder_abstract_field_type_id;
}

GType
qlite_statement_builder_abstract_field_get_type (void)
{
	static volatile gsize qlite_statement_builder_abstract_field_type_id__once = 0;
	if (g_once_init_enter (&qlite_statement_builder_abstract_field_type_id__once)) {
		GType qlite_statement_builder_abstract_field_type_id;
		qlite_statement_builder_abstract_field_type_id = qlite_statement_builder_abstract_field_get_type_once ();
		g_once_init_leave (&qlite_statement_builder_abstract_field_type_id__once, qlite_statement_builder_abstract_field_type_id);
	}
	return qlite_statement_builder_abstract_field_type_id__once;
}

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

void
qlite_statement_builder_abstract_field_unref (gpointer instance)
{
	QliteStatementBuilderAbstractField * self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		QLITE_STATEMENT_BUILDER_ABSTRACT_FIELD_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}

static inline gpointer
qlite_statement_builder_field_get_instance_private (QliteStatementBuilderField* self)
{
	return G_STRUCT_MEMBER_P (self, QliteStatementBuilderField_private_offset);
}

static gpointer
_qlite_column_ref0 (gpointer self)
{
	return self ? qlite_column_ref (self) : NULL;
}

QliteStatementBuilderField*
qlite_statement_builder_field_construct (GType object_type,
                                         GType t_type,
                                         GBoxedCopyFunc t_dup_func,
                                         GDestroyNotify t_destroy_func,
                                         QliteColumn* column,
                                         gconstpointer value)
{
	QliteStatementBuilderField* self = NULL;
	QliteColumn* _tmp0_;
	g_return_val_if_fail (column != NULL, NULL);
	self = (QliteStatementBuilderField*) qlite_statement_builder_abstract_field_construct (object_type, t_type, (GBoxedCopyFunc) t_dup_func, (GDestroyNotify) t_destroy_func, value);
	self->priv->t_type = t_type;
	self->priv->t_dup_func = t_dup_func;
	self->priv->t_destroy_func = t_destroy_func;
	_tmp0_ = _qlite_column_ref0 (column);
	_qlite_column_unref0 (((QliteStatementBuilderAbstractField*) self)->column);
	((QliteStatementBuilderAbstractField*) self)->column = _tmp0_;
	return self;
}

QliteStatementBuilderField*
qlite_statement_builder_field_new (GType t_type,
                                   GBoxedCopyFunc t_dup_func,
                                   GDestroyNotify t_destroy_func,
                                   QliteColumn* column,
                                   gconstpointer value)
{
	return qlite_statement_builder_field_construct (QLITE_STATEMENT_BUILDER_TYPE_FIELD, t_type, t_dup_func, t_destroy_func, column, value);
}

static void
qlite_statement_builder_field_real_bind (QliteStatementBuilderAbstractField* base,
                                         sqlite3_stmt* stmt,
                                         gint index)
{
	QliteStatementBuilderField * self;
	QliteColumn* _tmp0_;
	gconstpointer _tmp1_;
	self = (QliteStatementBuilderField*) base;
	g_return_if_fail (stmt != NULL);
	_tmp0_ = ((QliteStatementBuilderAbstractField*) self)->column;
	_tmp1_ = ((QliteStatementBuilderAbstractField*) self)->value;
	qlite_column_bind (G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, QLITE_TYPE_COLUMN, QliteColumn), stmt, index, _tmp1_);
}

static void
qlite_statement_builder_field_class_init (QliteStatementBuilderFieldClass * klass,
                                          gpointer klass_data)
{
	qlite_statement_builder_field_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &QliteStatementBuilderField_private_offset);
	((QliteStatementBuilderAbstractFieldClass *) klass)->bind = (void (*) (QliteStatementBuilderAbstractField*, sqlite3_stmt*, gint)) qlite_statement_builder_field_real_bind;
}

static void
qlite_statement_builder_field_instance_init (QliteStatementBuilderField * self,
                                             gpointer klass)
{
	self->priv = qlite_statement_builder_field_get_instance_private (self);
}

static GType
qlite_statement_builder_field_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (QliteStatementBuilderFieldClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) qlite_statement_builder_field_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (QliteStatementBuilderField), 0, (GInstanceInitFunc) qlite_statement_builder_field_instance_init, NULL };
	GType qlite_statement_builder_field_type_id;
	qlite_statement_builder_field_type_id = g_type_register_static (QLITE_STATEMENT_BUILDER_TYPE_ABSTRACT_FIELD, "QliteStatementBuilderField", &g_define_type_info, 0);
	QliteStatementBuilderField_private_offset = g_type_add_instance_private (qlite_statement_builder_field_type_id, sizeof (QliteStatementBuilderFieldPrivate));
	return qlite_statement_builder_field_type_id;
}

GType
qlite_statement_builder_field_get_type (void)
{
	static volatile gsize qlite_statement_builder_field_type_id__once = 0;
	if (g_once_init_enter (&qlite_statement_builder_field_type_id__once)) {
		GType qlite_statement_builder_field_type_id;
		qlite_statement_builder_field_type_id = qlite_statement_builder_field_get_type_once ();
		g_once_init_leave (&qlite_statement_builder_field_type_id__once, qlite_statement_builder_field_type_id);
	}
	return qlite_statement_builder_field_type_id__once;
}

static inline gpointer
qlite_statement_builder_null_field_get_instance_private (QliteStatementBuilderNullField* self)
{
	return G_STRUCT_MEMBER_P (self, QliteStatementBuilderNullField_private_offset);
}

QliteStatementBuilderNullField*
qlite_statement_builder_null_field_construct (GType object_type,
                                              GType t_type,
                                              GBoxedCopyFunc t_dup_func,
                                              GDestroyNotify t_destroy_func,
                                              QliteColumn* column)
{
	QliteStatementBuilderNullField* self = NULL;
	QliteColumn* _tmp0_;
	g_return_val_if_fail (column != NULL, NULL);
	self = (QliteStatementBuilderNullField*) qlite_statement_builder_abstract_field_construct (object_type, t_type, (GBoxedCopyFunc) t_dup_func, (GDestroyNotify) t_destroy_func, NULL);
	self->priv->t_type = t_type;
	self->priv->t_dup_func = t_dup_func;
	self->priv->t_destroy_func = t_destroy_func;
	_tmp0_ = _qlite_column_ref0 (column);
	_qlite_column_unref0 (((QliteStatementBuilderAbstractField*) self)->column);
	((QliteStatementBuilderAbstractField*) self)->column = _tmp0_;
	return self;
}

QliteStatementBuilderNullField*
qlite_statement_builder_null_field_new (GType t_type,
                                        GBoxedCopyFunc t_dup_func,
                                        GDestroyNotify t_destroy_func,
                                        QliteColumn* column)
{
	return qlite_statement_builder_null_field_construct (QLITE_STATEMENT_BUILDER_TYPE_NULL_FIELD, t_type, t_dup_func, t_destroy_func, column);
}

static void
qlite_statement_builder_null_field_real_bind (QliteStatementBuilderAbstractField* base,
                                              sqlite3_stmt* stmt,
                                              gint index)
{
	QliteStatementBuilderNullField * self;
	self = (QliteStatementBuilderNullField*) base;
	g_return_if_fail (stmt != NULL);
	sqlite3_bind_null (stmt, index);
}

static void
qlite_statement_builder_null_field_class_init (QliteStatementBuilderNullFieldClass * klass,
                                               gpointer klass_data)
{
	qlite_statement_builder_null_field_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &QliteStatementBuilderNullField_private_offset);
	((QliteStatementBuilderAbstractFieldClass *) klass)->bind = (void (*) (QliteStatementBuilderAbstractField*, sqlite3_stmt*, gint)) qlite_statement_builder_null_field_real_bind;
}

static void
qlite_statement_builder_null_field_instance_init (QliteStatementBuilderNullField * self,
                                                  gpointer klass)
{
	self->priv = qlite_statement_builder_null_field_get_instance_private (self);
}

static GType
qlite_statement_builder_null_field_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (QliteStatementBuilderNullFieldClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) qlite_statement_builder_null_field_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (QliteStatementBuilderNullField), 0, (GInstanceInitFunc) qlite_statement_builder_null_field_instance_init, NULL };
	GType qlite_statement_builder_null_field_type_id;
	qlite_statement_builder_null_field_type_id = g_type_register_static (QLITE_STATEMENT_BUILDER_TYPE_ABSTRACT_FIELD, "QliteStatementBuilderNullField", &g_define_type_info, 0);
	QliteStatementBuilderNullField_private_offset = g_type_add_instance_private (qlite_statement_builder_null_field_type_id, sizeof (QliteStatementBuilderNullFieldPrivate));
	return qlite_statement_builder_null_field_type_id;
}

GType
qlite_statement_builder_null_field_get_type (void)
{
	static volatile gsize qlite_statement_builder_null_field_type_id__once = 0;
	if (g_once_init_enter (&qlite_statement_builder_null_field_type_id__once)) {
		GType qlite_statement_builder_null_field_type_id;
		qlite_statement_builder_null_field_type_id = qlite_statement_builder_null_field_get_type_once ();
		g_once_init_leave (&qlite_statement_builder_null_field_type_id__once, qlite_statement_builder_null_field_type_id);
	}
	return qlite_statement_builder_null_field_type_id__once;
}

QliteStatementBuilderStringField*
qlite_statement_builder_string_field_construct (GType object_type,
                                                const gchar* value)
{
	QliteStatementBuilderStringField* self = NULL;
	g_return_val_if_fail (value != NULL, NULL);
	self = (QliteStatementBuilderStringField*) qlite_statement_builder_abstract_field_construct (object_type, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, value);
	return self;
}

QliteStatementBuilderStringField*
qlite_statement_builder_string_field_new (const gchar* value)
{
	return qlite_statement_builder_string_field_construct (QLITE_STATEMENT_BUILDER_TYPE_STRING_FIELD, value);
}

static void
qlite_statement_builder_string_field_real_bind (QliteStatementBuilderAbstractField* base,
                                                sqlite3_stmt* stmt,
                                                gint index)
{
	QliteStatementBuilderStringField * self;
	gconstpointer _tmp0_;
	gchar* _tmp1_;
	GDestroyNotify _tmp2_;
	self = (QliteStatementBuilderStringField*) base;
	g_return_if_fail (stmt != NULL);
	_tmp0_ = ((QliteStatementBuilderAbstractField*) self)->value;
	_tmp1_ = g_strdup ((const gchar*) _tmp0_);
	_tmp2_ = g_free;
	sqlite3_bind_text (stmt, index, _tmp1_, -1, _tmp2_);
}

static void
qlite_statement_builder_string_field_class_init (QliteStatementBuilderStringFieldClass * klass,
                                                 gpointer klass_data)
{
	qlite_statement_builder_string_field_parent_class = g_type_class_peek_parent (klass);
	((QliteStatementBuilderAbstractFieldClass *) klass)->bind = (void (*) (QliteStatementBuilderAbstractField*, sqlite3_stmt*, gint)) qlite_statement_builder_string_field_real_bind;
}

static void
qlite_statement_builder_string_field_instance_init (QliteStatementBuilderStringField * self,
                                                    gpointer klass)
{
}

static GType
qlite_statement_builder_string_field_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (QliteStatementBuilderStringFieldClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) qlite_statement_builder_string_field_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (QliteStatementBuilderStringField), 0, (GInstanceInitFunc) qlite_statement_builder_string_field_instance_init, NULL };
	GType qlite_statement_builder_string_field_type_id;
	qlite_statement_builder_string_field_type_id = g_type_register_static (QLITE_STATEMENT_BUILDER_TYPE_ABSTRACT_FIELD, "QliteStatementBuilderStringField", &g_define_type_info, 0);
	return qlite_statement_builder_string_field_type_id;
}

GType
qlite_statement_builder_string_field_get_type (void)
{
	static volatile gsize qlite_statement_builder_string_field_type_id__once = 0;
	if (g_once_init_enter (&qlite_statement_builder_string_field_type_id__once)) {
		GType qlite_statement_builder_string_field_type_id;
		qlite_statement_builder_string_field_type_id = qlite_statement_builder_string_field_get_type_once ();
		g_once_init_leave (&qlite_statement_builder_string_field_type_id__once, qlite_statement_builder_string_field_type_id);
	}
	return qlite_statement_builder_string_field_type_id__once;
}

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

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

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

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

static gchar*
qlite_value_statement_builder_collect_value (GValue* value,
                                             guint n_collect_values,
                                             GTypeCValue* collect_values,
                                             guint collect_flags)
{
	if (collect_values[0].v_pointer) {
		QliteStatementBuilder * 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 = qlite_statement_builder_ref (object);
	} else {
		value->data[0].v_pointer = NULL;
	}
	return NULL;
}

static gchar*
qlite_value_statement_builder_lcopy_value (const GValue* value,
                                           guint n_collect_values,
                                           GTypeCValue* collect_values,
                                           guint collect_flags)
{
	QliteStatementBuilder ** 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 = qlite_statement_builder_ref (value->data[0].v_pointer);
	}
	return NULL;
}

GParamSpec*
qlite_param_spec_statement_builder (const gchar* name,
                                    const gchar* nick,
                                    const gchar* blurb,
                                    GType object_type,
                                    GParamFlags flags)
{
	QliteParamSpecStatementBuilder* spec;
	g_return_val_if_fail (g_type_is_a (object_type, QLITE_TYPE_STATEMENT_BUILDER), 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
qlite_value_get_statement_builder (const GValue* value)
{
	g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, QLITE_TYPE_STATEMENT_BUILDER), NULL);
	return value->data[0].v_pointer;
}

void
qlite_value_set_statement_builder (GValue* value,
                                   gpointer v_object)
{
	QliteStatementBuilder * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, QLITE_TYPE_STATEMENT_BUILDER));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, QLITE_TYPE_STATEMENT_BUILDER));
		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;
		qlite_statement_builder_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		qlite_statement_builder_unref (old);
	}
}

void
qlite_value_take_statement_builder (GValue* value,
                                    gpointer v_object)
{
	QliteStatementBuilder * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, QLITE_TYPE_STATEMENT_BUILDER));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, QLITE_TYPE_STATEMENT_BUILDER));
		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) {
		qlite_statement_builder_unref (old);
	}
}

static void
qlite_statement_builder_class_init (QliteStatementBuilderClass * klass,
                                    gpointer klass_data)
{
	qlite_statement_builder_parent_class = g_type_class_peek_parent (klass);
	((QliteStatementBuilderClass *) klass)->finalize = qlite_statement_builder_finalize;
	((QliteStatementBuilderClass *) klass)->prepare = (sqlite3_stmt* (*) (QliteStatementBuilder*)) qlite_statement_builder_real_prepare;
}

static void
qlite_statement_builder_instance_init (QliteStatementBuilder * self,
                                       gpointer klass)
{
	self->ref_count = 1;
}

static void
qlite_statement_builder_finalize (QliteStatementBuilder * obj)
{
	QliteStatementBuilder * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, QLITE_TYPE_STATEMENT_BUILDER, QliteStatementBuilder);
	g_signal_handlers_destroy (self);
	_qlite_database_unref0 (self->db);
}

static GType
qlite_statement_builder_get_type_once (void)
{
	static const GTypeValueTable g_define_type_value_table = { qlite_value_statement_builder_init, qlite_value_statement_builder_free_value, qlite_value_statement_builder_copy_value, qlite_value_statement_builder_peek_pointer, "p", qlite_value_statement_builder_collect_value, "p", qlite_value_statement_builder_lcopy_value };
	static const GTypeInfo g_define_type_info = { sizeof (QliteStatementBuilderClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) qlite_statement_builder_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (QliteStatementBuilder), 0, (GInstanceInitFunc) qlite_statement_builder_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) };
	GType qlite_statement_builder_type_id;
	qlite_statement_builder_type_id = g_type_register_fundamental (g_type_fundamental_next (), "QliteStatementBuilder", &g_define_type_info, &g_define_type_fundamental_info, G_TYPE_FLAG_ABSTRACT);
	return qlite_statement_builder_type_id;
}

GType
qlite_statement_builder_get_type (void)
{
	static volatile gsize qlite_statement_builder_type_id__once = 0;
	if (g_once_init_enter (&qlite_statement_builder_type_id__once)) {
		GType qlite_statement_builder_type_id;
		qlite_statement_builder_type_id = qlite_statement_builder_get_type_once ();
		g_once_init_leave (&qlite_statement_builder_type_id__once, qlite_statement_builder_type_id);
	}
	return qlite_statement_builder_type_id__once;
}

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

void
qlite_statement_builder_unref (gpointer instance)
{
	QliteStatementBuilder * self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		QLITE_STATEMENT_BUILDER_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}

