/* contacts-io-parser.c generated by valac 0.56.3, the Vala compiler
 * generated from contacts-io-parser.vala, do not modify */

/*
 * Copyright (C) 2021 Niels De Graef <nielsdegraef@gmail.com>
 *
 * 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 2 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, see <http://www.gnu.org/licenses/>.
 */

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

#if !defined(VALA_EXTERN)
#if defined(_MSC_VER)
#define VALA_EXTERN __declspec(dllexport) extern
#elif __GNUC__ >= 4
#define VALA_EXTERN __attribute__((visibility("default"))) extern
#else
#define VALA_EXTERN extern
#endif
#endif

#define CONTACTS_IO_TYPE_PARSER (contacts_io_parser_get_type ())
#define CONTACTS_IO_PARSER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CONTACTS_IO_TYPE_PARSER, ContactsIoParser))
#define CONTACTS_IO_PARSER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CONTACTS_IO_TYPE_PARSER, ContactsIoParserClass))
#define CONTACTS_IO_IS_PARSER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CONTACTS_IO_TYPE_PARSER))
#define CONTACTS_IO_IS_PARSER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CONTACTS_IO_TYPE_PARSER))
#define CONTACTS_IO_PARSER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CONTACTS_IO_TYPE_PARSER, ContactsIoParserClass))

typedef struct _ContactsIoParser ContactsIoParser;
typedef struct _ContactsIoParserClass ContactsIoParserClass;
typedef struct _ContactsIoParserPrivate ContactsIoParserPrivate;
enum  {
	CONTACTS_IO_PARSER_0_PROPERTY,
	CONTACTS_IO_PARSER_NUM_PROPERTIES
};
static GParamSpec* contacts_io_parser_properties[CONTACTS_IO_PARSER_NUM_PROPERTIES];

struct _ContactsIoParser {
	GObject parent_instance;
	ContactsIoParserPrivate * priv;
};

struct _ContactsIoParserClass {
	GObjectClass parent_class;
	GHashTable** (*parse) (ContactsIoParser* self, GInputStream* input, gint* result_length1, GError** error);
};

static gpointer contacts_io_parser_parent_class = NULL;

VALA_EXTERN GType contacts_io_parser_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ContactsIoParser, g_object_unref)
VALA_EXTERN GHashTable** contacts_io_parser_parse (ContactsIoParser* self,
                                       GInputStream* input,
                                       gint* result_length1,
                                       GError** error);
static GHashTable** contacts_io_parser_real_parse (ContactsIoParser* self,
                                            GInputStream* input,
                                            gint* result_length1,
                                            GError** error);
VALA_EXTERN ContactsIoParser* contacts_io_parser_construct (GType object_type);
static GType contacts_io_parser_get_type_once (void);

/**
   * Takes the given input stream and tries to parse it into a
   * {@link GLib.HashTable}, which can then be used for methods like
   * {@link Folks.PersonaStore.add_persona_from_details}.
   */
static GHashTable**
contacts_io_parser_real_parse (ContactsIoParser* self,
                               GInputStream* input,
                               gint* result_length1,
                               GError** error)
{
	g_critical ("Type `%s' does not implement abstract method `contacts_io_parser_parse'", g_type_name (G_TYPE_FROM_INSTANCE (self)));
	return NULL;
}

GHashTable**
contacts_io_parser_parse (ContactsIoParser* self,
                          GInputStream* input,
                          gint* result_length1,
                          GError** error)
{
	ContactsIoParserClass* _klass_;
	g_return_val_if_fail (self != NULL, NULL);
	_klass_ = CONTACTS_IO_PARSER_GET_CLASS (self);
	if (_klass_->parse) {
		return _klass_->parse (self, input, result_length1, error);
	}
	return NULL;
}

ContactsIoParser*
contacts_io_parser_construct (GType object_type)
{
	ContactsIoParser * self = NULL;
	self = (ContactsIoParser*) g_object_new (object_type, NULL);
	return self;
}

static void
contacts_io_parser_class_init (ContactsIoParserClass * klass,
                               gpointer klass_data)
{
	contacts_io_parser_parent_class = g_type_class_peek_parent (klass);
	((ContactsIoParserClass *) klass)->parse = (GHashTable** (*) (ContactsIoParser*, GInputStream*, gint*, GError**)) contacts_io_parser_real_parse;
}

static void
contacts_io_parser_instance_init (ContactsIoParser * self,
                                  gpointer klass)
{
}

/**
 * An Parser is an object that can deal with importing a specific format
 * of describing a Contact (VCard is the most common example, but there exist
 * also CSV based formats and others).
 *
 * The main purpose of an Io.Parser is to parser whatever input it gets into a
 * {@link GLib.HashTable} with string keys and {@link Value} as values. After
 * that, we can choose to either serialize (using the serializing methods in
 * Contacts.Io), or to immediately import it in folks using
 * {@link Folks.PersonaStore.add_from_details}.
 */
 G_GNUC_NO_INLINE static GType
contacts_io_parser_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ContactsIoParserClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) contacts_io_parser_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ContactsIoParser), 0, (GInstanceInitFunc) contacts_io_parser_instance_init, NULL };
	GType contacts_io_parser_type_id;
	contacts_io_parser_type_id = g_type_register_static (G_TYPE_OBJECT, "ContactsIoParser", &g_define_type_info, G_TYPE_FLAG_ABSTRACT);
	return contacts_io_parser_type_id;
}

GType
contacts_io_parser_get_type (void)
{
	static volatile gsize contacts_io_parser_type_id__once = 0;
	if (g_once_init_enter (&contacts_io_parser_type_id__once)) {
		GType contacts_io_parser_type_id;
		contacts_io_parser_type_id = contacts_io_parser_get_type_once ();
		g_once_init_leave (&contacts_io_parser_type_id__once, contacts_io_parser_type_id);
	}
	return contacts_io_parser_type_id__once;
}

