## ccss_stylesheet_t

ccss_stylesheet_t

## Synopsis

    typedef             ccss_stylesheet_t;
    void                (*ccss_stylesheet_iterator_f)       (ccss_stylesheet_t *self,
                                                             char const *type_name,
                                                             void *user_data);
    enum                ccss_stylesheet_precedence_t;
    void                ccss_stylesheet_destroy             (ccss_stylesheet_t *self);
    ccss_stylesheet_t * ccss_stylesheet_reference           (ccss_stylesheet_t *self);
    unsigned int        ccss_stylesheet_get_reference_count (ccss_stylesheet_t const *self);
    unsigned int        ccss_stylesheet_add_from_buffer     (ccss_stylesheet_t *self,
                                                             char const *buffer,
                                                             size_t size,
                                                             ccss_stylesheet_precedence_t precedence,
                                                             void *user_data);
    unsigned int        ccss_stylesheet_add_from_file       (ccss_stylesheet_t *self,
                                                             char const *css_file,
                                                             ccss_stylesheet_precedence_t precedence,
                                                             void *user_data);
    void                ccss_stylesheet_foreach             (ccss_stylesheet_t *self,
                                                             ccss_stylesheet_iterator_f func,
                                                             void *user_data);
    ccss_style_t *      ccss_stylesheet_query_type          (ccss_stylesheet_t *self,
                                                             char const *type_name);
    ccss_style_t *      ccss_stylesheet_query               (ccss_stylesheet_t *self,
                                                             ccss_node_t *node);
    bool                ccss_stylesheet_unload              (ccss_stylesheet_t *self,
                                                             unsigned int descriptor);
    void                ccss_stylesheet_dump                (ccss_stylesheet_t const *self);

## Description

## Details

### ccss_stylesheet_t

    typedef struct ccss_stylesheet_ ccss_stylesheet_t;

Represents a parsed instance of a stylesheet.

### ccss_stylesheet_iterator_f ()

    void                (*ccss_stylesheet_iterator_f)       (ccss_stylesheet_t *self,
                                                             char const *type_name,
                                                             void *user_data);

Specifies the type of the function passed to `ccss_stylesheet_foreach()`.

`self` : | a ccss_stylesheet_t.
`type_name` : | node type name selectors are available for, e.g. `div'.
`user_data` : | user data passed to ccss_stylesheet_foreach.

### enum ccss_stylesheet_precedence_t

    typedef enum {
    	CCSS_STYLESHEET_USER_AGENT = 0,
    	CCSS_STYLESHEET_USER,
    	CCSS_STYLESHEET_AUTHOR
    } ccss_stylesheet_precedence_t;

See http://www.w3.org/TR/CSS21/cascade.html.

`CCSS_STYLESHEET_USER_AGENT` | the application's intrinsic CSS rules.
`CCSS_STYLESHEET_USER` | CSS rules provided by the user.
`CCSS_STYLESHEET_AUTHOR` | CSS rules provided by the author.

### ccss_stylesheet_destroy ()

    void                ccss_stylesheet_destroy             (ccss_stylesheet_t *self);

Decreases the reference count on `self` by one. If the result is zero, then `self` and all associated resources are freed. See `ccss_stylesheet_reference()`.

`self` : | a ccss_stylesheet_t.

### ccss_stylesheet_reference ()

    ccss_stylesheet_t * ccss_stylesheet_reference           (ccss_stylesheet_t *self);

Increases the reference count on `self` by one. This prevents `self` from being destroyed until a matching call to `ccss_stylesheet_destroy()` is made.

The number of references to a ccss_stylesheet_t can be acquired using `ccss_stylesheet_get_reference_count()`.

`self` : | a ccss_stylesheet_t.
Returns : | the referenced ccss_stylesheet_t.

### ccss_stylesheet_get_reference_count ()

    unsigned int        ccss_stylesheet_get_reference_count (ccss_stylesheet_t const *self);

`self` : | a ccss_stylesheet_t.
Returns : | the current reference count of `self`. If `self` is a nil object, 0 will be returned.

### ccss_stylesheet_add_from_buffer ()

    unsigned int        ccss_stylesheet_add_from_buffer     (ccss_stylesheet_t *self,
                                                             char const *buffer,
                                                             size_t size,
                                                             ccss_stylesheet_precedence_t precedence,
                                                             void *user_data);

Load a CSS file with a given precedence.

`self` : | a ccss_stylesheet_t.
`buffer` : | buffer to parse.
`size` : | size of the buffer.
`precedence` : | see ccss_stylesheet_precedence_t.
`user_data` : | user-data passed to property- and function-handlers.
Returns : | a stylesheet descriptor that can be used to unload the CSS file contents from the stylesheet instance.

### ccss_stylesheet_add_from_file ()

    unsigned int        ccss_stylesheet_add_from_file       (ccss_stylesheet_t *self,
                                                             char const *css_file,
                                                             ccss_stylesheet_precedence_t precedence,
                                                             void *user_data);

Load a CSS file with a given precedence.

`self` : | a ccss_stylesheet_t.
`css_file` : | file to parse.
`precedence` : | see ccss_stylesheet_precedence_t.
`user_data` : | user-data passed to property- and function-handlers.
Returns : | a stylesheet descriptor that can be used to unload the CSS file contents from the stylesheet instance.

### ccss_stylesheet_foreach ()

    void                ccss_stylesheet_foreach             (ccss_stylesheet_t *self,
                                                             ccss_stylesheet_iterator_f func,
                                                             void *user_data);

The iterator function `func` is called for each type in the stylesheet.

`self` : | a ccss_stylesheet_t.
`func` : | a ccss_stylesheet_iterator_f.
`user_data` : | user data to pass to the iterator function.

### ccss_stylesheet_query_type ()

    ccss_style_t *      ccss_stylesheet_query_type          (ccss_stylesheet_t *self,
                                                             char const *type_name);

Query the stylesheet for styling information regarding a type.

`self` : | a ccss_stylesheet_t.
`type_name` : | the type to query for, e.g. `h1'.
Returns : | a ccss_style_t that the results of the query are applied to or `NULL` if the query didn't yield results.

### ccss_stylesheet_query ()

    ccss_style_t *      ccss_stylesheet_query               (ccss_stylesheet_t *self,
                                                             ccss_node_t *node);

Query the stylesheet for styling information regarding a document node and apply the results to a ccss_style_t object.

`self` : | a ccss_stylesheet_t.
`node` : | a ccss_node_t implementation that is used by libccss to retrieve information about the underlying document.
Returns : | a ccss_style_t that the results of the query are applied to or `NULL` if the query didn't yield results.

### ccss_stylesheet_unload ()

    bool                ccss_stylesheet_unload              (ccss_stylesheet_t *self,
                                                             unsigned int descriptor);

Unload a CSS file, buffer or inline style that was loaded into the stylesheet.

`self` : | a ccss_stylesheet_t. `descriptor` descriptor of a part that was loaded.
Returns : | `TRUE` if anything had been unloaded.

### ccss_stylesheet_dump ()

    void                ccss_stylesheet_dump                (ccss_stylesheet_t const *self);

Print informations about the internal state of this object.

`self` : | a ccss_stylesheet_t.