[libcroco-list] cr-declaration enhancements



Hi,

This time there should be a code attachment :)
Cheers,

Rob.
Index: src/cr-declaration.h
===================================================================
RCS file: /cvs/gnome/libcroco/src/cr-declaration.h,v
retrieving revision 1.6
diff -u -3 -p -p -u -b -r1.6 cr-declaration.h
--- src/cr-declaration.h	14 Feb 2004 00:32:34 -0000	1.6
+++ src/cr-declaration.h	14 Feb 2004 12:16:09 -0000
@@ -112,6 +112,9 @@ cr_declaration_get_by_prop_name (CRDecla
 guchar *
 cr_declaration_to_string (CRDeclaration *a_this,
 			  gulong a_indent) ;
+guchar *
+cr_declaration_list_to_string (CRDeclaration *a_this,
+			  gulong a_indent) ;
 void 
 cr_declaration_ref (CRDeclaration *a_this) ;
 
Index: src/cr-declaration.c
===================================================================
RCS file: /cvs/gnome/libcroco/src/cr-declaration.c,v
retrieving revision 1.8
diff -u -3 -p -p -u -b -r1.8 cr-declaration.c
--- src/cr-declaration.c	14 Feb 2004 00:32:34 -0000	1.8
+++ src/cr-declaration.c	14 Feb 2004 12:16:09 -0000
@@ -603,6 +603,44 @@ cr_declaration_to_string (CRDeclaration 
 }
 
 /**
+ *Serializes the declaration list into a string
+ * param a_this the current instance of #CRDeclaration.
+ * param a_indent the number of indentation white char
+ *to put before the actual serialisation.
+ */
+guchar *
+cr_declaration_list_to_string (CRDeclaration *a_this,
+			  gulong a_indent)
+{
+	CRDeclaration *cur = NULL ;
+	GString *stringue = NULL ;
+	guchar *str = NULL, *result = NULL ;
+
+	g_return_val_if_fail (a_this, NULL) ;
+
+	stringue = g_string_new (NULL) ;
+
+	for (cur = a_this ; cur ; cur = cur->next)
+	{
+		str = cr_declaration_to_string (cur, a_indent) ;
+		if (str)
+		{
+			g_string_append_printf (stringue, "%s;", str) ;
+			g_free (str) ;
+		}
+		else
+			break;
+	}
+	if (stringue && stringue->str)
+	{
+		result = stringue->str ;
+		g_string_free (stringue, FALSE) ;
+	}
+
+	return result ;
+}
+
+/**
  *Return the number of properties in the declaration;
  * param a_this the current instance of #CRDeclaration.
  * return number of properties in the declaration list.
@@ -613,7 +651,7 @@ cr_declaration_nr_props (CRDeclaration *
 	CRDeclaration *cur = NULL ;
 	int nr = 0;
 
-	g_return_if_fail (a_this) ;
+	g_return_val_if_fail (a_this, NULL) ;
 
 	for (cur = a_this ; cur ; cur = cur->next)
 		nr ++;
@@ -633,7 +671,7 @@ cr_declaration_get_from_list (CRDeclarat
 	CRDeclaration *cur = NULL ;
 	int nr = 0;
 
-	g_return_if_fail (a_this) ;
+	g_return_val_if_fail (a_this, 0) ;
 
 	for (cur = a_this ; cur ; cur = cur->next)
 		if (nr++ == itemnr)
@@ -652,8 +690,8 @@ cr_declaration_get_by_prop_name (CRDecla
 {
 	CRDeclaration *cur = NULL ;
 
-	g_return_if_fail (a_this) ;
-	g_return_if_fail (a_prop) ;
+	g_return_val_if_fail (a_this, NULL) ;
+	g_return_val_if_fail (a_prop, NULL) ;
 
 	for (cur = a_this ; cur ; cur = cur->next)
 		if (!strcmp (cur->property->str, a_prop))


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