aboutsummaryrefslogtreecommitdiff
path: root/include/dtree/eztree.h
blob: a5388319fdd0d1a0e2a4fff438e0091c2ba490ee (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
#ifndef LIBDYNTREE_EZTREE_H
#define LIBDYNTREE_EZTREE_H

#include <dtree/dtree.h>
#include <stdlib.h>

/* Also make sure we're _always_ interpreted as a C file */
#ifdef __cplusplus
extern "C" {
#endif

#define EZTREE_LITERAL   0xA
#define EZTREE_NUMERIC   0xB
#define EZTREE_NESTED    0xC


/**
 * An quick create function for a literal node
 *
 * @param string
 * @return
 */
dtree *eztree_new_literal(const char *string);


/**
 * A quick create function for a number (numeric) node
 * @param num
 * @return
 */
dtree *eztree_new_numeric(const long num);


/**
 * A quick create function for a string key and an arbitrary type value.
 * The value needs to be marked properly or errors might occur.
 *
 * Nested nodes can be passed as values but need to be declared in before. This means
 * that the tree needs to be built bottom-up.
 *
 * @param key
 * @param val
 * @param type
 * @return
 */
dtree *eztree_new_pair(const char *key, void *val, short type);


/**
 * A quick create function for a list node with a certain number of children
 * ready to go. Children will be placed into a bufer that needs to be provided
 * and the new parent will be returned from the function.
 *
 * Provided size needs to be size of the child-buffer or else errors might occur!
 *
 * @param list
 * @param size
 * @return
 */
dtree *eztree_new_list(dtree **list, size_t size);

#ifdef __cplusplus
}
#endif

#endif //LIBDYNTREE_EZTREE_H