[gxml] StreamReader: add room on GXml.Element
- From: Daniel Espinosa Ortiz <despinosa src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gxml] StreamReader: add room on GXml.Element
- Date: Tue, 23 Jul 2019 18:48:01 +0000 (UTC)
commit e2c7a3ceb8cbb1e60bb9920c0e926efc82f90417
Author: Daniel Espinosa <esodan gmail com>
Date: Tue Jul 23 13:29:32 2019 -0500
StreamReader: add room on GXml.Element
gxml/Element.vala | 29 +++++++++++++++++++++++++----
gxml/XParser.vala | 5 +++++
2 files changed, 30 insertions(+), 4 deletions(-)
---
diff --git a/gxml/Element.vala b/gxml/Element.vala
index 89d99c2..75bc133 100644
--- a/gxml/Element.vala
+++ b/gxml/Element.vala
@@ -767,22 +767,43 @@ public class GXml.Element : GXml.Node,
* use {@link read_unparsed}.
*/
public bool parse_children { get; set; default = true; }
+
+ private string _unparsed = null;
/**
* Temporally stores, all unparsed children as plain string. See {@link parse_children}.
*
* If it is null, means all children have been already parsed.
*/
- public string unparsed { get; set; }
+ public string unparsed {
+ get {
+ if (read_buffer != null) {
+ return (string) read_buffer.data;
+ }
+ return _unparsed;
+ }
+ set {
+ _unparsed = value;
+ }
+ }
/**
* Parse all children, adding them to current node, stored in {@link unparsed}.
* Once it finish, sets {@link unparsed} to null.
*/
public void read_unparsed () throws GLib.Error {
- if (unparsed == null) return;
var parser = new XParser (this);
- parser.read_child_nodes_string (unparsed);
- unparsed = null;
+ if (unparsed != null) {
+ parser.read_child_nodes_string (unparsed);
+ unparsed = null;
+ }
+ if (read_buffer != null) {
+ parser.read_child_nodes_string ((string) read_buffer.data);
+ read_buffer = null;
+ }
}
+ /**
+ * On memory {@link MemoryOutputStream} with the unparsed
+ * string of the element
+ */
public MemoryOutputStream read_buffer { get; set; }
}
diff --git a/gxml/XParser.vala b/gxml/XParser.vala
index 66dbec9..65d7cd3 100644
--- a/gxml/XParser.vala
+++ b/gxml/XParser.vala
@@ -222,6 +222,11 @@ public class GXml.XParser : GLib.Object, GXml.Parser {
}
}
}
+ public void read_child_nodes_string (string str) throws GLib.Error {
+ tr = new TextReader.for_memory ((char[]) str.data, (int) str.data.length, "/gxml_memory");
+ read_child_nodes (_node);
+ tr = null;
+ }
public void read_child_nodes_stream (GLib.InputStream istream) throws GLib.Error {
var b = new MemoryOutputStream.resizable ();
b.splice (istream, 0);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]