[gxml] Added SerializableFloat class



commit a2ca96e0a1e223527c2ebd5deca404bca8371efa
Author: Daniel Espinosa <esodan gmail com>
Date:   Tue Oct 6 15:00:10 2015 -0500

    Added SerializableFloat class

 gxml/Makefile.am             |    1 +
 gxml/SerializableDouble.vala |    6 +++---
 gxml/SerializableFloat.vala  |   28 ++++++++++++++++++++++++++++
 3 files changed, 32 insertions(+), 3 deletions(-)
---
diff --git a/gxml/Makefile.am b/gxml/Makefile.am
index 3f3fed6..255e0e8 100644
--- a/gxml/Makefile.am
+++ b/gxml/Makefile.am
@@ -58,6 +58,7 @@ sources = \
        SerializableProperty.vala \
        SerializableBool.vala \
        SerializableDouble.vala \
+       SerializableFloat.vala \
        SerializableEnum.vala \
        SerializableInt.vala \
        SerializableValueList.vala \
diff --git a/gxml/SerializableDouble.vala b/gxml/SerializableDouble.vala
index 9683f1e..bf324e2 100644
--- a/gxml/SerializableDouble.vala
+++ b/gxml/SerializableDouble.vala
@@ -27,9 +27,9 @@ using Gee;
  */
 public class GXml.SerializableDouble : SerializableObjectModel, SerializableProperty
 {
-  private string _val = null;
-  private string _name = null;
-  private int _fraction = -1;
+  protected string _val = null;
+  protected string _name = null;
+  protected int _fraction = -1;
   public SerializableDouble.with_name (string name) { _name = name; }
   public int get_fraction () { return _fraction; }
   public void set_fraction (int fraction) {
diff --git a/gxml/SerializableFloat.vala b/gxml/SerializableFloat.vala
new file mode 100644
index 0000000..e807fda
--- /dev/null
+++ b/gxml/SerializableFloat.vala
@@ -0,0 +1,28 @@
+/* -*- 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>
+ */
+
+public class GXml.SerializableFloat : GXml.SerializableDouble
+{
+  public SerializableFloat (string name) { _name = name; }
+  public new float get_value () { return (float) double.parse (_val); }
+  public new void set_value (float val) { _val = val.to_string (); }
+}
\ No newline at end of file


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