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

#include "xmpp-vala.h"
#include <stdlib.h>
#include <string.h>
#include <glib.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 _XmppResultSetManagementParamSpecResultSetParameters XmppResultSetManagementParamSpecResultSetParameters;
#define _xmpp_stanza_entry_unref0(var) ((var == NULL) ? NULL : (var = (xmpp_stanza_entry_unref (var), NULL)))

struct _XmppResultSetManagementResultSetParametersPrivate {
	gchar* _before;
	gchar* _after;
	gint* _max;
};

struct _XmppResultSetManagementParamSpecResultSetParameters {
	GParamSpec parent_instance;
};

static gint XmppResultSetManagementResultSetParameters_private_offset;
static gpointer xmpp_result_set_management_result_set_parameters_parent_class = NULL;

static const gchar* xmpp_result_set_management_result_set_parameters_get_before (XmppResultSetManagementResultSetParameters* self);
static void xmpp_result_set_management_result_set_parameters_set_before (XmppResultSetManagementResultSetParameters* self,
                                                                  const gchar* value);
static const gchar* xmpp_result_set_management_result_set_parameters_get_after (XmppResultSetManagementResultSetParameters* self);
static void xmpp_result_set_management_result_set_parameters_set_after (XmppResultSetManagementResultSetParameters* self,
                                                                 const gchar* value);
static gint* xmpp_result_set_management_result_set_parameters_get_max (XmppResultSetManagementResultSetParameters* self);
static void xmpp_result_set_management_result_set_parameters_set_max (XmppResultSetManagementResultSetParameters* self,
                                                               gint* value);
static gint* _int_dup (gint* self);
static void xmpp_result_set_management_result_set_parameters_finalize (XmppResultSetManagementResultSetParameters * obj);
static GType xmpp_result_set_management_result_set_parameters_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
xmpp_result_set_management_result_set_parameters_get_instance_private (XmppResultSetManagementResultSetParameters* self)
{
	return G_STRUCT_MEMBER_P (self, XmppResultSetManagementResultSetParameters_private_offset);
}

XmppResultSetManagementResultSetParameters*
xmpp_result_set_management_result_set_parameters_construct (GType object_type)
{
	XmppResultSetManagementResultSetParameters* self = NULL;
	self = (XmppResultSetManagementResultSetParameters*) g_type_create_instance (object_type);
	return self;
}

XmppResultSetManagementResultSetParameters*
xmpp_result_set_management_result_set_parameters_new (void)
{
	return xmpp_result_set_management_result_set_parameters_construct (XMPP_RESULT_SET_MANAGEMENT_TYPE_RESULT_SET_PARAMETERS);
}

static const gchar*
xmpp_result_set_management_result_set_parameters_get_before (XmppResultSetManagementResultSetParameters* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_before;
	result = _tmp0_;
	return result;
}

static void
xmpp_result_set_management_result_set_parameters_set_before (XmppResultSetManagementResultSetParameters* self,
                                                             const gchar* value)
{
	gchar* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_strdup (value);
	_g_free0 (self->priv->_before);
	self->priv->_before = _tmp0_;
}

static const gchar*
xmpp_result_set_management_result_set_parameters_get_after (XmppResultSetManagementResultSetParameters* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_after;
	result = _tmp0_;
	return result;
}

static void
xmpp_result_set_management_result_set_parameters_set_after (XmppResultSetManagementResultSetParameters* self,
                                                            const gchar* value)
{
	gchar* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_strdup (value);
	_g_free0 (self->priv->_after);
	self->priv->_after = _tmp0_;
}

static gint*
xmpp_result_set_management_result_set_parameters_get_max (XmppResultSetManagementResultSetParameters* self)
{
	gint* result;
	gint* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_max;
	result = _tmp0_;
	return result;
}

static gint*
_int_dup (gint* self)
{
	gint* dup;
	dup = g_new0 (gint, 1);
	memcpy (dup, self, sizeof (gint));
	return dup;
}

