/* rygel-xml-utils.c generated by valac 0.40.8, the Vala compiler
 * generated from rygel-xml-utils.vala, do not modify */

/*
 * Copyright (C) 2008,2010 Nokia Corporation.
 * Copyright (C) 2008 Zeeshan Ali (Khattak) <zeeshanak@gnome.org>.
 *
 * Author: Zeeshan Ali (Khattak) <zeeshanak@gnome.org>
 *
 * This file is part of Rygel.
 *
 * Rygel 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.
 *
 * Rygel 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 <libxml/tree.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <gobject/gvaluecollector.h>


#define RYGEL_TYPE_XML_UTILS (rygel_xml_utils_get_type ())
#define RYGEL_XML_UTILS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_TYPE_XML_UTILS, RygelXMLUtils))
#define RYGEL_XML_UTILS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_TYPE_XML_UTILS, RygelXMLUtilsClass))
#define RYGEL_IS_XML_UTILS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_TYPE_XML_UTILS))
#define RYGEL_IS_XML_UTILS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_TYPE_XML_UTILS))
#define RYGEL_XML_UTILS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_TYPE_XML_UTILS, RygelXMLUtilsClass))

typedef struct _RygelXMLUtils RygelXMLUtils;
typedef struct _RygelXMLUtilsClass RygelXMLUtilsClass;
typedef struct _RygelXMLUtilsPrivate RygelXMLUtilsPrivate;
#define _g_free0(var) (var = (g_free (var), NULL))

#define RYGEL_XML_UTILS_TYPE_ITERATOR (rygel_xml_utils_iterator_get_type ())
#define RYGEL_XML_UTILS_ITERATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_XML_UTILS_TYPE_ITERATOR, RygelXMLUtilsIterator))
#define RYGEL_XML_UTILS_ITERATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_XML_UTILS_TYPE_ITERATOR, RygelXMLUtilsIteratorClass))
#define RYGEL_XML_UTILS_IS_ITERATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_XML_UTILS_TYPE_ITERATOR))
#define RYGEL_XML_UTILS_IS_ITERATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_XML_UTILS_TYPE_ITERATOR))
#define RYGEL_XML_UTILS_ITERATOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_XML_UTILS_TYPE_ITERATOR, RygelXMLUtilsIteratorClass))

typedef struct _RygelXMLUtilsIterator RygelXMLUtilsIterator;
typedef struct _RygelXMLUtilsIteratorClass RygelXMLUtilsIteratorClass;
typedef struct _RygelXMLUtilsIteratorPrivate RygelXMLUtilsIteratorPrivate;
typedef struct _RygelXMLUtilsParamSpecIterator RygelXMLUtilsParamSpecIterator;

#define RYGEL_XML_UTILS_TYPE_CHILD_ITERATOR (rygel_xml_utils_child_iterator_get_type ())
#define RYGEL_XML_UTILS_CHILD_ITERATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_XML_UTILS_TYPE_CHILD_ITERATOR, RygelXMLUtilsChildIterator))
#define RYGEL_XML_UTILS_CHILD_ITERATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_XML_UTILS_TYPE_CHILD_ITERATOR, RygelXMLUtilsChildIteratorClass))
#define RYGEL_XML_UTILS_IS_CHILD_ITERATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_XML_UTILS_TYPE_CHILD_ITERATOR))
#define RYGEL_XML_UTILS_IS_CHILD_ITERATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_XML_UTILS_TYPE_CHILD_ITERATOR))
#define RYGEL_XML_UTILS_CHILD_ITERATOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_XML_UTILS_TYPE_CHILD_ITERATOR, RygelXMLUtilsChildIteratorClass))

typedef struct _RygelXMLUtilsChildIterator RygelXMLUtilsChildIterator;
typedef struct _RygelXMLUtilsChildIteratorClass RygelXMLUtilsChildIteratorClass;
typedef struct _RygelXMLUtilsChildIteratorPrivate RygelXMLUtilsChildIteratorPrivate;
typedef struct _RygelParamSpecXMLUtils RygelParamSpecXMLUtils;

struct _RygelXMLUtils {
	GTypeInstance parent_instance;
	volatile int ref_count;
	RygelXMLUtilsPrivate * priv;
};

struct _RygelXMLUtilsClass {
	GTypeClass parent_class;
	void (*finalize) (RygelXMLUtils *self);
};

struct _RygelXMLUtilsIterator {
	GTypeInstance parent_instance;
	volatile int ref_count;
	RygelXMLUtilsIteratorPrivate * priv;
};

struct _RygelXMLUtilsIteratorClass {
	GTypeClass parent_class;
	void (*finalize) (RygelXMLUtilsIterator *self);
};

struct _RygelXMLUtilsIteratorPrivate {
	xmlNode* iter;
};

struct _RygelXMLUtilsParamSpecIterator {
	GParamSpec parent_instance;
};

struct _RygelXMLUtilsChildIterator {
	RygelXMLUtilsIterator parent_instance;
	RygelXMLUtilsChildIteratorPrivate * priv;
};

struct _RygelXMLUtilsChildIteratorClass {
	RygelXMLUtilsIteratorClass parent_class;
};

struct _RygelParamSpecXMLUtils {
	GParamSpec parent_instance;
};


static gpointer rygel_xml_utils_parent_class = NULL;
static gpointer rygel_xml_utils_iterator_parent_class = NULL;
static gpointer rygel_xml_utils_child_iterator_parent_class = NULL;

gpointer rygel_xml_utils_ref (gpointer instance);
void rygel_xml_utils_unref (gpointer instance);
GParamSpec* rygel_param_spec_xml_utils (const gchar* name,
                                        const gchar* nick,
                                        const gchar* blurb,
                                        GType object_type,
                                        GParamFlags flags);
void rygel_value_set_xml_utils (GValue* value,
                                gpointer v_object);
void rygel_value_take_xml_utils (GValue* value,
                                 gpointer v_object);
gpointer rygel_value_get_xml_utils (const GValue* value);
GType rygel_xml_utils_get_type (void) G_GNUC_CONST;
xmlNode* rygel_xml_utils_get_element (xmlNode* node,
                                      ...);
RygelXMLUtils* rygel_xml_utils_new (void);
RygelXMLUtils* rygel_xml_utils_construct (GType object_type);
gpointer rygel_xml_utils_iterator_ref (gpointer instance);
void rygel_xml_utils_iterator_unref (gpointer instance);
GParamSpec* rygel_xml_utils_param_spec_iterator (const gchar* name,
                                                 const gchar* nick,
                                                 const gchar* blurb,
                                                 GType object_type,
                                                 GParamFlags flags);
void rygel_xml_utils_value_set_iterator (GValue* value,
                                         gpointer v_object);
void rygel_xml_utils_value_take_iterator (GValue* value,
                                          gpointer v_object);
gpointer rygel_xml_utils_value_get_iterator (const GValue* value);
GType rygel_xml_utils_iterator_get_type (void) G_GNUC_CONST;
#define RYGEL_XML_UTILS_ITERATOR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), RYGEL_XML_UTILS_TYPE_ITERATOR, RygelXMLUtilsIteratorPrivate))
RygelXMLUtilsIterator* rygel_xml_utils_iterator_new (xmlNode* node);
RygelXMLUtilsIterator* rygel_xml_utils_iterator_construct (GType object_type,
                                                           xmlNode* node);
RygelXMLUtilsIterator* rygel_xml_utils_iterator_iterator (RygelXMLUtilsIterator* self);
gboolean rygel_xml_utils_iterator_next (RygelXMLUtilsIterator* self);
xmlNode* rygel_xml_utils_iterator_get (RygelXMLUtilsIterator* self);
static void rygel_xml_utils_iterator_finalize (RygelXMLUtilsIterator * obj);
GType rygel_xml_utils_child_iterator_get_type (void) G_GNUC_CONST;
RygelXMLUtilsChildIterator* rygel_xml_utils_child_iterator_new (xmlNode* node);
RygelXMLUtilsChildIterator* rygel_xml_utils_child_iterator_construct (GType object_type,
                                                                      xmlNode* node);
static void rygel_xml_utils_finalize (RygelXMLUtils * obj);


xmlNode*
rygel_xml_utils_get_element (xmlNode* node,
                             ...)
{
	xmlNode* result = NULL;
	xmlNode* ret = NULL;
	va_list list = {0};
	xmlNode* _tmp13_;
	ret = node;
	va_start (list, node);
	while (TRUE) {
		gchar* arg = NULL;
		const gchar* _tmp0_;
		gchar* _tmp1_;
		const gchar* _tmp2_;
		xmlNode* _tmp12_;
		_tmp0_ = va_arg (list, gchar*);
		_tmp1_ = g_strdup (_tmp0_);
		arg = _tmp1_;
		_tmp2_ = arg;
		if (_tmp2_ == NULL) {
			_g_free0 (arg);
			break;
		}
		{
			xmlNode* _tmp3_;
			xmlNode* _tmp4_;
			gboolean _tmp5_ = FALSE;
			_tmp3_ = ret;
			_tmp4_ = _tmp3_->children;
			ret = _tmp4_;
			_tmp5_ = TRUE;
			while (TRUE) {
				xmlNode* _tmp8_;
				const gchar* _tmp9_;
				xmlNode* _tmp10_;
				const gchar* _tmp11_;
				if (!_tmp5_) {
					xmlNode* _tmp6_;
					xmlNode* _tmp7_;
					_tmp6_ = ret;
					_tmp7_ = _tmp6_->next;
					ret = _tmp7_;
				}
				_tmp5_ = FALSE;
				_tmp8_ = ret;
				if (!(_tmp8_ != NULL)) {
					break;
				}
				_tmp9_ = arg;
				_tmp10_ = ret;
				_tmp11_ = _tmp10_->name;
				if (g_strcmp0 (_tmp9_, _tmp11_) == 0) {
					break;
				}
			}
		}
		_tmp12_ = ret;
		if (_tmp12_ == NULL) {
			_g_free0 (arg);
			break;
		}
		_g_free0 (arg);
	}
	_tmp13_ = ret;
	result = _tmp13_;
	va_end (list);
	return result;
}


RygelXMLUtils*
rygel_xml_utils_construct (GType object_type)
{
	RygelXMLUtils* self = NULL;
	self = (RygelXMLUtils*) g_type_create_instance (object_type);
	return self;
}


RygelXMLUtils*
rygel_xml_utils_new (void)
{
	return rygel_xml_utils_construct (RYGEL_TYPE_XML_UTILS);
}


RygelXMLUtilsIterator*
rygel_xml_utils_iterator_construct (GType object_type,
                                    xmlNode* node)
{
	RygelXMLUtilsIterator* self = NULL;
	self = (RygelXMLUtilsIterator*) g_type_create_instance (object_type);
	self->priv->iter = node;
	return self;
}


RygelXMLUtilsIterator*
rygel_xml_utils_iterator_new (xmlNode* node)
{
	return rygel_xml_utils_iterator_construct (RYGEL_XML_UTILS_TYPE_ITERATOR, node);
}


static gpointer
_rygel_xml_utils_iterator_ref0 (gpointer self)
{
	return self ? rygel_xml_utils_iterator_ref (self) : NULL;
}


RygelXMLUtilsIterator*
rygel_xml_utils_iterator_iterator (RygelXMLUtilsIterator* self)
{
	RygelXMLUtilsIterator* result = NULL;
	RygelXMLUtilsIterator* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = _rygel_xml_utils_iterator_ref0 (self);
	result = _tmp0_;
	return result;
}


gboolean
rygel_xml_utils_iterator_next (RygelXMLUtilsIterator* self)
{
	gboolean result = FALSE;
	xmlNode* _tmp0_;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = self->priv->iter;
	result = _tmp0_ != NULL;
	return result;
}


xmlNode*
rygel_xml_utils_iterator_get (RygelXMLUtilsIterator* self)
{
	xmlNode* result = NULL;
	xmlNode* current = NULL;
	xmlNode* _tmp0_;
	xmlNode* _tmp1_;
	xmlNode* _tmp2_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->iter;
	current = _tmp0_;
	_tmp1_ = self->priv->iter;
	_tmp2_ = _tmp1_->next;
	self->priv->iter = _tmp2_;
	result = current;
	return result;
}


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


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


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


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


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


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


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


void
rygel_xml_utils_value_set_iterator (GValue* value,
                                    gpointer v_object)
{
	RygelXMLUtilsIterator * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, RYGEL_XML_UTILS_TYPE_ITERATOR));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, RYGEL_XML_UTILS_TYPE_ITERATOR));
		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;
		rygel_xml_utils_iterator_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		rygel_xml_utils_iterator_unref (old);
	}
}


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


static void
rygel_xml_utils_iterator_class_init (RygelXMLUtilsIteratorClass * klass)
{
	rygel_xml_utils_iterator_parent_class = g_type_class_peek_parent (klass);
	((RygelXMLUtilsIteratorClass *) klass)->finalize = rygel_xml_utils_iterator_finalize;
	g_type_class_add_private (klass, sizeof (RygelXMLUtilsIteratorPrivate));
}


static void
rygel_xml_utils_iterator_instance_init (RygelXMLUtilsIterator * self)
{
	self->priv = RYGEL_XML_UTILS_ITERATOR_GET_PRIVATE (self);
	self->ref_count = 1;
}


static void
rygel_xml_utils_iterator_finalize (RygelXMLUtilsIterator * obj)
{
	RygelXMLUtilsIterator * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, RYGEL_XML_UTILS_TYPE_ITERATOR, RygelXMLUtilsIterator);
	g_signal_handlers_destroy (self);
}


/**
     * Convenience class to iterate over Xml.Node's siblings in vala's foreach
     * loop.
     */
