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

/* GXmlNamespace.vala
 *
 * Copyright (C) 2016  Daniel Espinosa <esodan@gmail.com>
 *
 * 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 2.1 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.

 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
 *
 * Authors:
 *      Daniel Espinosa <esodan@gmail.com>
 */

#include <glib.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <gee.h>
#include <gio/gio.h>
#include <libxml/tree.h>


#define GXML_TYPE_NODE (gxml_node_get_type ())
#define GXML_NODE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GXML_TYPE_NODE, GXmlNode))
#define GXML_IS_NODE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GXML_TYPE_NODE))
#define GXML_NODE_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GXML_TYPE_NODE, GXmlNodeIface))

typedef struct _GXmlNode GXmlNode;
typedef struct _GXmlNodeIface GXmlNodeIface;

#define GXML_TYPE_ELEMENT_LIST (gxml_element_list_get_type ())
#define GXML_ELEMENT_LIST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GXML_TYPE_ELEMENT_LIST, GXmlElementList))
#define GXML_ELEMENT_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GXML_TYPE_ELEMENT_LIST, GXmlElementListClass))
#define GXML_IS_ELEMENT_LIST(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GXML_TYPE_ELEMENT_LIST))
#define GXML_IS_ELEMENT_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GXML_TYPE_ELEMENT_LIST))
#define GXML_ELEMENT_LIST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GXML_TYPE_ELEMENT_LIST, GXmlElementListClass))

typedef struct _GXmlElementList GXmlElementList;
typedef struct _GXmlElementListClass GXmlElementListClass;

#define GXML_TYPE_NAMESPACE (gxml_namespace_get_type ())
#define GXML_NAMESPACE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GXML_TYPE_NAMESPACE, GXmlNamespace))
#define GXML_IS_NAMESPACE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GXML_TYPE_NAMESPACE))
#define GXML_NAMESPACE_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GXML_TYPE_NAMESPACE, GXmlNamespaceIface))

typedef struct _GXmlNamespace GXmlNamespace;
typedef struct _GXmlNamespaceIface GXmlNamespaceIface;

#define GXML_TYPE_NODE_TYPE (gxml_node_type_get_type ())

#define GXML_TYPE_DOCUMENT (gxml_document_get_type ())
#define GXML_DOCUMENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GXML_TYPE_DOCUMENT, GXmlDocument))
#define GXML_IS_DOCUMENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GXML_TYPE_DOCUMENT))
#define GXML_DOCUMENT_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GXML_TYPE_DOCUMENT, GXmlDocumentIface))

typedef struct _GXmlDocument GXmlDocument;
typedef struct _GXmlDocumentIface GXmlDocumentIface;

#define GXML_TYPE_GNODE (gxml_gnode_get_type ())
#define GXML_GNODE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GXML_TYPE_GNODE, GXmlGNode))
#define GXML_GNODE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GXML_TYPE_GNODE, GXmlGNodeClass))
#define GXML_IS_GNODE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GXML_TYPE_GNODE))
#define GXML_IS_GNODE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GXML_TYPE_GNODE))
#define GXML_GNODE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GXML_TYPE_GNODE, GXmlGNodeClass))

typedef struct _GXmlGNode GXmlGNode;
typedef struct _GXmlGNodeClass GXmlGNodeClass;
typedef struct _GXmlGNodePrivate GXmlGNodePrivate;

#define GXML_TYPE_GDOCUMENT (gxml_gdocument_get_type ())
#define GXML_GDOCUMENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GXML_TYPE_GDOCUMENT, GXmlGDocument))
#define GXML_GDOCUMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GXML_TYPE_GDOCUMENT, GXmlGDocumentClass))
#define GXML_IS_GDOCUMENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GXML_TYPE_GDOCUMENT))
#define GXML_IS_GDOCUMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GXML_TYPE_GDOCUMENT))
#define GXML_GDOCUMENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GXML_TYPE_GDOCUMENT, GXmlGDocumentClass))

typedef struct _GXmlGDocument GXmlGDocument;
typedef struct _GXmlGDocumentClass GXmlGDocumentClass;

