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

/* GXmlText.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_TEXT (gxml_text_get_type ())
#define GXML_TEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GXML_TYPE_TEXT, GXmlText))
#define GXML_IS_TEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GXML_TYPE_TEXT))
#define GXML_TEXT_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GXML_TYPE_TEXT, GXmlTextIface))

typedef struct _GXmlText GXmlText;
typedef struct _GXmlTextIface GXmlTextIface;

#define GXML_TYPE_GTEXT (gxml_gtext_get_type ())
#define GXML_GTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GXML_TYPE_GTEXT, GXmlGText))
#define GXML_GTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GXML_TYPE_GTEXT, GXmlGTextClass))
#define GXML_IS_GTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GXML_TYPE_GTEXT))
#define GXML_IS_GTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GXML_TYPE_GTEXT))
#define GXML_GTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GXML_TYPE_GTEXT, GXmlGTextClass))

typedef struct _GXmlGText GXmlGText;
typedef struct _GXmlGTextClass GXmlGTextClass;
typedef struct _GXmlGTextPrivate GXmlGTextPrivate;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

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 _GXmlTextIface {
	GTypeInterface parent_iface;
	gchar* (*get_str) (GXmlText* self);
};

struct _GXmlGText {
	GXmlGNode parent_instance;
	GXmlGTextPrivate * priv;
};

struct _GXmlGTextClass {
	GXmlGNodeClass parent_class;
};


static gpointer gxml_gtext_parent_class = NULL;
static GXmlTextIface* gxml_gtext_gxml_text_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_text_get_type (void) G_GNUC_CONST;
GType gxml_gtext_get_type (void) G_GNUC_CONST;
enum  {
	GXML_GTEXT_DUMMY_PROPERTY,
	GXML_GTEXT_NAME,
	GXML_GTEXT_STR
};
GXmlGText* gxml_gtext_new (GXmlGDocument* doc, xmlNode* node);
GXmlGText* gxml_gtext_construct (GType object_type, GXmlGDocument* doc, xmlNode* node);
GXmlGNode* gxml_gnode_construct (GType object_type);
gchar* gxml_gnode_get_value (GXmlGNode* self);
gchar* gxml_gnode_get_name (GXmlGNode* self);
gchar* gxml_text_get_str (GXmlText* self);
static void _vala_gxml_gtext_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);


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


GXmlGText* gxml_gtext_construct (GType object_type, GXmlGDocument* doc, xmlNode* node) {
	GXmlGText * self = NULL;
	xmlNode* _tmp0_ = NULL;
	GXmlGDocument* _tmp1_ = NULL;
	GXmlGDocument* _tmp2_ = NULL;
	g_return_val_if_fail (doc != NULL, NULL);
	self = (GXmlGText*) gxml_gnode_construct (object_type);
	_tmp0_ = node;
	((GXmlGNode*) self)->_node = _tmp0_;
	_tmp1_ = doc;
	_tmp2_ = _g_object_ref0 (_tmp1_);
	_g_object_unref0 (((GXmlGNode*) self)->_doc);
	((GXmlGNode*) self)->_doc = _tmp2_;
	return self;
}


GXmlGText* gxml_gtext_new (GXmlGDocument* doc, xmlNode* node) {
	return gxml_gtext_construct (GXML_TYPE_GTEXT, doc, node);
}


static gchar* gxml_gtext_real_get_name (GXmlGNode* base) {
	gchar* result;
	GXmlGText* self;
	gchar* _tmp0_ = NULL;
	self = (GXmlGText*) base;
	_tmp0_ = g_strdup ("#text");
	result = _tmp0_;
	return result;
}


static gchar* gxml_gtext_real_get_str (GXmlText* base) {
	gchar* result;
	GXmlGText* self;
	gchar* _tmp0_ = NULL;
	self = (GXmlGText*) base;
	_tmp0_ = GXML_GNODE_CLASS (gxml_gtext_parent_class)->get_value (G_TYPE_CHECK_INSTANCE_CAST (self, GXML_TYPE_GNODE, GXmlGNode));
	result = _tmp0_;
	return result;
}


static void gxml_gtext_class_init (GXmlGTextClass * klass) {
	gxml_gtext_parent_class = g_type_class_peek_parent (klass);
	GXML_GNODE_CLASS (klass)->get_name = gxml_gtext_real_get_name;
	G_OBJECT_CLASS (klass)->get_property = _vala_gxml_gtext_get_property;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_GTEXT_NAME, g_param_spec_string ("name", "name", "name", 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_GTEXT_STR, g_param_spec_string ("str", "str", "str", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
}


static void gxml_gtext_gxml_text_interface_init (GXmlTextIface * iface) {
	gxml_gtext_gxml_text_parent_iface = g_type_interface_peek_parent (iface);
	iface->get_str = gxml_gtext_real_get_str;
}


static void gxml_gtext_instance_init (GXmlGText * self) {
}


/**
 * Class implemeting {@link GXml.Text} interface, not tied to libxml-2.0 library.
 */
GType gxml_gtext_get_type (void) {
	static volatile gsize gxml_gtext_type_id__volatile = 0;
	if (g_once_init_enter (&gxml_gtext_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (GXmlGTextClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gxml_gtext_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GXmlGText), 0, (GInstanceInitFunc) gxml_gtext_instance_init, NULL };
		static const GInterfaceInfo gxml_text_info = { (GInterfaceInitFunc) gxml_gtext_gxml_text_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
		GType gxml_gtext_type_id;
		gxml_gtext_type_id = g_type_register_static (GXML_TYPE_GNODE, "GXmlGText", &g_define_type_info, 0);
		g_type_add_interface_static (gxml_gtext_type_id, GXML_TYPE_TEXT, &gxml_text_info);
		g_once_init_leave (&gxml_gtext_type_id__volatile, gxml_gtext_type_id);
	}
	return gxml_gtext_type_id__volatile;
}


static void _vala_gxml_gtext_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
	GXmlGText * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GXML_TYPE_GTEXT, GXmlGText);
	switch (property_id) {
		case GXML_GTEXT_NAME:
		g_value_take_string (value, gxml_gnode_get_name ((GXmlGNode*) self));
		break;
		case GXML_GTEXT_STR:
		g_value_take_string (value, gxml_text_get_str ((GXmlText*) self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}