GType
rygel_xml_utils_iterator_get_type (void)
{
	static volatile gsize rygel_xml_utils_iterator_type_id__volatile = 0;
	if (g_once_init_enter (&rygel_xml_utils_iterator_type_id__volatile)) {
		static const GTypeValueTable g_define_type_value_table = { rygel_xml_utils_value_iterator_init, rygel_xml_utils_value_iterator_free_value, rygel_xml_utils_value_iterator_copy_value, rygel_xml_utils_value_iterator_peek_pointer, "p", rygel_xml_utils_value_iterator_collect_value, "p", rygel_xml_utils_value_iterator_lcopy_value };
		static const GTypeInfo g_define_type_info = { sizeof (RygelXMLUtilsIteratorClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) rygel_xml_utils_iterator_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (RygelXMLUtilsIterator), 0, (GInstanceInitFunc) rygel_xml_utils_iterator_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 rygel_xml_utils_iterator_type_id;
		rygel_xml_utils_iterator_type_id = g_type_register_fundamental (g_type_fundamental_next (), "RygelXMLUtilsIterator", &g_define_type_info, &g_define_type_fundamental_info, 0);
		g_once_init_leave (&rygel_xml_utils_iterator_type_id__volatile, rygel_xml_utils_iterator_type_id);
	}
	return rygel_xml_utils_iterator_type_id__volatile;
}


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


void
rygel_xml_utils_iterator_unref (gpointer instance)
{
	RygelXMLUtilsIterator * self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		RYGEL_XML_UTILS_ITERATOR_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}


RygelXMLUtilsChildIterator*
rygel_xml_utils_child_iterator_construct (GType object_type,
                                          xmlNode* node)
{
	RygelXMLUtilsChildIterator* self = NULL;
	xmlNode* _tmp0_;
	_tmp0_ = node->children;
	self = (RygelXMLUtilsChildIterator*) rygel_xml_utils_iterator_construct (object_type, _tmp0_);
	return self;
}


RygelXMLUtilsChildIterator*
rygel_xml_utils_child_iterator_new (xmlNode* node)
{
	return rygel_xml_utils_child_iterator_construct (RYGEL_XML_UTILS_TYPE_CHILD_ITERATOR, node);
}


static void
rygel_xml_utils_child_iterator_class_init (RygelXMLUtilsChildIteratorClass * klass)
{
	rygel_xml_utils_child_iterator_parent_class = g_type_class_peek_parent (klass);
}


static void
rygel_xml_utils_child_iterator_instance_init (RygelXMLUtilsChildIterator * self)
{
}


GType
rygel_xml_utils_child_iterator_get_type (void)
{
	static volatile gsize rygel_xml_utils_child_iterator_type_id__volatile = 0;
	if (g_once_init_enter (&rygel_xml_utils_child_iterator_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (RygelXMLUtilsChildIteratorClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) rygel_xml_utils_child_iterator_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (RygelXMLUtilsChildIterator), 0, (GInstanceInitFunc) rygel_xml_utils_child_iterator_instance_init, NULL };
		GType rygel_xml_utils_child_iterator_type_id;
		rygel_xml_utils_child_iterator_type_id = g_type_register_static (RYGEL_XML_UTILS_TYPE_ITERATOR, "RygelXMLUtilsChildIterator", &g_define_type_info, 0);
		g_once_init_leave (&rygel_xml_utils_child_iterator_type_id__volatile, rygel_xml_utils_child_iterator_type_id);
	}
	return rygel_xml_utils_child_iterator_type_id__volatile;
}


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


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


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


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


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


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


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


void
rygel_value_set_xml_utils (GValue* value,
                           gpointer v_object)
{
	RygelXMLUtils * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, RYGEL_TYPE_XML_UTILS));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, RYGEL_TYPE_XML_UTILS));
		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;
		rygel_xml_utils_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		rygel_xml_utils_unref (old);
	}
}


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


