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

/* SPDX-License-Identifier: GPL-3.0-or-later*/

#include "graphs.h"
#include <sqlite3.h>
#include <glib.h>
#include <glib-object.h>
#include <gio/gio.h>
#include <stdlib.h>
#include <string.h>
#include <float.h>
#include <math.h>
#include <glib/gi18n-lib.h>

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

enum  {
	GRAPHS_DATABASE_READER_0_PROPERTY,
	GRAPHS_DATABASE_READER_NUM_PROPERTIES
};
static GParamSpec* graphs_database_reader_properties[GRAPHS_DATABASE_READER_NUM_PROPERTIES];
#define _sqlite3_close0(var) ((var == NULL) ? NULL : (var = (sqlite3_close (var), NULL)))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _sqlite3_finalize0(var) ((var == NULL) ? NULL : (var = (sqlite3_finalize (var), NULL)))
#define _g_array_unref0(var) ((var == NULL) ? NULL : (var = (g_array_unref (var), NULL)))

struct _GraphsDatabaseReaderPrivate {
	sqlite3* db;
	GraphsImportSettings* settings;
};

static gint GraphsDatabaseReader_private_offset;
static gpointer graphs_database_reader_parent_class = NULL;

static gchar** graphs_database_reader_get_table_names (GraphsDatabaseReader* self,
                                                gint* result_length1,
                                                GError** error);
static void _g_free0_ (gpointer var);
static void _vala_gchar_free_function_content_of (gpointer data);
static gchar** _vala_array_dup3 (gchar** self,
                          gssize length);
static gboolean graphs_database_reader_is_numeric_type (GraphsDatabaseReader* self,
                                                 const gchar* type);
static gchar** _vala_array_dup4 (gchar** self,
                          gssize length);
static gdouble* graphs_database_reader_get_column_data (GraphsDatabaseReader* self,
                                                 const gchar* table_name,
                                                 const gchar* column_name,
                                                 gint* result_length1,
                                                 GError** error);
static gchar** _vala_array_dup5 (gchar** self,
                          gssize length);
static void graphs_database_reader_finalize (GObject * obj);
static GType graphs_database_reader_get_type_once (void);
static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
graphs_database_reader_get_instance_private (GraphsDatabaseReader* self)
{
	return G_STRUCT_MEMBER_P (self, GraphsDatabaseReader_private_offset);
}

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

GraphsDatabaseReader*
graphs_database_reader_construct (GType object_type,
                                  GraphsImportSettings* settings,
                                  GError** error)
{
	GraphsDatabaseReader * self = NULL;
	GraphsImportSettings* _tmp0_;
	gchar* file_path = NULL;
	GFile* _tmp1_;
	GFile* _tmp2_;
	gchar* _tmp3_;
	const gchar* _tmp4_;
	sqlite3* _tmp5_ = NULL;
	gint _tmp6_;
	gchar** _tmp13_ = NULL;
	gint _tmp14_ = 0;
	gchar** _tmp15_;
	gint _tmp13__length1;
	gint __tmp13__size_;
	gchar** _tmp16_;
	gint _tmp16__length1;
	GError* _inner_error0_ = NULL;
	g_return_val_if_fail (settings != NULL, NULL);
	self = (GraphsDatabaseReader*) g_object_new (object_type, NULL);
	_tmp0_ = _g_object_ref0 (settings);
	_g_object_unref0 (self->priv->settings);
	self->priv->settings = _tmp0_;
	_tmp1_ = graphs_import_settings_get_file (settings);
	_tmp2_ = _tmp1_;
	_tmp3_ = g_file_get_path (_tmp2_);
	file_path = _tmp3_;
	_tmp4_ = file_path;
	_tmp6_ = sqlite3_open (_tmp4_, &_tmp5_);
	_sqlite3_close0 (self->priv->db);
	self->priv->db = _tmp5_;
	if (_tmp6_ != SQLITE_OK) {
		sqlite3* _tmp7_;
		const gchar* _tmp8_;
		gchar* _tmp9_;
		gchar* _tmp10_;
		GError* _tmp11_;
		GError* _tmp12_;
		_tmp7_ = self->priv->db;
		_tmp8_ = sqlite3_errmsg (_tmp7_);
		_tmp9_ = g_strdup_printf ("Failed to open SQL Database: %s", _tmp8_);
		_tmp10_ = _tmp9_;
		_tmp11_ = g_error_new_literal (G_IO_ERROR, G_IO_ERROR_FAILED, _tmp10_);
		_tmp12_ = _tmp11_;
		_g_free0 (_tmp10_);
		_inner_error0_ = _tmp12_;
		if (_inner_error0_->domain == G_IO_ERROR) {
			g_propagate_error (error, _inner_error0_);
			_g_free0 (file_path);
			_g_object_unref0 (self);
			return NULL;
		} else {
			_g_free0 (file_path);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return NULL;
		}
	}
	_tmp15_ = graphs_database_reader_get_table_names (self, &_tmp14_, &_inner_error0_);
	_tmp13_ = _tmp15_;
	_tmp13__length1 = _tmp14_;
	__tmp13__size_ = _tmp13__length1;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		if (_inner_error0_->domain == G_IO_ERROR) {
			g_propagate_error (error, _inner_error0_);
			_g_free0 (file_path);
			_g_object_unref0 (self);
			return NULL;
		} else {
			_g_free0 (file_path);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return NULL;
		}
	}
	_tmp16_ = _tmp13_;
	_tmp16__length1 = _tmp13__length1;
	_tmp13_ = NULL;
	_tmp13__length1 = 0;
	self->table_names = (_vala_array_free (self->table_names, self->table_names_length1, (GDestroyNotify) g_free), NULL);
	self->table_names = _tmp16_;
	self->table_names_length1 = _tmp16__length1;
	_tmp13_ = (_vala_array_free (_tmp13_, _tmp13__length1, (GDestroyNotify) g_free), NULL);
	_g_free0 (file_path);
	return self;
}

