diff options
author | Nick Wellnhofer <wellnhofer@aevum.de> | 2015-01-19 15:06:14 +0100 |
---|---|---|
committer | Nick Wellnhofer <wellnhofer@aevum.de> | 2015-01-20 18:12:28 +0100 |
commit | 040def592d73c7babf4634a0990e51de1a68d635 (patch) | |
tree | 6f6670ab2871c2ec1ba6ac4244a81790b18ae6ae /src | |
parent | 3f4d605546fc82a3cdce8056790f1bb140a62903 (diff) |
Add user data field for nodes
Diffstat (limited to 'src')
-rw-r--r-- | src/cmark.h | 11 | ||||
-rw-r--r-- | src/node.c | 18 | ||||
-rw-r--r-- | src/node.h | 2 |
3 files changed, 31 insertions, 0 deletions
diff --git a/src/cmark.h b/src/cmark.h index 04ca6d7..74fa4c7 100644 --- a/src/cmark.h +++ b/src/cmark.h @@ -226,6 +226,17 @@ cmark_iter_reset(cmark_iter *iter, cmark_node *current, * ## Accessors */ +/** Returns the user data of 'node'. + */ +CMARK_EXPORT void* +cmark_node_get_user_data(cmark_node *node); + +/** Sets arbitrary user data for 'node'. Returns 1 on success, + * 0 on failure. + */ +CMARK_EXPORT int +cmark_node_set_user_data(cmark_node *node, void *user_data); + /** Returns the type of 'node', or `CMARK_NODE_NONE` on error. */ CMARK_EXPORT cmark_node_type @@ -189,6 +189,24 @@ cmark_node_last_child(cmark_node *node) } } +void* +cmark_node_get_user_data(cmark_node *node) { + if (node == NULL) { + return NULL; + } else { + return node->user_data; + } +} + +int +cmark_node_set_user_data(cmark_node *node, void *user_data) { + if (node == NULL) { + return 0; + } + node->user_data = user_data; + return 1; +} + static char* S_strdup(const char *str) { @@ -49,6 +49,8 @@ struct cmark_node { struct cmark_node *first_child; struct cmark_node *last_child; + void *user_data; + int start_line; int start_column; int end_line; |