summaryrefslogtreecommitdiffstats
path: root/libcnary/include
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2011-06-13 18:30:37 +0200
committerGravatar Nikias Bassen2011-06-13 18:30:37 +0200
commitc7412d4813ccb994fdd219f421eaba8bb37831dd (patch)
tree5b7f3016ceb337b31afdd62c9fee646f33e8b271 /libcnary/include
parent3277a11f0beedda8b5d65ffccb05fabd4e8ded28 (diff)
downloadlibplist-c7412d4813ccb994fdd219f421eaba8bb37831dd.tar.gz
libplist-c7412d4813ccb994fdd219f421eaba8bb37831dd.tar.bz2
Bundle libcnary for better packaging1.5
Diffstat (limited to 'libcnary/include')
-rw-r--r--libcnary/include/iterator.h33
-rw-r--r--libcnary/include/list.h24
-rw-r--r--libcnary/include/node.h59
-rw-r--r--libcnary/include/node_iterator.h39
-rw-r--r--libcnary/include/node_list.h31
-rw-r--r--libcnary/include/object.h25
6 files changed, 211 insertions, 0 deletions
diff --git a/libcnary/include/iterator.h b/libcnary/include/iterator.h
new file mode 100644
index 0000000..debc1c5
--- /dev/null
+++ b/libcnary/include/iterator.h
@@ -0,0 +1,33 @@
1/*
2 * iterator.h
3 *
4 * Created on: Mar 8, 2011
5 * Author: posixninja
6 */
7
8#ifndef ITERATOR_H_
9#define ITERATOR_H_
10
11struct list_t;
12struct object_t;
13
14typedef struct iterator_t {
15 struct object_t*(*next)(struct iterator_t* iterator);
16 int(*bind)(struct iterator_t* iterator, struct list_t* list);
17
18 unsigned int count;
19 unsigned int position;
20
21 struct list_t* list;
22 struct object_t* end;
23 struct object_t* begin;
24 struct object_t* value;
25} iterator_t;
26
27void iterator_destroy(struct iterator_t* iterator);
28struct iterator_t* iterator_create(struct list_t* list);
29
30struct object_t* iterator_next(struct iterator_t* iterator);
31int iterator_bind(struct iterator_t* iterator, struct list_t* list);
32
33#endif /* ITERATOR_H_ */
diff --git a/libcnary/include/list.h b/libcnary/include/list.h
new file mode 100644
index 0000000..237aba0
--- /dev/null
+++ b/libcnary/include/list.h
@@ -0,0 +1,24 @@
1/*
2 * list.h
3 *
4 * Created on: Mar 8, 2011
5 * Author: posixninja
6 */
7
8#ifndef LIST_H_
9#define LIST_H_
10
11#include "object.h"
12
13typedef struct list_t {
14 void* next;
15 void* prev;
16} list_t;
17
18void list_init(struct list_t* list);
19void list_destroy(struct list_t* list);
20
21int list_add(struct list_t* list, struct object_t* object);
22int list_remove(struct list_t* list, struct object_t* object);
23
24#endif /* LIST_H_ */
diff --git a/libcnary/include/node.h b/libcnary/include/node.h
new file mode 100644
index 0000000..35f6333
--- /dev/null
+++ b/libcnary/include/node.h
@@ -0,0 +1,59 @@
1/*
2 * node.h
3 *
4 * Created on: Mar 7, 2011
5 * Author: posixninja
6 */
7
8#ifndef NODE_H_
9#define NODE_H_
10
11#include "object.h"
12
13#define NODE_TYPE 1;
14
15struct node_list_t;
16
17// This class implements the abstract iterator class
18typedef struct node_t {
19 // Super class
20 struct node_t* next;
21 struct node_t* prev;
22 unsigned int count;
23
24 // Local Properties
25 int isRoot;
26 int isLeaf;
27
28 // Local Members
29 void *data;
30 unsigned int depth;
31 struct node_t* parent;
32 struct node_list_t* children;
33
34 // Virtual Functions
35 int(*attach)(struct node_t* parent, struct node_t* child);
36 int(*detach)(struct node_t* parent, struct node_t* child);
37
38} node_t;
39
40void node_destroy(struct node_t* node);
41struct node_t* node_create(struct node_t* parent, void* data);
42
43int node_attach(struct node_t* parent, struct node_t* child);
44int node_detach(struct node_t* parent, struct node_t* child);
45int node_insert(struct node_t* parent, unsigned int index, struct node_t* child);
46
47unsigned int node_n_children(struct node_t* node);
48node_t* node_nth_child(struct node_t* node, unsigned int n);
49node_t* node_first_child(struct node_t* node);
50node_t* node_prev_sibling(struct node_t* node);
51node_t* node_next_sibling(struct node_t* node);
52int node_child_position(struct node_t* parent, node_t* child);
53
54typedef void* (*copy_func_t)(const void *src);
55node_t* node_copy_deep(node_t* node, copy_func_t copy_func);
56
57void node_debug(struct node_t* node);
58
59#endif /* NODE_H_ */
diff --git a/libcnary/include/node_iterator.h b/libcnary/include/node_iterator.h
new file mode 100644
index 0000000..8f39ceb
--- /dev/null
+++ b/libcnary/include/node_iterator.h
@@ -0,0 +1,39 @@
1/*
2 * node_iterator.h
3 *
4 * Created on: Mar 8, 2011
5 * Author: posixninja
6 */
7
8#ifndef NODE_ITERATOR_H_
9#define NODE_ITERATOR_H_
10
11#include "iterator.h"
12#include "node_list.h"
13
14// This class implements the abstract iterator class
15typedef struct node_iterator_t {
16 // Super class
17 struct iterator_t super;
18
19 // Local members
20 struct node_t*(*next)(struct node_iterator_t* iterator);
21 int(*bind)(struct node_iterator_t* iterator, struct node_list_t* list);
22
23 unsigned int count;
24 unsigned int position;
25
26 struct node_list_t* list;
27 struct node_t* end;
28 struct node_t* begin;
29 struct node_t* value;
30
31} node_iterator_t;
32
33void node_iterator_destroy(node_iterator_t* iterator);
34node_iterator_t* node_iterator_create(node_list_t* list);
35
36struct node_t* node_iterator_next(struct node_iterator_t* iterator);
37int node_iterator_bind(struct node_iterator_t* iterator, struct node_list_t* list);
38
39#endif /* NODE_ITERATOR_H_ */
diff --git a/libcnary/include/node_list.h b/libcnary/include/node_list.h
new file mode 100644
index 0000000..bb9fcae
--- /dev/null
+++ b/libcnary/include/node_list.h
@@ -0,0 +1,31 @@
1/*
2 * node_list.h
3 *
4 * Created on: Mar 8, 2011
5 * Author: posixninja
6 */
7
8#ifndef NODE_LIST_H_
9#define NODE_LIST_H_
10
11struct node_t;
12
13// This class implements the list_t abstract class
14typedef struct node_list_t {
15 // list_t members
16 struct node_t* begin;
17 struct node_t* end;
18
19 // node_list_t members
20 unsigned int count;
21
22} node_list_t;
23
24void node_list_destroy(struct node_list_t* list);
25struct node_list_t* node_list_create(struct node_t* node);
26
27int node_list_add(node_list_t* list, node_t* node);
28int node_list_insert(node_list_t* list, unsigned int index, node_t* node);
29int node_list_remove(node_list_t* list, node_t* node);
30
31#endif /* NODE_LIST_H_ */
diff --git a/libcnary/include/object.h b/libcnary/include/object.h
new file mode 100644
index 0000000..adf1891
--- /dev/null
+++ b/libcnary/include/object.h
@@ -0,0 +1,25 @@
1/*
2 * object.h
3 *
4 * Created on: Mar 8, 2011
5 * Author: posixninja
6 */
7
8#ifndef OBJECT_H_
9#define OBJECT_H_
10
11#ifndef TRUE
12#define TRUE 1
13#endif
14
15#ifndef FALSE
16#define FALSE 0
17#endif
18
19typedef struct object_t {
20 void* value;
21 unsigned int type;
22 unsigned int size;
23} object_t;
24
25#endif /* OBJECT_H_ */