GraphsDatabaseReader*
graphs_database_reader_new (GraphsImportSettings* settings,
                            GError** error)
{
	return graphs_database_reader_construct (GRAPHS_TYPE_DATABASE_READER, settings, error);
}

static void
_g_free0_ (gpointer var)
{
	var = (g_free (var), NULL);
}

static void
_vala_gchar_free_function_content_of (gpointer data)
{
	gchar* self;
	self = *((gchar**) data);
	_g_free0_ (self);
}

static gchar**
_vala_array_dup3 (gchar** self,
                  gssize length)
{
	if (length >= 0) {
		gchar** result;
		gssize i;
		result = g_new0 (gchar*, length + 1);
		for (i = 0; i < length; i++) {
			gchar* _tmp0_;
			_tmp0_ = g_strdup (self[i]);
			result[i] = _tmp0_;
		}
		return result;
	}
	return NULL;
}

gchar**
graphs_database_reader_get_columns (GraphsDatabaseReader* self,
                                    const gchar* table_name,
                                    gint* result_length1,
                                    GError** error)
{
	GArray* columns = NULL;
	GArray* _tmp0_;
	sqlite3_stmt* stmt = NULL;
	gchar* sql = NULL;
	gchar* _tmp1_;
	sqlite3* _tmp2_;
	const gchar* _tmp3_;
	sqlite3_stmt* _tmp4_ = NULL;
	gint _tmp5_;
	GArray* _tmp17_;
	gpointer* _tmp18_;
	gint _tmp18__length1;
	gchar** _tmp19_;
	gint _tmp19__length1;
	gchar** _tmp20_;
	gint _tmp20__length1;
	GError* _inner_error0_ = NULL;
	gchar** result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (table_name != NULL, NULL);
	_tmp0_ = g_array_new (TRUE, TRUE, sizeof (gchar*));
	g_array_set_clear_func (_tmp0_, (GDestroyNotify) _vala_gchar_free_function_content_of);
	columns = _tmp0_;
	_tmp1_ = g_strdup_printf ("PRAGMA table_info(`%s`)", table_name);
	sql = _tmp1_;
	_tmp2_ = self->priv->db;
	_tmp3_ = sql;
	_tmp5_ = sqlite3_prepare_v2 (_tmp2_, _tmp3_, -1, &_tmp4_, NULL);
	_sqlite3_finalize0 (stmt);
	stmt = _tmp4_;
	if (_tmp5_ != SQLITE_OK) {
		sqlite3* _tmp6_;
		const gchar* _tmp7_;
		gchar* _tmp8_;
		gchar* _tmp9_;
		GError* _tmp10_;
		GError* _tmp11_;
		_tmp6_ = self->priv->db;
		_tmp7_ = sqlite3_errmsg (_tmp6_);
		_tmp8_ = g_strdup_printf ("Failed to retrieve SQL Column names: %s", _tmp7_);
		_tmp9_ = _tmp8_;
		_tmp10_ = g_error_new_literal (G_IO_ERROR, G_IO_ERROR_FAILED, _tmp9_);
		_tmp11_ = _tmp10_;
		_g_free0 (_tmp9_);
		_inner_error0_ = _tmp11_;
		if (_inner_error0_->domain == G_IO_ERROR) {
			g_propagate_error (error, _inner_error0_);
			_g_free0 (sql);
			_sqlite3_finalize0 (stmt);
			_g_array_unref0 (columns);
			return NULL;
		} else {
			_g_free0 (sql);
			_sqlite3_finalize0 (stmt);
			_g_array_unref0 (columns);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return NULL;
		}
	}
	while (TRUE) {
		sqlite3_stmt* _tmp12_;
		GArray* _tmp13_;
		sqlite3_stmt* _tmp14_;
		const gchar* _tmp15_;
		gchar* _tmp16_;
		_tmp12_ = stmt;
		if (!(sqlite3_step (_tmp12_) == SQLITE_ROW)) {
			break;
		}
		_tmp13_ = columns;
		_tmp14_ = stmt;
		_tmp15_ = (const gchar*) sqlite3_column_text (_tmp14_, 1);
		_tmp16_ = g_strdup (_tmp15_);
		g_array_append_val (_tmp13_, _tmp16_);
	}
	_tmp17_ = columns;
	_tmp18_ = _tmp17_->data;
	_tmp18__length1 = _tmp17_->len;
	_tmp19_ = (_tmp18_ != NULL) ? _vala_array_dup3 (_tmp18_, _tmp18__length1) : _tmp18_;
	_tmp19__length1 = _tmp18__length1;
	_tmp20_ = _tmp19_;
	_tmp20__length1 = _tmp19__length1;
	if (result_length1) {
		*result_length1 = _tmp20__length1;
	}
	result = _tmp20_;
	_g_free0 (sql);
	_sqlite3_finalize0 (stmt);
	_g_array_unref0 (columns);
	return result;
}

static gchar**
_vala_array_dup4 (gchar** self,
                  gssize length)
{
	if (length >= 0) {
		gchar** result;
		gssize i;
		result = g_new0 (gchar*, length + 1);
		for (i = 0; i < length; i++) {
			gchar* _tmp0_;
			_tmp0_ = g_strdup (self[i]);
			result[i] = _tmp0_;
		}
		return result;
	}
	return NULL;
}