static gpointer
__int_dup0 (gpointer self)
{
	return self ? _int_dup (self) : NULL;
}

static void
xmpp_result_set_management_result_set_parameters_set_max (XmppResultSetManagementResultSetParameters* self,
                                                          gint* value)
{
	gint* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = __int_dup0 (value);
	_g_free0 (self->priv->_max);
	self->priv->_max = _tmp0_;
}

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

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

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

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

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

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

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

void
xmpp_result_set_management_value_set_result_set_parameters (GValue* value,
                                                            gpointer v_object)
{
	XmppResultSetManagementResultSetParameters * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, XMPP_RESULT_SET_MANAGEMENT_TYPE_RESULT_SET_PARAMETERS));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, XMPP_RESULT_SET_MANAGEMENT_TYPE_RESULT_SET_PARAMETERS));
		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;
		xmpp_result_set_management_result_set_parameters_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		xmpp_result_set_management_result_set_parameters_unref (old);
	}
}

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

static void
xmpp_result_set_management_result_set_parameters_class_init (XmppResultSetManagementResultSetParametersClass * klass,
                                                             gpointer klass_data)
{
	xmpp_result_set_management_result_set_parameters_parent_class = g_type_class_peek_parent (klass);
	((XmppResultSetManagementResultSetParametersClass *) klass)->finalize = xmpp_result_set_management_result_set_parameters_finalize;
	g_type_class_adjust_private_offset (klass, &XmppResultSetManagementResultSetParameters_private_offset);
}

static void
xmpp_result_set_management_result_set_parameters_instance_init (XmppResultSetManagementResultSetParameters * self,
                                                                gpointer klass)
{
	self->priv = xmpp_result_set_management_result_set_parameters_get_instance_private (self);
	self->ref_count = 1;
}

static void
xmpp_result_set_management_result_set_parameters_finalize (XmppResultSetManagementResultSetParameters * obj)
{
	XmppResultSetManagementResultSetParameters * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, XMPP_RESULT_SET_MANAGEMENT_TYPE_RESULT_SET_PARAMETERS, XmppResultSetManagementResultSetParameters);
	g_signal_handlers_destroy (self);
	_g_free0 (self->priv->_before);
	_g_free0 (self->priv->_after);
	_g_free0 (self->priv->_max);
}

