libcss
Loading...
Searching...
No Matches
Classes | Macros | Typedefs | Functions
hash.c File Reference
#include <stdio.h>
#include <string.h>
#include <libcss/hint.h>
#include "stylesheet.h"
#include "select/hash.h"
#include "select/mq.h"
#include "utils/utils.h"

Classes

struct  hash_entry
 
struct  hash_t
 
struct  css_selector_hash
 

Macros

#define DEFAULT_SLOTS   (1<<6)
 
#define _hash_name(name)    lwc_string_hash_value(name->insensitive)
 
#define RULE_HAS_BYTECODE(r)    (((css_rule_selector *)(r->sel->rule))->style != NULL)
 

Typedefs

typedef struct hash_entry hash_entry
 
typedef struct hash_t hash_t
 

Functions

css_error css__selector_hash_create (css_selector_hash **hash)
 
css_error css__selector_hash_destroy (css_selector_hash *hash)
 
css_error css__selector_hash_insert (css_selector_hash *hash, const css_selector *selector)
 
css_error css__selector_hash_remove (css_selector_hash *hash, const css_selector *selector)
 
css_error css__selector_hash_find (css_selector_hash *hash, const struct css_hash_selection_requirments *req, css_selector_hash_iterator *iterator, const css_selector ***matched)
 
css_error css__selector_hash_find_by_class (css_selector_hash *hash, const struct css_hash_selection_requirments *req, css_selector_hash_iterator *iterator, const css_selector ***matched)
 
css_error css__selector_hash_find_by_id (css_selector_hash *hash, const struct css_hash_selection_requirments *req, css_selector_hash_iterator *iterator, const css_selector ***matched)
 
css_error css__selector_hash_find_universal (css_selector_hash *hash, const struct css_hash_selection_requirments *req, css_selector_hash_iterator *iterator, const css_selector ***matched)
 
css_error css__selector_hash_size (css_selector_hash *hash, size_t *size)
 

Macro Definition Documentation

◆ _hash_name

#define _hash_name (   name)     lwc_string_hash_value(name->insensitive)

◆ DEFAULT_SLOTS

#define DEFAULT_SLOTS   (1<<6)

◆ RULE_HAS_BYTECODE

#define RULE_HAS_BYTECODE (   r)     (((css_rule_selector *)(r->sel->rule))->style != NULL)

Typedef Documentation

◆ hash_entry

typedef struct hash_entry hash_entry

◆ hash_t

typedef struct hash_t hash_t

Function Documentation

◆ css__selector_hash_create()

css_error css__selector_hash_create ( css_selector_hash **  hash)

Create a hash

Parameters
hashPointer to location to receive result
Returns
CSS_OK on success, appropriate error otherwise

◆ css__selector_hash_destroy()

css_error css__selector_hash_destroy ( css_selector_hash hash)

Destroy a hash

Parameters
hashThe hash to destroy
Returns
CSS_OK on success, appropriate error otherwise

◆ css__selector_hash_find()

css_error css__selector_hash_find ( css_selector_hash hash,
const struct css_hash_selection_requirments req,
css_selector_hash_iterator iterator,
const css_selector ***  matched 
)

Find the first selector that matches name

Parameters
hashHash to search
qnameQualified name to match
iteratorPointer to location to receive iterator function
matchedPointer to location to receive selector
Returns
CSS_OK on success, appropriate error otherwise

If nothing matches, CSS_OK will be returned and **matched == NULL

◆ css__selector_hash_find_by_class()

css_error css__selector_hash_find_by_class ( css_selector_hash hash,
const struct css_hash_selection_requirments req,
css_selector_hash_iterator iterator,
const css_selector ***  matched 
)

Find the first selector that has a class that matches name

Parameters
hashHash to search
nameName to match
iteratorPointer to location to receive iterator function
matchedPointer to location to receive selector
Returns
CSS_OK on success, appropriate error otherwise

If nothing matches, CSS_OK will be returned and **matched == NULL

◆ css__selector_hash_find_by_id()

css_error css__selector_hash_find_by_id ( css_selector_hash hash,
const struct css_hash_selection_requirments req,
css_selector_hash_iterator iterator,
const css_selector ***  matched 
)

Find the first selector that has an ID that matches name

Parameters
hashHash to search
nameName to match
iteratorPointer to location to receive iterator function
matchedPointer to location to receive selector
Returns
CSS_OK on success, appropriate error otherwise

If nothing matches, CSS_OK will be returned and **matched == NULL

◆ css__selector_hash_find_universal()

css_error css__selector_hash_find_universal ( css_selector_hash hash,
const struct css_hash_selection_requirments req,
css_selector_hash_iterator iterator,
const css_selector ***  matched 
)

Find the first universal selector

Parameters
hashHash to search
iteratorPointer to location to receive iterator function
matchedPointer to location to receive selector
Returns
CSS_OK on success, appropriate error otherwise

If nothing matches, CSS_OK will be returned and **matched == NULL

◆ css__selector_hash_insert()

css_error css__selector_hash_insert ( css_selector_hash hash,
const css_selector selector 
)

Insert an item into a hash

Parameters
hashThe hash to insert into
selectorPointer to selector
Returns
CSS_OK on success, appropriate error otherwise

◆ css__selector_hash_remove()

css_error css__selector_hash_remove ( css_selector_hash hash,
const css_selector selector 
)

Remove an item from a hash

Parameters
hashThe hash to remove from
selectorPointer to selector
Returns
CSS_OK on success, appropriate error otherwise

◆ css__selector_hash_size()

css_error css__selector_hash_size ( css_selector_hash hash,
size_t *  size 
)

Determine the memory-resident size of a hash

Parameters
hashHash to consider
sizePointer to location to receive byte count
Returns
CSS_OK on success.
Note
The returned size will represent the size of the hash datastructures, and will not include the size of the data stored in the hash.