gchar**
graphs_database_reader_get_numeric_columns (GraphsDatabaseReader* self,
                                            const gchar* table_name,
                                            gint* result_length1,
                                            GError** error)
{
	GArray* columns = NULL;
	GArray* _tmp0_;
	sqlite3_stmt* stmt = NULL;
	gchar* sql = NULL;
	gchar* _tmp1_;
	sqlite3* _tmp2_;
	const gchar* _tmp3_;
	sqlite3_stmt* _tmp4_ = NULL;
	gint _tmp5_;
	GArray* _tmp23_;
	gpointer* _tmp24_;
	gint _tmp24__length1;
	gchar** _tmp25_;
	gint _tmp25__length1;
	gchar** _tmp26_;
	gint _tmp26__length1;
	GError* _inner_error0_ = NULL;
	gchar** result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (table_name != NULL, NULL);
	_tmp0_ = g_array_new (TRUE, TRUE, sizeof (gchar*));
	g_array_set_clear_func (_tmp0_, (GDestroyNotify) _vala_gchar_free_function_content_of);
	columns = _tmp0_;
	_tmp1_ = g_strdup_printf ("PRAGMA table_info(`%s`)", table_name);
	sql = _tmp1_;
	_tmp2_ = self->priv->db;
	_tmp3_ = sql;
	_tmp5_ = sqlite3_prepare_v2 (_tmp2_, _tmp3_, -1, &_tmp4_, NULL);
	_sqlite3_finalize0 (stmt);
	stmt = _tmp4_;
	if (_tmp5_ != SQLITE_OK) {
		sqlite3* _tmp6_;
		const gchar* _tmp7_;
		gchar* _tmp8_;
		gchar* _tmp9_;
		GError* _tmp10_;
		GError* _tmp11_;
		_tmp6_ = self->priv->db;
		_tmp7_ = sqlite3_errmsg (_tmp6_);
		_tmp8_ = g_strdup_printf ("Failed to retrieve SQL Column names: %s", _tmp7_);
		_tmp9_ = _tmp8_;
		_tmp10_ = g_error_new_literal (G_IO_ERROR, G_IO_ERROR_FAILED, _tmp9_);
		_tmp11_ = _tmp10_;
		_g_free0 (_tmp9_);
		_inner_error0_ = _tmp11_;
		if (_inner_error0_->domain == G_IO_ERROR) {
			g_propagate_error (error, _inner_error0_);
			_g_free0 (sql);
			_sqlite3_finalize0 (stmt);
			_g_array_unref0 (columns);
			return NULL;
		} else {
			_g_free0 (sql);
			_sqlite3_finalize0 (stmt);
			_g_array_unref0 (columns);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return NULL;
		}
	}
	while (TRUE) {
		sqlite3_stmt* _tmp12_;
		gchar* col_name = NULL;
		sqlite3_stmt* _tmp13_;
		const gchar* _tmp14_;
		gchar* _tmp15_;
		gchar* col_type = NULL;
		sqlite3_stmt* _tmp16_;
		const gchar* _tmp17_;
		gchar* _tmp18_;
		const gchar* _tmp19_;
		_tmp12_ = stmt;
		if (!(sqlite3_step (_tmp12_) == SQLITE_ROW)) {
			break;
		}
		_tmp13_ = stmt;
		_tmp14_ = (const gchar*) sqlite3_column_text (_tmp13_, 1);
		_tmp15_ = g_strdup (_tmp14_);
		col_name = _tmp15_;
		_tmp16_ = stmt;
		_tmp17_ = (const gchar*) sqlite3_column_text (_tmp16_, 2);
		_tmp18_ = g_utf8_strup (_tmp17_, (gssize) -1);
		col_type = _tmp18_;
		_tmp19_ = col_type;
		if (graphs_database_reader_is_numeric_type (self, _tmp19_)) {
			GArray* _tmp20_;
			const gchar* _tmp21_;
			gchar* _tmp22_;
			_tmp20_ = columns;
			_tmp21_ = col_name;
			_tmp22_ = g_strdup (_tmp21_);
			g_array_append_val (_tmp20_, _tmp22_);
		}
		_g_free0 (col_type);
		_g_free0 (col_name);
	}
	_tmp23_ = columns;
	_tmp24_ = _tmp23_->data;
	_tmp24__length1 = _tmp23_->len;
	_tmp25_ = (_tmp24_ != NULL) ? _vala_array_dup4 (_tmp24_, _tmp24__length1) : _tmp24_;
	_tmp25__length1 = _tmp24__length1;
	_tmp26_ = _tmp25_;
	_tmp26__length1 = _tmp25__length1;
	if (result_length1) {
		*result_length1 = _tmp26__length1;
	}
	result = _tmp26_;
	_g_free0 (sql);
	_sqlite3_finalize0 (stmt);
	_g_array_unref0 (columns);
	return result;
}

static gboolean
string_contains (const gchar* self,
                 const gchar* needle)
{
	gchar* _tmp0_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (needle != NULL, FALSE);
	_tmp0_ = strstr ((gchar*) self, (gchar*) needle);
	result = _tmp0_ != NULL;
	return result;
}

static gboolean
graphs_database_reader_is_numeric_type (GraphsDatabaseReader* self,
                                        const gchar* type)
{
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	gboolean _tmp2_ = FALSE;
	gboolean _tmp3_ = FALSE;
	gboolean _tmp4_ = FALSE;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (type != NULL, FALSE);
	if (string_contains (type, "INT")) {
		_tmp4_ = TRUE;
	} else {
		_tmp4_ = string_contains (type, "REAL");
	}
	if (_tmp4_) {
		_tmp3_ = TRUE;
	} else {
		_tmp3_ = string_contains (type, "FLOAT");
	}
	if (_tmp3_) {
		_tmp2_ = TRUE;
	} else {
		_tmp2_ = string_contains (type, "DOUBLE");
	}
	if (_tmp2_) {
		_tmp1_ = TRUE;
	} else {
		_tmp1_ = string_contains (type, "NUMERIC");
	}
	if (_tmp1_) {
		_tmp0_ = TRUE;
	} else {
		_tmp0_ = string_contains (type, "DECIMAL");
	}
	result = _tmp0_;
	return result;
}

