[libgdata] [core] Tidy up some objects' parsing methods



commit 078e7bda419b5320d55c8d24ec80c545451f5bb1
Author: Philip Withnall <philip tecnocode co uk>
Date:   Wed Mar 24 00:50:48 2010 +0000

    [core] Tidy up some objects' parsing methods

 gdata/atom/gdata-author.c                    |    7 ++-----
 gdata/atom/gdata-generator.c                 |    7 +------
 gdata/gd/gdata-gd-name.c                     |    7 ++-----
 gdata/gd/gdata-gd-phone-number.c             |    7 +------
 gdata/gd/gdata-gd-postal-address.c           |    7 ++-----
 gdata/media/gdata-media-category.c           |    7 +------
 gdata/media/gdata-media-credit.c             |    7 +------
 gdata/services/youtube/gdata-youtube-group.c |    6 ++----
 gdata/services/youtube/gdata-youtube-state.c |    7 +------
 gdata/services/youtube/gdata-youtube-video.c |    7 ++-----
 10 files changed, 15 insertions(+), 54 deletions(-)
---
diff --git a/gdata/atom/gdata-author.c b/gdata/atom/gdata-author.c
index a6378cd..17c0a45 100644
--- a/gdata/atom/gdata-author.c
+++ b/gdata/atom/gdata-author.c
@@ -197,12 +197,9 @@ parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_da
 	    gdata_parser_string_from_element (node, "uri", P_NO_DUPES | P_REQUIRED | P_NON_EMPTY, &(priv->uri), &success, error) == TRUE ||
 	    gdata_parser_string_from_element (node, "email", P_NO_DUPES | P_REQUIRED | P_NON_EMPTY, &(priv->email_address), &success, error) == TRUE) {
 		return success;
-	} else if (GDATA_PARSABLE_CLASS (gdata_author_parent_class)->parse_xml (parsable, doc, node, user_data, error) == FALSE) {
-		/* Error! */
-		return FALSE;
+	} else {
+		return GDATA_PARSABLE_CLASS (gdata_author_parent_class)->parse_xml (parsable, doc, node, user_data, error);
 	}
-
-	return TRUE;
 }
 
 static gboolean
diff --git a/gdata/atom/gdata-generator.c b/gdata/atom/gdata-generator.c
index f9086ff..86cbf1c 100644
--- a/gdata/atom/gdata-generator.c
+++ b/gdata/atom/gdata-generator.c
@@ -185,12 +185,7 @@ parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_da
 	if (node->type != XML_ELEMENT_NODE)
 		return TRUE;
 
-	if (GDATA_PARSABLE_CLASS (gdata_generator_parent_class)->parse_xml (parsable, doc, node, user_data, error) == FALSE) {
-		/* Error! */
-		return FALSE;
-	}
-
-	return TRUE;
+	return GDATA_PARSABLE_CLASS (gdata_generator_parent_class)->parse_xml (parsable, doc, node, user_data, error);
 }
 
 /**
diff --git a/gdata/gd/gdata-gd-name.c b/gdata/gd/gdata-gd-name.c
index 4facd1d..689aeb8 100644
--- a/gdata/gd/gdata-gd-name.c
+++ b/gdata/gd/gdata-gd-name.c
@@ -287,12 +287,9 @@ parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_da
 	    gdata_parser_string_from_element (node, "nameSuffix", P_NO_DUPES, &(priv->suffix), &success, error) == TRUE ||
 	    gdata_parser_string_from_element (node, "fullName", P_NO_DUPES, &(priv->full_name), &success, error) == TRUE) {
 		return success;
-	} else if (GDATA_PARSABLE_CLASS (gdata_gd_name_parent_class)->parse_xml (parsable, doc, node, user_data, error) == FALSE) {
-		/* Error! */
-		return FALSE;
+	} else {
+		return GDATA_PARSABLE_CLASS (gdata_gd_name_parent_class)->parse_xml (parsable, doc, node, user_data, error);
 	}
