return ret;
}
+/**
+ * zak_form_get_compare_type_as_string:
+ * @type:
+ *
+ * Returns: the stringify version of #ZakFormCompareType.
+ */
+const gchar
+*zak_form_get_compare_type_as_string (ZakFormCompareType type)
+{
+ const gchar *ret;
+
+ switch (type)
+ {
+ case ZAK_FORM_COMPARE_TYPE_LESSER:
+ ret = "lt";
+ break;
+
+ case ZAK_FORM_COMPARE_TYPE_LESSER_EQUAL:
+ ret = "let";
+ break;
+
+ case ZAK_FORM_COMPARE_TYPE_EQUAL:
+ ret = "e";
+ break;
+
+ case ZAK_FORM_COMPARE_TYPE_NOT_EQUAL:
+ ret = "ne";
+ break;
+
+ case ZAK_FORM_COMPARE_TYPE_GREATER:
+ ret = "gt";
+ break;
+
+ case ZAK_FORM_COMPARE_TYPE_GREATER_EQUAL:
+ ret = "get";
+ break;
+
+ default:
+ ret = _("NOT SUPPORTED");
+ break;
+ }
+
+ return ret;
+}
+
/**
* zak_form_get_compare_type_stringify:
* @type:
/*
- * Copyright (C) 2015 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
} ZakFormCompareType;
ZakFormCompareType zak_form_get_compare_type_from_string (const gchar *str);
+const gchar *zak_form_get_compare_type_as_string (ZakFormCompareType type);
const gchar *zak_form_get_compare_type_stringify (ZakFormCompareType type);
ZakFormElement *zak_form_get_element_by_id (GPtrArray *ar_elements, const gchar *id);
xmlAddChild (xroot, xnode);
}
+ for (i = 0; i < priv->ar_validators->len; i++)
+ {
+ xnode = zak_form_validator_get_xml ((ZakFormValidator *)g_ptr_array_index (priv->ar_validators, i), _version);
+ xmlAddChild (xroot, xnode);
+ }
+
g_free (_version);
return xdoc;
xmlSetProp (xnode, (const xmlChar *)"type", (const xmlChar *)"zak_form_validator_compare");
- xmlSetProp (xnode, (const xmlChar *)"type_comp", (const xmlChar *)zak_form_validator_compare_get_compare_type (validator_compare));
+ xmlSetProp (xnode, (const xmlChar *)"type_comp", (const xmlChar *)zak_form_get_compare_type_as_string (priv->type));
xmlSetProp (xnode, (const xmlChar *)"element1", (const xmlChar *)zak_form_validator_compare_get_element1 (validator_compare));
static void
zak_form_validator_compare_date_get_xml (ZakFormValidator *validator, const gchar *version, xmlNode *xnode)
{
- ZakFormValidatorCompareDate *validator_compare_date = ZAK_FORM_VALIDATOR_COMPARE_DATE (validator_compare_date);
+ ZakFormValidatorCompareDate *validator_compare_date = ZAK_FORM_VALIDATOR_COMPARE_DATE (validator);
ZakFormValidatorCompareDatePrivate *priv = ZAK_FORM_VALIDATOR_COMPARE_DATE_GET_PRIVATE (validator_compare_date);
xmlSetProp (xnode, (const xmlChar *)"type", (const xmlChar *)"zak_form_validator_compare_date");
- xmlSetProp (xnode, (const xmlChar *)"type_comp", (const xmlChar *)zak_form_validator_compare_date_get_compare_type (validator_compare_date));
+ xmlSetProp (xnode, (const xmlChar *)"type_comp", (const xmlChar *)zak_form_get_compare_type_as_string (priv->type));
xmlSetProp (xnode, (const xmlChar *)"element1", (const xmlChar *)zak_form_validator_compare_date_get_element1 (validator_compare_date));
static void
zak_form_validator_compare_number_get_xml (ZakFormValidator *validator, const gchar *version, xmlNode *xnode)
{
- ZakFormValidatorCompareNumber *validator_compare_number = ZAK_FORM_VALIDATOR_COMPARE_NUMBER (validator_compare_number);
+ ZakFormValidatorCompareNumber *validator_compare_number = ZAK_FORM_VALIDATOR_COMPARE_NUMBER (validator);
ZakFormValidatorCompareNumberPrivate *priv = ZAK_FORM_VALIDATOR_COMPARE_NUMBER_GET_PRIVATE (validator_compare_number);
xmlSetProp (xnode, (const xmlChar *)"type", (const xmlChar *)"zak_form_validator_compare_number");
- xmlSetProp (xnode, (const xmlChar *)"type_comp", (const xmlChar *)zak_form_validator_compare_number_get_compare_type (validator_compare_number));
+ xmlSetProp (xnode, (const xmlChar *)"type_comp", (const xmlChar *)zak_form_get_compare_type_as_string (priv->type));
xmlSetProp (xnode, (const xmlChar *)"element1", (const xmlChar *)zak_form_validator_compare_number_get_element1 (validator_compare_number));