void
graphs_database_reader_set_default_selection (GraphsDatabaseReader* self,
                                              GError** error)
{
	gchar** _tmp0_;
	gint _tmp0__length1;
	gchar* first_table = NULL;
	gchar** _tmp2_;
	gint _tmp2__length1;
	const gchar* _tmp3_;
	gchar* _tmp4_;
	gchar** columns = NULL;
	gint _tmp5_ = 0;
	gchar** _tmp6_;
	gint columns_length1;
	gint _columns_size_;
	GraphsImportSettings* _tmp7_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->table_names;
	_tmp0__length1 = self->table_names_length1;
	if (_tmp0__length1 == 0) {
		GError* _tmp1_;
		_tmp1_ = g_error_new_literal (G_IO_ERROR, G_IO_ERROR_FAILED, "No tables found in database");
		_inner_error0_ = _tmp1_;
		if (_inner_error0_->domain == G_IO_ERROR) {
			g_propagate_error (error, _inner_error0_);
			return;
		} else {
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return;
		}
	}
	_tmp2_ = self->table_names;
	_tmp2__length1 = self->table_names_length1;
	_tmp3_ = _tmp2_[0];
	_tmp4_ = g_strdup (_tmp3_);
	first_table = _tmp4_;
	_tmp6_ = graphs_database_reader_get_numeric_columns (self, first_table, &_tmp5_, &_inner_error0_);
	columns = _tmp6_;
	columns_length1 = _tmp5_;
	_columns_size_ = columns_length1;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		if (_inner_error0_->domain == G_IO_ERROR) {
			g_propagate_error (error, _inner_error0_);
			_g_free0 (first_table);
			return;
		} else {
			_g_free0 (first_table);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return;
		}
	}
	_tmp7_ = self->priv->settings;
	graphs_import_settings_set_string (_tmp7_, "table-name", first_table);
	if (columns_length1 == 0) {
		GraphsImportSettings* _tmp8_;
		GraphsImportSettings* _tmp9_;
		GraphsImportSettings* _tmp10_;
		GraphsImportSettings* _tmp11_;
		_tmp8_ = self->priv->settings;
		graphs_import_settings_set_string (_tmp8_, "x-column", "");
		_tmp9_ = self->priv->settings;
		graphs_import_settings_set_string (_tmp9_, "y-column", "");
		_tmp10_ = self->priv->settings;
		graphs_import_settings_set_string (_tmp10_, "xerr-column", "");
		_tmp11_ = self->priv->settings;
		graphs_import_settings_set_string (_tmp11_, "yerr-column", "");
	} else {
		GraphsImportSettings* _tmp12_;
		const gchar* _tmp13_;
		GraphsImportSettings* _tmp14_;
		const gchar* _tmp15_;
		GraphsImportSettings* _tmp16_;
		const gchar* _tmp17_;
		GraphsImportSettings* _tmp18_;
		const gchar* _tmp19_;
		_tmp12_ = self->priv->settings;
		_tmp13_ = columns[0];
		graphs_import_settings_set_string (_tmp12_, "x-column", _tmp13_);
		_tmp14_ = self->priv->settings;
		_tmp15_ = columns[0];
		graphs_import_settings_set_string (_tmp14_, "y-column", _tmp15_);
		_tmp16_ = self->priv->settings;
		_tmp17_ = columns[0];
		graphs_import_settings_set_string (_tmp16_, "xerr-column", _tmp17_);
		_tmp18_ = self->priv->settings;
		_tmp19_ = columns[0];
		graphs_import_settings_set_string (_tmp18_, "yerr-column", _tmp19_);
	}
	columns = (_vala_array_free (columns, columns_length1, (GDestroyNotify) g_free), NULL);
	_g_free0 (first_table);
}

static gdouble*
graphs_database_reader_get_column_data (GraphsDatabaseReader* self,
                                        const gchar* table_name,
                                        const gchar* column_name,
                                        gint* result_length1,
                                        GError** error)
{
	gdouble* _result_ = NULL;
	gdouble* _tmp0_;
	gint _result__length1;
	gint __result__size_;
	gint n_results = 0;
	sqlite3_stmt* stmt = NULL;
	gchar* sql = NULL;
	gchar* _tmp1_;
	sqlite3* _tmp2_;
	const gchar* _tmp3_;
	sqlite3_stmt* _tmp4_ = NULL;
	gint _tmp5_;
	gint _tmp19_;
	gdouble* _tmp20_;
	gint _tmp20__length1;
	GError* _inner_error0_ = NULL;
	gdouble* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (table_name != NULL, NULL);
	g_return_val_if_fail (column_name != NULL, NULL);
	_tmp0_ = g_new0 (gdouble, 64);
	_result_ = _tmp0_;
	_result__length1 = 64;
	__result__size_ = _result__length1;
	n_results = 0;
	_tmp1_ = g_strdup_printf ("SELECT `%s` FROM `%s`", column_name, table_name);
	sql = _tmp1_;
	_tmp2_ = self->priv->db;
	_tmp3_ = sql;
	_tmp5_ = sqlite3_prepare_v2 (_tmp2_, _tmp3_, -1, &_tmp4_, NULL);
	_sqlite3_finalize0 (stmt);
	stmt = _tmp4_;
	if (_tmp5_ != SQLITE_OK) {
		sqlite3* _tmp6_;
		const gchar* _tmp7_;
		gchar* _tmp8_;
		gchar* _tmp9_;
		GError* _tmp10_;
		GError* _tmp11_;
		_tmp6_ = self->priv->db;
		_tmp7_ = sqlite3_errmsg (_tmp6_);
		_tmp8_ = g_strdup_printf ("Failed to prepare SQL statement: %s", _tmp7_);
		_tmp9_ = _tmp8_;
		_tmp10_ = g_error_new_literal (G_IO_ERROR, G_IO_ERROR_FAILED, _tmp9_);
		_tmp11_ = _tmp10_;
		_g_free0 (_tmp9_);
		_inner_error0_ = _tmp11_;
		if (_inner_error0_->domain == G_IO_ERROR) {
			g_propagate_error (error, _inner_error0_);
			_g_free0 (sql);
			_sqlite3_finalize0 (stmt);
			_result_ = (g_free (_result_), NULL);
			return NULL;
		} else {
			_g_free0 (sql);
			_sqlite3_finalize0 (stmt);
			_result_ = (g_free (_result_), NULL);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return NULL;
		}
	}
	while (TRUE) {
		sqlite3_stmt* _tmp12_;
		gdouble* _tmp13_;
		gint _tmp13__length1;
		gdouble* _tmp16_;
		gint _tmp16__length1;
		gint _tmp17_;
		sqlite3_stmt* _tmp18_;
		_tmp12_ = stmt;
		if (!(sqlite3_step (_tmp12_) == SQLITE_ROW)) {
			break;
		}
		_tmp13_ = _result_;
		_tmp13__length1 = _result__length1;
		if (n_results == _tmp13__length1) {
			gdouble* _tmp14_;
			gint _tmp14__length1;
			gint _tmp15_;
			_tmp14_ = _result_;
			_tmp14__length1 = _result__length1;
			_tmp15_ = _tmp14__length1 * 2;
			_result_ = g_renew (gdouble, _result_, _tmp14__length1 * 2);
			(_tmp15_ > _result__length1) ? memset (_result_ + _result__length1, 0, sizeof (gdouble) * (_tmp15_ - _result__length1)) : NULL;
			_result__length1 = _tmp15_;
			__result__size_ = _tmp15_;
		}
		_tmp16_ = _result_;
		_tmp16__length1 = _result__length1;
		_tmp17_ = n_results;
		n_results = _tmp17_ + 1;
		_tmp18_ = stmt;
		_tmp16_[_tmp17_] = sqlite3_column_double (_tmp18_, 0);
	}
	_tmp19_ = n_results;
	_result_ = g_renew (gdouble, _result_, n_results);
	(_tmp19_ > _result__length1) ? memset (_result_ + _result__length1, 0, sizeof (gdouble) * (_tmp19_ - _result__length1)) : NULL;
	_result__length1 = _tmp19_;
	__result__size_ = _tmp19_;
	_tmp20_ = _result_;
	_tmp20__length1 = _result__length1;
	if (result_length1) {
		*result_length1 = _tmp20__length1;
	}
	result = _tmp20_;
	_g_free0 (sql);
	_sqlite3_finalize0 (stmt);
	return result;
}

