cr-declaration

cr-declaration

Synopsis

                    CRStatement;
                    CRDeclaration;
CRDeclaration *     cr_declaration_new                  (CRStatement *a_statement,
                                                         CRString *a_property,
                                                         CRTerm *a_value);
CRDeclaration *     cr_declaration_parse_from_buf       (CRStatement *a_statement,
                                                         const guchar *a_str,
                                                         enum CREncoding a_enc);
CRDeclaration *     cr_declaration_parse_list_from_buf  (const guchar *a_str,
                                                         enum CREncoding a_enc);
CRDeclaration *     cr_declaration_append               (CRDeclaration *a_this,
                                                         CRDeclaration *a_new);
CRDeclaration *     cr_declaration_append2              (CRDeclaration *a_this,
                                                         CRString *a_prop,
                                                         CRTerm *a_value);
CRDeclaration *     cr_declaration_prepend              (CRDeclaration *a_this,
                                                         CRDeclaration *a_new);
CRDeclaration *     cr_declaration_unlink               (CRDeclaration *a_decl);
void                cr_declaration_dump                 (CRDeclaration const *a_this,
                                                         FILE *a_fp,
                                                         glong a_indent,
                                                         gboolean a_one_per_line);
void                cr_declaration_dump_one             (CRDeclaration const *a_this,
                                                         FILE *a_fp,
                                                         glong a_indent);
gint                cr_declaration_nr_props             (CRDeclaration const *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);
gchar *             cr_declaration_to_string            (CRDeclaration const *a_this,
                                                         gulong a_indent);
guchar *            cr_declaration_list_to_string       (CRDeclaration const *a_this,
                                                         gulong a_indent);
guchar *            cr_declaration_list_to_string2      (CRDeclaration const *a_this,
                                                         gulong a_indent,
                                                         gboolean a_one_decl_per_line);
void                cr_declaration_ref                  (CRDeclaration *a_this);
gboolean            cr_declaration_unref                (CRDeclaration *a_this);
void                cr_declaration_destroy              (CRDeclaration *a_this);

Description

Details

CRStatement

typedef struct {
	/**
	 *The type of the statement.
	 */
	enum CRStatementType type ;

	union
	{
		CRRuleSet *ruleset ;
		CRAtImportRule *import_rule ;
		CRAtMediaRule *media_rule ;
		CRAtPageRule *page_rule ;
		CRAtCharsetRule *charset_rule ;
		CRAtFontFaceRule *font_face_rule ;
	} kind ;

        /*
         *the specificity of the selector
         *that matched this statement.
         *This is only used by the cascading
         *order determination algorithm.
         */
        gulong specificity ;

        /*
         *the style sheet that contains
         *this css statement.
         */
        CRStyleSheet *parent_sheet ;
	CRStatement *next ;
	CRStatement *prev ;

        CRParsingLocation location ;

        /**
         *a custom pointer useable by
         *applications that use libcroco.
         *libcroco itself will never modify
         *this pointer.
         */        
        gpointer app_data ;

        /**
         *a custom pointer used
         *by the upper layers of libcroco.
         *application should never use this
         *pointer.
         */
        gpointer croco_data ;
} CRStatement;


CRDeclaration

typedef struct {
	/**The property.*/
	CRString *property ;

	/**The value of the property.*/
	CRTerm *value ;
	
	/*the ruleset that contains this declaration*/
	CRStatement *parent_statement ;

	/*the next declaration*/
	CRDeclaration *next ;

	/*the previous one declaration*/
	CRDeclaration *prev ;

	/*does the declaration have the important keyword ?*/
	gboolean important ;

	glong ref_count ;

	CRParsingLocation location ;
	/*reserved for future usage*/	
	gpointer rfu0 ;	
	gpointer rfu1 ;
	gpointer rfu2 ;
	gpointer rfu3 ;
} CRDeclaration;


cr_declaration_new ()

CRDeclaration *     cr_declaration_new                  (CRStatement *a_statement,
                                                         CRString *a_property,
                                                         CRTerm *a_value);

a_statement :

the statement this declaration belongs to. can be NULL.

a_property :

the property string of the declaration

a_value :

the value expression of the declaration. Constructor of CRDeclaration.

Returns :

the newly built instance of CRDeclaration, or NULL in case of error. The returned CRDeclaration takes ownership of a_property and a_value. (E.g. cr_declaration_destroy on this CRDeclaration will also free a_property and a_value.)

cr_declaration_parse_from_buf ()

CRDeclaration *     cr_declaration_parse_from_buf       (CRStatement *a_statement,
                                                         const guchar *a_str,
                                                         enum CREncoding a_enc);

Parses a text buffer that contains a css declaration.

a_statement :

the parent css2 statement of this this declaration. Must be non NULL and of type RULESET_STMT (must be a ruleset).

a_str :

the string that contains the statement.

a_enc :

the encoding of a_str.

Returns :

the parsed declaration, or NULL in case of error.

cr_declaration_parse_list_from_buf ()

CRDeclaration *     cr_declaration_parse_list_from_buf  (const guchar *a_str,
                                                         enum CREncoding a_enc);

Parses a ';' separated list of properties declaration.

