]> saetta.ns0.it Git - zakform/libzakform/commitdiff
Added function ZakForm::get_compare_type_as_string; enabled get_xml for FormValidator.
authorAndrea Zagli <azagli@libero.it>
Thu, 28 May 2020 08:20:43 +0000 (10:20 +0200)
committerAndrea Zagli <azagli@libero.it>
Thu, 28 May 2020 08:20:43 +0000 (10:20 +0200)
src/commons.c
src/commons.h
src/form.c
src/formvalidatorcompare.c
src/formvalidatorcomparedate.c
src/formvalidatorcomparenumber.c

index b70af0f3f7b88afd9bc4ecd6385371a1274f7a80..e22acae561c5f54c756f28bee89bb2638bb51bde 100644 (file)
@@ -79,6 +79,51 @@ zak_form_get_compare_type_from_string (const gchar *str)
        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:
index 6663ca87071c8fce81c21c371f64f936006d1afb..440c497cb16a862854d6d2a2712938fa5c0a5ac9 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * 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
@@ -41,6 +41,7 @@ typedef enum
        } 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);
index 852d861c1e2d76f97c829c30c490ded185fedc07..c6bb5c256a9d2dc6a096c92240009966188e44c3 100644 (file)
@@ -870,6 +870,12 @@ xmlDoc
                        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;
index d847fea48cf65268e9c654da7e5fc21304ef5022..906f84c2cbcd9a1557e7a672bae0b0f7e5d40bd3 100644 (file)
@@ -371,7 +371,7 @@ zak_form_validator_compare_get_xml (ZakFormValidator *validator, const gchar *ve
 
        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));
 
index 3ff8be64fd22b4caa6dad4d44a573a62f22d539d..58dc8a165f71058147dff4ba21cb04a76ab45419 100644 (file)
@@ -436,12 +436,12 @@ zak_form_validator_compare_date_validate (ZakFormValidator *validator)
 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));
 
index e207f140be3fd85f86905390f5c11f7739f30126..88bb514af4b558877a81f54d1de818f46779e343 100644 (file)
@@ -368,12 +368,12 @@ zak_form_validator_compare_number_validate (ZakFormValidator *validator)
 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));