44 lines
1.0 KiB
C
44 lines
1.0 KiB
C
#ifndef __NODE_H_
|
|
#define __NODE_H_
|
|
|
|
typedef struct node{
|
|
char *name;
|
|
char *type;
|
|
|
|
/** childc keeps track of allocated space,
|
|
not amount of children. For that use
|
|
NOD_NodeChildCount */
|
|
int childc;
|
|
struct node* *childv;
|
|
struct node *parent;
|
|
|
|
void* data;
|
|
|
|
} NOD_Node;
|
|
|
|
#define NOD(x) ((NOD_Node*)x)
|
|
|
|
NOD_Node *NOD_CreateNode(char *name);
|
|
NOD_Node *NOD_CreateNodeEX(char *type, char *name);
|
|
void NOD_DestroyNode(NOD_Node *node);
|
|
void NOD_DestroyNodeBranch(NOD_Node *node);
|
|
|
|
/* Passing a derivative of node will throw
|
|
* a warning if not casted to a NOD_Node pointer,
|
|
* so we're doing doing that
|
|
*/
|
|
|
|
#define NOD_NodeAddChild(x, y) _nod_add_child(NOD(x), NOD(y))
|
|
#define NOD_NodeUnparent(x) _nod_unparent(NOD(x))
|
|
|
|
void _nod_add_child(NOD_Node *parent, NOD_Node *child);
|
|
void _nod_unparent(NOD_Node *child);
|
|
|
|
#define NOD_PrintNodeTree(x) _nod_print_tree(NOD(x))
|
|
#define NOD_NodeChildCount(x) _nod_child_count(NOD(x));
|
|
|
|
void _nod_print_tree(NOD_Node *node);
|
|
int _nod_child_count(NOD_Node *node);
|
|
|
|
#endif // __NODE_H_
|