[libgdata/gxml] * port gdata-{category, generator, link, gd-phone-number}
- From: Richard Hans Schwarting <rschwart src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgdata/gxml] * port gdata-{category, generator, link, gd-phone-number}
- Date: Sat, 24 Sep 2011 06:22:04 +0000 (UTC)
commit 3171732cc074a74381c648aacafb81de18ae7bc6
Author: Richard Schwarting <aquarichy gmail com>
Date: Fri Jul 22 17:11:18 2011 -0400
* port gdata-{category,generator,link,gd-phone-number}
gdata/atom/gdata-category.c | 19 ++++++++--------
gdata/atom/gdata-generator.c | 25 +++++++++++----------
gdata/atom/gdata-link.c | 43 +++++++++++++++++++------------------
gdata/gd/gdata-gd-phone-number.c | 35 +++++++++++++++---------------
4 files changed, 63 insertions(+), 59 deletions(-)
---
diff --git a/gdata/atom/gdata-category.c b/gdata/atom/gdata-category.c
index 87c5603..e30c164 100644
--- a/gdata/atom/gdata-category.c
+++ b/gdata/atom/gdata-category.c
@@ -30,7 +30,7 @@
**/
#include <glib.h>
-#include <libxml/parser.h>
+#include <gxml.h>
#include "gdata-category.h"
#include "gdata-parsable.h"
@@ -41,7 +41,7 @@ static void gdata_category_comparable_init (GDataComparableIface *iface);
static void gdata_category_finalize (GObject *object);
static void gdata_category_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec);
static void gdata_category_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec);
-static gboolean pre_parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *root_node, gpointer user_data, GError **error);
+static gboolean pre_parse_xml (GDataParsable *parsable, GXmlDomDocument *doc, GXmlDomXNode *root_node, gpointer user_data, GError **error);
static void pre_get_xml (GDataParsable *parsable, GString *xml_string);
struct _GDataCategoryPrivate {
@@ -203,20 +203,21 @@ gdata_category_set_property (GObject *object, guint property_id, const GValue *v
}
static gboolean
-pre_parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *root_node, gpointer user_data, GError **error)
+pre_parse_xml (GDataParsable *parsable, GXmlDomDocument *doc, GXmlDomXNode *root_node, gpointer user_data, GError **error)
{
- xmlChar *term;
+ gchar *term;
GDataCategory *self = GDATA_CATEGORY (parsable);
+ GXmlDomElement *root_elem = GXML_DOM_ELEMENT (root_node);
- term = xmlGetProp (root_node, (xmlChar*) "term");
+ term = gxml_dom_element_get_attribute (root_elem, "term");
if (term == NULL || *term == '\0') {
- xmlFree (term);
+ g_free (term);
return gdata_parser_error_required_property_missing (root_node, "term", error);
}
- self->priv->term = (gchar*) term;
+ self->priv->term = term;
- self->priv->scheme = (gchar*) xmlGetProp (root_node, (xmlChar*) "scheme");
- self->priv->label = (gchar*) xmlGetProp (root_node, (xmlChar*) "label");
+ self->priv->scheme = gxml_dom_element_get_attribute (root_elem, "scheme");
+ self->priv->label = gxml_dom_element_get_attribute (root_elem, "label");
return TRUE;
}
diff --git a/gdata/atom/gdata-generator.c b/gdata/atom/gdata-generator.c
index f5090b3..20d9088 100644
--- a/gdata/atom/gdata-generator.c
+++ b/gdata/atom/gdata-generator.c
@@ -28,7 +28,7 @@
**/
#include <glib.h>
-#include <libxml/parser.h>
+#include <gxml.h>
#include "gdata-generator.h"
#include "gdata-parsable.h"
@@ -38,8 +38,8 @@
static void gdata_generator_comparable_init (GDataComparableIface *iface);
static void gdata_generator_finalize (GObject *object);
static void gdata_generator_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec);
-static gboolean pre_parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *root_node, gpointer user_data, GError **error);
-static gboolean parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *root_node, gpointer user_data, GError **error);
+static gboolean pre_parse_xml (GDataParsable *parsable, GXmlDomDocument *doc, GXmlDomXNode *root_node, gpointer user_data, GError **error);
+static gboolean parse_xml (GDataParsable *parsable, GXmlDomDocument *doc, GXmlDomXNode *root_node, gpointer user_data, GError **error);
struct _GDataGeneratorPrivate {
gchar *name;
@@ -177,29 +177,30 @@ gdata_generator_get_property (GObject *object, guint property_id, GValue *value,
}
static gboolean
-pre_parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *root_node, gpointer user_data, GError **error)
+pre_parse_xml (GDataParsable *parsable, GXmlDomDocument *doc, GXmlDomXNode *root_node, gpointer user_data, GError **error)
{
- xmlChar *uri;
+ gchar *uri;
GDataGeneratorPrivate *priv = GDATA_GENERATOR (parsable)->priv;
+ GXmlDomElement *root_elem = GXML_DOM_ELEMENT (root_node);
- uri = xmlGetProp (root_node, (xmlChar*) "uri");
+ uri = gxml_dom_element_get_attribute (root_elem, "uri");
if (uri != NULL && *uri == '\0') {
- xmlFree (uri);
+ g_free (uri);
return gdata_parser_error_required_property_missing (root_node, "uri", error);
}
- priv->uri = (gchar*) uri;
+ priv->uri = uri;
- priv->name = (gchar*) xmlNodeListGetString (doc, root_node->children, TRUE);
- priv->version = (gchar*) xmlGetProp (root_node, (xmlChar*) "version");
+ priv->name = gxml_dom_node_list_to_string (gxml_dom_xnode_get_child_nodes (root_node), TRUE); // TODO:GXML: consider adding a _contents_to_string for elements
+ priv->version = gxml_dom_element_get_attribute (root_elem, "version");
return TRUE;
}
static gboolean
-parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_data, GError **error)
+parse_xml (GDataParsable *parsable, GXmlDomDocument *doc, GXmlDomXNode *node, gpointer user_data, GError **error)
{
/* Textual content's handled in pre_parse_xml */
- if (node->type != XML_ELEMENT_NODE)
+ if (gxml_dom_xnode_get_node_type (node) != GXML_DOM_NODE_TYPE_ELEMENT)
return TRUE;
return GDATA_PARSABLE_CLASS (gdata_generator_parent_class)->parse_xml (parsable, doc, node, user_data, error);
diff --git a/gdata/atom/gdata-link.c b/gdata/atom/gdata-link.c
index 5c927e6..4504656 100644
--- a/gdata/atom/gdata-link.c
+++ b/gdata/atom/gdata-link.c
@@ -30,7 +30,7 @@
**/
#include <glib.h>
-#include <libxml/parser.h>
+#include <gxml.h>
#include <string.h>
#include "gdata-link.h"
@@ -42,7 +42,7 @@ static void gdata_link_comparable_init (GDataComparableIface *iface);
static void gdata_link_finalize (GObject *object);
static void gdata_link_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec);
static void gdata_link_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec);
-static gboolean pre_parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *root_node, gpointer user_data, GError **error);
+static gboolean pre_parse_xml (GDataParsable *parsable, GXmlDomDocument *doc, GXmlDomXNode *root_node, gpointer user_data, GError **error);
static void pre_get_xml (GDataParsable *parsable, GString *xml_string);
struct _GDataLinkPrivate {
@@ -282,55 +282,56 @@ gdata_link_set_property (GObject *object, guint property_id, const GValue *value
}
static gboolean
-pre_parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *root_node, gpointer user_data, GError **error)
+pre_parse_xml (GDataParsable *parsable, GXmlDomDocument *doc, GXmlDomXNode *root_node, gpointer user_data, GError **error)
{
- xmlChar *uri, *relation_type, *content_type, *language, *length;
+ gchar *uri, *relation_type, *content_type, *language, *length;
GDataLink *self = GDATA_LINK (parsable);
+ GXmlDomElement *root_elem = GXML_DOM_ELEMENT (root_node);
/* href */
- uri = xmlGetProp (root_node, (xmlChar*) "href");
+ uri = gxml_dom_element_get_attribute (root_elem, "href");
if (uri == NULL || *uri == '\0') {
- xmlFree (uri);
+ g_free (uri);
return gdata_parser_error_required_property_missing (root_node, "href", error);
}
- self->priv->uri = (gchar*) uri;
+ self->priv->uri = uri;
/* rel */
- relation_type = xmlGetProp (root_node, (xmlChar*) "rel");
+ relation_type = gxml_dom_element_get_attribute (root_elem, "rel");
if (relation_type != NULL && *relation_type == '\0') {
- xmlFree (relation_type);
+ g_free (relation_type);
return gdata_parser_error_required_property_missing (root_node, "rel", error);
}
- gdata_link_set_relation_type (self, (const gchar*) relation_type);
- xmlFree (relation_type);
+ gdata_link_set_relation_type (self, relation_type);
+ g_free (relation_type);
/* type */
- content_type = xmlGetProp (root_node, (xmlChar*) "type");
+ content_type = gxml_dom_element_get_attribute (root_elem, "type");
if (content_type != NULL && *content_type == '\0') {
- xmlFree (content_type);
+ g_free (content_type);
return gdata_parser_error_required_property_missing (root_node, "type", error);
}
- self->priv->content_type = (gchar*) content_type;
+ self->priv->content_type = content_type;
/* hreflang */
- language = xmlGetProp (root_node, (xmlChar*) "hreflang");
+ language = gxml_dom_element_get_attribute (root_elem, "hreflang");
if (language != NULL && *language == '\0') {
- xmlFree (language);
+ g_free (language);
return gdata_parser_error_required_property_missing (root_node, "hreflang", error);
}
- self->priv->language = (gchar*) language;
+ self->priv->language = language;
/* title */
- self->priv->title = (gchar*) xmlGetProp (root_node, (xmlChar*) "title");
+ self->priv->title = gxml_dom_element_get_attribute (root_elem, "title"); // TODO:GXML: perhaps when dealing with so many, I should just get the HashMap directly
/* length */
- length = xmlGetProp (root_node, (xmlChar*) "length");
+ length = gxml_dom_element_get_attribute (root_elem, "length");
if (length == NULL)
self->priv->length = -1;
else
- self->priv->length = strtoul ((gchar*) length, NULL, 10);
- xmlFree (length);
+ self->priv->length = strtoul (length, NULL, 10);
+ g_free (length);
return TRUE;
}
diff --git a/gdata/gd/gdata-gd-phone-number.c b/gdata/gd/gdata-gd-phone-number.c
index d160b97..6596b94 100644
--- a/gdata/gd/gdata-gd-phone-number.c
+++ b/gdata/gd/gdata-gd-phone-number.c
@@ -30,7 +30,7 @@
**/
#include <glib.h>
-#include <libxml/parser.h>
+#include <gxml.h>
#include <string.h>
#include "gdata-gd-phone-number.h"
@@ -42,8 +42,8 @@ static void gdata_gd_phone_number_comparable_init (GDataComparableIface *iface);
static void gdata_gd_phone_number_finalize (GObject *object);
static void gdata_gd_phone_number_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec);
static void gdata_gd_phone_number_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec);
-static gboolean pre_parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *root_node, gpointer user_data, GError **error);
-static gboolean parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_data, GError **error);
+static gboolean pre_parse_xml (GDataParsable *parsable, GXmlDomDocument *doc, GXmlDomXNode *root_node, gpointer user_data, GError **error);
+static gboolean parse_xml (GDataParsable *parsable, GXmlDomDocument *doc, GXmlDomXNode *node, gpointer user_data, GError **error);
static void pre_get_xml (GDataParsable *parsable, GString *xml_string);
static void get_xml (GDataParsable *parsable, GString *xml_string);
static void get_namespaces (GDataParsable *parsable, GHashTable *namespaces);
@@ -257,45 +257,46 @@ gdata_gd_phone_number_set_property (GObject *object, guint property_id, const GV
}
static gboolean
-pre_parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *root_node, gpointer user_data, GError **error)
+pre_parse_xml (GDataParsable *parsable, GXmlDomDocument *doc, GXmlDomXNode *root_node, gpointer user_data, GError **error)
{
- xmlChar *number, *rel;
+ gchar *number, *rel;
gboolean primary_bool;
GDataGDPhoneNumberPrivate *priv = GDATA_GD_PHONE_NUMBER (parsable)->priv;
+ GXmlDomElement *root_elem = GXML_DOM_ELEMENT (root_node);
/* Is it the primary phone number? */
if (gdata_parser_boolean_from_property (root_node, "primary", &primary_bool, 0, error) == FALSE)
return FALSE;
- number = xmlNodeListGetString (doc, root_node->children, TRUE);
+ number = gxml_dom_element_content_to_string (root_elem);
if (number == NULL || *number == '\0') {
- xmlFree (number);
+ g_free (number);
return gdata_parser_error_required_content_missing (root_node, error);
}
- rel = xmlGetProp (root_node, (xmlChar*) "rel");
+ rel = gxml_dom_element_get_attribute (root_elem, "rel");
if (rel != NULL && *rel == '\0') {
- xmlFree (rel);
- xmlFree (number);
+ g_free (rel);
+ g_free (number);
return gdata_parser_error_required_property_missing (root_node, "rel", error);
}
- gdata_gd_phone_number_set_number (GDATA_GD_PHONE_NUMBER (parsable), (gchar*) number);
- priv->uri = (gchar*) xmlGetProp (root_node, (xmlChar*) "uri");
- priv->relation_type = (gchar*) rel;
- priv->label = (gchar*) xmlGetProp (root_node, (xmlChar*) "label");
+ gdata_gd_phone_number_set_number (GDATA_GD_PHONE_NUMBER (parsable), number);
+ priv->uri = gxml_dom_element_get_attribute (root_elem, "uri");
+ priv->relation_type = rel;
+ priv->label = gxml_dom_element_get_attribute (root_elem, "label");
priv->is_primary = primary_bool;
- xmlFree (number);
+ g_free (number);
return TRUE;
}
static gboolean
-parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_data, GError **error)
+parse_xml (GDataParsable *parsable, GXmlDomDocument *doc, GXmlDomXNode *node, gpointer user_data, GError **error)
{
/* Textual content's handled in pre_parse_xml */
- if (node->type != XML_ELEMENT_NODE)
+ if (gxml_dom_xnode_get_node_type (node) != GXML_DOM_NODE_TYPE_ELEMENT)
return TRUE;
return GDATA_PARSABLE_CLASS (gdata_gd_phone_number_parent_class)->parse_xml (parsable, doc, node, user_data, error);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]