[lasem] dom_parser: add lsm_dom_document_append_from_memory.



commit e25802b24c6f04325f1016eeda6e8d2ad7f4ca59
Author: Emmanuel Pacaud <emmanuel gnome org>
Date:   Mon Apr 9 15:31:34 2012 +0200

    dom_parser: add lsm_dom_document_append_from_memory.

 docs/reference/lasem/Makefile.am        |    1 +
 docs/reference/lasem/lasem-sections.txt |    1 +
 src/lsmdomparser.c                      |   48 +++++++++++++++++++++++++++----
 src/lsmdomparser.h                      |    2 +
 4 files changed, 46 insertions(+), 6 deletions(-)
---
diff --git a/docs/reference/lasem/Makefile.am b/docs/reference/lasem/Makefile.am
index 1482e33..8dacf0e 100644
--- a/docs/reference/lasem/Makefile.am
+++ b/docs/reference/lasem/Makefile.am
@@ -106,6 +106,7 @@ IGNORE_HFILES=\
 	lsmmathmlglyphtableams.h		\
 	lsmmathmlalignmarkelement.h		\
 	lsmmathmlaligngroupelement.h		\
+	lsmmathmlsemanticselement.h		\
 	lsmmathmlitexelement.h			\
 	lsmmathmlutils.h			\
 	lsmmathmllayoututils.h			\
diff --git a/docs/reference/lasem/lasem-sections.txt b/docs/reference/lasem/lasem-sections.txt
index 14dd85c..2ec4d7d 100644
--- a/docs/reference/lasem/lasem-sections.txt
+++ b/docs/reference/lasem/lasem-sections.txt
@@ -95,6 +95,7 @@ LsmDomDocumentCreateFunction
 lsm_dom_implementation_create_document
 lsm_dom_implementation_add_document_create_function
 lsm_dom_implementation_cleanup
+lsm_dom_document_append_from_memory
 lsm_dom_document_new_from_memory
 lsm_dom_document_new_from_path
 lsm_dom_document_new_from_url
diff --git a/src/lsmdomparser.c b/src/lsmdomparser.c
index 8f42734..7177439 100644
--- a/src/lsmdomparser.c
+++ b/src/lsmdomparser.c
@@ -69,7 +69,6 @@ lsm_dom_parser_start_document (void *user_data)
 	LsmDomSaxParserState *state = user_data;
 
 	state->state = STATE;
-	state->document = NULL;
 	state->is_error = FALSE;
 	state->error_depth = 0;
 	state->entities = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, _free_entity);
@@ -263,14 +262,17 @@ typedef enum {
 	LSM_DOM_DOCUMENT_ERROR_INVALID_XML
 } LsmDomDocumentError;
 
-LsmDomDocument *
-lsm_dom_document_new_from_memory (const void *buffer, int size, GError **error)
+static LsmDomDocument *
+_parse_memory (LsmDomDocument *document, LsmDomNode *node,
+	       const void *buffer, int size, GError **error)
 {
 	static LsmDomSaxParserState state;
 
-	g_return_val_if_fail (buffer != NULL, NULL);
-
-	state.document = NULL;
+	state.document = document;
+	if (node != NULL)
+		state.current_node = node;
+	else
+		state.current_node = LSM_DOM_NODE (document);
 
 	if (size < 0)
 		size = strlen (buffer);
@@ -291,6 +293,40 @@ lsm_dom_document_new_from_memory (const void *buffer, int size, GError **error)
 	return state.document;
 }
 
+/**
+ * lsm_dom_document_append_from_memory:
+ * @document: a #LsmDomDocument
+ * @node: a #LsmDomNode
+ * @buffer: a memory buffer holding xml data
+ * @size: size of the xml data, in bytes
+ * @error: an error placeholder
+ *
+ * Append a chunk of xml tree to an existing document. The resulting nodes will be appended to
+ * @node, or to @document if @node == NULL.
+ *
+ * Size set to a negative value indicated an unknow xml data size.
+ */
+
+void
+lsm_dom_document_append_from_memory (LsmDomDocument *document, LsmDomNode *node,
+				     const void *buffer, int size, GError **error)
+{
+	g_return_if_fail (LSM_IS_DOM_DOCUMENT (document));
+	g_return_if_fail (LSM_IS_DOM_NODE (node) || node == NULL);
+	g_return_if_fail (buffer != NULL);
+
+	_parse_memory (document, node, buffer, size, error);
+}
+
+LsmDomDocument *
+lsm_dom_document_new_from_memory (const void *buffer, int size, GError **error)
+{
+	g_return_val_if_fail (buffer != NULL, NULL);
+
+	return _parse_memory (NULL, NULL, buffer, size, error); 
+}
+
+
 static LsmDomDocument *
 lsm_dom_document_new_from_file (GFile *file, GError **error)
 {
diff --git a/src/lsmdomparser.h b/src/lsmdomparser.h
index 5ff6b6c..b47a4d5 100644
--- a/src/lsmdomparser.h
+++ b/src/lsmdomparser.h
@@ -29,6 +29,8 @@
 
 G_BEGIN_DECLS
 
+void 			lsm_dom_document_append_from_memory 	(LsmDomDocument *document, LsmDomNode *node,
+								 const void *buffer, int size, GError **error);
 LsmDomDocument * 	lsm_dom_document_new_from_memory 	(const void *buffer, int size, GError **error);
 LsmDomDocument * 	lsm_dom_document_new_from_path 		(const char *path, GError **error);
 LsmDomDocument * 	lsm_dom_document_new_from_url 		(const char *url, GError **error);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]