#define GXML_TYPE_GNAMESPACE (gxml_gnamespace_get_type ())
#define GXML_GNAMESPACE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GXML_TYPE_GNAMESPACE, GXmlGNamespace))
#define GXML_GNAMESPACE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GXML_TYPE_GNAMESPACE, GXmlGNamespaceClass))
#define GXML_IS_GNAMESPACE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GXML_TYPE_GNAMESPACE))
#define GXML_IS_GNAMESPACE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GXML_TYPE_GNAMESPACE))
#define GXML_GNAMESPACE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GXML_TYPE_GNAMESPACE, GXmlGNamespaceClass))

typedef struct _GXmlGNamespace GXmlGNamespace;
typedef struct _GXmlGNamespaceClass GXmlGNamespaceClass;
typedef struct _GXmlGNamespacePrivate GXmlGNamespacePrivate;

struct _GXmlNamespaceIface {
	GTypeInterface parent_iface;
	gchar* (*get_uri) (GXmlNamespace* self);
	gchar* (*get_prefix) (GXmlNamespace* self);
};

typedef enum  {
	GXML_NODE_TYPE_X_UNKNOWN = 0,
	GXML_NODE_TYPE_ELEMENT = 1,
	GXML_NODE_TYPE_ATTRIBUTE,
	GXML_NODE_TYPE_TEXT,
	GXML_NODE_TYPE_CDATA_SECTION,
	GXML_NODE_TYPE_ENTITY_REFERENCE,
	GXML_NODE_TYPE_ENTITY,
	GXML_NODE_TYPE_PROCESSING_INSTRUCTION,
	GXML_NODE_TYPE_COMMENT,
	GXML_NODE_TYPE_DOCUMENT,
	GXML_NODE_TYPE_DOCUMENT_TYPE,
	GXML_NODE_TYPE_DOCUMENT_FRAGMENT,
	GXML_NODE_TYPE_NOTATION
} GXmlNodeType;

struct _GXmlDocumentIface {
	GTypeInterface parent_iface;
	GXmlNode* (*create_element) (GXmlDocument* self, const gchar* name, GError** error);
	GXmlNode* (*create_text) (GXmlDocument* self, const gchar* text);
	GXmlNode* (*create_comment) (GXmlDocument* self, const gchar* text);
	GXmlNode* (*create_cdata) (GXmlDocument* self, const gchar* text);
	GXmlNode* (*create_pi) (GXmlDocument* self, const gchar* target, const gchar* data);
	gboolean (*save) (GXmlDocument* self, GCancellable* cancellable, GError** error);
	gboolean (*save_as) (GXmlDocument* self, GFile* f, GCancellable* cancellable, GError** error);
	gboolean (*get_indent) (GXmlDocument* self);
	void (*set_indent) (GXmlDocument* self, gboolean value);
	gboolean (*get_ns_top) (GXmlDocument* self);
	void (*set_ns_top) (GXmlDocument* self, gboolean value);
	gboolean (*get_prefix_default_ns) (GXmlDocument* self);
	void (*set_prefix_default_ns) (GXmlDocument* self, gboolean value);
	gboolean (*get_backup) (GXmlDocument* self);
	void (*set_backup) (GXmlDocument* self, gboolean value);
	GXmlNode* (*get_root) (GXmlDocument* self);
	GFile* (*get_file) (GXmlDocument* self);
	void (*set_file) (GXmlDocument* self, GFile* value);
};

struct _GXmlNodeIface {
	GTypeInterface parent_iface;
	GXmlNode* (*get) (GXmlNode* self, const gchar* key);
	GXmlElementList* (*get_elements_by_property_value) (GXmlNode* self, const gchar* property, const gchar* value);
	gchar* (*to_string) (GXmlNode* self);
	gboolean (*set_namespace) (GXmlNode* self, const gchar* uri, const gchar* prefix);
	gchar* (*ns_prefix) (GXmlNode* self);
	gchar* (*ns_uri) (GXmlNode* self);
	GeeList* (*get_namespaces) (GXmlNode* self);
	GeeBidirList* (*get_childs) (GXmlNode* self);
	GeeBidirList* (*get_children) (GXmlNode* self);
	GeeMap* (*get_attrs) (GXmlNode* self);
	gchar* (*get_name) (GXmlNode* self);
	gchar* (*get_value) (GXmlNode* self);
	void (*set_value) (GXmlNode* self, const gchar* value);
	GXmlNodeType (*get_type_node) (GXmlNode* self);
	GXmlDocument* (*get_document) (GXmlNode* self);
	GXmlNode* (*get_parent) (GXmlNode* self);
};

