ccss_grammar_t

ccss_grammar_t

Synopsis

typedef             ccss_grammar_t;
ccss_grammar_t *    ccss_grammar_create_css             (void);
ccss_grammar_t *    ccss_grammar_create_generic         (void);
void                ccss_grammar_destroy                (ccss_grammar_t *self);
ccss_grammar_t *    ccss_grammar_reference              (ccss_grammar_t *self);
unsigned int        ccss_grammar_get_reference_count    (ccss_grammar_t const *self);
void                ccss_grammar_add_properties         (ccss_grammar_t *self,
                                                         ccss_property_class_t const *properties);
ccss_property_class_t const * ccss_grammar_lookup_property
                                                        (ccss_grammar_t const *self,
                                                         char const *name);
void                ccss_grammar_add_functions          (ccss_grammar_t *self,
                                                         ccss_function_t const *functions);
ccss_function_t const * ccss_grammar_lookup_function    (ccss_grammar_t const *self,
                                                         char const *name);
ccss_stylesheet_t * ccss_grammar_create_stylesheet      (ccss_grammar_t *self);
ccss_stylesheet_t * ccss_grammar_create_stylesheet_from_buffer
                                                        (ccss_grammar_t *self,
                                                         char const *buffer,
                                                         size_t size,
                                                         void *user_data);
ccss_stylesheet_t * ccss_grammar_create_stylesheet_from_file
                                                        (ccss_grammar_t *self,
                                                         char const *css_file,
                                                         void *user_data);
char *              ccss_grammar_invoke_function        (ccss_grammar_t const *self,
                                                         char const *function_name,
                                                         CRTerm const *values,
                                                         void *user_data);

Description

Details

ccss_grammar_t

typedef struct ccss_grammar_ ccss_grammar_t;

Represents a context for the creation of stylesheets of similar kind.


ccss_grammar_create_css ()

ccss_grammar_t *    ccss_grammar_create_css             (void);

Create a new grammar instance that interprets suppported CSS rules.

Grammar objects provide a factory to create stylesheets of the same class.

Returns :

a new ccss_grammar_t instance.

ccss_grammar_create_generic ()

ccss_grammar_t *    ccss_grammar_create_generic         (void);

Create a new grammar instance.

Grammar objects provide a factory to create stylesheets of the same class.

Returns :

a new ccss_grammar_t instance.

ccss_grammar_destroy ()

void                ccss_grammar_destroy                (ccss_grammar_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_grammar_reference().

self :

a ccss_grammar_t.

ccss_grammar_reference ()

ccss_grammar_t *    ccss_grammar_reference              (ccss_grammar_t *self);

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

The number of references to a ccss_grammar_t can be acquired using ccss_grammar_get_reference_count().

self :

a ccss_grammar_t.

Returns :

the referenced ccss_grammar_t.

ccss_grammar_get_reference_count ()

unsigned int        ccss_grammar_get_reference_count    (ccss_grammar_t const *self);

self :

a ccss_grammar_t.

Returns :

the current reference count of self. If self is a nil object, 0 will be returned.

ccss_grammar_add_properties ()

void                ccss_grammar_add_properties         (ccss_grammar_t *self,
                                                         ccss_property_class_t const *properties);

Register a set of custom CSS properties with the grammar.

self :

a ccss_grammar_t.

properties :

Null-terminated array of ccss_property_class_t to register.

ccss_grammar_lookup_property ()

ccss_property_class_t const * ccss_grammar_lookup_property
                                                        (ccss_grammar_t const *self,
                                                         char const *name);

Look up a property handler by name.

self :

a ccss_grammar_t.

name :

name of the property class to look up.

Returns :

the property handler or NULL if not found.

ccss_grammar_add_functions ()

void                ccss_grammar_add_functions          (ccss_grammar_t *self,
                                                         ccss_function_t const *functions);

Register a set of custom css function handlers with the grammar.

self :

a ccss_grammar_t.

functions :

Null-terminated array of ccss_function_t to register.

ccss_grammar_lookup_function ()

ccss_function_t const * ccss_grammar_lookup_function    (ccss_grammar_t const *self,
                                                         char const *name);

Look up a function handler by name.

self :

a ccss_grammar_t.

name :

name of the function handler to look up.

Returns :

the property handler or NULL if not found.

ccss_grammar_create_stylesheet ()

ccss_stylesheet_t * ccss_grammar_create_stylesheet      (ccss_grammar_t *self);

Create an empty stylesheet associated with grammar self.

self :

a ccss_grammar_t.

Returns :

an empty ccss_stylesheet_t.

ccss_grammar_create_stylesheet_from_buffer ()

ccss_stylesheet_t * ccss_grammar_create_stylesheet_from_buffer
                                                        (ccss_grammar_t *self,
                                                         char const *buffer,
                                                         size_t size,
                                                         void *user_data);

Create a new stylesheet instance based on a CSS string.

self :

a ccss_grammar_t.

buffer :

buffer to parse.

size :

size of the buffer.

user_data :

user-data passed to property- and function-handlers.

Returns :

a ccss_stylesheet_t representation of the CSS string.

ccss_grammar_create_stylesheet_from_file ()

ccss_stylesheet_t * ccss_grammar_create_stylesheet_from_file
                                                        (ccss_grammar_t *self,
                                                         char const *css_file,
                                                         void *user_data);

Create a new stylesheet instance based on a CSS file.

self :

a ccss_grammar_t.

css_file :

file to parse.

user_data :

user-data passed to property- and function-handlers.

Returns :

a ccss_stylesheet_t representation of the CSS file.

ccss_grammar_invoke_function ()

char *              ccss_grammar_invoke_function        (ccss_grammar_t const *self,
                                                         char const *function_name,
                                                         CRTerm const *values,
                                                         void *user_data);

Invoke a registerd function handler. This API is meant to be used by property implementations, like when parsing properties like `background-image: url(foo.png)'.

self :

a ccss_grammar_t.

function_name :

name of the function to invoke, e.g. url.

values :

arguments passed to the function handler.

user_data :

user-data passed to the function handler. Overrides the user-data assigned in the function handler's definition.

Returns :

string value passed back by the ccss API consumer.