[gxml] Added missing files



commit 579af9bbad3e3b3664350846fd0658b042ff34ad
Author: Daniel Espinosa <esodan gmail com>
Date:   Thu Sep 29 13:39:45 2016 -0500

    Added missing files

 gxml/GXPathObject.vala |   56 +++++++++++++++++++++++++++
 gxml/XPath.vala        |   98 ++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 154 insertions(+), 0 deletions(-)
---
diff --git a/gxml/GXPathObject.vala b/gxml/GXPathObject.vala
new file mode 100644
index 0000000..31d4286
--- /dev/null
+++ b/gxml/GXPathObject.vala
@@ -0,0 +1,56 @@
+/* -*- Mode: vala; indent-tabs-mode: t; c-basic-offset: 2; tab-width: 2 -*- */
+/*
+ *
+ * Copyright (C) 2016  Yannick Inizan <inizan yannick gmail com>
+ * Copyright (C) 2016  Daniel Espinosa <esodan gmail com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors:
+ *      Daniel Espinosa <esodan gmail com>
+ */
+
+public class GXml.GXPathObject : GLib.Object, GXml.XPathObject {
+  private GXml.GDomHTMLCollection _collection;
+  private GXml.XPathObjectType _object_type;
+  private bool _boolean_value;
+  private string _string_value;
+  private double _number_value;
+
+  public GXPathObject (GXml.GDocument document, Xml.XPath.Object* pointer) {
+    _collection = new GXml.GDomHTMLCollection();
+
+    _object_type = (GXml.XPathObjectType) pointer->type;
+
+    if (_object_type == GXml.XPathObjectType.NODESET)
+      for (var i = 0; i < pointer->nodesetval->length(); i++)
+        _collection.add (new GXml.GElement (document, pointer->nodesetval->item (i)));
+    else if (_object_type == GXml.XPathObjectType.BOOLEAN)
+      _boolean_value = pointer->boolval == 1;
+    else if (_object_type == GXml.XPathObjectType.STRING)
+      _string_value = pointer->stringval;
+    else if (object_type == GXml.XPathObjectType.NUMBER)
+      _number_value = pointer->floatval;
+  }
+
+  public GXml.XPathObjectType object_type { get { return _object_type; } }
+
+  public bool boolean_value { get { return _boolean_value; } }
+
+  public string string_value { get { return _string_value; } }
+
+  public double number_value { get { return _number_value; } }
+
+  public GXml.DomHTMLCollection nodeset { get { return _collection; } }
+}
diff --git a/gxml/XPath.vala b/gxml/XPath.vala
new file mode 100644
index 0000000..67237cd
--- /dev/null
+++ b/gxml/XPath.vala
@@ -0,0 +1,98 @@
+/* -*- Mode: vala; indent-tabs-mode: t; c-basic-offset: 2; tab-width: 2 -*- */
+/*
+ *
+ * Copyright (C) 2016  Yannick Inizan <inizan yannick gmail com>
+ * Copyright (C) 2016  Daniel Espinosa <esodan gmail com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors:
+ *      Daniel Espinosa <esodan gmail com>
+ */
+public enum GXml.XPathObjectType {
+  UNDEFINED,
+  NODESET,
+  BOOLEAN,
+  NUMBER,
+  STRING,
+  POINT, // unused
+  RANGE, // not implemented
+  LOCATIONSET, // unused
+  USERS, // unused
+  XSLT_TREE // not implemented
+}
+
+public errordomain GXml.XPathError {
+  EXPRESSION_OK,
+  NUMBER_ERROR,
+  UNFINISHED_LITERAL_ERROR,
+  START_LITERAL_ERROR,
+  VARIABLE_REF_ERROR,
+  UNDEF_VARIABLE_ERROR,
+  INVALID_PREDICATE_ERROR,
+  EXPR_ERROR,
+  UNCLOSED_ERROR,
+  UNKNOWN_FUNC_ERROR,
+  INVALID_OPERAND,
+  INVALID_TYPE,
+  INVALID_ARITY,
+  INVALID_CTXT_SIZE,
+  INVALID_CTXT_POSITION,
+  MEMORY_ERROR,
+  XPTR_SYNTAX_ERROR,
+  XPTR_RESOURCE_ERROR,
+  XPTR_SUB_RESOURCE_ERROR,
+  UNDEF_PREFIX_ERROR,
+  ENCODING_ERROR,
+  INVALID_CHAR_ERROR,
+  INVALID_CTXT
+}
+
+public interface GXml.XPathContext : GLib.Object {
+  /**
+   * Evaluate XPath expression.
+   *
+   * This method evaluates provided expression, registers provided namespaces in resolver and returns an 
{@link GXml.XPath.Object}.
+   *
+   * Throw {@link GXml.XPath.Error} if one of provided namespaces is invalid.
+   */
+  public abstract GXml.XPathObject evaluate (string expression,
+                                            Gee.List<GXml.Namespace>? resolver)
+                                            throws GXml.XPathError;
+
+}
+
+public interface GXml.XPathObject : GLib.Object {
+  /**
+   *
+   */
+  public abstract GXml.XPathObjectType object_type { get; }
+  /**
+   *
+   */
+  public abstract bool boolean_value { get; }
+  /**
+   *
+   */
+  public abstract string string_value { get; }
+  /**
+   *
+   */
+  public abstract double number_value { get; }
+  /**
+   *
+   */
+  public abstract GXml.DomHTMLCollection nodeset { get; }
+}
+


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