tobogganSe connecter

packages

The Louise packages, each released on its own

Clone avec HTTPS, un jeton personnel en mot de passe, ou avec SSH, une clé ajoutée dans vos paramètres.

81 lignes · 3154 octetsBrut · Historique
1/* The StringZilla subset Louise binds (packages/stringzilla), in the
2 * dialect `louise bindgen` reads: plain C99 types, a string is a
3 * `const char *` followed by its length, offsets are `int64_t` (-1: not
4 * found), and the sort's state is an opaque struct with a finalizer.
5 * StringZilla's own headers are not bindgen input: their declarations
6 * rely on macros (`SZ_DYNAMIC`) and typedefs (`sz_cptr_t`), and `sz_find`
7 * returns a pointer, which bindings cannot convert.
8 *
9 * Implemented by api.c over the vendored StringZilla (vendor/); the
10 * bindings are generated from this file and checked in:
11 *
12 * louise bindgen csrc/api.h --lse src/bindings.lse --c csrc/bindings.c
13 */
14#ifndef LOUISE_STRINGZILLA_API_H
15#define LOUISE_STRINGZILLA_API_H
16
17#include <stdbool.h>
18#include <stddef.h>
19#include <stdint.h>
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
25/* The byte offset of `needle`'s first occurrence in `haystack`, or -1.
26 * An empty needle matches at 0. */
27int64_t szl_find(const char *haystack, size_t haystack_len, const char *needle, size_t needle_len);
28
29/* The byte offset of `needle`'s last occurrence in `haystack`, or -1.
30 * An empty needle matches at `haystack_len`. */
31int64_t szl_rfind(const char *haystack, size_t haystack_len, const char *needle, size_t needle_len);
32
33/* The non-overlapping occurrences of `needle` in `haystack`; an empty
34 * needle matches at every gap: `haystack_len + 1`. */
35size_t szl_count(const char *haystack, size_t haystack_len, const char *needle, size_t needle_len);
36
37/* The byte offset of the first byte of `s` equal to `byte`, or -1. */
38int64_t szl_find_byte(const char *s, size_t len, uint8_t byte);
39
40/* The byte offset of the last byte of `s` equal to `byte`, or -1. */
41int64_t szl_rfind_byte(const char *s, size_t len, uint8_t byte);
42
43/* `a` against `b`, byte-wise: -1, 0 or 1. */
44int szl_order(const char *a, size_t a_len, const char *b, size_t b_len);
45
46/* The low 63 bits of StringZilla's 64-bit hash of `s` with `seed`. */
47int64_t szl_hash(const char *s, size_t len, int64_t seed);
48
49/* The low 63 bits of StringZilla's byte-sum sketch of `s`. */
50int64_t szl_bytesum(const char *s, size_t len);
51
52/* The vendored StringZilla's version: "major.minor.patch". */
53const char *szl_version(void);
54
55/* The SIMD tiers in use on this machine, e.g. "serial,westmere,haswell". */
56const char *szl_capabilities(void);
57
58/* Sorting a set of strings by bytes (`sz_sequence_argsort`). The pushed
59 * strings are copied; the copies live until the finalizer. */
60typedef struct szl_sort szl_sort;
61szl_sort *szl_sort_new(void);
62void szl_sort_free(szl_sort *s);
63
64/* Appends a copy of `text`; false if out of memory. */
65bool szl_sort_push(szl_sort *s, const char *text, size_t text_len);
66
67/* How many strings were pushed. */
68size_t szl_sort_count(const szl_sort *s);
69
70/* Sorts the pushed strings; false if out of memory. */
71bool szl_sort_argsort(szl_sort *s);
72
73/* The pushed index of the `i`-th smallest string. Unchecked: `i` must be
74 * below szl_sort_count(s), and szl_sort_argsort must have run. */
75int64_t szl_sort_order(const szl_sort *s, size_t i);
76
77#ifdef __cplusplus
78}
79#endif
80
81#endif /* LOUISE_STRINGZILLA_API_H */