xmlNode *xroot;
xmlNode *xnode;
+ GHashTable *ht;
+
+ guint i;
+
+ ZakFormElementPrivate *priv = zak_form_element_get_instance_private (element);
+
xroot = xmlNewNode (NULL, (xmlChar *)"element");
if (zak_form_element_get_name (element) != NULL)
xmlAddChild (xroot, xnode);
}
- GHashTable *ht;
-
ht = zak_form_element_get_format (element);
if (ht != NULL)
{
GHashTableIter iter;
gpointer key;
gpointer value;
+ gboolean first;
- xnode = xmlNewNode (NULL, (xmlChar *)"format");
-
+ first = TRUE;
g_hash_table_iter_init (&iter, ht);
while (g_hash_table_iter_next (&iter, &key, &value))
{
+ if (first)
+ {
+ xnode = xmlNewNode (NULL, (xmlChar *)"format");
+ first = FALSE;
+ }
if (g_strcmp0 (key, "content") == 0)
{
xmlNodeSetContent (xnode, (xmlChar *)value);
ZAK_FORM_ELEMENT_GET_CLASS (element)->get_xml (element, xroot, version);
}
+ for (i = 0; i < priv->pa_filters->len; i++)
+ {
+ xnode = zak_form_element_filter_get_xml ((ZakFormElementFilter *)g_ptr_array_index (priv->pa_filters, i), version);
+ xmlAddChild (xroot, xnode);
+ }
+
return xroot;
}
/*
- * 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
zak_form_element_filter_init (ZakFormElementFilter *zak_form_element_filter)
{
ZakFormElementFilterPrivate *priv = zak_form_element_filter_get_instance_private (zak_form_element_filter);
+
}
gboolean
{
ZakFormElementFilterPrivate *priv = zak_form_element_filter_get_instance_private (filter);
+ g_free (priv->id);
if (id == NULL)
{
priv->id = g_strdup ("");
priv->enabled = enabled;
}
+/**
+ * zak_form_element_filter_get_xml
+ * @filter:
+ * @version: not used.
+ *
+ * Returns: the xml for the filter.
+ */
+xmlNode
+*zak_form_element_filter_get_xml (ZakFormElementFilter *filter, const gchar *version)
+{
+ xmlNode *xnode;
+
+ xnode = xmlNewNode (NULL, (xmlChar *)"filter");
+
+ if (zak_form_element_filter_get_id (filter) != NULL
+ && g_strcmp0 (zak_form_element_filter_get_id (filter), "") != 0)
+ {
+ xmlSetProp (xnode, (const xmlChar *)"id", (xmlChar *)zak_form_element_filter_get_id (filter));
+ }
+
+ if (ZAK_FORM_ELEMENT_FILTER_GET_CLASS (filter)->get_xml!= NULL)
+ {
+ ZAK_FORM_ELEMENT_FILTER_GET_CLASS (filter)->get_xml (filter, version, xnode);
+ }
+
+ return xnode;
+}
+
/* PRIVATE */
static void
zak_form_element_filter_set_property (GObject *object,
/*
- * 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
gboolean (*xml_parsing) (ZakFormElementFilter *filter, xmlNode *xnode);
gchar *(*filter) (ZakFormElementFilter *self, const gchar *value);
+
+ void (*get_xml) (ZakFormElementFilter *self, const gchar *version, xmlNode *xnode);
};
gboolean zak_form_element_filter_xml_parsing (ZakFormElementFilter *filter, xmlNode *xnode);
gboolean zak_form_element_filter_get_enabled (ZakFormElementFilter *filter);
void zak_form_element_filter_set_enabled (ZakFormElementFilter *filter, gboolean enabled);
+xmlNode *zak_form_element_filter_get_xml (ZakFormElementFilter *filter, const gchar *version);
+
G_END_DECLS
/*
- * 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
static gboolean zak_form_element_filter_luc_xml_parsing (ZakFormElementFilter *filter, xmlNode *xnode);
static gchar *zak_form_element_filter_luc_filter (ZakFormElementFilter *filter_luc, const gchar *value);
+static void zak_form_element_filter_luc_get_xml (ZakFormElementFilter *filter, const gchar *version, xmlNode *xnode);
enum
{
parent_class->xml_parsing = zak_form_element_filter_luc_xml_parsing;
parent_class->filter = zak_form_element_filter_luc_filter;
+ parent_class->get_xml = zak_form_element_filter_luc_get_xml;
g_type_class_add_private (object_class, sizeof (ZakFormElementFilterLucPrivate));
}
return ret;
}
+
+static void
+zak_form_element_filter_luc_get_xml (ZakFormElementFilter *filter, const gchar *version, xmlNode *xnode)
+{
+ ZakFormElementFilterLuc *zak_form_element = ZAK_FORM_ELEMENT_FILTER_LUC (filter);
+ ZakFormElementFilterLucPrivate *priv = ZAK_FORM_ELEMENT_FILTER_LUC_GET_PRIVATE (zak_form_element);
+
+ xmlSetProp (xnode, (const xmlChar *)"type", (const xmlChar *)"zak_form_element_filter_luc");
+
+ switch (priv->type)
+ {
+ case LOWER:
+ xmlNodeSetContent (xnode, (xmlChar *)"lower");
+ break;
+
+ case UPPER:
+ xmlNodeSetContent (xnode, (xmlChar *)"upper");
+ break;
+
+ case CAMEL:
+ xmlNodeSetContent (xnode, (xmlChar *)"camel");
+ break;
+ }
+}
/*
- * 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
static gboolean zak_form_element_filter_trim_xml_parsing (ZakFormElementFilter *filter, xmlNode *xnode);
static gchar *zak_form_element_filter_trim_filter (ZakFormElementFilter *filter_trim, const gchar *value);
+static void zak_form_element_filter_trim_get_xml (ZakFormElementFilter *filter, const gchar *version, xmlNode *xnode);
struct _ZakFormElementFilterTrim
{
parent_class->xml_parsing = zak_form_element_filter_trim_xml_parsing;
parent_class->filter = zak_form_element_filter_trim_filter;
+ parent_class->get_xml = zak_form_element_filter_trim_get_xml;
g_type_class_add_private (object_class, sizeof (ZakFormElementFilterTrimPrivate));
}
return ret;
}
+
+static void
+zak_form_element_filter_trim_get_xml (ZakFormElementFilter *filter, const gchar *version, xmlNode *xnode)
+{
+ ZakFormElementFilterTrim *zak_form_element = ZAK_FORM_ELEMENT_FILTER_TRIM (filter);
+ ZakFormElementFilterTrimPrivate *priv = ZAK_FORM_ELEMENT_FILTER_TRIM_GET_PRIVATE (zak_form_element);
+
+ xmlSetProp (xnode, (const xmlChar *)"type", (const xmlChar *)"zak_form_element_filter_trim");
+}