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

/* -*- Mode: vala; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
 *
 * Copyright © 2014 Nikhar Agrawal
 *
 * This file is part of libgnome-games-support.
 *
 * libgnome-games-support 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 3 of the License, or
 * (at your option) any later version.
 *
 * libgnome-games-support 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 libgnome-games-support.  If not, see <http://www.gnu.org/licenses/>.
 */

#include "libgnome-games-support.h"
#include <stdlib.h>
#include <string.h>
#include <glib.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  {
	GAMES_SCORES_CATEGORY_0_PROPERTY,
	GAMES_SCORES_CATEGORY_KEY_PROPERTY,
	GAMES_SCORES_CATEGORY_NAME_PROPERTY,
	GAMES_SCORES_CATEGORY_NUM_PROPERTIES
};
static GParamSpec* games_scores_category_properties[GAMES_SCORES_CATEGORY_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))

struct _GamesScoresCategoryPrivate {
	gchar* _key;
	gchar* _name;
};

static gint GamesScoresCategory_private_offset;
static gpointer games_scores_category_parent_class = NULL;

static void games_scores_category_finalize (GObject * obj);
static GType games_scores_category_get_type_once (void);
static void _vala_games_scores_category_get_property (GObject * object,
                                               guint property_id,
                                               GValue * value,
                                               GParamSpec * pspec);
static void _vala_games_scores_category_set_property (GObject * object,
                                               guint property_id,
                                               const GValue * value,
                                               GParamSpec * pspec);

static inline gpointer
games_scores_category_get_instance_private (GamesScoresCategory* self)
{
	return G_STRUCT_MEMBER_P (self, GamesScoresCategory_private_offset);
}

/**
     * Creates a new Category.
     *
     */
GamesScoresCategory*
games_scores_category_construct (GType object_type,
                                 const gchar* key,
                                 const gchar* name)
{
	GamesScoresCategory * self = NULL;
	g_return_val_if_fail (key != NULL, NULL);
	g_return_val_if_fail (name != NULL, NULL);
	self = (GamesScoresCategory*) g_object_new (object_type, "key", key, "name", name, NULL);
	return self;
}

GamesScoresCategory*
games_scores_category_new (const gchar* key,
                           const gchar* name)
{
	return games_scores_category_construct (GAMES_SCORES_TYPE_CATEGORY, key, name);
}

const gchar*
games_scores_category_get_key (GamesScoresCategory* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_key;
	result = _tmp0_;
	return result;
}

static gchar
string_get (const gchar* self,
            glong index)
{
	gchar _tmp0_;
	gchar result;
	g_return_val_if_fail (self != NULL, '\0');
	_tmp0_ = ((gchar*) self)[index];
	result = _tmp0_;
	return result;
}

void
games_scores_category_set_key (GamesScoresCategory* self,
                               const gchar* value)
{
	gchar* _tmp4_;
	g_return_if_fail (self != NULL);
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp0_ = FALSE;
			_tmp0_ = TRUE;
			while (TRUE) {
				gboolean _tmp2_ = FALSE;
				gboolean _tmp3_ = FALSE;
				if (!_tmp0_) {
					gint _tmp1_;
					_tmp1_ = i;
					i = _tmp1_ + 1;
				}
				_tmp0_ = FALSE;
				if (!(string_get (value, (glong) i) != '\0')) {
					break;
				}
				if (!g_ascii_isalnum (string_get (value, (glong) i))) {
					_tmp3_ = string_get (value, (glong) i) != '-';
				} else {
					_tmp3_ = FALSE;
				}
				if (_tmp3_) {
					_tmp2_ = string_get (value, (glong) i) != '_';
				} else {
					_tmp2_ = FALSE;
				}
				if (_tmp2_) {
					g_error ("category.vala:46: Category keys may contain only hyphens, underscores," \
" and alphanumeric characters.");
				}
			}
		}
	}
	_tmp4_ = g_strdup (value);
	_g_free0 (self->priv->_key);
	self->priv->_key = _tmp4_;
	g_object_notify_by_pspec ((GObject *) self, games_scores_category_properties[GAMES_SCORES_CATEGORY_KEY_PROPERTY]);
}

const gchar*
games_scores_category_get_name (GamesScoresCategory* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_name;
	result = _tmp0_;
	return result;
}

