summaryrefslogtreecommitdiff
path: root/src/core/cdatasection.c
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2007-07-28 14:34:59 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2007-07-28 14:34:59 +0000
commit7cbcc882de7d5747e2342f0829bbcc9f2bcca60f (patch)
treed3fe522992dec910758c2b86d0d02ec9c2d005a9 /src/core/cdatasection.c
parent6d0ecccfcf47341393d66e2379ce82cb8350a20f (diff)
downloadlibdom-7cbcc882de7d5747e2342f0829bbcc9f2bcca60f.tar.gz
libdom-7cbcc882de7d5747e2342f0829bbcc9f2bcca60f.tar.bz2
Sort out somewhat messy object construction.
We now have explicit types for all classes (rather than using the parent class for those which inherit but add no extra data content). svn path=/trunk/dom/; revision=3465
Diffstat (limited to 'src/core/cdatasection.c')
-rw-r--r--src/core/cdatasection.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/core/cdatasection.c b/src/core/cdatasection.c
new file mode 100644
index 0000000..c477dd7
--- /dev/null
+++ b/src/core/cdatasection.c
@@ -0,0 +1,56 @@
+/*
+ * This file is part of libdom.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2007 John-Mark Bell <jmb@netsurf-browser.org>
+ */
+
+#include "core/cdatasection.h"
+#include "core/document.h"
+#include "core/text.h"
+
+/**
+ * A DOM CDATA section
+ */
+struct dom_cdata_section {
+ struct dom_text base; /**< Base node */
+};
+
+/**
+ * Create a CDATA section
+ *
+ * \param doc The owning document
+ * \param name The name of the node to create
+ * \param value The text content of the node
+ * \param result Pointer to location to receive created node
+ * \return DOM_NO_ERR on success,
+ * DOM_NO_MEM_ERR on memory exhaustion.
+ *
+ * ::doc, ::name and ::value will have their reference counts increased.
+ *
+ * The returned node will already be referenced.
+ */
+dom_exception dom_cdata_section_create(struct dom_document *doc,
+ struct dom_string *name, struct dom_string *value,
+ struct dom_cdata_section **result)
+{
+ struct dom_cdata_section *c;
+ dom_exception err;
+
+ /* Allocate the comment node */
+ c = dom_document_alloc(doc, NULL, sizeof(struct dom_cdata_section));
+ if (c == NULL)
+ return DOM_NO_MEM_ERR;
+
+ /* And initialise the node */
+ err = dom_text_initialise(&c->base, doc, DOM_CDATA_SECTION_NODE,
+ name, value);
+ if (err != DOM_NO_ERR) {
+ dom_document_alloc(doc, c, 0);
+ return err;
+ }
+
+ *result = c;
+
+ return DOM_NO_ERR;
+}