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

/*
 * Copyright © 2025 Alain M. (https://github.com/alainm23/planify)
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public
 * License as published by the Free Software Foundation; either
 * version 3 of the License, or (at your option) any later version.
 *
 * This program 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
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public
 * License along with this program; if not, write to the
 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301 USA
 *
 * Authored by: Alain M. <alainmh23@gmail.com>
 */

#include "chrono.h"
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <glib-object.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  {
	CHRONO_PARSE_RESULT_0_PROPERTY,
	CHRONO_PARSE_RESULT_DATE_PROPERTY,
	CHRONO_PARSE_RESULT_RECURRENCE_PROPERTY,
	CHRONO_PARSE_RESULT_START_INDEX_PROPERTY,
	CHRONO_PARSE_RESULT_END_INDEX_PROPERTY,
	CHRONO_PARSE_RESULT_MATCHED_TEXT_PROPERTY,
	CHRONO_PARSE_RESULT_NUM_PROPERTIES
};
static GParamSpec* chrono_parse_result_properties[CHRONO_PARSE_RESULT_NUM_PROPERTIES];
#define _g_date_time_unref0(var) ((var == NULL) ? NULL : (var = (g_date_time_unref (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))

struct _ChronoParseResultPrivate {
	GDateTime* _date;
	ChronoRecurrenceRule* _recurrence;
	gint _start_index;
	gint _end_index;
	gchar* _matched_text;
};

static gint ChronoParseResult_private_offset;
static gpointer chrono_parse_result_parent_class = NULL;

static void chrono_parse_result_finalize (GObject * obj);
static GType chrono_parse_result_get_type_once (void);
static void _vala_chrono_parse_result_get_property (GObject * object,
                                             guint property_id,
                                             GValue * value,
                                             GParamSpec * pspec);
static void _vala_chrono_parse_result_set_property (GObject * object,
                                             guint property_id,
                                             const GValue * value,
                                             GParamSpec * pspec);

static inline gpointer
chrono_parse_result_get_instance_private (ChronoParseResult* self)
{
	return G_STRUCT_MEMBER_P (self, ChronoParseResult_private_offset);
}

ChronoParseResult*
chrono_parse_result_construct (GType object_type)
{
	ChronoParseResult * self = NULL;
	self = (ChronoParseResult*) g_object_new (object_type, NULL);
	chrono_parse_result_set_start_index (self, -1);
	chrono_parse_result_set_end_index (self, -1);
	chrono_parse_result_set_matched_text (self, "");
	return self;
}

ChronoParseResult*
chrono_parse_result_new (void)
{
	return chrono_parse_result_construct (CHRONO_TYPE_PARSE_RESULT);
}

GDateTime*
chrono_parse_result_get_date (ChronoParseResult* self)
{
	GDateTime* result;
	GDateTime* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_date;
	result = _tmp0_;
	return result;
}

static gpointer
_g_date_time_ref0 (gpointer self)
{
	return self ? g_date_time_ref (self) : NULL;
}

void
chrono_parse_result_set_date (ChronoParseResult* self,
                              GDateTime* value)
{
	GDateTime* old_value;
	g_return_if_fail (self != NULL);
	old_value = chrono_parse_result_get_date (self);
	if (old_value != value) {
		GDateTime* _tmp0_;
		_tmp0_ = _g_date_time_ref0 (value);
		_g_date_time_unref0 (self->priv->_date);
		self->priv->_date = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, chrono_parse_result_properties[CHRONO_PARSE_RESULT_DATE_PROPERTY]);
	}
}

ChronoRecurrenceRule*
chrono_parse_result_get_recurrence (ChronoParseResult* self)
{
	ChronoRecurrenceRule* result;
	ChronoRecurrenceRule* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_recurrence;
	result = _tmp0_;
	return result;
}

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

void
chrono_parse_result_set_recurrence (ChronoParseResult* self,
                                    ChronoRecurrenceRule* value)
{
	ChronoRecurrenceRule* old_value;
	g_return_if_fail (self != NULL);
	old_value = chrono_parse_result_get_recurrence (self);
	if (old_value != value) {
		ChronoRecurrenceRule* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_recurrence);
		self->priv->_recurrence = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, chrono_parse_result_properties[CHRONO_PARSE_RESULT_RECURRENCE_PROPERTY]);
	}
}

