## ccss_property_t

ccss_property_t

## Functions

ccss_property_t * | (*ccss_property_create_f) ()
void | (*ccss_property_destroy_f) ()
bool | (*ccss_property_convert_f) ()
bool | (*ccss_property_factory_f) ()
bool | (*ccss_property_inherit_f) ()
char * | (*ccss_property_serialize_f) ()
void | ccss_property_init ()

## Types and Values

| ccss_property_class_t
typedef | ccss_property_t
| ccss_property_generic_t
enum | ccss_property_state_t
enum | ccss_property_type_t

## Description

## Functions

### ccss_property_create_f ()

    ccss_property_t *
    (*ccss_property_create_f) (struct ccss_grammar_ const *grammar,
                               CRTerm const *values,
                               void *user_data);

Hook function for instantiating a property.

#### Parameters

grammar | the grammar associated with this property. |
values | libcroco CSS values to parse for the property, see CRTerm. |
user_data | user data passed to property- or function-handler. |

#### Returns

pointer to the allocated property instance or `NULL` if parsing fails.

### ccss_property_destroy_f ()

    void
    (*ccss_property_destroy_f) (ccss_property_t *self);

Hook function for deallocating a property instance.

#### Parameters

self | pointer to property instance. |

### ccss_property_convert_f ()

    bool
    (*ccss_property_convert_f) (ccss_property_t const *self,
                                ccss_property_type_t target,
                                void *value);

Hook function for converting a property instance.

#### Parameters

self | pointer to property instance. |
target | conversion target type, see ccss_property_type_t. |
value | pointer to memory location where to place the converted value. |

#### Returns

`TRUE` if the conversion was successful.

### ccss_property_factory_f ()

    bool
    (*ccss_property_factory_f) (struct ccss_grammar_ const *grammar,
                                struct ccss_block_ *block,
                                char const *name,
                                CRTerm const *values,
                                void *user_data);

Hook function to handle the creation of multiple properties from a single CSS property, e.g. `border'.

#### Parameters

grammar | the grammar associated with this property. |
block | the ccss_block_t the properties will be associated to. |
name | name of the property. |
values | libcroco CSS values to parse for the property, see CRTerm. |
user_data | user data passed to property- or function-handler. |

#### Returns

`TRUE` when sucessful.

### ccss_property_inherit_f ()

    bool
    (*ccss_property_inherit_f) (struct ccss_style_ const *container_style,
                                struct ccss_style_ *style);

Hook function to inherit multi-value properties like `border'.

#### Parameters

container_style | style to inherit from. |
style | style to inherit to. |

#### Returns

`TRUE` if property inheritance could be resolved.

### ccss_property_serialize_f ()

    char *
    (*ccss_property_serialize_f) (ccss_property_t const *self);

Hook function to reformat a property to CSS syntax.

#### Parameters

self | pointer to property instance. |

#### Returns

`TRUE` if property inheritance could be resolved.

### ccss_property_init ()

    void
    ccss_property_init (ccss_property_t *self,
                        ccss_property_class_t const *property_class);

Initializes `self` , needs to be called before the property is registered with ccss.

#### Parameters

self | a ccss_property_t. |
property_class | a ccss_property_class_t vtable. |

## Types and Values

### ccss_property_class_t

    typedef struct {
    	char const			*name;
    	ccss_property_create_f		 create;
    	ccss_property_destroy_f		 destroy;
    	ccss_property_convert_f		 convert;
    	ccss_property_factory_f		 factory;
    	ccss_property_inherit_f		 inherit;
    	ccss_property_serialize_f	 serialize;
    } ccss_property_class_t;

Property interpretation vtable entry.

#### Members

char const *`name`; | property name. |
ccss_property_create_f `create`; | allocation hook, see ccss_property_create_f. |
ccss_property_destroy_f `destroy`; | deallocation hook, see ccss_property_destroy_f. |
ccss_property_convert_f `convert`; | conversion hook, see ccss_property_convert_f. |
ccss_property_factory_f `factory`; | factory hook, see ccss_property_factory_f. |
ccss_property_inherit_f `inherit`; | inherit hook, see ccss_property_inherit_f. |
ccss_property_serialize_f `serialize`; | serialize hook, see ccss_property_serialize_f. |

### ccss_property_t

    typedef struct ccss_property_ ccss_property_t;

This structure has to be embedded at the beginning of every custom property.

### ccss_property_generic_t

    typedef struct {
    	ccss_property_t		 base;

    	char			*name;
    	CRTerm			*values;
    } ccss_property_generic_t;

Implementation of a generic, single-value property.

#### Members

ccss_property_t `base`; | base property. |
char *`name`; | name of the property, e.g. `color`. |
CRTerm *`values`; | linked list of values. |

### enum ccss_property_state_t

This enum must be embedded as first field in every property implementation.

#### Members

CCSS_PROPERTY_STATE_INVALID | error state, invalid property. |
CCSS_PROPERTY_STATE_NONE | property set to `none', switched off. |
CCSS_PROPERTY_STATE_INHERIT | inherit property from container. |
CCSS_PROPERTY_STATE_SET | property is valid and set. |
CCSS_PROPERTY_STATE_ERROR_OVERFLOW | error state, used for bounds checking. |

### enum ccss_property_type_t

Type descriptions for generic properties.

#### Members

CCSS_PROPERTY_TYPE_DOUBLE | property represented by a floating point number. |
CCSS_PROPERTY_TYPE_STRING | property represented by a string. |