|
|
#define | STR(__s) ((struct str) {.hd=__s, .length=sizeof(__s) - 1}) |
| | Static string declaration convenience.
|
| |
| #define | empty(T) |
| | Get the empty value for type T.
|
| |
| #define | next(iter) |
| | Return the next value of ITER.
|
| |
| #define | len(iter) |
| | Read length of ITER.
|
| |
| #define | hd(iter) |
| | Get the underyling "value" of ITER.
|
| |
| #define | done(iter) |
| | Free dynamically allocated ITER.
|
| |
| #define | insert(iter, value) |
| | Return the next value of ITER.
|
| |
| #define | filter(iter, f) |
| | Filter out all elements in ITER that don't pass F.
|
| |
| #define | map(iter, f) |
| | F(x) for x in ITER. Memory semantics specific to each struct.
|
| |
| #define | split(iter, match, f) |
| | Reduce INIT with each x in ITER in the callback F.
|
| |
|
|
int | min (int a, int b) |
| | Get min of A, B, ...
|
| |
|
int | max (int a, int b) |
| | max function
|
| |
|
struct str | str (const char *fmt,...) |
| | Malloc a char buffer from the format string FMT and wrap it in the returned str.
|
| |
|
struct str | strn (char *hd, size_t length) |
| | Move HD of length LENGTH into a struct str.
|
| |
|
struct str | __str_next (struct str s) |
| | Offset string S buffer pointer by 1.
|
| |
| size_t | __str_len (struct str s) |
| | Read S string length.
|
| |
|
char * | __str_get (struct str s) |
| | Get the pointer to the backing byte buffer in S. This is optional for callers because you can just access s.val directly.
|
| |
|
bool | __str_done (struct str s) |
| | Cleanup dynamically allocated string S.
|
| |
|
bool | __str_insert (struct str s, char ch) |
| | Appends char CH directly to S's buffer if IS_MUTABLE. Otherwise, return a copy of S.
|
| |
|
struct str | __str_filter (struct str s, bool f(int c, uint i)) |
| | For each char C at index I in S, include C in the returned S if F(C, I) = true.
|
| |
|
struct str | __str_map (struct str s, int f(int c)) |
| | Map each char C in S to new char F(C).
|
| |
|
struct str * | __str_split (struct str s, struct str m, size_t *n) |
| | Split S against matches of M into N elements.
|
| |
|
struct str | __str_slice (const struct str s, uint start, uint end) |
| | Get back S[START:END] (end is exclusive index)
|
| |
|
char * | __str_to_string (const struct str s) |
| |
|
struct list * | __list_next (struct list *ls) |
| | Get the next node in the list in LS, if it exists.
|
| |
|
size_t | __list_len (struct list *ls) |
| | Compute number of element in list LS.
|
| |
|
struct str | __list_get (struct list *ls) |
| | Read underlying of node LS.
|
| |
|
bool | __list_done (struct list *ls) |
| | Cleanup dynamically allocated list LS. This does NOT free the str buffers from the nodes, so YOU are in charge of freeing those.
|
| |
|
bool | __list_insert (struct list *ls, struct str s) |
| | Appends S to the tail end of LS dynamically.
|
| |
| struct list * | __list_filter (struct list **ls, bool f(struct str s, uint i)) |
| | Returns the filtered list head for all nodes that pass F and writes out the head of the reject list to LS.
|
| |
|
struct str | __queue_next (struct queue *q) |
| | Pops the front string of Q.
|
| |
|
size_t | __queue_len (struct queue *q) |
| | Read size of Q;.
|
| |
|
struct str | __queue_get (struct queue *q) |
| | Peek the front string of Q.
|
| |
|
bool | __queue_done (struct queue *q) |
| | Cleanup dynamically allocated Q.
|
| |
|
bool | __queue_insert (struct queue *q, struct str s) |
| | Enqueue S in Q.
|
| |
|
char * | dsnprintf (size_t *n, const char *fmt,...) |
| |
A python-inspired API for general C scripts.