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

/*
    Copyright (C) 2014 Johan Mattsson

    This library 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.

    This library 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.
*/

#include "xmlbird.h"
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <glib.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 B_TYPE_XML_STRING (b_xml_string_get_type ())
#define B_XML_STRING(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), B_TYPE_XML_STRING, BXmlString))
#define B_XML_STRING_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), B_TYPE_XML_STRING, BXmlStringClass))
#define B_IS_XML_STRING(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), B_TYPE_XML_STRING))
#define B_IS_XML_STRING_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), B_TYPE_XML_STRING))
#define B_XML_STRING_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), B_TYPE_XML_STRING, BXmlStringClass))

typedef struct _BXmlString BXmlString;
typedef struct _BXmlStringClass BXmlStringClass;
enum  {
	B_ATTRIBUTE_0_PROPERTY,
	B_ATTRIBUTE_NUM_PROPERTIES
};
static GParamSpec* b_attribute_properties[B_ATTRIBUTE_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
typedef struct _BXmlStringPrivate BXmlStringPrivate;

struct _BAttributePrivate {
	BXmlString* ns;
	BXmlString* name;
	BXmlString* content;
	gchar* element_ns;
	gchar* element_name;
	gchar* element_content;
};

struct _BXmlString {
	GObject parent_instance;
	BXmlStringPrivate * priv;
	gint length;
	gchar* data;
};

struct _BXmlStringClass {
	GObjectClass parent_class;
};

static gint BAttribute_private_offset;
static gpointer b_attribute_parent_class = NULL;

VALA_EXTERN GType b_xml_string_get_type (void) G_GNUC_CONST ;
VALA_EXTERN BAttribute* b_attribute_new (BXmlString* ns,
                             BXmlString* name,
                             BXmlString* content);
VALA_EXTERN BAttribute* b_attribute_construct (GType object_type,
                                   BXmlString* ns,
                                   BXmlString* name,
                                   BXmlString* content);
VALA_EXTERN BAttribute* b_attribute_new_element (BXmlElement* element);
VALA_EXTERN BAttribute* b_attribute_construct_element (GType object_type,
                                           BXmlElement* element);
VALA_EXTERN BXmlString* b_xml_string_new (gchar* data,
                              gint length);
VALA_EXTERN BXmlString* b_xml_string_construct (GType object_type,
                                    gchar* data,
                                    gint length);
VALA_EXTERN BAttribute* b_attribute_new_empty (void);
VALA_EXTERN BAttribute* b_attribute_construct_empty (GType object_type);
VALA_EXTERN gchar* b_xml_string_to_string (BXmlString* self);
VALA_EXTERN gint b_attribute_get_name_length (BAttribute* self);
static void b_attribute_finalize (GObject * obj);
static GType b_attribute_get_type_once (void);

static inline gpointer
b_attribute_get_instance_private (BAttribute* self)
{
	return G_STRUCT_MEMBER_P (self, BAttribute_private_offset);
}

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

BAttribute*
b_attribute_construct (GType object_type,
                       BXmlString* ns,
                       BXmlString* name,
                       BXmlString* content)
{
	BAttribute * self = NULL;
	BXmlString* _tmp0_;
	BXmlString* _tmp1_;
	BXmlString* _tmp2_;
	g_return_val_if_fail (ns != NULL, NULL);
	g_return_val_if_fail (name != NULL, NULL);
	g_return_val_if_fail (content != NULL, NULL);
	self = (BAttribute*) g_object_new (object_type, NULL);
	_tmp0_ = _g_object_ref0 (ns);
	_g_object_unref0 (self->priv->ns);
	self->priv->ns = _tmp0_;
	_tmp1_ = _g_object_ref0 (name);
	_g_object_unref0 (self->priv->name);
	self->priv->name = _tmp1_;
	_tmp2_ = _g_object_ref0 (content);
	_g_object_unref0 (self->priv->content);
	self->priv->content = _tmp2_;
	return self;
}

BAttribute*
b_attribute_new (BXmlString* ns,
                 BXmlString* name,
                 BXmlString* content)
{
	return b_attribute_construct (B_TYPE_ATTRIBUTE, ns, name, content);
}

BAttribute*
b_attribute_construct_element (GType object_type,
                               BXmlElement* element)
{
	BAttribute * self = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	const gchar* _tmp3_;
	const gchar* _tmp4_;
	gint _tmp5_;
	gint _tmp6_;
	BXmlString* _tmp7_;
	const gchar* _tmp8_;
	const gchar* _tmp9_;
	gint _tmp10_;
	gint _tmp11_;
	BXmlString* _tmp12_;
	const gchar* _tmp13_;
	const gchar* _tmp14_;
	gint _tmp15_;
	gint _tmp16_;
	BXmlString* _tmp17_;
	g_return_val_if_fail (element != NULL, NULL);
	self = (BAttribute*) g_object_new (object_type, NULL);
	_tmp0_ = b_xml_element_get_namespace (element);
	_g_free0 (self->priv->element_ns);
	self->priv->element_ns = _tmp0_;
	_tmp1_ = b_xml_element_get_name (element);
	_g_free0 (self->priv->element_name);
	self->priv->element_name = _tmp1_;
	_tmp2_ = b_xml_element_get_content (element);
	_g_free0 (self->priv->element_content);
	self->priv->element_content = _tmp2_;
	_tmp3_ = self->priv->element_ns;
	_tmp4_ = self->priv->element_ns;
	_tmp5_ = strlen ((const gchar*) _tmp4_);
	_tmp6_ = _tmp5_;
	_tmp7_ = b_xml_string_new ((const gchar*) _tmp3_, _tmp6_);
	_g_object_unref0 (self->priv->ns);
	self->priv->ns = _tmp7_;
	_tmp8_ = self->priv->element_name;
	_tmp9_ = self->priv->element_name;
	_tmp10_ = strlen ((const gchar*) _tmp9_);
	_tmp11_ = _tmp10_;
	_tmp12_ = b_xml_string_new ((const gchar*) _tmp8_, _tmp11_);
	_g_object_unref0 (self->priv->name);
	self->priv->name = _tmp12_;
	_tmp13_ = self->priv->element_content;
	_tmp14_ = self->priv->element_content;
	_tmp15_ = strlen ((const gchar*) _tmp14_);
	_tmp16_ = _tmp15_;
	_tmp17_ = b_xml_string_new ((const gchar*) _tmp13_, _tmp16_);
	_g_object_unref0 (self->priv->content);
	self->priv->content = _tmp17_;
	return self;
}

BAttribute*
b_attribute_new_element (BXmlElement* element)
{
	return b_attribute_construct_element (B_TYPE_ATTRIBUTE, element);
}

BAttribute*
b_attribute_construct_empty (GType object_type)
{
	BAttribute * self = NULL;
	BXmlString* _tmp0_;
	BXmlString* _tmp1_;
	BXmlString* _tmp2_;
	self = (BAttribute*) g_object_new (object_type, NULL);
	_tmp0_ = b_xml_string_new ("", 0);
	_g_object_unref0 (self->priv->ns);
	self->priv->ns = _tmp0_;
	_tmp1_ = b_xml_string_new ("", 0);
	_g_object_unref0 (self->priv->name);
	self->priv->name = _tmp1_;
	_tmp2_ = b_xml_string_new ("", 0);
	_g_object_unref0 (self->priv->content);
	self->priv->content = _tmp2_;
	return self;
}

BAttribute*
b_attribute_new_empty (void)
{
	return b_attribute_construct_empty (B_TYPE_ATTRIBUTE);
}

/** 
 * @return namespace part for this attribute.
 */
gchar*
b_attribute_get_namespace (BAttribute* self)
{
	BXmlString* _tmp0_;
	gchar* _tmp1_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->ns;
	_tmp1_ = b_xml_string_to_string (_tmp0_);
	result = _tmp1_;
	return result;
}

/**
 * @return the name of this attribute. 
 */
gchar*
b_attribute_get_name (BAttribute* self)
{
	BXmlString* _tmp0_;
	gchar* _tmp1_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->name;
	_tmp1_ = b_xml_string_to_string (_tmp0_);
	result = _tmp1_;
	return result;
}

/** 
 * @return the value of this attribute.
 */
gchar*
b_attribute_get_content (BAttribute* self)
{
	BXmlString* _tmp0_;
	gchar* _tmp1_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->content;
	_tmp1_ = b_xml_string_to_string (_tmp0_);
	result = _tmp1_;
	return result;
}

gint
b_attribute_get_name_length (BAttribute* self)
{
	BXmlString* _tmp0_;
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	_tmp0_ = self->priv->name;
	result = _tmp0_->length;
	return result;
}

static void
b_attribute_class_init (BAttributeClass * klass,
                        gpointer klass_data)
{
	b_attribute_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &BAttribute_private_offset);
	G_OBJECT_CLASS (klass)->finalize = b_attribute_finalize;
}