gint
chrono_parse_result_get_start_index (ChronoParseResult* self)
{
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	result = self->priv->_start_index;
	return result;
}

void
chrono_parse_result_set_start_index (ChronoParseResult* self,
                                     gint value)
{
	gint old_value;
	g_return_if_fail (self != NULL);
	old_value = chrono_parse_result_get_start_index (self);
	if (old_value != value) {
		self->priv->_start_index = value;
		g_object_notify_by_pspec ((GObject *) self, chrono_parse_result_properties[CHRONO_PARSE_RESULT_START_INDEX_PROPERTY]);
	}
}

gint
chrono_parse_result_get_end_index (ChronoParseResult* self)
{
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	result = self->priv->_end_index;
	return result;
}

void
chrono_parse_result_set_end_index (ChronoParseResult* self,
                                   gint value)
{
	gint old_value;
	g_return_if_fail (self != NULL);
	old_value = chrono_parse_result_get_end_index (self);
	if (old_value != value) {
		self->priv->_end_index = value;
		g_object_notify_by_pspec ((GObject *) self, chrono_parse_result_properties[CHRONO_PARSE_RESULT_END_INDEX_PROPERTY]);
	}
}

const gchar*
chrono_parse_result_get_matched_text (ChronoParseResult* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_matched_text;
	result = _tmp0_;
	return result;
}

void
chrono_parse_result_set_matched_text (ChronoParseResult* self,
                                      const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = chrono_parse_result_get_matched_text (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_matched_text);
		self->priv->_matched_text = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, chrono_parse_result_properties[CHRONO_PARSE_RESULT_MATCHED_TEXT_PROPERTY]);
	}
}

