## camel-trie camel-trie |

## Synopsis

                        CamelTrie;
    CamelTrie *         camel_trie_new                      (gboolean icase);
    void                camel_trie_free                     (CamelTrie *trie);
    void                camel_trie_add                      (CamelTrie *trie,
                                                             const gchar *pattern,
                                                             gint pattern_id);
    const gchar *       camel_trie_search                   (CamelTrie *trie,
                                                             const gchar *buffer,
                                                             gsize buflen,
                                                             gint *matched_id);

## Description

## Details

### CamelTrie

    typedef struct _CamelTrie CamelTrie;

A trie data structure.

### camel_trie_new ()

    CamelTrie *         camel_trie_new                      (gboolean icase);

Creates a new CamelTrie. If `icase` is `TRUE`, then pattern matching done by the CamelTrie will be case insensitive.

`icase` : | Case sensitivity for the CamelTrie.
Returns : | The newly-created CamelTrie.

### camel_trie_free ()

    void                camel_trie_free                     (CamelTrie *trie);

Frees the memory associated with the CamelTrie `trie`.

`trie` : | The CamelTrie to free.

### camel_trie_add ()

    void                camel_trie_add                      (CamelTrie *trie,
                                                             const gchar *pattern,
                                                             gint pattern_id);

Add a new pattern to the CamelTrie `trie`.

`trie` : | The CamelTrie to add a pattern to.
`pattern` : | The pattern to add.
`pattern_id` : | The id to use for the pattern.

### camel_trie_search ()

    const gchar *       camel_trie_search                   (CamelTrie *trie,
                                                             const gchar *buffer,
                                                             gsize buflen,
                                                             gint *matched_id);

Try to match the string `buffer` with a pattern in `trie`.

`trie` : | The CamelTrie to search in.
`buffer` : | The string to match against a pattern in `trie`.
`buflen` : | The length of `buffer`.
`matched_id` : | An integer address to store the matched pattern id in.
Returns : | The matched pattern, or `NULL` if no pattern is matched.