I am looking to implement a multi level data structure which looks like as shown below.
object {
object A {
child {
myChild;
};
child 1 {
mychild;
};
};
object B {
child {
};
};
};
My approach is to implement this using a linked list as shown below.
typedef struct node_s {
struct node_s *next;
struct node_s *first_child;
struct node_s *parent;
char *text;
} node_t;
Converting above list to STAILQ (sys/queue.h linux) will be
typedef struct node_s {
char *text;
....;
} node_t;
typedef struct list_s {
STAILQ_ENTRY(list_s) link;
node_t *first_child;
node_t *parent;
node_t *next;
int level;
} list_t;
typedef STAILQ_HEAD(list_head_s, list_s) list_head_t;
Please suggest if there is any other better way of implementing this other than a linked list or using linked list?