static gchar**
_vala_array_dup5 (gchar** self,
                  gssize length)
{
	if (length >= 0) {
		gchar** result;
		gssize i;
		result = g_new0 (gchar*, length + 1);
		for (i = 0; i < length; i++) {
			gchar* _tmp0_;
			_tmp0_ = g_strdup (self[i]);
			result[i] = _tmp0_;
		}
		return result;
	}
	return NULL;
}

static gchar**
graphs_database_reader_get_table_names (GraphsDatabaseReader* self,
                                        gint* result_length1,
                                        GError** error)
{
	GArray* names = NULL;
	GArray* _tmp0_;
	sqlite3_stmt* stmt = NULL;
	gchar* sql = NULL;
	gchar* _tmp1_;
	sqlite3* _tmp2_;
	const gchar* _tmp3_;
	sqlite3_stmt* _tmp4_ = NULL;
	gint _tmp5_;
	GArray* _tmp17_;
	gpointer* _tmp18_;
	gint _tmp18__length1;
	gchar** _tmp19_;
	gint _tmp19__length1;
	gchar** _tmp20_;
	gint _tmp20__length1;
	GError* _inner_error0_ = NULL;
	gchar** result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = g_array_new (TRUE, TRUE, sizeof (gchar*));
	g_array_set_clear_func (_tmp0_, (GDestroyNotify) _vala_gchar_free_function_content_of);
	names = _tmp0_;
	_tmp1_ = g_strdup ("SELECT name FROM sqlite_master WHERE type='table' AND name NOT LIKE 's" \
"qlite_%'");
	sql = _tmp1_;
	_tmp2_ = self->priv->db;
	_tmp3_ = sql;
	_tmp5_ = sqlite3_prepare_v2 (_tmp2_, _tmp3_, -1, &_tmp4_, NULL);
	_sqlite3_finalize0 (stmt);
	stmt = _tmp4_;
	if (_tmp5_ != SQLITE_OK) {
		sqlite3* _tmp6_;
		const gchar* _tmp7_;
		gchar* _tmp8_;
		gchar* _tmp9_;
		GError* _tmp10_;
		GError* _tmp11_;
		_tmp6_ = self->priv->db;
		_tmp7_ = sqlite3_errmsg (_tmp6_);
		_tmp8_ = g_strdup_printf ("Failed to get SQL Table names: %s", _tmp7_);
		_tmp9_ = _tmp8_;
		_tmp10_ = g_error_new_literal (G_IO_ERROR, G_IO_ERROR_FAILED, _tmp9_);
		_tmp11_ = _tmp10_;
		_g_free0 (_tmp9_);
		_inner_error0_ = _tmp11_;
		if (_inner_error0_->domain == G_IO_ERROR) {
			g_propagate_error (error, _inner_error0_);
			_g_free0 (sql);
			_sqlite3_finalize0 (stmt);
			_g_array_unref0 (names);
			return NULL;
		} else {
			_g_free0 (sql);
			_sqlite3_finalize0 (stmt);
			_g_array_unref0 (names);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return NULL;
		}
	}
	while (TRUE) {
		sqlite3_stmt* _tmp12_;
		GArray* _tmp13_;
		sqlite3_stmt* _tmp14_;
		const gchar* _tmp15_;
		gchar* _tmp16_;
		_tmp12_ = stmt;
		if (!(sqlite3_step (_tmp12_) == SQLITE_ROW)) {
			break;
		}
		_tmp13_ = names;
		_tmp14_ = stmt;
		_tmp15_ = (const gchar*) sqlite3_column_text (_tmp14_, 0);
		_tmp16_ = g_strdup (_tmp15_);
		g_array_append_val (_tmp13_, _tmp16_);
	}
	_tmp17_ = names;
	_tmp18_ = _tmp17_->data;
	_tmp18__length1 = _tmp17_->len;
	_tmp19_ = (_tmp18_ != NULL) ? _vala_array_dup5 (_tmp18_, _tmp18__length1) : _tmp18_;
	_tmp19__length1 = _tmp18__length1;
	_tmp20_ = _tmp19_;
	_tmp20__length1 = _tmp19__length1;
	if (result_length1) {
		*result_length1 = _tmp20__length1;
	}
	result = _tmp20_;
	_g_free0 (sql);
	_sqlite3_finalize0 (stmt);
	_g_array_unref0 (names);
	return result;
}

