[gxml] DOM4: Implemented DomProcessingInstruction
- From: Daniel Espinosa Ortiz <despinosa src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gxml] DOM4: Implemented DomProcessingInstruction
- Date: Mon, 18 Jul 2016 05:45:12 +0000 (UTC)
commit aa863b726d0a92b5be3d7adef0b7c0fee2bf8bd3
Author: Daniel Espinosa <esodan gmail com>
Date: Wed Jul 13 17:22:05 2016 -0500
DOM4: Implemented DomProcessingInstruction
* Added default implementation for DomCharacterData methods
* Simplified DomComment implementation by GComment
* Implemented DomProcessingInstruction on GProcessingInstruction
* Implemented DomText on GText
This is a work in progress, it doesn't compile at all.
At this point start build fixes
gxml/DomCharacter.vala | 35 +++++++++++++++++++++++++++++------
gxml/GXmlComment.vala | 30 +-----------------------------
gxml/GXmlProcessingInstruction.vala | 21 ++++++++++++++++++---
gxml/GXmlText.vala | 11 ++++++++++-
4 files changed, 58 insertions(+), 39 deletions(-)
---
diff --git a/gxml/DomCharacter.vala b/gxml/DomCharacter.vala
index 50bb76c..d2f897d 100644
--- a/gxml/DomCharacter.vala
+++ b/gxml/DomCharacter.vala
@@ -25,12 +25,35 @@ public interface GXml.DomCharacterData : GLib.Object, GXml.DomNode, GXml.DomNonD
* Null is an empty string.
*/
public abstract string data { get; set; }
- public abstract ulong length { get; }
- public abstract string substring_data (ulong offset, ulong count) throws GLib.Error;
- public abstract void append_data (string data);
- public abstract void insert_data (ulong offset, string data) throws GLib.Error;
- public abstract void delete_data (ulong offset, ulong count) throws GLib.Error;
- public abstract void replace_data (ulong offset, ulong count, string data) throws GLib.Error;
+
+ public virtual ulong length { get { return this.data.length; } }
+ public virtual string substring_data (ulong offset, ulong count) throws GLib.Error {
+ if (((int)offset) > this.data.length)
+ throw new DomError.INDEX_SIZE_ERROR (_("Invalid offset for substring"));
+ int c = (int) count;
+ if (c > this.data.length) c = this.data.length;
+ return this.data[(int)offset:(int)c];
+ }
+ public virtual void append_data (string data) {
+ this.data += data;
+ }
+ public virtual void insert_data (ulong offset, string data) throws GLib.Error {
+ replace_data (offset, 0, data);
+ }
+ public virtual void delete_data (ulong offset, ulong count) throws GLib.Error {
+ replace_data (offset, count, "");
+ }
+ public virtual void replace_data (ulong offset, ulong count, string data) throws GLib.Error {
+ if (((int)offset) > this.data.length)
+ throw new DomError.INDEX_SIZE_ERROR (_("Invalid offset for replace data"));
+ int c = (int) count;
+ if (((int)offset + c) > str.length) c = str.length - (int)offset;
+
+ string s = this.data[0:(int)offset];
+ string s2 = this.data[0:(s.length - (int)offset - c)];
+ string sr = data[0:(int)count];
+ str = s+sr+s2;
+ }
}
public interface GXml.DomText : GXml.DomCharacterData {
diff --git a/gxml/GXmlComment.vala b/gxml/GXmlComment.vala
index 77a3175..3fa02ff 100644
--- a/gxml/GXmlComment.vala
+++ b/gxml/GXmlComment.vala
@@ -38,7 +38,7 @@ public class GXml.GComment : GXml.GNode, GXml.Comment, GXml.DomCharacterData, GX
}
// GXml.Comment
public string str { owned get { return base.value; } }
-
+ // GXml.DomCharacterData
public string data {
get {
return str;
@@ -47,32 +47,4 @@ public class GXml.GComment : GXml.GNode, GXml.Comment, GXml.DomCharacterData, GX
str = value;
}
}
- public ulong length { get { return str.length; } }
- public string substring_data (ulong offset, ulong count) throws GLib.Error {
- if (((int)offset) > str.length)
- throw new DomError.INDEX_SIZE_ERROR (_("Invalid offset for substring"));
- int c = (int) count;
- if (c > str.length) c = str.length;
- return str[(int)offset:(int)c];
- }
- public void append_data (string data) {
- str += data;
- }
- public void insert_data (ulong offset, string data) throws GLib.Error {
- replace_data (offset, 0, data);
- }
- public void delete_data (ulong offset, ulong count) throws GLib.Error {
- replace_data (offset, count, "");
- }
- public void replace_data (ulong offset, ulong count, string data) throws GLib.Error {
- if (((int)offset) > str.length)
- throw new DomError.INDEX_SIZE_ERROR (_("Invalid offset for replace data"));
- int c = (int) count;
- if (((int)offset + c) > str.length) c = str.length - (int)offset;
-
- string s = str[0:(int)offset];
- string s2 = str[0:(s.length - (int)offset - c)];
- string sr = data[0:(int)count];
- str = s+sr+s2;
- }
}
diff --git a/gxml/GXmlProcessingInstruction.vala b/gxml/GXmlProcessingInstruction.vala
index 54e5665..b911a95 100644
--- a/gxml/GXmlProcessingInstruction.vala
+++ b/gxml/GXmlProcessingInstruction.vala
@@ -24,7 +24,9 @@ using Gee;
/**
* Class implemeting {@link GXml.ProcessingInstruction} interface, not tied to libxml-2.0 library.
*/
-public class GXml.GProcessingInstruction : GXml.GNode, GXml.ProcessingInstruction
+public class GXml.GProcessingInstruction : GXml.GNode,
+ GXml.ProcessingInstruction, GXml.DomCharacterData,
+ GXml.DomProcessingInstruction
{
public GProcessingInstruction (GDocument doc, Xml.Node *node)
{
@@ -32,6 +34,19 @@ public class GXml.GProcessingInstruction : GXml.GNode, GXml.ProcessingInstructio
_doc = doc;
}
// GXml.ProcessingInstruction
- public string target { owned get { return name; } }
- public string data { owned get { return base.value; } }
+ public string GXml.ProcessingInstruction.target { owned get { return name; } }
+ public string GXml.ProcessingInstruction.data { owned get { return base.value; } }
+ // GXml.DomCharacterData
+ public string GXml.DomCharacterData.data {
+ get {
+ return (this as GXml.ProcessingInstruction).value;
+ }
+ set {
+ (this as GXml.ProcessingInstruction).value = value;
+ }
+ }
+ // GXml.DomProcessingInstruction
+ public string GXml.DomProcessingInstruction.target {
+ owned get { return (this as GXml.ProcessingInstruction).name; }
+ }
}
diff --git a/gxml/GXmlText.vala b/gxml/GXmlText.vala
index 2dc07ab..a3bcae4 100644
--- a/gxml/GXmlText.vala
+++ b/gxml/GXmlText.vala
@@ -24,7 +24,7 @@ using Gee;
/**
* Class implemeting {@link GXml.Text} interface, not tied to libxml-2.0 library.
*/
-public class GXml.GText : GXml.GNode, GXml.Text
+public class GXml.GText : GXml.GNode, GXml.Text, GXml.DomCharacterData, GXml.DomText
{
public GText (GDocument doc, Xml.Node *node)
{
@@ -38,4 +38,13 @@ public class GXml.GText : GXml.GNode, GXml.Text
}
// GXml.Text
public string str { owned get { return base.value; } }
+ // GXml.DomCharacterData
+ public string data {
+ get {
+ return str;
+ }
+ set {
+ str = value;
+ }
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]