/*
- * Copyright (C) 2015-2017 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2015-2020 Andrea Zagli <azagli@libero.it>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
priv->v1 = NULL;
priv->v2 = NULL;
+ priv->format1 = g_strdup ("");
+ priv->format2 = g_strdup ("");
}
/**
zak_form_validator_compare_date_xml_parsing (ZakFormValidator *validator, xmlNode *xnode, gpointer form)
{
gchar *prop;
+ gchar *prop2;
ZakFormValidatorCompareDatePrivate *priv = ZAK_FORM_VALIDATOR_COMPARE_DATE_GET_PRIVATE (validator);
prop = (gchar *)xmlGetProp (xnode, (const xmlChar *)"type_comp");
- priv->type = zak_form_get_compare_type_from_string (prop);
+ zak_form_validator_compare_date_set_compare_type ((ZakFormValidatorCompareDate *)validator, prop);
g_free (prop);
prop = (gchar *)xmlGetProp (xnode, (const xmlChar *)"element1");
- priv->v1 = zak_form_form_get_element_by_id ((ZakFormForm *)form, prop);
+ prop2 = (gchar *)xmlGetProp (xnode, (const xmlChar *)"format1");
+ zak_form_validator_compare_date_set_element1 ((ZakFormValidatorCompareDate *)validator, (ZakFormForm *)form, prop, prop2);
g_free (prop);
+ g_free (prop2);
prop = (gchar *)xmlGetProp (xnode, (const xmlChar *)"element2");
- priv->v2 = zak_form_form_get_element_by_id ((ZakFormForm *)form, prop);
+ prop2 = (gchar *)xmlGetProp (xnode, (const xmlChar *)"format2");
+ zak_form_validator_compare_date_set_element2 ((ZakFormValidatorCompareDate *)validator, (ZakFormForm *)form, prop, prop2);
g_free (prop);
+ g_free (prop2);
- prop = (gchar *)xmlGetProp (xnode, (const xmlChar *)"format1");
- priv->format1 = g_strdup (prop);
- g_free (prop);
+ return TRUE;
+}
- prop = (gchar *)xmlGetProp (xnode, (const xmlChar *)"format2");
- priv->format2 = g_strdup (prop);
- g_free (prop);
+/**
+ * zak_form_validator_compare_date_set_compare_type:
+ * @validator:
+ * @type:
+ *
+ * Sets the validator compare type.
+ */
+void
+zak_form_validator_compare_date_set_compare_type (ZakFormValidatorCompareDate *validator, const gchar *type)
+{
+ ZakFormValidatorCompareDatePrivate *priv = ZAK_FORM_VALIDATOR_COMPARE_DATE_GET_PRIVATE (validator);
- return TRUE;
+ priv->type = zak_form_get_compare_type_from_string (type);
+}
+
+/**
+ * zak_form_validator_compare_date_get_compare_type:
+ * @validator:
+ *
+ * Returns: the validator compare type.
+ */
+const gchar
+*zak_form_validator_compare_date_get_compare_type (ZakFormValidatorCompareDate *validator)
+{
+ ZakFormValidatorCompareDatePrivate *priv = ZAK_FORM_VALIDATOR_COMPARE_DATE_GET_PRIVATE (validator);
+
+ zak_form_get_compare_type_stringify (priv->type);
+}
+
+/**
+ * zak_form_validator_compare_date_set_element1:
+ * @validator:
+ * @element1:
+ * @format1:
+ *
+ * Sets the validator element1.
+ */
+void
+zak_form_validator_compare_date_set_element1 (ZakFormValidatorCompareDate *validator, ZakFormForm *form, const gchar *element1, const gchar *format1)
+{
+ ZakFormValidatorCompareDatePrivate *priv = ZAK_FORM_VALIDATOR_COMPARE_DATE_GET_PRIVATE (validator);
+
+ priv->v1 = zak_form_form_get_element_by_id (form, element1);
+ if (!ZAK_FORM_IS_ELEMENT (priv->v1))
+ {
+ g_warning ("Validator compare: element «%s» isn't a ZakFormElement.", element1);
+ }
+ else
+ {
+ g_free (priv->format1);
+ priv->format1 = g_strdup (format1);
+ }
+}
+
+/**
+ * zak_form_validator_compare_date_get_element1:
+ * @validator:
+ *
+ * Returns: the validator element1 name.
+ */
+const gchar
+*zak_form_validator_compare_date_get_element1 (ZakFormValidatorCompareDate *validator)
+{
+ ZakFormValidatorCompareDatePrivate *priv = ZAK_FORM_VALIDATOR_COMPARE_DATE_GET_PRIVATE (validator);
+
+ if (ZAK_FORM_IS_ELEMENT (priv->v2))
+ {
+ return zak_form_element_get_name (priv->v2);
+ }
+ else
+ {
+ return "";
+ }
+}
+
+/**
+ * zak_form_validator_compare_date_get_element1_format:
+ * @validator:
+ *
+ * Returns: the validator element1 format.
+ */
+const gchar
+*zak_form_validator_compare_date_get_element1_format (ZakFormValidatorCompareDate *validator)
+{
+ ZakFormValidatorCompareDatePrivate *priv = ZAK_FORM_VALIDATOR_COMPARE_DATE_GET_PRIVATE (validator);
+
+ return g_strdup (priv->format1);
+}
+
+/**
+ * zak_form_validator_compare_date_set_element2:
+ * @validator:
+ * @element2:
+ * @format2:
+ *
+ * Sets the validator element2.
+ */
+void
+zak_form_validator_compare_date_set_element2 (ZakFormValidatorCompareDate *validator, ZakFormForm *form, const gchar *element2, const gchar *format2)
+{
+ ZakFormValidatorCompareDatePrivate *priv = ZAK_FORM_VALIDATOR_COMPARE_DATE_GET_PRIVATE (validator);
+
+ priv->v1 = zak_form_form_get_element_by_id (form, element2);
+ if (!ZAK_FORM_IS_ELEMENT (priv->v2))
+ {
+ g_warning ("Validator compare: element «%s» isn't a ZakFormElement.", element2);
+ }
+ else
+ {
+ g_free (priv->format2);
+ priv->format2 = g_strdup (format2);
+ }
+}
+
+/**
+ * zak_form_validator_compare_date_get_element2:
+ * @validator:
+ *
+ * Returns: the validator element2 name.
+ */
+const gchar
+*zak_form_validator_compare_date_get_element2 (ZakFormValidatorCompareDate *validator)
+{
+ ZakFormValidatorCompareDatePrivate *priv = ZAK_FORM_VALIDATOR_COMPARE_DATE_GET_PRIVATE (validator);
+
+ if (ZAK_FORM_IS_ELEMENT (priv->v2))
+ {
+ return zak_form_element_get_name (priv->v2);
+ }
+ else
+ {
+ return "";
+ }
+}
+
+/**
+ * zak_form_validator_compare_date_get_element2_format:
+ * @validator:
+ *
+ * Returns: the validator element2 format.
+ */
+const gchar
+*zak_form_validator_compare_date_get_element2_format (ZakFormValidatorCompareDate *validator)
+{
+ ZakFormValidatorCompareDatePrivate *priv = ZAK_FORM_VALIDATOR_COMPARE_DATE_GET_PRIVATE (validator);
+
+ return g_strdup (priv->format2);
}
/* PRIVATE */
/*
- * Copyright (C) 2015-2017 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2015-2020 Andrea Zagli <azagli@libero.it>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
#include <libxml/tree.h>
+#include "form.h"
#include "formvalidator.h"
ZakFormValidatorCompareDate *zak_form_validator_compare_date_new (void);
+void zak_form_validator_compare_date_set_compare_type (ZakFormValidatorCompareDate *validator, const gchar *type);
+const gchar *zak_form_validator_compare_date_get_compare_type (ZakFormValidatorCompareDate *validator);
+
+void zak_form_validator_compare_date_set_element1 (ZakFormValidatorCompareDate *validator, ZakFormForm *form, const gchar *element1, const gchar *format1);
+const gchar *zak_form_validator_compare_date_get_element1 (ZakFormValidatorCompareDate *validator);
+const gchar *zak_form_validator_compare_date_get_element1_format (ZakFormValidatorCompareDate *validator);
+
+void zak_form_validator_compare_date_set_element2 (ZakFormValidatorCompareDate *validator, ZakFormForm *form, const gchar *element2, const gchar *format2);
+const gchar *zak_form_validator_compare_date_get_element2 (ZakFormValidatorCompareDate *validator);
+const gchar *zak_form_validator_compare_date_get_element2_format (ZakFormValidatorCompareDate *validator);
+
G_END_DECLS