gchar*
graphs_database_reader_parse (GraphsDatabaseReader* self,
                              GraphsItemList* items,
                              GraphsImportSettings* settings,
                              GraphsData* data,
                              GError** error)
{
	gchar* table_name = NULL;
	gchar* _tmp0_;
	gchar** _tmp1_ = NULL;
	const gchar* _tmp2_;
	gint _tmp3_ = 0;
	gchar** _tmp4_;
	gint _tmp1__length1;
	gint __tmp1__size_;
	gchar* x_column = NULL;
	gchar* _tmp9_;
	gchar* y_column = NULL;
	gchar* _tmp10_;
	gdouble* xdata = NULL;
	const gchar* _tmp11_;
	const gchar* _tmp12_;
	gint _tmp13_ = 0;
	gdouble* _tmp14_;
	gint xdata_length1;
	gint _xdata_size_;
	gdouble* ydata = NULL;
	const gchar* _tmp15_;
	const gchar* _tmp16_;
	gint _tmp17_ = 0;
	gdouble* _tmp18_;
	gint ydata_length1;
	gint _ydata_size_;
	gdouble* _tmp19_;
	gint _tmp19__length1;
	gdouble* xerr = NULL;
	gint xerr_length1;
	gint _xerr_size_;
	gdouble* yerr = NULL;
	gint yerr_length1;
	gint _yerr_size_;
	GraphsDataItem* item = NULL;
	gdouble* _tmp37_;
	gint _tmp37__length1;
	gdouble* _tmp38_;
	gint _tmp38__length1;
	gdouble* _tmp39_;
	gint _tmp39__length1;
	gdouble* _tmp40_;
	gint _tmp40__length1;
	GraphsDataItem* _tmp41_;
	GraphsDataItem* _tmp42_;
	const gchar* _tmp43_;
	GraphsDataItem* _tmp44_;
	const gchar* _tmp45_;
	GraphsDataItem* _tmp46_;
	const gchar* _tmp47_;
	gchar* _tmp48_;
	gchar* _tmp49_;
	const gchar* _tmp50_;
	gchar* _tmp51_;
	gchar* _tmp52_;
	GraphsDataItem* _tmp53_;
	gchar* _tmp54_;
	GError* _inner_error0_ = NULL;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (items != NULL, NULL);
	g_return_val_if_fail (settings != NULL, NULL);
	g_return_val_if_fail (data != NULL, NULL);
	_tmp0_ = graphs_import_settings_get_string (settings, "table-name");
	table_name = _tmp0_;
	_tmp2_ = table_name;
	_tmp4_ = graphs_database_reader_get_numeric_columns (self, _tmp2_, &_tmp3_, &_inner_error0_);
	_tmp1_ = _tmp4_;
	_tmp1__length1 = _tmp3_;
	__tmp1__size_ = _tmp1__length1;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		if (_inner_error0_->domain == G_IO_ERROR) {
			g_propagate_error (error, _inner_error0_);
			_g_free0 (table_name);
			return NULL;
		} else {
			_g_free0 (table_name);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return NULL;
		}
	}
	if (_tmp1__length1 == 0) {
		gchar* msg = NULL;
		gchar* _tmp5_;
		const gchar* _tmp6_;
		const gchar* _tmp7_;
		gchar* _tmp8_;
		_tmp5_ = g_strdup (_ ("Could not import data from table \"%s\", no numeric columns were found"));
		msg = _tmp5_;
		_tmp6_ = msg;
		_tmp7_ = table_name;
		_tmp8_ = g_strdup_printf (_tmp6_, _tmp7_);
		result = _tmp8_;
		_g_free0 (msg);
		_tmp1_ = (_vala_array_free (_tmp1_, _tmp1__length1, (GDestroyNotify) g_free), NULL);
		_g_free0 (table_name);
		return result;
	}
	_tmp9_ = graphs_import_settings_get_string (settings, "x-column");
	x_column = _tmp9_;
	_tmp10_ = graphs_import_settings_get_string (settings, "y-column");
	y_column = _tmp10_;
	_tmp11_ = table_name;
	_tmp12_ = x_column;
	_tmp14_ = graphs_database_reader_get_column_data (self, _tmp11_, _tmp12_, &_tmp13_, &_inner_error0_);
	xdata = _tmp14_;
	xdata_length1 = _tmp13_;
	_xdata_size_ = xdata_length1;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		if (_inner_error0_->domain == G_IO_ERROR) {
			g_propagate_error (error, _inner_error0_);
			_g_free0 (y_column);
			_g_free0 (x_column);
			_tmp1_ = (_vala_array_free (_tmp1_, _tmp1__length1, (GDestroyNotify) g_free), NULL);
			_g_free0 (table_name);
			return NULL;
		} else {
			_g_free0 (y_column);
			_g_free0 (x_column);
			_tmp1_ = (_vala_array_free (_tmp1_, _tmp1__length1, (GDestroyNotify) g_free), NULL);
			_g_free0 (table_name);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return NULL;
		}
	}
	_tmp15_ = table_name;
	_tmp16_ = y_column;
	_tmp18_ = graphs_database_reader_get_column_data (self, _tmp15_, _tmp16_, &_tmp17_, &_inner_error0_);
	ydata = _tmp18_;
	ydata_length1 = _tmp17_;
	_ydata_size_ = ydata_length1;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		if (_inner_error0_->domain == G_IO_ERROR) {
			g_propagate_error (error, _inner_error0_);
			xdata = (g_free (xdata), NULL);
			_g_free0 (y_column);
			_g_free0 (x_column);
			_tmp1_ = (_vala_array_free (_tmp1_, _tmp1__length1, (GDestroyNotify) g_free), NULL);
			_g_free0 (table_name);
			return NULL;
		} else {
			xdata = (g_free (xdata), NULL);
			_g_free0 (y_column);
			_g_free0 (x_column);
			_tmp1_ = (_vala_array_free (_tmp1_, _tmp1__length1, (GDestroyNotify) g_free), NULL);
			_g_free0 (table_name);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return NULL;
		}
	}
	_tmp19_ = xdata;
	_tmp19__length1 = xdata_length1;
	if (_tmp19__length1 == 0) {
		gchar* _tmp20_;
		_tmp20_ = g_strdup (_ ("No data found in table column"));
		result = _tmp20_;
		ydata = (g_free (ydata), NULL);
		xdata = (g_free (xdata), NULL);
		_g_free0 (y_column);
		_g_free0 (x_column);
		_tmp1_ = (_vala_array_free (_tmp1_, _tmp1__length1, (GDestroyNotify) g_free), NULL);
		_g_free0 (table_name);
		return result;
	}
	xerr = NULL;
	xerr_length1 = 0;
	_xerr_size_ = xerr_length1;
	yerr = NULL;
	yerr_length1 = 0;
	_yerr_size_ = yerr_length1;
	if (graphs_import_settings_get_boolean (settings, "use-xerr")) {
		gdouble* _tmp21_ = NULL;
		const gchar* _tmp22_;
		gchar* _tmp23_;
		gchar* _tmp24_;
		gint _tmp25_ = 0;
		gdouble* _tmp26_;
		gdouble* _tmp27_;
		gint _tmp27__length1;
		gint _tmp21__length1;
		gint __tmp21__size_;
		gdouble* _tmp28_;
		gint _tmp28__length1;
		_tmp22_ = table_name;
		_tmp23_ = graphs_import_settings_get_string (settings, "xerr-column");
		_tmp24_ = _tmp23_;
		_tmp26_ = graphs_database_reader_get_column_data (self, _tmp22_, _tmp24_, &_tmp25_, &_inner_error0_);
		_tmp27_ = _tmp26_;
		_tmp27__length1 = _tmp25_;
		_g_free0 (_tmp24_);
		_tmp21_ = _tmp27_;
		_tmp21__length1 = _tmp27__length1;
		__tmp21__size_ = _tmp21__length1;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			if (_inner_error0_->domain == G_IO_ERROR) {
				g_propagate_error (error, _inner_error0_);
				yerr = (g_free (yerr), NULL);
				xerr = (g_free (xerr), NULL);
				ydata = (g_free (ydata), NULL);
				xdata = (g_free (xdata), NULL);
				_g_free0 (y_column);
				_g_free0 (x_column);
				_tmp1_ = (_vala_array_free (_tmp1_, _tmp1__length1, (GDestroyNotify) g_free), NULL);
				_g_free0 (table_name);
				return NULL;
			} else {
				yerr = (g_free (yerr), NULL);
				xerr = (g_free (xerr), NULL);
				ydata = (g_free (ydata), NULL);
				xdata = (g_free (xdata), NULL);
				_g_free0 (y_column);
				_g_free0 (x_column);
				_tmp1_ = (_vala_array_free (_tmp1_, _tmp1__length1, (GDestroyNotify) g_free), NULL);
				_g_free0 (table_name);
				g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
				g_clear_error (&_inner_error0_);
				return NULL;
			}
		}
		_tmp28_ = _tmp21_;
		_tmp28__length1 = _tmp21__length1;
		_tmp21_ = NULL;
		_tmp21__length1 = 0;
		xerr = (g_free (xerr), NULL);
		xerr = _tmp28_;
		xerr_length1 = _tmp28__length1;
		_xerr_size_ = xerr_length1;
		_tmp21_ = (g_free (_tmp21_), NULL);
	}
	if (graphs_import_settings_get_boolean (settings, "use-yerr")) {
		gdouble* _tmp29_ = NULL;
		const gchar* _tmp30_;
		gchar* _tmp31_;
		gchar* _tmp32_;
		gint _tmp33_ = 0;
		gdouble* _tmp34_;
		gdouble* _tmp35_;
		gint _tmp35__length1;
		gint _tmp29__length1;
		gint __tmp29__size_;
		gdouble* _tmp36_;
		gint _tmp36__length1;
		_tmp30_ = table_name;
		_tmp31_ = graphs_import_settings_get_string (settings, "yerr-column");
		_tmp32_ = _tmp31_;
		_tmp34_ = graphs_database_reader_get_column_data (self, _tmp30_, _tmp32_, &_tmp33_, &_inner_error0_);
		_tmp35_ = _tmp34_;
		_tmp35__length1 = _tmp33_;
		_g_free0 (_tmp32_);
		_tmp29_ = _tmp35_;
		_tmp29__length1 = _tmp35__length1;
		__tmp29__size_ = _tmp29__length1;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			if (_inner_error0_->domain == G_IO_ERROR) {
				g_propagate_error (error, _inner_error0_);
				yerr = (g_free (yerr), NULL);
				xerr = (g_free (xerr), NULL);
				ydata = (g_free (ydata), NULL);
				xdata = (g_free (xdata), NULL);
				_g_free0 (y_column);
				_g_free0 (x_column);
				_tmp1_ = (_vala_array_free (_tmp1_, _tmp1__length1, (GDestroyNotify) g_free), NULL);
				_g_free0 (table_name);
				return NULL;
			} else {
				yerr = (g_free (yerr), NULL);
				xerr = (g_free (xerr), NULL);
				ydata = (g_free (ydata), NULL);
				xdata = (g_free (xdata), NULL);
				_g_free0 (y_column);
				_g_free0 (x_column);
				_tmp1_ = (_vala_array_free (_tmp1_, _tmp1__length1, (GDestroyNotify) g_free), NULL);
				_g_free0 (table_name);
				g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
				g_clear_error (&_inner_error0_);
				return NULL;
			}
		}
		_tmp36_ = _tmp29_;
		_tmp36__length1 = _tmp29__length1;
		_tmp29_ = NULL;
		_tmp29__length1 = 0;
		yerr = (g_free (yerr), NULL);
		yerr = _tmp36_;
		yerr_length1 = _tmp36__length1;
		_yerr_size_ = yerr_length1;
		_tmp29_ = (g_free (_tmp29_), NULL);
	}
	_tmp37_ = xdata;
	_tmp37__length1 = xdata_length1;
	_tmp38_ = ydata;
	_tmp38__length1 = ydata_length1;
	_tmp39_ = xerr;
	_tmp39__length1 = xerr_length1;
	_tmp40_ = yerr;
	_tmp40__length1 = yerr_length1;
	_tmp41_ = graphs_item_factory_new_data_item (data, _tmp37_, (gint) _tmp37__length1, _tmp38_, (gint) _tmp38__length1, _tmp39_, (gint) _tmp39__length1, _tmp40_, (gint) _tmp40__length1);
	item = _tmp41_;
	_tmp42_ = item;
	_tmp43_ = x_column;
	graphs_item_set_xlabel ((GraphsItem*) _tmp42_, _tmp43_);
	_tmp44_ = item;
	_tmp45_ = y_column;
	graphs_item_set_ylabel ((GraphsItem*) _tmp44_, _tmp45_);
	_tmp46_ = item;
	_tmp47_ = x_column;
	_tmp48_ = g_strconcat (_tmp47_, " vs ", NULL);
	_tmp49_ = _tmp48_;
	_tmp50_ = y_column;
	_tmp51_ = g_strconcat (_tmp49_, _tmp50_, NULL);
	_tmp52_ = _tmp51_;
	graphs_item_set_name ((GraphsItem*) _tmp46_, _tmp52_);
	_g_free0 (_tmp52_);
	_g_free0 (_tmp49_);
	_tmp53_ = item;
	graphs_item_list_add (items, (GraphsItem*) _tmp53_);
	_tmp54_ = g_strdup ("");
	result = _tmp54_;
	_g_object_unref0 (item);
	yerr = (g_free (yerr), NULL);
	xerr = (g_free (xerr), NULL);
	ydata = (g_free (ydata), NULL);
	xdata = (g_free (xdata), NULL);
	_g_free0 (y_column);
	_g_free0 (x_column);
	_tmp1_ = (_vala_array_free (_tmp1_, _tmp1__length1, (GDestroyNotify) g_free), NULL);
	_g_free0 (table_name);
	return result;
}