static void
b_attribute_instance_init (BAttribute * self,
                           gpointer klass)
{
	self->priv = b_attribute_get_instance_private (self);
	self->priv->element_ns = NULL;
	self->priv->element_name = NULL;
	self->priv->element_content = NULL;
}

static void
b_attribute_finalize (GObject * obj)
{
	BAttribute * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, B_TYPE_ATTRIBUTE, BAttribute);
	_g_object_unref0 (self->priv->ns);
	_g_object_unref0 (self->priv->name);
	_g_object_unref0 (self->priv->content);
	_g_free0 (self->priv->element_ns);
	_g_free0 (self->priv->element_name);
	_g_free0 (self->priv->element_content);
	G_OBJECT_CLASS (b_attribute_parent_class)->finalize (obj);
}

/** 
 * Representation of one XML attribute.
 */
static GType
b_attribute_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (BAttributeClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) b_attribute_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (BAttribute), 0, (GInstanceInitFunc) b_attribute_instance_init, NULL };
	GType b_attribute_type_id;
	b_attribute_type_id = g_type_register_static (G_TYPE_OBJECT, "BAttribute", &g_define_type_info, 0);
	BAttribute_private_offset = g_type_add_instance_private (b_attribute_type_id, sizeof (BAttributePrivate));
	return b_attribute_type_id;
}

GType
b_attribute_get_type (void)
{
	static volatile gsize b_attribute_type_id__once = 0;
	if (g_once_init_enter (&b_attribute_type_id__once)) {
		GType b_attribute_type_id;
		b_attribute_type_id = b_attribute_get_type_once ();
		g_once_init_leave (&b_attribute_type_id__once, b_attribute_type_id);
	}
	return b_attribute_type_id__once;
}

