[gxml] Added SerializableBool class
- From: Daniel Espinosa Ortiz <despinosa src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gxml] Added SerializableBool class
- Date: Tue, 29 Sep 2015 21:36:11 +0000 (UTC)
commit d99dc6cb1b85bf8a7a84d3af33f47156c910d969
Author: Daniel Espinosa <esodan gmail com>
Date: Sat Sep 26 16:47:27 2015 -0700
Added SerializableBool class
gxml/Makefile.am | 1 +
gxml/SerializableBool.vala | 62 ++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 63 insertions(+), 0 deletions(-)
---
diff --git a/gxml/Makefile.am b/gxml/Makefile.am
index 959721a..922b914 100644
--- a/gxml/Makefile.am
+++ b/gxml/Makefile.am
@@ -56,6 +56,7 @@ sources = \
libxml-Text.vala \
Serializable.vala \
SerializableProperty.vala \
+ SerializableBool.vala \
Enumeration.vala \
SerializableObjectModel.vala \
SerializableJson.vala \
diff --git a/gxml/SerializableBool.vala b/gxml/SerializableBool.vala
new file mode 100644
index 0000000..d16dea4
--- /dev/null
+++ b/gxml/SerializableBool.vala
@@ -0,0 +1,62 @@
+/* -*- Mode: vala; indent-tabs-mode: nil; c-basic-offset: 2; tab-width: 2 -*- */
+/* SerializableBool.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.SerializableBool : SerializableObjectModel, SerializableProperty
+{
+ private string _val = null;
+ private string _name = null;
+ public SerializableBool.with_name (string name) { _name = name; }
+ public string get_serializable_property_value () { return _val; }
+ public void set_serializable_property_value (string val) { _val = (bool.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 (bool.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]