static void
graphs_database_reader_class_init (GraphsDatabaseReaderClass * klass,
                                   gpointer klass_data)
{
	graphs_database_reader_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GraphsDatabaseReader_private_offset);
	G_OBJECT_CLASS (klass)->finalize = graphs_database_reader_finalize;
}

static void
graphs_database_reader_instance_init (GraphsDatabaseReader * self,
                                      gpointer klass)
{
	self->priv = graphs_database_reader_get_instance_private (self);
}

static void
graphs_database_reader_finalize (GObject * obj)
{
	GraphsDatabaseReader * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GRAPHS_TYPE_DATABASE_READER, GraphsDatabaseReader);
	_sqlite3_close0 (self->priv->db);
	self->table_names = (_vala_array_free (self->table_names, self->table_names_length1, (GDestroyNotify) g_free), NULL);
	_g_object_unref0 (self->priv->settings);
	G_OBJECT_CLASS (graphs_database_reader_parent_class)->finalize (obj);
}

/**
     * Database reader class that handles all database operations
     */
static GType
graphs_database_reader_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GraphsDatabaseReaderClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) graphs_database_reader_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GraphsDatabaseReader), 0, (GInstanceInitFunc) graphs_database_reader_instance_init, NULL };
	GType graphs_database_reader_type_id;
	graphs_database_reader_type_id = g_type_register_static (G_TYPE_OBJECT, "GraphsDatabaseReader", &g_define_type_info, 0);
	GraphsDatabaseReader_private_offset = g_type_add_instance_private (graphs_database_reader_type_id, sizeof (GraphsDatabaseReaderPrivate));
	return graphs_database_reader_type_id;
}