-
-	return TRUE;
 }
 
 static void
diff --git a/gdata/gd/gdata-gd-phone-number.c b/gdata/gd/gdata-gd-phone-number.c
index 9e9cf04..e7b1252 100644
--- a/gdata/gd/gdata-gd-phone-number.c
+++ b/gdata/gd/gdata-gd-phone-number.c
@@ -284,12 +284,7 @@ parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_da
 	if (node->type != XML_ELEMENT_NODE)
 		return TRUE;
 
-	if (GDATA_PARSABLE_CLASS (gdata_gd_phone_number_parent_class)->parse_xml (parsable, doc, node, user_data, error) == FALSE) {
-		/* Error! */
-		return FALSE;
-	}
-
-	return TRUE;
+	return GDATA_PARSABLE_CLASS (gdata_gd_phone_number_parent_class)->parse_xml (parsable, doc, node, user_data, error);
 }
 
 static void
diff --git a/gdata/gd/gdata-gd-postal-address.c b/gdata/gd/gdata-gd-postal-address.c
index bb524ea..4c21557 100644
--- a/gdata/gd/gdata-gd-postal-address.c
+++ b/gdata/gd/gdata-gd-postal-address.c
@@ -586,12 +586,9 @@ parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_da
 	    gdata_parser_string_from_element (node, "country", P_NO_DUPES, &(priv->country), &success, error) == TRUE ||
 	    gdata_parser_string_from_element (node, "formattedAddress", P_NO_DUPES, &(priv->formatted_address), &success, error) == TRUE) {
 		return success;
-	} else if (GDATA_PARSABLE_CLASS (gdata_gd_postal_address_parent_class)->parse_xml (parsable, doc, node, user_data, error) == FALSE) {
-		/* Error! */
-		return FALSE;
+	} else {
+		return GDATA_PARSABLE_CLASS (gdata_gd_postal_address_parent_class)->parse_xml (parsable, doc, node, user_data, error);
 	}
-
-	return TRUE;
 }
 
 static void
diff --git a/gdata/media/gdata-media-category.c b/gdata/media/gdata-media-category.c
index 98c2e00..6302714 100644
--- a/gdata/media/gdata-media-category.c
+++ b/gdata/media/gdata-media-category.c
@@ -226,12 +226,7 @@ parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_da
 	if (node->type != XML_ELEMENT_NODE)
 		return TRUE;
 
-	if (GDATA_PARSABLE_CLASS (gdata_media_category_parent_class)->parse_xml (parsable, doc, node, user_data, error) == FALSE) {
-		/* Error! */
-		return FALSE;
-	}
-
-	return TRUE;
+	return GDATA_PARSABLE_CLASS (gdata_media_category_parent_class)->parse_xml (parsable, doc, node, user_data, error);
 }
 
 static void
diff --git a/gdata/media/gdata-media-credit.c b/gdata/media/gdata-media-credit.c
index e2e0a7e..04b11c2 100644
--- a/gdata/media/gdata-media-credit.c
+++ b/gdata/media/gdata-media-credit.c
@@ -208,12 +208,7 @@ parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_da
 	if (node->type != XML_ELEMENT_NODE)
 		return TRUE;
 
-	if (GDATA_PARSABLE_CLASS (gdata_media_credit_parent_class)->parse_xml (parsable, doc, node, user_data, error) == FALSE) {
-		/* Error! */
-		return FALSE;
-	}
-
-	return TRUE;
+	return GDATA_PARSABLE_CLASS (gdata_media_credit_parent_class)->parse_xml (parsable, doc, node, user_data, error);
 }
 
 static void
