[gxml] Added SerializableInt class
- From: Daniel Espinosa Ortiz <despinosa src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gxml] Added SerializableInt class
- Date: Tue, 6 Oct 2015 13:46:45 +0000 (UTC)
commit 259f898f4caa1ea85063f64ca6c3eadf760956b7
Author: Daniel Espinosa <esodan gmail com>
Date: Tue Oct 6 08:35:02 2015 -0500
Added SerializableInt class
gxml/Makefile.am | 1 +
gxml/SerializableInt.vala | 69 +++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 70 insertions(+), 0 deletions(-)
---
diff --git a/gxml/Makefile.am b/gxml/Makefile.am
index 7039dda..30bcd30 100644
--- a/gxml/Makefile.am
+++ b/gxml/Makefile.am
@@ -58,6 +58,7 @@ sources = \
SerializableProperty.vala \
SerializableBool.vala \
SerializableEnum.vala \
+ SerializableInt.vala \
SerializableValueList.vala \
Enumeration.vala \
SerializableObjectModel.vala \
diff --git a/gxml/SerializableInt.vala b/gxml/SerializableInt.vala
new file mode 100644
index 0000000..adfd14e
--- /dev/null
+++ b/gxml/SerializableInt.vala
@@ -0,0 +1,69 @@
+/* -*- Mode: vala; indent-tabs-mode: nil; c-basic-offset: 2; tab-width: 2 -*- */
+/* SerializableInt.vala
+ *
+ * Copyright (C) 2015 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>
+ */
+
+using Gee;
+/**
+ * Represent any boolean property to be added as a { link GXml.Attr} to a { link GXml.Element}
+ *
+ */
+public class GXml.SerializableInt : SerializableObjectModel, SerializableProperty
+{
+ private string _val = null;
+ private string _name = null;
+ public SerializableInt.with_name (string name) { _name = name; }
+ public int get_value () { return (int) double.parse (_val); }
+ public void set_value (int val) { _val = val.to_string (); }
+ public string get_serializable_property_value () { return _val; }
+ public void set_serializable_property_value (string? val) {
+ if (val == null)
+ _val = val;
+ else
+ _val = ((int) double.parse (val)).to_string ();
+ }
+ public string get_serializable_property_name () { return _name; }
+ public void set_serializable_property_name (string name) { _name = name; }
+ public override GXml.Node? serialize (GXml.Node node) throws GLib.Error
+ {
+ return default_serializable_property_serialize (node);
+ }
+ public override GXml.Node? serialize_property (GXml.Node element,
+ GLib.ParamSpec prop)
+ throws GLib.Error
+ {
+ return default_serializable_property_serialize_property (element, prop);
+ }
+ public override GXml.Node? deserialize (GXml.Node node)
+ throws GLib.Error
+ {
+ return default_serializable_property_deserialize (node);
+ }
+ public override bool deserialize_property (GXml.Node property_node)
+ throws GLib.Error
+ {
+ default_serializable_property_deserialize (property_node);
+ return true;
+ }
+ public override string to_string () {
+ if (_val != null) return ((int) double.parse (_val)).to_string ();
+ return false.to_string ();
+ }
+}
\ No newline at end of file
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]