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-4ec61c2eb062f73d8e310a339dc0172e6fd4f1ec.tar.gz
libplist-4ec61c2eb062f73d8e310a339dc0172e6fd4f1ec.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 @@
+/*
+ * iterator.h
+ *
+ * Created on: Mar 8, 2011
+ * Author: posixninja
+ */
+
+#ifndef ITERATOR_H_
+#define ITERATOR_H_
+
+struct list_t;
+struct object_t;
+
+typedef struct iterator_t {
+ struct object_t*(*next)(struct iterator_t* iterator);
+ int(*bind)(struct iterator_t* iterator, struct list_t* list);
+
+ unsigned int count;
+ unsigned int position;
+
+ struct list_t* list;
+ struct object_t* end;
+ struct object_t* begin;
+ struct object_t* value;
+} iterator_t;
+
+void iterator_destroy(struct iterator_t* iterator);
+struct iterator_t* iterator_create(struct list_t* list);
+
+struct object_t* iterator_next(struct iterator_t* iterator);
+int iterator_bind(struct iterator_t* iterator, struct list_t* list);
+
+#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 @@
+/*
+ * list.h
+ *
+ * Created on: Mar 8, 2011
+ * Author: posixninja
+ */
+
+#ifndef LIST_H_
+#define LIST_H_
+
+#include "object.h"
+
+typedef struct list_t {
+ void* next;
+ void* prev;
+} list_t;
+
+void list_init(struct list_t* list);
+void list_destroy(struct list_t* list);
+
+int list_add(struct list_t* list, struct object_t* object);
+int list_remove(struct list_t* list, struct object_t* object);
+
+#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 @@
+/*
+ * node.h
+ *
+ * Created on: Mar 7, 2011
+ * Author: posixninja
+ */
+
+#ifndef NODE_H_
+#define NODE_H_
+
+#include "object.h"
+
+#define NODE_TYPE 1;
+
+struct node_list_t;
+
+// This class implements the abstract iterator class
+typedef struct node_t {
+ // Super class
+ struct node_t* next;
+ struct node_t* prev;
+ unsigned int count;
+
+ // Local Properties
+ int isRoot;
+ int isLeaf;
+
+ // Local Members
+ void *data;
+ unsigned int depth;
+ struct node_t* parent;
+ struct node_list_t* children;
+
+ // Virtual Functions
+ int(*attach)(struct node_t* parent, struct node_t* child);
+ int(*detach)(struct node_t* parent, struct node_t* child);
+
+} node_t;
+
+void node_destroy(struct node_t* node);
+struct node_t* node_create(struct node_t* parent, void* data);
+
+int node_attach(struct node_t* parent, struct node_t* child);
+int node_detach(struct node_t* parent, struct node_t* child);
+int node_insert(struct node_t* parent, unsigned int index, struct node_t* child);
+
+unsigned int node_n_children(struct node_t* node);
+node_t* node_nth_child(struct node_t* node, unsigned int n);
+node_t* node_first_child(struct node_t* node);
+node_t* node_prev_sibling(struct node_t* node);
+node_t* node_next_sibling(struct node_t* node);
+int node_child_position(struct node_t* parent, node_t* child);
+
+typedef void* (*copy_func_t)(const void *src);
+node_t* node_copy_deep(node_t* node, copy_func_t copy_func);
+
+void node_debug(struct node_t* node);
+
+#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 @@
+/*
+ * node_iterator.h
+ *
+ * Created on: Mar 8, 2011
+ * Author: posixninja
+ */
+
+#ifndef NODE_ITERATOR_H_
+#define NODE_ITERATOR_H_
+
+#include "iterator.h"
+#include "node_list.h"
+
+// This class implements the abstract iterator class
+typedef struct node_iterator_t {
+ // Super class
+ struct iterator_t super;
+
+ // Local members
+ struct node_t*(*next)(struct node_iterator_t* iterator);
+ int(*bind)(struct node_iterator_t* iterator, struct node_list_t* list);
+
+ unsigned int count;
+ unsigned int position;
+
+ struct node_list_t* list;
+ struct node_t* end;
+ struct node_t* begin;
+ struct node_t* value;
+
+} node_iterator_t;
+
+void node_iterator_destroy(node_iterator_t* iterator);
+node_iterator_t* node_iterator_create(node_list_t* list);
+
+struct node_t* node_iterator_next(struct node_iterator_t* iterator);
+int node_iterator_bind(struct node_iterator_t* iterator, struct node_list_t* list);
+
+#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 @@
+/*
+ * node_list.h
+ *
+ * Created on: Mar 8, 2011
+ * Author: posixninja
+ */
+
+#ifndef NODE_LIST_H_
+#define NODE_LIST_H_
+
+struct node_t;
+
+// This class implements the list_t abstract class
+typedef struct node_list_t {
+ // list_t members
+ struct node_t* begin;
+ struct node_t* end;
+
+ // node_list_t members
+ unsigned int count;
+
+} node_list_t;
+
+void node_list_destroy(struct node_list_t* list);
+struct node_list_t* node_list_create(struct node_t* node);
+
+int node_list_add(node_list_t* list, node_t* node);
+int node_list_insert(node_list_t* list, unsigned int index, node_t* node);
+int node_list_remove(node_list_t* list, node_t* node);
+
+#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 @@
+/*
+ * object.h
+ *
+ * Created on: Mar 8, 2011
+ * Author: posixninja
+ */
+
+#ifndef OBJECT_H_
+#define OBJECT_H_
+
+#ifndef TRUE
+#define TRUE 1
+#endif
+
+#ifndef FALSE
+#define FALSE 0
+#endif
+
+typedef struct object_t {
+ void* value;
+ unsigned int type;
+ unsigned int size;
+} object_t;
+
+#endif /* OBJECT_H_ */