static void
chrono_parse_result_class_init (ChronoParseResultClass * klass,
                                gpointer klass_data)
{
	chrono_parse_result_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ChronoParseResult_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_chrono_parse_result_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_chrono_parse_result_set_property;
	G_OBJECT_CLASS (klass)->finalize = chrono_parse_result_finalize;
	/** The parsed date and time. */
	g_object_class_install_property (G_OBJECT_CLASS (klass), CHRONO_PARSE_RESULT_DATE_PROPERTY, chrono_parse_result_properties[CHRONO_PARSE_RESULT_DATE_PROPERTY] = g_param_spec_boxed ("date", "date", "date", G_TYPE_DATE_TIME, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	/** The parsed recurrence rule, if any. */
	g_object_class_install_property (G_OBJECT_CLASS (klass), CHRONO_PARSE_RESULT_RECURRENCE_PROPERTY, chrono_parse_result_properties[CHRONO_PARSE_RESULT_RECURRENCE_PROPERTY] = g_param_spec_object ("recurrence", "recurrence", "recurrence", CHRONO_TYPE_RECURRENCE_RULE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	/** Start index of the matched text in the original string. */
	g_object_class_install_property (G_OBJECT_CLASS (klass), CHRONO_PARSE_RESULT_START_INDEX_PROPERTY, chrono_parse_result_properties[CHRONO_PARSE_RESULT_START_INDEX_PROPERTY] = g_param_spec_int ("start-index", "start-index", "start-index", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	/** End index of the matched text in the original string. */
	g_object_class_install_property (G_OBJECT_CLASS (klass), CHRONO_PARSE_RESULT_END_INDEX_PROPERTY, chrono_parse_result_properties[CHRONO_PARSE_RESULT_END_INDEX_PROPERTY] = g_param_spec_int ("end-index", "end-index", "end-index", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	/** The substring that was matched. */
	g_object_class_install_property (G_OBJECT_CLASS (klass), CHRONO_PARSE_RESULT_MATCHED_TEXT_PROPERTY, chrono_parse_result_properties[CHRONO_PARSE_RESULT_MATCHED_TEXT_PROPERTY] = g_param_spec_string ("matched-text", "matched-text", "matched-text", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
}

static void
chrono_parse_result_instance_init (ChronoParseResult * self,
                                   gpointer klass)
{
	self->priv = chrono_parse_result_get_instance_private (self);
}

static void
chrono_parse_result_finalize (GObject * obj)
{
	ChronoParseResult * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, CHRONO_TYPE_PARSE_RESULT, ChronoParseResult);
	_g_date_time_unref0 (self->priv->_date);
	_g_object_unref0 (self->priv->_recurrence);
	_g_free0 (self->priv->_matched_text);
	G_OBJECT_CLASS (chrono_parse_result_parent_class)->finalize (obj);
}

/**
     * Holds the result of a successful parse operation.
     */
 G_GNUC_NO_INLINE static GType
chrono_parse_result_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ChronoParseResultClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) chrono_parse_result_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ChronoParseResult), 0, (GInstanceInitFunc) chrono_parse_result_instance_init, NULL };
	GType chrono_parse_result_type_id;
	chrono_parse_result_type_id = g_type_register_static (G_TYPE_OBJECT, "ChronoParseResult", &g_define_type_info, 0);
	ChronoParseResult_private_offset = g_type_add_instance_private (chrono_parse_result_type_id, sizeof (ChronoParseResultPrivate));
	return chrono_parse_result_type_id;
}

GType
chrono_parse_result_get_type (void)
{
	static gsize chrono_parse_result_type_id__once = 0;
	if (g_once_init_enter (&chrono_parse_result_type_id__once)) {
		GType chrono_parse_result_type_id;
		chrono_parse_result_type_id = chrono_parse_result_get_type_once ();
		g_once_init_leave (&chrono_parse_result_type_id__once, chrono_parse_result_type_id);
	}
	return chrono_parse_result_type_id__once;
}

static void
_vala_chrono_parse_result_get_property (GObject * object,
                                        guint property_id,
                                        GValue * value,
                                        GParamSpec * pspec)
{
	ChronoParseResult * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, CHRONO_TYPE_PARSE_RESULT, ChronoParseResult);
	switch (property_id) {
		case CHRONO_PARSE_RESULT_DATE_PROPERTY:
		g_value_set_boxed (value, chrono_parse_result_get_date (self));
		break;
		case CHRONO_PARSE_RESULT_RECURRENCE_PROPERTY:
		g_value_set_object (value, chrono_parse_result_get_recurrence (self));
		break;
		case CHRONO_PARSE_RESULT_START_INDEX_PROPERTY:
		g_value_set_int (value, chrono_parse_result_get_start_index (self));
		break;
		case CHRONO_PARSE_RESULT_END_INDEX_PROPERTY:
		g_value_set_int (value, chrono_parse_result_get_end_index (self));
		break;
		case CHRONO_PARSE_RESULT_MATCHED_TEXT_PROPERTY:
		g_value_set_string (value, chrono_parse_result_get_matched_text (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_chrono_parse_result_set_property (GObject * object,
                                        guint property_id,
                                        const GValue * value,
                                        GParamSpec * pspec)
{
	ChronoParseResult * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, CHRONO_TYPE_PARSE_RESULT, ChronoParseResult);
	switch (property_id) {
		case CHRONO_PARSE_RESULT_DATE_PROPERTY:
		chrono_parse_result_set_date (self, g_value_get_boxed (value));
		break;
		case CHRONO_PARSE_RESULT_RECURRENCE_PROPERTY:
		chrono_parse_result_set_recurrence (self, g_value_get_object (value));
		break;
		case CHRONO_PARSE_RESULT_START_INDEX_PROPERTY:
		chrono_parse_result_set_start_index (self, g_value_get_int (value));
		break;
		case CHRONO_PARSE_RESULT_END_INDEX_PROPERTY:
		chrono_parse_result_set_end_index (self, g_value_get_int (value));
		break;
		case CHRONO_PARSE_RESULT_MATCHED_TEXT_PROPERTY:
		chrono_parse_result_set_matched_text (self, g_value_get_string (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

