aboutsummaryrefslogtreecommitdiff
path: root/README.md
blob: bd9ac7bddb0aa1ede529b47e7c4734664a5e5cc0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
libbowl [![][badge]][badge-link]
=======

The last C datastructure library you will ever use. Provides a
versalite API to build nested, serial and hashed structure nodes.

Check out the [issue tracker][issues]

I hope you enjoy ❤

[badge]: https://builds.sr.ht/~spacekookie/libbowl.svg
[badge-link]: https://builds.sr.ht/~spacekookie/libbowl?
[issues]: https://todo.sr.ht/~spacekookie/libbowl

Exampple
--------

The root structure in `libbowl` is a `bowl`. It can either be a leaf
node, containing some data (`bowl_data`, which can be many types),
or be a structure node, either in `ARRAY`, `LINK` or `HASH` mode.

Each `libbowl` function returns a status code and uses reverse-input
pointers to communicate results. A convenience `DEBUG` macro is included.

```C
bowl *list;
int r = bowl_malloc(&list, ARRAY);
if(r) { printf("Failed to malloc!\n"); exit(2); }

// `DEBUG` does the same thing as the above `if`
bowl *number;
DEBUG (data_malloc(&number, INTEGER, 1312))

// Finally append data into list
DEBUG (bowl_append(list, number))
```

Generally, `data` prefixed functions are convenience wrappers around
allocating a `bowl`, setting it's type to `LEAF`, and inserting some
data into it (performing at least 2 allocation calls).

Freeing a `bowl` structure is as easy as calling free on the top node.

```C
// ...
DEBUG (bowl_free(list))
```

How to build
------------

Build dependencies

- gcc (`4.0+`)
- cmake (`2.18+`)

An out-of-source build is recommended. You can specify the linking
behaviour with `-DLINK_DYNAMIC=1`. Optionally you can disable tests
with `-DRUN_TESTS=0`.

```
$ mkdir build; cd build
$ cmake .. -DLINK_DYNAMIC=1 -DRUN_TESTS=1
$ make
```

License
-------

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or (at
your option) any later version.