static void
rygel_xml_utils_class_init (RygelXMLUtilsClass * klass)
{
	rygel_xml_utils_parent_class = g_type_class_peek_parent (klass);
	((RygelXMLUtilsClass *) klass)->finalize = rygel_xml_utils_finalize;
}


static void
rygel_xml_utils_instance_init (RygelXMLUtils * self)
{
	self->ref_count = 1;
}


static void
rygel_xml_utils_finalize (RygelXMLUtils * obj)
{
	RygelXMLUtils * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, RYGEL_TYPE_XML_UTILS, RygelXMLUtils);
	g_signal_handlers_destroy (self);
}


/**
 * XML utility API.
 */
GType
rygel_xml_utils_get_type (void)
{
	static volatile gsize rygel_xml_utils_type_id__volatile = 0;
	if (g_once_init_enter (&rygel_xml_utils_type_id__volatile)) {
		static const GTypeValueTable g_define_type_value_table = { rygel_value_xml_utils_init, rygel_value_xml_utils_free_value, rygel_value_xml_utils_copy_value, rygel_value_xml_utils_peek_pointer, "p", rygel_value_xml_utils_collect_value, "p", rygel_value_xml_utils_lcopy_value };
		static const GTypeInfo g_define_type_info = { sizeof (RygelXMLUtilsClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) rygel_xml_utils_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (RygelXMLUtils), 0, (GInstanceInitFunc) rygel_xml_utils_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 rygel_xml_utils_type_id;
		rygel_xml_utils_type_id = g_type_register_fundamental (g_type_fundamental_next (), "RygelXMLUtils", &g_define_type_info, &g_define_type_fundamental_info, 0);
		g_once_init_leave (&rygel_xml_utils_type_id__volatile, rygel_xml_utils_type_id);
	}
	return rygel_xml_utils_type_id__volatile;
}


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


void
rygel_xml_utils_unref (gpointer instance)
{
	RygelXMLUtils * self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		RYGEL_XML_UTILS_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}



