From cb6a50718eeb9ea9ad59fbbd793c44d9d4519860 Mon Sep 17 00:00:00 2001 From: Dodji Seketeli Date: Sat, 14 Feb 2004 00:32:34 +0000 Subject: applied a patch from Rob BUIS that adds these api entry 2004-02-14 Dodji Seketeli * 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 that adds these api entry points. --- ChangeLog | 9 ++++++++ src/cr-declaration.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++ src/cr-declaration.h | 9 ++++++++ 3 files changed, 77 insertions(+) diff --git a/ChangeLog b/ChangeLog index f772e5d..1b5a973 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2004-02-14 Dodji Seketeli + + * 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 that adds + these api entry points. + 2004-02-13 Dodji Seketeli * 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 @@ -602,6 +602,65 @@ cr_declaration_to_string (CRDeclaration *a_this, 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. + */ +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) ; -- cgit v1.2.1