static GType
xmpp_result_set_management_result_set_parameters_get_type_once (void)
{
	static const GTypeValueTable g_define_type_value_table = { xmpp_result_set_management_value_result_set_parameters_init, xmpp_result_set_management_value_result_set_parameters_free_value, xmpp_result_set_management_value_result_set_parameters_copy_value, xmpp_result_set_management_value_result_set_parameters_peek_pointer, "p", xmpp_result_set_management_value_result_set_parameters_collect_value, "p", xmpp_result_set_management_value_result_set_parameters_lcopy_value };
	static const GTypeInfo g_define_type_info = { sizeof (XmppResultSetManagementResultSetParametersClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) xmpp_result_set_management_result_set_parameters_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (XmppResultSetManagementResultSetParameters), 0, (GInstanceInitFunc) xmpp_result_set_management_result_set_parameters_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 xmpp_result_set_management_result_set_parameters_type_id;
	xmpp_result_set_management_result_set_parameters_type_id = g_type_register_fundamental (g_type_fundamental_next (), "XmppResultSetManagementResultSetParameters", &g_define_type_info, &g_define_type_fundamental_info, 0);
	XmppResultSetManagementResultSetParameters_private_offset = g_type_add_instance_private (xmpp_result_set_management_result_set_parameters_type_id, sizeof (XmppResultSetManagementResultSetParametersPrivate));
	return xmpp_result_set_management_result_set_parameters_type_id;
}

GType
xmpp_result_set_management_result_set_parameters_get_type (void)
{
	static volatile gsize xmpp_result_set_management_result_set_parameters_type_id__once = 0;
	if (g_once_init_enter (&xmpp_result_set_management_result_set_parameters_type_id__once)) {
		GType xmpp_result_set_management_result_set_parameters_type_id;
		xmpp_result_set_management_result_set_parameters_type_id = xmpp_result_set_management_result_set_parameters_get_type_once ();
		g_once_init_leave (&xmpp_result_set_management_result_set_parameters_type_id__once, xmpp_result_set_management_result_set_parameters_type_id);
	}
	return xmpp_result_set_management_result_set_parameters_type_id__once;
}

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

void
xmpp_result_set_management_result_set_parameters_unref (gpointer instance)
{
	XmppResultSetManagementResultSetParameters * self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		XMPP_RESULT_SET_MANAGEMENT_RESULT_SET_PARAMETERS_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}

XmppStanzaNode*
xmpp_result_set_management_create_set_rsm_node_before (const gchar* before_id)
{
	XmppStanzaNode* max_node = NULL;
	XmppStanzaNode* _tmp0_;
	XmppStanzaNode* _tmp1_;
	XmppStanzaNode* _tmp2_;
	XmppStanzaNode* _tmp3_;
	XmppStanzaNode* _tmp4_;
	XmppStanzaNode* _tmp5_;
	XmppStanzaNode* node = NULL;
	XmppStanzaNode* _tmp6_;
	XmppStanzaNode* _tmp7_;
	XmppStanzaNode* _tmp8_;
	XmppStanzaNode* _tmp9_;
	XmppStanzaNode* _tmp10_;
	XmppStanzaNode* _tmp11_;
	XmppStanzaNode* _tmp12_;
	XmppStanzaNode* before_node = NULL;
	XmppStanzaNode* _tmp13_;
	XmppStanzaNode* _tmp19_;
	XmppStanzaNode* _tmp20_;
	XmppStanzaNode* _tmp21_;
	XmppStanzaNode* _tmp22_;
	XmppStanzaNode* result;
	_tmp0_ = xmpp_stanza_node_new_build ("max", XMPP_RESULT_SET_MANAGEMENT_NS_URI, NULL, NULL);
	_tmp1_ = _tmp0_;
	_tmp2_ = xmpp_stanza_node_new_text ("20");
	_tmp3_ = _tmp2_;
	_tmp4_ = xmpp_stanza_node_put_node (_tmp1_, _tmp3_);
	_tmp5_ = _tmp4_;
	_xmpp_stanza_entry_unref0 (_tmp3_);
	_xmpp_stanza_entry_unref0 (_tmp1_);
	max_node = _tmp5_;
	_tmp6_ = xmpp_stanza_node_new_build ("set", XMPP_RESULT_SET_MANAGEMENT_NS_URI, NULL, NULL);
	_tmp7_ = _tmp6_;
	_tmp8_ = xmpp_stanza_node_add_self_xmlns (_tmp7_);
	_tmp9_ = _tmp8_;
	_tmp10_ = max_node;
	_tmp11_ = xmpp_stanza_node_put_node (_tmp9_, _tmp10_);
	_tmp12_ = _tmp11_;
	_xmpp_stanza_entry_unref0 (_tmp9_);
	_xmpp_stanza_entry_unref0 (_tmp7_);
	node = _tmp12_;
	_tmp13_ = xmpp_stanza_node_new_build ("before", XMPP_RESULT_SET_MANAGEMENT_NS_URI, NULL, NULL);
	before_node = _tmp13_;
	if (before_id != NULL) {
		XmppStanzaNode* _tmp14_;
		XmppStanzaNode* _tmp15_;
		XmppStanzaNode* _tmp16_;
		XmppStanzaNode* _tmp17_;
		XmppStanzaNode* _tmp18_;
		_tmp14_ = before_node;
		_tmp15_ = xmpp_stanza_node_new_text (before_id);
		_tmp16_ = _tmp15_;
		_tmp17_ = xmpp_stanza_node_put_node (_tmp14_, _tmp16_);
		_tmp18_ = _tmp17_;
		_xmpp_stanza_entry_unref0 (_tmp18_);
		_xmpp_stanza_entry_unref0 (_tmp16_);
	}
	_tmp19_ = node;
	_tmp20_ = before_node;
	_tmp21_ = xmpp_stanza_node_put_node (_tmp19_, _tmp20_);
	_tmp22_ = _tmp21_;
	_xmpp_stanza_entry_unref0 (_tmp22_);
	result = node;
	_xmpp_stanza_entry_unref0 (before_node);
	_xmpp_stanza_entry_unref0 (max_node);
	return result;
}

XmppStanzaNode*
xmpp_result_set_management_create_set_rsm_node_after (const gchar* after_id)
{
	XmppStanzaNode* max_node = NULL;
	XmppStanzaNode* _tmp0_;
	XmppStanzaNode* _tmp1_;
	XmppStanzaNode* _tmp2_;
	XmppStanzaNode* _tmp3_;
	XmppStanzaNode* _tmp4_;
	XmppStanzaNode* _tmp5_;
	XmppStanzaNode* node = NULL;
	XmppStanzaNode* _tmp6_;
	XmppStanzaNode* _tmp7_;
	XmppStanzaNode* _tmp8_;
	XmppStanzaNode* _tmp9_;
	XmppStanzaNode* _tmp10_;
	XmppStanzaNode* _tmp11_;
	XmppStanzaNode* after_node = NULL;
	XmppStanzaNode* _tmp12_;
	XmppStanzaNode* _tmp13_;
	XmppStanzaNode* _tmp14_;
	XmppStanzaNode* _tmp15_;
	XmppStanzaNode* _tmp16_;
	XmppStanzaNode* _tmp17_;
	XmppStanzaNode* _tmp18_;
	XmppStanzaNode* _tmp19_;
	XmppStanzaNode* result;
	g_return_val_if_fail (after_id != NULL, NULL);
	_tmp0_ = xmpp_stanza_node_new_build ("max", XMPP_RESULT_SET_MANAGEMENT_NS_URI, NULL, NULL);
	_tmp1_ = _tmp0_;
	_tmp2_ = xmpp_stanza_node_new_text ("20");
	_tmp3_ = _tmp2_;
	_tmp4_ = xmpp_stanza_node_put_node (_tmp1_, _tmp3_);
	_tmp5_ = _tmp4_;
	_xmpp_stanza_entry_unref0 (_tmp3_);
	_xmpp_stanza_entry_unref0 (_tmp1_);
	max_node = _tmp5_;
	_tmp6_ = xmpp_stanza_node_new_build ("set", XMPP_RESULT_SET_MANAGEMENT_NS_URI, NULL, NULL);
	_tmp7_ = _tmp6_;
	_tmp8_ = xmpp_stanza_node_add_self_xmlns (_tmp7_);
	_tmp9_ = _tmp8_;
	_tmp10_ = xmpp_stanza_node_put_node (_tmp9_, max_node);
	_tmp11_ = _tmp10_;
	_xmpp_stanza_entry_unref0 (_tmp9_);
	_xmpp_stanza_entry_unref0 (_tmp7_);
	node = _tmp11_;
	_tmp12_ = xmpp_stanza_node_new_build ("after", XMPP_RESULT_SET_MANAGEMENT_NS_URI, NULL, NULL);
	_tmp13_ = _tmp12_;
	_tmp14_ = xmpp_stanza_node_new_text (after_id);
	_tmp15_ = _tmp14_;
	_tmp16_ = xmpp_stanza_node_put_node (_tmp13_, _tmp15_);
	_tmp17_ = _tmp16_;
	_xmpp_stanza_entry_unref0 (_tmp15_);
	_xmpp_stanza_entry_unref0 (_tmp13_);
	after_node = _tmp17_;
	_tmp18_ = xmpp_stanza_node_put_node (node, after_node);
	_tmp19_ = _tmp18_;
	_xmpp_stanza_entry_unref0 (_tmp19_);
	result = node;
	_xmpp_stanza_entry_unref0 (after_node);
	_xmpp_stanza_entry_unref0 (max_node);
	return result;
}

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