struct _GXmlGNode {
	GObject parent_instance;
	GXmlGNodePrivate * priv;
	GXmlGDocument* _doc;
	xmlNode* _node;
};

struct _GXmlGNodeClass {
	GObjectClass parent_class;
	gboolean (*set_namespace) (GXmlGNode* self, const gchar* uri, const gchar* prefix);
	gchar* (*to_string) (GXmlGNode* self);
	GeeMap* (*get_attrs) (GXmlGNode* self);
	GeeBidirList* (*get_children) (GXmlGNode* self);
	GeeList* (*get_namespaces) (GXmlGNode* self);
	GXmlDocument* (*get_document) (GXmlGNode* self);
	GXmlNode* (*get_parent) (GXmlGNode* self);
	GXmlNodeType (*get_type_node) (GXmlGNode* self);
	gchar* (*get_name) (GXmlGNode* self);
	gchar* (*get_value) (GXmlGNode* self);
	void (*set_value) (GXmlGNode* self, const gchar* value);
};

struct _GXmlGNamespace {
	GXmlGNode parent_instance;
	GXmlGNamespacePrivate * priv;
};

struct _GXmlGNamespaceClass {
	GXmlGNodeClass parent_class;
};

struct _GXmlGNamespacePrivate {
	xmlNs* _ns;
};


static gpointer gxml_gnamespace_parent_class = NULL;
static GXmlNamespaceIface* gxml_gnamespace_gxml_namespace_parent_iface = NULL;

GType gxml_element_list_get_type (void) G_GNUC_CONST;
GType gxml_namespace_get_type (void) G_GNUC_CONST;
GType gxml_node_type_get_type (void) G_GNUC_CONST;
GType gxml_document_get_type (void) G_GNUC_CONST;
GType gxml_node_get_type (void) G_GNUC_CONST;
GType gxml_gnode_get_type (void) G_GNUC_CONST;
GType gxml_gdocument_get_type (void) G_GNUC_CONST;
GType gxml_gnamespace_get_type (void) G_GNUC_CONST;
#define GXML_GNAMESPACE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GXML_TYPE_GNAMESPACE, GXmlGNamespacePrivate))
enum  {
	GXML_GNAMESPACE_DUMMY_PROPERTY,
	GXML_GNAMESPACE_URI,
	GXML_GNAMESPACE_PREFIX
};
GXmlGNamespace* gxml_gnamespace_new (xmlNs* ns);
GXmlGNamespace* gxml_gnamespace_construct (GType object_type, xmlNs* ns);
GXmlGNode* gxml_gnode_construct (GType object_type);
xmlNs* gxml_gnamespace_get_internal_ns (GXmlGNamespace* self);
static void gxml_gnamespace_finalize (GObject* obj);
gchar* gxml_namespace_get_uri (GXmlNamespace* self);
gchar* gxml_namespace_get_prefix (GXmlNamespace* self);
static void _vala_gxml_gnamespace_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);


GXmlGNamespace* gxml_gnamespace_construct (GType object_type, xmlNs* ns) {
	GXmlGNamespace * self = NULL;
	xmlNs* _tmp0_ = NULL;
	self = (GXmlGNamespace*) gxml_gnode_construct (object_type);
	_tmp0_ = ns;
	self->priv->_ns = _tmp0_;
	return self;
}


GXmlGNamespace* gxml_gnamespace_new (xmlNs* ns) {
	return gxml_gnamespace_construct (GXML_TYPE_GNAMESPACE, ns);
}


xmlNs* gxml_gnamespace_get_internal_ns (GXmlGNamespace* self) {
	xmlNs* result = NULL;
	xmlNs* _tmp0_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_ns;
	result = _tmp0_;
	return result;
}