GType
graphs_database_reader_get_type (void)
{
	static volatile gsize graphs_database_reader_type_id__once = 0;
	if (g_once_init_enter (&graphs_database_reader_type_id__once)) {
		GType graphs_database_reader_type_id;
		graphs_database_reader_type_id = graphs_database_reader_get_type_once ();
		g_once_init_leave (&graphs_database_reader_type_id__once, graphs_database_reader_type_id);
	}
	return graphs_database_reader_type_id__once;
}

static void
_vala_array_destroy (gpointer array,
                     gssize array_length,
                     GDestroyNotify destroy_func)
{
	if ((array != NULL) && (destroy_func != NULL)) {
		gssize i;
		for (i = 0; i < array_length; i = i + 1) {
			if (((gpointer*) array)[i] != NULL) {
				destroy_func (((gpointer*) array)[i]);
			}
		}
	}
}

static void
_vala_array_free (gpointer array,
                  gssize array_length,
                  GDestroyNotify destroy_func)
{
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}

static inline gpointer
_vala_memdup2 (gconstpointer mem,
               gsize byte_size)
{
	gpointer new_mem;
	if (mem && byte_size != 0) {
		new_mem = g_malloc (byte_size);
		memcpy (new_mem, mem, byte_size);
	} else {
		new_mem = NULL;
	}
	return new_mem;
}

