summaryrefslogtreecommitdiffstats
path: root/wv_dom.h
diff options
context:
space:
mode:
Diffstat (limited to 'wv_dom.h')
-rw-r--r--wv_dom.h69
1 files changed, 69 insertions, 0 deletions
diff --git a/wv_dom.h b/wv_dom.h
new file mode 100644
index 0000000..9a2c281
--- /dev/null
+++ b/wv_dom.h
@@ -0,0 +1,69 @@
+#ifndef WV_DOM_H
+#define WV_DOM_H
+
+#include "wv_mem.h"
+
+typedef enum {
+ WV_TAG_UNKNOWN = 0,
+ WV_TAG_DOCUMENT,
+ WV_TAG_HTML,
+ WV_TAG_HEAD,
+ WV_TAG_META,
+ WV_TAG_TITLE,
+ WV_TAG_LINK,
+ WV_TAG_BODY,
+ WV_TAG_HEADER,
+ WV_TAG_H1,
+ WV_TAG_A,
+ WV_TAG_ARTICLE,
+ WV_TAG_UL,
+ WV_TAG_LI,
+ WV_TAG_TIME,
+ WV_TAG_FOOTER,
+ WV_TAG_P
+} wv_tag_id;
+
+typedef enum {
+ WV_NODE_DOCUMENT,
+ WV_NODE_ELEMENT,
+ WV_NODE_TEXT
+} wv_node_type;
+
+struct wv_attr {
+ wv_ref key; /* E.g., "href" */
+ wv_ref val; /* E.g., "/log/vcs-1/" */
+ wv_ref next; /* Next attribute in the list */
+};
+
+struct wv_node {
+ wv_node_type type;
+
+ wv_ref parent;
+ wv_ref first_child;
+ wv_ref last_child;
+ wv_ref prev_sibling;
+ wv_ref next_sibling;
+
+ union {
+ struct {
+ wv_tag_id tag_id;
+ wv_ref attr_head;
+ } element;
+
+ struct {
+ wv_ref str;
+ size_t len;
+ } text;
+ } u;
+};
+
+/* DOM operations */
+wv_ref wv_node_new(struct wv_arena *arena, wv_node_type type);
+void wv_node_append(struct wv_arena *arena, wv_ref parent, wv_ref child);
+
+/* Attribute operations */
+wv_ref wv_attr_get(struct wv_arena *arena, wv_ref node_ref, const char *key_name);
+void wv_attr_set(struct wv_arena *arena, wv_ref node_ref, wv_ref key_str, wv_ref val_str);
+
+#endif /* WV_DOM_H */
+