void
games_scores_category_set_name (GamesScoresCategory* self,
                                const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = games_scores_category_get_name (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_name);
		self->priv->_name = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, games_scores_category_properties[GAMES_SCORES_CATEGORY_NAME_PROPERTY]);
	}
}

static void
games_scores_category_class_init (GamesScoresCategoryClass * klass,
                                  gpointer klass_data)
{
	games_scores_category_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GamesScoresCategory_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_games_scores_category_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_games_scores_category_set_property;
	G_OBJECT_CLASS (klass)->finalize = games_scores_category_finalize;
	/**
	     * A non-translated string that is not user facing and is used to identify the Category.
	     *
	     * Category ``key``s may contain only hyphens, underscores, and alphanumeric characters.
	     *
	     */
	g_object_class_install_property (G_OBJECT_CLASS (klass), GAMES_SCORES_CATEGORY_KEY_PROPERTY, games_scores_category_properties[GAMES_SCORES_CATEGORY_KEY_PROPERTY] = g_param_spec_string ("key", "key", "key", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	/**
	     * A user-friendly name for the Category.
	     * This should be marked for translation.
	     *
	     */
	g_object_class_install_property (G_OBJECT_CLASS (klass), GAMES_SCORES_CATEGORY_NAME_PROPERTY, games_scores_category_properties[GAMES_SCORES_CATEGORY_NAME_PROPERTY] = g_param_spec_string ("name", "name", "name", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
}

static void
games_scores_category_instance_init (GamesScoresCategory * self,
                                     gpointer klass)
{
	self->priv = games_scores_category_get_instance_private (self);
}

static void
games_scores_category_finalize (GObject * obj)
{
	GamesScoresCategory * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GAMES_SCORES_TYPE_CATEGORY, GamesScoresCategory);
	_g_free0 (self->priv->_key);
	_g_free0 (self->priv->_name);
	G_OBJECT_CLASS (games_scores_category_parent_class)->finalize (obj);
}

/**
 * A category of {@link Games.Scores.Score}, usually the game mode (hard, easy, medium) that a score is from.
 *
 */
 G_GNUC_NO_INLINE static GType
games_scores_category_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GamesScoresCategoryClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) games_scores_category_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GamesScoresCategory), 0, (GInstanceInitFunc) games_scores_category_instance_init, NULL };
	GType games_scores_category_type_id;
	games_scores_category_type_id = g_type_register_static (G_TYPE_OBJECT, "GamesScoresCategory", &g_define_type_info, G_TYPE_FLAG_NONE);
	GamesScoresCategory_private_offset = g_type_add_instance_private (games_scores_category_type_id, sizeof (GamesScoresCategoryPrivate));
	return games_scores_category_type_id;
}

GType
games_scores_category_get_type (void)
{
	static gsize games_scores_category_type_id__once = 0;
	if (g_once_init_enter (&games_scores_category_type_id__once)) {
		GType games_scores_category_type_id;
		games_scores_category_type_id = games_scores_category_get_type_once ();
		g_once_init_leave (&games_scores_category_type_id__once, games_scores_category_type_id);
	}
	return games_scores_category_type_id__once;
}

static void
_vala_games_scores_category_get_property (GObject * object,
                                          guint property_id,
                                          GValue * value,
                                          GParamSpec * pspec)
{
	GamesScoresCategory * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GAMES_SCORES_TYPE_CATEGORY, GamesScoresCategory);
	switch (property_id) {
		case GAMES_SCORES_CATEGORY_KEY_PROPERTY:
		g_value_set_string (value, games_scores_category_get_key (self));
		break;
		case GAMES_SCORES_CATEGORY_NAME_PROPERTY:
		g_value_set_string (value, games_scores_category_get_name (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_games_scores_category_set_property (GObject * object,
                                          guint property_id,
                                          const GValue * value,
                                          GParamSpec * pspec)
{
	GamesScoresCategory * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GAMES_SCORES_TYPE_CATEGORY, GamesScoresCategory);
	switch (property_id) {
		case GAMES_SCORES_CATEGORY_KEY_PROPERTY:
		games_scores_category_set_key (self, g_value_get_string (value));
		break;
		case GAMES_SCORES_CATEGORY_NAME_PROPERTY:
		games_scores_category_set_name (self, g_value_get_string (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