static gchar* gxml_gnamespace_real_get_uri (GXmlNamespace* base) {
	gchar* result;
	GXmlGNamespace* self;
	xmlNs* _tmp0_ = NULL;
	xmlNs* _tmp1_ = NULL;
	const gchar* _tmp2_ = NULL;
	gchar* _tmp3_ = NULL;
	self = (GXmlGNamespace*) base;
	_tmp0_ = self->priv->_ns;
	if (_tmp0_ == NULL) {
		result = NULL;
		return result;
	}
	_tmp1_ = self->priv->_ns;
	_tmp2_ = _tmp1_->href;
	_tmp3_ = g_strdup (_tmp2_);
	result = _tmp3_;
	return result;
}


static gchar* gxml_gnamespace_real_get_prefix (GXmlNamespace* base) {
	gchar* result;
	GXmlGNamespace* self;
	xmlNs* _tmp0_ = NULL;
	xmlNs* _tmp1_ = NULL;
	const gchar* _tmp2_ = NULL;
	gchar* _tmp3_ = NULL;
	self = (GXmlGNamespace*) base;
	_tmp0_ = self->priv->_ns;
	if (_tmp0_ == NULL) {
		result = NULL;
		return result;
	}
	_tmp1_ = self->priv->_ns;
	_tmp2_ = _tmp1_->prefix;
	_tmp3_ = g_strdup (_tmp2_);
	result = _tmp3_;
	return result;
}


static void gxml_gnamespace_class_init (GXmlGNamespaceClass * klass) {
	gxml_gnamespace_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (GXmlGNamespacePrivate));
	G_OBJECT_CLASS (klass)->get_property = _vala_gxml_gnamespace_get_property;
	G_OBJECT_CLASS (klass)->finalize = gxml_gnamespace_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_GNAMESPACE_URI, g_param_spec_string ("uri", "uri", "uri", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_GNAMESPACE_PREFIX, g_param_spec_string ("prefix", "prefix", "prefix", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
}


static void gxml_gnamespace_gxml_namespace_interface_init (GXmlNamespaceIface * iface) {
	gxml_gnamespace_gxml_namespace_parent_iface = g_type_interface_peek_parent (iface);
	iface->get_uri = gxml_gnamespace_real_get_uri;
	iface->get_prefix = gxml_gnamespace_real_get_prefix;
}


static void gxml_gnamespace_instance_init (GXmlGNamespace * self) {
	self->priv = GXML_GNAMESPACE_GET_PRIVATE (self);
}


static void gxml_gnamespace_finalize (GObject* obj) {
	GXmlGNamespace * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GXML_TYPE_GNAMESPACE, GXmlGNamespace);
	G_OBJECT_CLASS (gxml_gnamespace_parent_class)->finalize (obj);
}


/**
 * Class implemeting {@link GXml.Namespace}
 */
GType gxml_gnamespace_get_type (void) {
	static volatile gsize gxml_gnamespace_type_id__volatile = 0;
	if (g_once_init_enter (&gxml_gnamespace_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (GXmlGNamespaceClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gxml_gnamespace_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GXmlGNamespace), 0, (GInstanceInitFunc) gxml_gnamespace_instance_init, NULL };
		static const GInterfaceInfo gxml_namespace_info = { (GInterfaceInitFunc) gxml_gnamespace_gxml_namespace_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
		GType gxml_gnamespace_type_id;
		gxml_gnamespace_type_id = g_type_register_static (GXML_TYPE_GNODE, "GXmlGNamespace", &g_define_type_info, 0);
		g_type_add_interface_static (gxml_gnamespace_type_id, GXML_TYPE_NAMESPACE, &gxml_namespace_info);
		g_once_init_leave (&gxml_gnamespace_type_id__volatile, gxml_gnamespace_type_id);
	}
	return gxml_gnamespace_type_id__volatile;
}


static void _vala_gxml_gnamespace_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
	GXmlGNamespace * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GXML_TYPE_GNAMESPACE, GXmlGNamespace);
	switch (property_id) {
		case GXML_GNAMESPACE_URI:
		g_value_take_string (value, gxml_namespace_get_uri ((GXmlNamespace*) self));
		break;
		case GXML_GNAMESPACE_PREFIX:
		g_value_take_string (value, gxml_namespace_get_prefix ((GXmlNamespace*) self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}



