/* Generated file (by generator) */

/*
 * SPDX-FileCopyrightText: 2015 William Yu <williamyu@gnome.org>
 *
 * SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0
 */

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include "i-cal-vcard-value.h"
#include "libical-glib-private.h"
#include "i-cal-vcard-derived-value.h"

G_DEFINE_TYPE (ICalVcardValue, i_cal_vcard_value, I_CAL_TYPE_OBJECT)

static void i_cal_vcard_value_class_init (G_GNUC_UNUSED ICalVcardValueClass *klass)
{
}

static void i_cal_vcard_value_init (G_GNUC_UNUSED ICalVcardValue *self)
{
}

/**
 * i_cal_vcard_value_new_full: (skip)
 * @native: The native libical object.
 * @owner: The parent.
 *
 * Create a new libical-glib object from the native libical object and the owner.
 *
 * Returns: (transfer full): The newly create libical-glib object.
 *
 * Since: 1.0
 **/
ICalVcardValue *
i_cal_vcard_value_new_full (vcardvalue *native, 
                            GObject *owner)
{
    ICalVcardValue *object;
    if (native == NULL) {
        return NULL;
    }
    
    
    object = i_cal_object_construct (I_CAL_VCARD_TYPE_VALUE,
                            (gpointer) native,
                            (GDestroyNotify) vcardvalue_free,
                            FALSE,
                            owner);

    return object;
}


/**
 * i_cal_vcard_value_new:
 * @kind: A #ICalVcardValueKind
 *
 * Creates a new #ICalVcardValue with the specified @kind.
 *
 * Returns: (transfer full): The newly created #ICalVcardValue.
 *
 * Since: 4.0
 *
 **/
ICalVcardValue *
i_cal_vcard_value_new (ICalVcardValueKind kind)
{
	return i_cal_vcard_value_new_full (vcardvalue_new ((vcardvalue_kind) (kind)), NULL);
}

/**
 * i_cal_vcard_value_clone:
 * @value: The #ICalVcardValue to be cloned.
 *
 * Deeply clones an #ICalVcardValue.
 *
 * Returns: (transfer full): The newly created #ICalVcardValue with the same property as @value.
 *
 * Since: 4.0
 *
 **/
ICalVcardValue *
i_cal_vcard_value_clone (const ICalVcardValue *value)
{
    g_return_val_if_fail (I_CAL_VCARD_IS_VALUE ((ICalVcardValue*)value), NULL);

	return i_cal_vcard_value_new_full (vcardvalue_clone ((vcardvalue *)i_cal_object_get_native (I_CAL_OBJECT ((ICalObject *)value))), NULL);
}

/**
 * i_cal_vcard_value_new_from_string:
 * @kind: A #ICalVcardValueKind
 * @str: A string
 *
 * Creates a new #ICalVcardValue based on the #ICalVcardValueKind and a string.
 *
 * Returns: (transfer full): The newly created #ICalVcardValue based on the @kind and @str.
 *
 * Since: 4.0
 *
 **/
ICalVcardValue *
i_cal_vcard_value_new_from_string (ICalVcardValueKind kind, 
                                   const gchar *str)
{
    g_return_val_if_fail (str != NULL, NULL);

	return i_cal_vcard_value_new_full (vcardvalue_new_from_string ((vcardvalue_kind) (kind), str), NULL);
}

/**
 * i_cal_vcard_value_free: (skip)
 * @value: The #ICalVcardValue to be freed
 *
 * Frees an #ICalVcardValue.
 *
 * Since: 4.0
 *
 **/
void
i_cal_vcard_value_free (ICalVcardValue *value)
{
    g_return_if_fail (I_CAL_VCARD_IS_VALUE ((ICalVcardValue*)value));

	vcardvalue_free ((vcardvalue *)i_cal_object_get_native (I_CAL_OBJECT ((ICalObject *)value)));
}

/**
 * i_cal_vcard_value_is_valid:
 * @value: The #ICalVcardValue to be checked
 *
 * Checks if #ICalVcardValue is valid.
 *
 * Returns: true if valid, false if not.
 *
 * Since: 4.0
 *
 **/
gboolean
i_cal_vcard_value_is_valid (const ICalVcardValue *value)
{
    g_return_val_if_fail (I_CAL_VCARD_IS_VALUE ((ICalVcardValue*)value), FALSE);

	return vcardvalue_is_valid ((vcardvalue *)i_cal_object_get_native (I_CAL_OBJECT ((ICalObject *)value)));
}

/**
 * i_cal_vcard_value_as_vcard_string:
 * @value: A #ICalVcardValue
 *
 * Converts the #ICalVcardValue to a string.
 *
 * Returns: (transfer full): The string representation.
 *
 * Since: 4.0
 *
 **/
