/* vbfconfignodelist.c generated by valac 0.12.1.1-323029-dirty, the Vala compiler
 * generated from vbfconfignodelist.vala, do not modify */

/*
 *  vbfconfignodelist.vala - Vala Build Framework library
 *  
 *  Copyright (C) 2008 - Andrea Del Signore <sejerpz@tin.it>
 *  
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License as published by the Free Software Foundation; either
 *  version 2.1 of the License, or (at your option) any later version.
 *
 *  This library 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
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
 */

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


#define VBF_TYPE_CONFIG_NODE (vbf_config_node_get_type ())
#define VBF_CONFIG_NODE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), VBF_TYPE_CONFIG_NODE, VbfConfigNode))
#define VBF_CONFIG_NODE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), VBF_TYPE_CONFIG_NODE, VbfConfigNodeClass))
#define VBF_IS_CONFIG_NODE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), VBF_TYPE_CONFIG_NODE))
#define VBF_IS_CONFIG_NODE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), VBF_TYPE_CONFIG_NODE))
#define VBF_CONFIG_NODE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), VBF_TYPE_CONFIG_NODE, VbfConfigNodeClass))

typedef struct _VbfConfigNode VbfConfigNode;
typedef struct _VbfConfigNodeClass VbfConfigNodeClass;
typedef struct _VbfConfigNodePrivate VbfConfigNodePrivate;

#define VBF_TYPE_CONFIG_NODE_LIST (vbf_config_node_list_get_type ())
#define VBF_CONFIG_NODE_LIST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), VBF_TYPE_CONFIG_NODE_LIST, VbfConfigNodeList))
#define VBF_CONFIG_NODE_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), VBF_TYPE_CONFIG_NODE_LIST, VbfConfigNodeListClass))
#define VBF_IS_CONFIG_NODE_LIST(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), VBF_TYPE_CONFIG_NODE_LIST))
#define VBF_IS_CONFIG_NODE_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), VBF_TYPE_CONFIG_NODE_LIST))
#define VBF_CONFIG_NODE_LIST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), VBF_TYPE_CONFIG_NODE_LIST, VbfConfigNodeListClass))

typedef struct _VbfConfigNodeList VbfConfigNodeList;
typedef struct _VbfConfigNodeListClass VbfConfigNodeListClass;
typedef struct _VbfConfigNodeListPrivate VbfConfigNodeListPrivate;
#define _vala_iterable_unref0(var) ((var == NULL) ? NULL : (var = (vala_iterable_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _VbfConfigNode {
	GObject parent_instance;
	VbfConfigNodePrivate * priv;
	VbfConfigNode* parent;
};

struct _VbfConfigNodeClass {
	GObjectClass parent_class;
	gchar* (*to_string) (VbfConfigNode* self);
};

struct _VbfConfigNodeList {
	VbfConfigNode parent_instance;
	VbfConfigNodeListPrivate * priv;
	ValaList* values;
};

struct _VbfConfigNodeListClass {
	VbfConfigNodeClass parent_class;
};


static gpointer vbf_config_node_list_parent_class = NULL;

GType vbf_config_node_get_type (void) G_GNUC_CONST;
GType vbf_config_node_list_get_type (void) G_GNUC_CONST;
enum  {
	VBF_CONFIG_NODE_LIST_DUMMY_PROPERTY
};
ValaList* vbf_config_node_list_get_values (VbfConfigNodeList* self);
void vbf_config_node_list_add_value (VbfConfigNodeList* self, VbfConfigNode* val);
void vbf_config_node_list_replace_config_node (VbfConfigNodeList* self, VbfConfigNode* source, VbfConfigNode* target);
static gchar* vbf_config_node_list_real_to_string (VbfConfigNode* base);
gchar* vbf_config_node_to_string (VbfConfigNode* self);
VbfConfigNodeList* vbf_config_node_list_new (void);
VbfConfigNodeList* vbf_config_node_list_construct (GType object_type);
VbfConfigNode* vbf_config_node_construct (GType object_type);
static void vbf_config_node_list_finalize (GObject* obj);


static gpointer _vala_iterable_ref0 (gpointer self) {
	return self ? vala_iterable_ref (self) : NULL;
}


ValaList* vbf_config_node_list_get_values (VbfConfigNodeList* self) {
	ValaList* result = NULL;
	ValaList* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = _vala_iterable_ref0 (self->values);
	result = _tmp0_;
	return result;
}


void vbf_config_node_list_add_value (VbfConfigNodeList* self, VbfConfigNode* val) {
	g_return_if_fail (self != NULL);
	g_return_if_fail (val != NULL);
	vala_collection_add ((ValaCollection*) self->values, val);
}


void vbf_config_node_list_replace_config_node (VbfConfigNodeList* self, VbfConfigNode* source, VbfConfigNode* target) {
	gboolean _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (source != NULL);
	g_return_if_fail (target != NULL);
	_tmp0_ = vala_collection_contains ((ValaCollection*) self->values, source);
	if (_tmp0_) {
		vala_collection_remove ((ValaCollection*) self->values, source);
		if (target != NULL) {
			vala_collection_add ((ValaCollection*) self->values, target);
		}
	}
}


static glong string_strnlen (gchar* str, glong maxlen) {
	glong result = 0L;
	gchar* _tmp0_ = NULL;
	gchar* end;
	_tmp0_ = memchr (str, 0, (gsize) maxlen);
	end = _tmp0_;
	if (end == NULL) {
		result = maxlen;
		return result;
	} else {
		result = (glong) (end - str);
		return result;
	}
}


