summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog9
-rw-r--r--src/cr-declaration.c59
-rw-r--r--src/cr-declaration.h9
3 files changed, 77 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index f772e5d..1b5a973 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2004-02-14 Dodji Seketeli <dodji@gnome.org>
+
+ * src/cr-declaration.[ch]:
+ (cr_declaration_nr_props),
+ (cr_declaration_get_from_list),
+ (cr_declaration_get_by_prop_name):
+ applied a patch from Rob BUIS<rwlbuis@xs4all.nl> that adds
+ these api entry points.
+
2004-02-13 Dodji Seketeli <dodji@gnome.org>
* src/cr-declaration.c:
diff --git a/src/cr-declaration.c b/src/cr-declaration.c
index aee63a8..925e758 100644
--- a/src/cr-declaration.c
+++ b/src/cr-declaration.c
@@ -603,6 +603,65 @@ cr_declaration_to_string (CRDeclaration *a_this,
}
/**
+ *Return the number of properties in the declaration;
+ *@param a_this the current instance of #CRDeclaration.
+ *@return number of properties in the declaration list.
+ */
+int
+cr_declaration_nr_props (CRDeclaration *a_this)
+{
+ CRDeclaration *cur = NULL ;
+ int nr = 0;
+
+ g_return_if_fail (a_this) ;
+
+ for (cur = a_this ; cur ; cur = cur->next)
+ nr ++;
+ return nr;
+}
+
+/**
+ *Use an index to get a CRDeclaration from the declaration list.
+ *@param a_this the current instance of #CRDeclaration.
+ *@param itemnr the index into the declaration list.
+ *@return CRDeclaration at position itemnr, if itemnr > number of declarations - 1,
+ *it will return NULL.
+ */
+CRDeclaration *
+cr_declaration_get_from_list (CRDeclaration *a_this, int itemnr)
+{
+ CRDeclaration *cur = NULL ;
+ int nr = 0;
+
+ g_return_if_fail (a_this) ;
+
+ for (cur = a_this ; cur ; cur = cur->next)
+ if (nr++ == itemnr)
+ return cur;
+ return NULL;
+}
+
+/**
+ *Use property name to get a CRDeclaration from the declaration list.
+ *@param a_this the current instance of #CRDeclaration.
+ *@param a_prop the property name to search for.
+ *@return CRDeclaration with property name a_prop, or NULL if not found.
+ */
+CRDeclaration *
+cr_declaration_get_by_prop_name (CRDeclaration *a_this, const guchar *a_prop)
+{
+ CRDeclaration *cur = NULL ;
+
+ g_return_if_fail (a_this) ;
+ g_return_if_fail (a_prop) ;
+
+ for (cur = a_this ; cur ; cur = cur->next)
+ if (!strcmp (cur->property->str, a_prop))
+ return cur;
+ return NULL;
+}
+
+/**
*Increases the ref count of the current instance of #CRDeclaration.
*@param a_this the current instance of #CRDeclaration.
*/
diff --git a/src/cr-declaration.h b/src/cr-declaration.h
index c96c551..a423495 100644
--- a/src/cr-declaration.h
+++ b/src/cr-declaration.h
@@ -100,6 +100,15 @@ void
cr_declaration_dump (CRDeclaration *a_this, FILE *a_fp, glong a_indent,
gboolean a_one_per_line) ;
+int
+cr_declaration_nr_props (CRDeclaration *a_this) ;
+
+CRDeclaration *
+cr_declaration_get_from_list (CRDeclaration *a_this, int itemnr) ;
+
+CRDeclaration *
+cr_declaration_get_by_prop_name (CRDeclaration *a_this, const guchar *a_str) ;
+
guchar *
cr_declaration_to_string (CRDeclaration *a_this,
gulong a_indent) ;