gchar *
i_cal_vcard_value_as_vcard_string (const ICalVcardValue *value)
{
    g_return_val_if_fail (I_CAL_VCARD_IS_VALUE ((ICalVcardValue*)value), NULL);

	return i_cal_memory_str_to_glib (vcardvalue_as_vcard_string_r ((vcardvalue *)i_cal_object_get_native (I_CAL_OBJECT ((ICalObject *)value))));
}

/**
 * i_cal_vcard_value_isa:
 * @value: A #ICalVcardValue
 *
 * Gets the kind of #ICalVcardValue.
 *
 * Returns: The kind of @value.
 *
 * Since: 4.0
 *
 **/
ICalVcardValueKind
i_cal_vcard_value_isa (const ICalVcardValue *value)
{
    g_return_val_if_fail (I_CAL_VCARD_IS_VALUE ((ICalVcardValue*)value), I_CAL_VCARD_NO_VALUE);

	return (ICalVcardValueKind) (vcardvalue_isa ((vcardvalue *)i_cal_object_get_native (I_CAL_OBJECT ((ICalObject *)value))));
}

/**
 * i_cal_vcard_value_isa_value:
 * @value: A #ICalVcardValue
 *
 * Checks whether the native part of #ICalVcardValue is an ical;s vcardvalue.
 *
 * Returns: true if yes, false if not.
 *
 * Since: 4.0
 *
 **/
gboolean
i_cal_vcard_value_isa_value (ICalVcardValue *value)
{
    g_return_val_if_fail (I_CAL_VCARD_IS_VALUE ((ICalVcardValue*)value), FALSE);

	return vcardvalue_isa_value ((vcardvalue *)i_cal_object_get_native (I_CAL_OBJECT ((ICalObject *)value)));
}

/**
 * i_cal_vcard_value_kind_from_string:
 * @str: A string
 *
 * Converts a string to #ICalVcardValueKind.
 *
 * Returns: A #ICalVcardValueKind.
 *
 * Since: 4.0
 *
 **/
ICalVcardValueKind
i_cal_vcard_value_kind_from_string (const gchar *str)
{
    g_return_val_if_fail (str != NULL, I_CAL_VCARD_NO_VALUE);

	return (ICalVcardValueKind) (vcardvalue_string_to_kind (str));
}

/**
 * i_cal_vcard_value_kind_to_string:
 * @kind: A #ICalVcardValueKind
 *
 * Converts the #ICalVcardValueKind to a string.
 *
 * Returns: The string representation of #ICalVcardValueKind.
 *
 * Since: 4.0
 *
 **/
const gchar *
i_cal_vcard_value_kind_to_string (ICalVcardValueKind kind)
{
	return vcardvalue_kind_to_string ((vcardvalue_kind) (kind));
}

/**
 * i_cal_vcard_value_kind_is_valid:
 * @kind: The #ICalVcardValueKind to be checked
 *
 * Checks whether the @kind is a valid #ICalVcardValueKind.
 *
 * Returns: true if yes, false if not.
 *
 * Since: 4.0
 *
 **/
gboolean
i_cal_vcard_value_kind_is_valid (ICalVcardValueKind kind)
{
	return vcardvalue_kind_is_valid ((vcardvalue_kind) (kind));
}

/**
 * i_cal_vcard_value_reset_kind:
 * @value: The #ICalVcardValue to be queried
 *
 * Reset's the value's kind.
 *
 * Since: 4.0
 *
 **/
void
i_cal_vcard_value_reset_kind (ICalVcardValue *value)
{
    g_return_if_fail (I_CAL_VCARD_IS_VALUE ((ICalVcardValue*)value));

	vcardvalue_reset_kind ((vcardvalue *)i_cal_object_get_native (I_CAL_OBJECT ((ICalObject *)value)));
}

/**
 * i_cal_vcard_value_dequote_text: (skip)
 * @text: (inout): pointer to a string to dequote
 * @separators: (nullable): a string with separators, or %NULL
 *
 * Dequotes the text in @text and advanced the pointer after the end of the read text. The reading stops
 * either at the end of the @text or when any of the letters from the @separators is reached unescaped.
 *
 * Returns: (nullable) (transfer full): a TEXT property, dequoted from the @text, or %NULL if failed
 *
 * Since: 4.0
 *
 **/
gchar *
i_cal_vcard_value_dequote_text (const gchar **text, 
                                const gchar *separators)
{
    gchar *res, *dequoted;

    g_return_val_if_fail(text != NULL, NULL);

    dequoted = vcardvalue_strdup_and_dequote_text(text, separators);
    if(!dequoted) {
        return NULL;
    }
    res = g_strdup(dequoted);
    icalmemory_free_buffer(dequoted);

    return res;
}