a_str :

the input buffer that contains the list of declaration to parse.

a_enc :

the encoding of a_str

Returns :

the parsed list of declaration, NULL if parsing failed.

cr_declaration_append ()

CRDeclaration *     cr_declaration_append               (CRDeclaration *a_this,
                                                         CRDeclaration *a_new);

Appends a new declaration to the current declarations list.

a_this :

the current declaration list.

a_new :

the declaration to append.

Returns :

the declaration list with a_new appended to it, or NULL in case of error.

cr_declaration_append2 ()

CRDeclaration *     cr_declaration_append2              (CRDeclaration *a_this,
                                                         CRString *a_prop,
                                                         CRTerm *a_value);

Appends a declaration to the current declaration list.

a_this :

the current declaration list.

a_prop :

the property string of the declaration to append.

a_value :

the value of the declaration to append.

Returns :

the list with the new property appended to it, or NULL in case of an error.

cr_declaration_prepend ()

CRDeclaration *     cr_declaration_prepend              (CRDeclaration *a_this,
                                                         CRDeclaration *a_new);

prepends a declaration to the current declaration list.

a_this :

the current declaration list.

a_new :

the declaration to prepend.

Returns :

the list with a_new prepended or NULL in case of error.

cr_declaration_unlink ()

CRDeclaration *     cr_declaration_unlink               (CRDeclaration *a_decl);

Unlinks the declaration from the declaration list. case of a successfull completion, NULL otherwise.

a_decl :

Returns :

a pointer to the unlinked declaration in

cr_declaration_dump ()

void                cr_declaration_dump                 (CRDeclaration const *a_this,
                                                         FILE *a_fp,
                                                         glong a_indent,
                                                         gboolean a_one_per_line);

Dumps a declaration list to a file.

a_this :

the current instance of CRDeclaration.

a_fp :

the destination file.

a_indent :

the number of indentation white char.

a_one_per_line :

whether to put one declaration per line of not .

cr_declaration_dump_one ()

void                cr_declaration_dump_one             (CRDeclaration const *a_this,
                                                         FILE *a_fp,
                                                         glong a_indent);

Dumps the first declaration of the declaration list to a file.

a_this :

the current instance of CRDeclaration.

a_fp :

the destination file.

a_indent :

the number of indentation white char.

cr_declaration_nr_props ()

gint                cr_declaration_nr_props             (CRDeclaration const *a_this);

a_this :

the current instance of CRDeclaration. Return the number of properties in the declaration

Returns :


cr_declaration_get_from_list ()

CRDeclaration *     cr_declaration_get_from_list        (CRDeclaration *a_this,
                                                         int itemnr);

Use an index to get a CRDeclaration from the declaration list.

a_this :

the current instance of CRDeclaration.

itemnr :

the index into the declaration list.

Returns :

CRDeclaration at position itemnr, if itemnr > number of declarations - 1, it will return NULL.

cr_declaration_get_by_prop_name ()

CRDeclaration *     cr_declaration_get_by_prop_name     (CRDeclaration *a_this,
                                                         const guchar *a_str);

Use property name to get a CRDeclaration from the declaration list.

a_this :

the current instance of CRDeclaration.

a_str :

Returns :

CRDeclaration with property name a_prop, or NULL if not found.

cr_declaration_to_string ()

gchar *             cr_declaration_to_string            (CRDeclaration const *a_this,
                                                         gulong a_indent);

Serializes the declaration into a string

a_this :

the current instance of CRDeclaration.

a_indent :

the number of indentation white char to put before the actual serialisation.

Returns :

the serialized form the declaration. The caller must free the string using g_free().

cr_declaration_list_to_string ()

guchar *            cr_declaration_list_to_string       (CRDeclaration const *a_this,
                                                         gulong a_indent);

Serializes the declaration list into a string

a_this :

the current instance of CRDeclaration.

a_indent :

the number of indentation white char to put before the actual serialisation.

Returns :


cr_declaration_list_to_string2 ()

guchar *            cr_declaration_list_to_string2      (CRDeclaration const *a_this,
                                                         gulong a_indent,
                                                         gboolean a_one_decl_per_line);

Serializes the declaration list into a string

a_this :

the current instance of CRDeclaration.

a_indent :

the number of indentation white char

a_one_decl_per_line :

whether to output one doc per line or not. to put before the actual serialisation.

Returns :

the serialized form the declararation.

cr_declaration_ref ()

void                cr_declaration_ref                  (CRDeclaration *a_this);

Increases the ref count of the current instance of CRDeclaration.

a_this :

the current instance of CRDeclaration.

cr_declaration_unref ()

gboolean            cr_declaration_unref                (CRDeclaration *a_this);

Decrements the ref count of the current instance of CRDeclaration. If the ref count reaches zero, the current instance of CRDeclaration if destroyed.

a_this :

the current instance of CRDeclaration.

Returns :

TRUE if a_this was destroyed (ref count reached zero), FALSE otherwise.

cr_declaration_destroy ()

void                cr_declaration_destroy              (CRDeclaration *a_this);

Destructor of the declaration list.

a_this :

the current instance of CRDeclaration.