diff --git a/gdata/services/youtube/gdata-youtube-group.c b/gdata/services/youtube/gdata-youtube-group.c
index e5da07e..208195a 100644
--- a/gdata/services/youtube/gdata-youtube-group.c
+++ b/gdata/services/youtube/gdata-youtube-group.c
@@ -94,7 +94,8 @@ parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_da
 	GDataYouTubeGroup *self = GDATA_YOUTUBE_GROUP (parsable);
 
 	if (gdata_parser_object_from_element_setter (node, "content", P_REQUIRED, GDATA_TYPE_YOUTUBE_CONTENT,
-	                                             _gdata_media_group_add_content, self, &success, error) == TRUE) {
+	                                             _gdata_media_group_add_content, self, &success, error) == TRUE ||
+	    gdata_parser_string_from_element (node, "videoid", P_NO_DUPES, &(self->priv->video_id), &success, error) == TRUE) {
 		return success;
 	} else if (xmlStrcmp (node->name, (xmlChar*) "credit") == 0) {
 		/* media:credit */
@@ -135,9 +136,6 @@ parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_da
 		xmlFree (uploaded);
 
 		self->priv->uploaded = uploaded_timeval;
-	} else if (gdata_parser_string_from_element (node, "videoid", P_NO_DUPES, &(self->priv->video_id), &success, error) == TRUE) {
-		/* yt:videoid */
-		return success;
 	} else if (xmlStrcmp (node->name, (xmlChar*) "aspectRatio") == 0) {
 		/* yt:aspectRatio */
 		xmlChar *aspect_ratio = xmlNodeGetContent (node);
diff --git a/gdata/services/youtube/gdata-youtube-state.c b/gdata/services/youtube/gdata-youtube-state.c
index 3d05062..139d95c 100644
--- a/gdata/services/youtube/gdata-youtube-state.c
+++ b/gdata/services/youtube/gdata-youtube-state.c
@@ -214,12 +214,7 @@ parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_da
 	if (node->type != XML_ELEMENT_NODE)
 		return TRUE;
 
-	if (GDATA_PARSABLE_CLASS (gdata_youtube_state_parent_class)->parse_xml (parsable, doc, node, user_data, error) == FALSE) {
-		/* Error! */
-		return FALSE;
-	}
-
-	return TRUE;
+	return GDATA_PARSABLE_CLASS (gdata_youtube_state_parent_class)->parse_xml (parsable, doc, node, user_data, error);
 }
 
 static void
diff --git a/gdata/services/youtube/gdata-youtube-video.c b/gdata/services/youtube/gdata-youtube-video.c
index 390482e..4b9ac81 100644
--- a/gdata/services/youtube/gdata-youtube-video.c
+++ b/gdata/services/youtube/gdata-youtube-video.c
@@ -630,7 +630,8 @@ parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_da
 	if (gdata_parser_object_from_element (node, "group", P_REQUIRED | P_NO_DUPES, GDATA_TYPE_YOUTUBE_GROUP,
 	                                      &(self->priv->media_group), &success, error) == TRUE ||
 	    gdata_parser_object_from_element (node, "control", P_REQUIRED | P_NO_DUPES, GDATA_TYPE_YOUTUBE_CONTROL,
-	                                      &(self->priv->youtube_control), &success, error) == TRUE) {
+	                                      &(self->priv->youtube_control), &success, error) == TRUE ||
+	    gdata_parser_string_from_element (node, "location", P_NONE, &(self->priv->location), &success, error) == TRUE) {
 		return success;
 	} else if (xmlStrcmp (node->name, (xmlChar*) "rating") == 0) {
 		/* gd:rating */
@@ -710,10 +711,6 @@ parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_da
 		favorite_count = xmlGetProp (node, (xmlChar*) "favoriteCount");
 		self->priv->favorite_count = (favorite_count != NULL) ? strtoul ((gchar*) favorite_count, NULL, 10) : 0;
 		xmlFree (favorite_count);
-	} else if (xmlStrcmp (node->name, (xmlChar*) "location") == 0) {
-		/* yt:location */
-		g_free (self->priv->location);
-		self->priv->location = (gchar*) xmlNodeListGetString (doc, node->children, TRUE);
 	} else if (xmlStrcmp (node->name, (xmlChar*) "noembed") == 0) {
 		/* yt:noembed */
 		/* Ignore this now; it's been superceded by yt:accessControl.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]