static gchar* string_substring (const gchar* self, glong offset, glong len) {
	gchar* result = NULL;
	glong string_length = 0L;
	gboolean _tmp0_ = FALSE;
	gchar* _tmp3_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	if (offset >= 0) {
		_tmp0_ = len >= 0;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		glong _tmp1_;
		_tmp1_ = string_strnlen ((gchar*) self, offset + len);
		string_length = _tmp1_;
	} else {
		gint _tmp2_;
		_tmp2_ = strlen (self);
		string_length = (glong) _tmp2_;
	}
	if (offset < 0) {
		offset = string_length + offset;
		g_return_val_if_fail (offset >= 0, NULL);
	} else {
		g_return_val_if_fail (offset <= string_length, NULL);
	}
	if (len < 0) {
		len = string_length - offset;
	}
	g_return_val_if_fail ((offset + len) <= string_length, NULL);
	_tmp3_ = g_strndup (((gchar*) self) + offset, (gsize) len);
	result = _tmp3_;
	return result;
}


static gchar* vbf_config_node_list_real_to_string (VbfConfigNode* base) {
	VbfConfigNodeList * self;
	gchar* result = NULL;
	gchar* _tmp0_;
	gchar* res;
	gint _tmp9_;
	self = (VbfConfigNodeList*) base;
	_tmp0_ = g_strdup ("");
	res = _tmp0_;
	{
		ValaList* _tmp1_;
		ValaList* _item_list;
		gint _tmp2_;
		gint _item_size;
		gint _item_index;
		_tmp1_ = _vala_iterable_ref0 (self->values);
		_item_list = _tmp1_;
		_tmp2_ = vala_collection_get_size ((ValaCollection*) _item_list);
		_item_size = _tmp2_;
		_item_index = -1;
		while (TRUE) {
			gpointer _tmp3_ = NULL;
			VbfConfigNode* item;
			_item_index = _item_index + 1;
			if (!(_item_index < _item_size)) {
				break;
			}
			_tmp3_ = vala_list_get (_item_list, _item_index);
			item = (VbfConfigNode*) _tmp3_;
			if (item != NULL) {
				gchar* _tmp4_ = NULL;
				gchar* _tmp5_;
				gchar* _tmp6_ = NULL;
				gchar* _tmp7_;
				gchar* _tmp8_;
				_tmp4_ = vbf_config_node_to_string (item);
				_tmp5_ = _tmp4_;
				_tmp6_ = g_strdup_printf ("%s, ", _tmp5_);
				_tmp7_ = _tmp6_;
				_tmp8_ = g_strconcat (res, _tmp7_, NULL);
				_g_free0 (res);
				res = _tmp8_;
				_g_free0 (_tmp7_);
				_g_free0 (_tmp5_);
			} else {
				g_critical ("vbfconfignodelist.vala:56: item is null");
			}
			_g_object_unref0 (item);
		}
		_vala_iterable_unref0 (_item_list);
	}
	_tmp9_ = strlen (res);
	if (_tmp9_ > 2) {
		gint _tmp10_;
		gchar* _tmp11_ = NULL;
		_tmp10_ = strlen (res);
		_tmp11_ = string_substring (res, (glong) 0, (glong) (_tmp10_ - 2));
		_g_free0 (res);
		res = _tmp11_;
	}
	result = res;
	return result;
}


VbfConfigNodeList* vbf_config_node_list_construct (GType object_type) {
	VbfConfigNodeList * self = NULL;
	self = (VbfConfigNodeList*) vbf_config_node_construct (object_type);
	return self;
}


VbfConfigNodeList* vbf_config_node_list_new (void) {
	return vbf_config_node_list_construct (VBF_TYPE_CONFIG_NODE_LIST);
}


static void vbf_config_node_list_class_init (VbfConfigNodeListClass * klass) {
	vbf_config_node_list_parent_class = g_type_class_peek_parent (klass);
	VBF_CONFIG_NODE_CLASS (klass)->to_string = vbf_config_node_list_real_to_string;
	G_OBJECT_CLASS (klass)->finalize = vbf_config_node_list_finalize;
}


static void vbf_config_node_list_instance_init (VbfConfigNodeList * self) {
	ValaArrayList* _tmp0_ = NULL;
	_tmp0_ = vala_array_list_new (VBF_TYPE_CONFIG_NODE, (GBoxedCopyFunc) g_object_ref, g_object_unref, g_direct_equal);
	self->values = (ValaList*) _tmp0_;
}


static void vbf_config_node_list_finalize (GObject* obj) {
	VbfConfigNodeList * self;
	self = VBF_CONFIG_NODE_LIST (obj);
	_vala_iterable_unref0 (self->values);
	G_OBJECT_CLASS (vbf_config_node_list_parent_class)->finalize (obj);
}


GType vbf_config_node_list_get_type (void) {
	static volatile gsize vbf_config_node_list_type_id__volatile = 0;
	if (g_once_init_enter (&vbf_config_node_list_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (VbfConfigNodeListClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) vbf_config_node_list_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (VbfConfigNodeList), 0, (GInstanceInitFunc) vbf_config_node_list_instance_init, NULL };
		GType vbf_config_node_list_type_id;
		vbf_config_node_list_type_id = g_type_register_static (VBF_TYPE_CONFIG_NODE, "VbfConfigNodeList", &g_define_type_info, 0);
		g_once_init_leave (&vbf_config_node_list_type_id__volatile, vbf_config_node_list_type_id);
	}
	return vbf_config_node_list_type_id__volatile;
}



