/* rygel-xml-utils.c generated by valac 0.56.19, 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 "rygel-core.h"
#include <libxml/tree.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <stdarg.h>
#include <glib-object.h>
#include <gobject/gvaluecollector.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 _g_free0(var) (var = (g_free (var), NULL))
typedef struct _RygelXMLUtilsParamSpecIterator RygelXMLUtilsParamSpecIterator;
typedef struct _RygelParamSpecXMLUtils RygelParamSpecXMLUtils;

struct _RygelXMLUtilsIteratorPrivate {
	xmlNode* iter;
};

struct _RygelXMLUtilsParamSpecIterator {
	GParamSpec parent_instance;
};

struct _RygelParamSpecXMLUtils {
	GParamSpec parent_instance;
};

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

static void rygel_xml_utils_iterator_finalize (RygelXMLUtilsIterator * obj);
static GType rygel_xml_utils_iterator_get_type_once (void);
static GType rygel_xml_utils_child_iterator_get_type_once (void);
static void rygel_xml_utils_finalize (RygelXMLUtils * obj);
static GType rygel_xml_utils_get_type_once (void);

xmlNs*
rygel_xml_utils_get_namespace (xmlNode* root,
                               const gchar* href,
                               const gchar* prefix)
{
	xmlNs* ns = NULL;
	xmlNs* _tmp0_;
	xmlNs* _tmp1_;
	xmlNs* _tmp3_;
	xmlNs* result;
	g_return_val_if_fail (href != NULL, NULL);
	g_return_val_if_fail (prefix != NULL, NULL);
	_tmp0_ = xmlNewNs (root, (xmlChar*) href, (xmlChar*) prefix);
	ns = _tmp0_;
	_tmp1_ = ns;
	if (_tmp1_ != NULL) {
		xmlNs* _tmp2_;
		_tmp2_ = ns;
		result = _tmp2_;
		return result;
	}
	_tmp3_ = root->nsDef;
	ns = _tmp3_;
	while (TRUE) {
		xmlNs* _tmp4_;
		xmlNs* _tmp5_;
		const gchar* _tmp6_;
		xmlNs* _tmp8_;
		xmlNs* _tmp9_;
		_tmp4_ = ns;
		if (!(_tmp4_ != NULL)) {
			break;
		}
		_tmp5_ = ns;
		_tmp6_ = _tmp5_->prefix;
		if (g_strcmp0 (_tmp6_, prefix) == 0) {
			xmlNs* _tmp7_;
			_tmp7_ = ns;
			result = _tmp7_;
			return result;
		}
		_tmp8_ = ns;
		_tmp9_ = _tmp8_->next;
		ns = _tmp9_;
	}
	g_assert_not_reached ();
}

xmlNode*
rygel_xml_utils_get_element (xmlNode* node,
                             ...)
{
	xmlNode* ret = NULL;
	va_list list = {0};
	xmlNode* _tmp13_;
	xmlNode* result;
	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);
}

static inline gpointer
rygel_xml_utils_iterator_get_instance_private (RygelXMLUtilsIterator* self)
{
	return G_STRUCT_MEMBER_P (self, RygelXMLUtilsIterator_private_offset);
}

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* _tmp0_;
	RygelXMLUtilsIterator* result;
	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)
{
	xmlNode* _tmp0_;
	gboolean result;
	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* current = NULL;
	xmlNode* _tmp0_;
	xmlNode* _tmp1_;
	xmlNode* _tmp2_;
	xmlNode* result;
	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,
                                     gpointer klass_data)
{
	rygel_xml_utils_iterator_parent_class = g_type_class_peek_parent (klass);
	((RygelXMLUtilsIteratorClass *) klass)->finalize = rygel_xml_utils_iterator_finalize;
	g_type_class_adjust_private_offset (klass, &RygelXMLUtilsIterator_private_offset);
}

static void
rygel_xml_utils_iterator_instance_init (RygelXMLUtilsIterator * self,
                                        gpointer klass)
{
	self->priv = rygel_xml_utils_iterator_get_instance_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.
     */
 G_GNUC_NO_INLINE static GType
rygel_xml_utils_iterator_get_type_once (void)
{
	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);
	RygelXMLUtilsIterator_private_offset = g_type_add_instance_private (rygel_xml_utils_iterator_type_id, sizeof (RygelXMLUtilsIteratorPrivate));
	return rygel_xml_utils_iterator_type_id;
}

GType
rygel_xml_utils_iterator_get_type (void)
{
	static volatile gsize rygel_xml_utils_iterator_type_id__once = 0;
	if (g_once_init_enter (&rygel_xml_utils_iterator_type_id__once)) {
		GType rygel_xml_utils_iterator_type_id;
		rygel_xml_utils_iterator_type_id = rygel_xml_utils_iterator_get_type_once ();
		g_once_init_leave (&rygel_xml_utils_iterator_type_id__once, rygel_xml_utils_iterator_type_id);
	}
	return rygel_xml_utils_iterator_type_id__once;
}

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,
                                           gpointer klass_data)
{
	rygel_xml_utils_child_iterator_parent_class = g_type_class_peek_parent (klass);
}

static void
rygel_xml_utils_child_iterator_instance_init (RygelXMLUtilsChildIterator * self,
                                              gpointer klass)
{
}

 G_GNUC_NO_INLINE static GType
rygel_xml_utils_child_iterator_get_type_once (void)
{
	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);
	return rygel_xml_utils_child_iterator_type_id;
}

GType
rygel_xml_utils_child_iterator_get_type (void)
{
	static volatile gsize rygel_xml_utils_child_iterator_type_id__once = 0;
	if (g_once_init_enter (&rygel_xml_utils_child_iterator_type_id__once)) {
		GType rygel_xml_utils_child_iterator_type_id;
		rygel_xml_utils_child_iterator_type_id = rygel_xml_utils_child_iterator_get_type_once ();
		g_once_init_leave (&rygel_xml_utils_child_iterator_type_id__once, rygel_xml_utils_child_iterator_type_id);
	}
	return rygel_xml_utils_child_iterator_type_id__once;
}

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,
                            gpointer klass_data)
{
	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,
                               gpointer klass)
{
	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.
 */
 G_GNUC_NO_INLINE static GType
rygel_xml_utils_get_type_once (void)
{
	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);
	return rygel_xml_utils_type_id;
}

GType
rygel_xml_utils_get_type (void)
{
	static volatile gsize rygel_xml_utils_type_id__once = 0;
	if (g_once_init_enter (&rygel_xml_utils_type_id__once)) {
		GType rygel_xml_utils_type_id;
		rygel_xml_utils_type_id = rygel_xml_utils_get_type_once ();
		g_once_init_leave (&rygel_xml_utils_type_id__once, rygel_xml_utils_type_id);
	}
	return rygel_xml_utils_type_id__once;
}

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);
	}
}

