diff options
author | John Mark Bell <jmb@netsurf-browser.org> | 2007-07-26 22:19:48 +0000 |
---|---|---|
committer | John Mark Bell <jmb@netsurf-browser.org> | 2007-07-26 22:19:48 +0000 |
commit | 4aa51a22bf3e600ed7d8fde4a7ca60bc2ecca02b (patch) | |
tree | 07ad40b1cb4623ecd3d1d7df5be0cc5211156fec /src/core/characterdata.c | |
parent | d208ad37e9dea0e3854e70eef40e33716c54aff0 (diff) | |
download | libdom-4aa51a22bf3e600ed7d8fde4a7ca60bc2ecca02b.tar.gz libdom-4aa51a22bf3e600ed7d8fde4a7ca60bc2ecca02b.tar.bz2 |
Implement type-specific node constructors and veneer the appropriate Document APIs onto them.
svn path=/trunk/dom/; revision=3463
Diffstat (limited to 'src/core/characterdata.c')
-rw-r--r-- | src/core/characterdata.c | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/src/core/characterdata.c b/src/core/characterdata.c index bfcf6a1..61275b5 100644 --- a/src/core/characterdata.c +++ b/src/core/characterdata.c @@ -9,9 +9,68 @@ #include <dom/core/string.h> #include "core/characterdata.h" +#include "core/document.h" #include "utils/utils.h" /** + * Create a character data node of the given type + * + * \param doc The owning document + * \param type The type of node to create + * \param name The node name, or NULL + * \param value The node value, or NULL + * \param result Pointer to location to receive created node + * \return DOM_NO_ERR on success, appropriate error otherwise + * + * ::doc, ::name and ::value will have their reference counts increased. + * + * The created node will already be referenced. + */ +dom_exception dom_characterdata_create(struct dom_document *doc, + dom_node_type type, struct dom_string *name, + struct dom_string *value, struct dom_characterdata **result) +{ + struct dom_characterdata *cdata; + dom_exception err; + + /* Allocate object */ + cdata = dom_document_alloc(doc, NULL, + sizeof(struct dom_characterdata)); + if (cdata == NULL) + return DOM_NO_MEM_ERR; + + /* Initialise node contents */ + err = dom_characterdata_initialise(cdata, doc, type, name, value); + if (err != DOM_NO_ERR) { + dom_document_alloc(doc, cdata, 0); + return err; + } + + *result = cdata; + + return DOM_NO_ERR; +} + +/** + * Initialise a character data node + * + * \param node The node to initialise + * \param doc The document which owns the node + * \param type The node type required + * \param name The node name, or NULL + * \param value The node value, or NULL + * \return DOM_NO_ERR on success. + * + * ::doc, ::name and ::value will have their reference counts increased. + */ +dom_exception dom_characterdata_initialise(struct dom_characterdata *cdata, + struct dom_document *doc, dom_node_type type, + struct dom_string *name, struct dom_string *value) +{ + return dom_node_initialise(&cdata->base, doc, type, name, value); +} + +/** * Retrieve data from a character data node * * \param cdata Character data node to retrieve data from |