[geary/mjog/search-update: 16/29] Geary.NamedFlag: Add serialise method for non-debug persistence




commit 5d2377995e5a900dfbf538ebc8a4e24b8b12fb85
Author: Michael Gratton <mike vee net>
Date:   Wed Nov 4 00:51:38 2020 +1100

    Geary.NamedFlag: Add serialise method for non-debug persistence

 src/engine/api/geary-contact.vala     |  2 +-
 src/engine/api/geary-named-flag.vala  |  3 +--
 src/engine/api/geary-named-flags.vala | 12 +++++++++++-
 3 files changed, 13 insertions(+), 4 deletions(-)
---
diff --git a/src/engine/api/geary-contact.vala b/src/engine/api/geary-contact.vala
index 7da8e6ca0..63f43071b 100644
--- a/src/engine/api/geary-contact.vala
+++ b/src/engine/api/geary-contact.vala
@@ -43,7 +43,7 @@ public class Geary.Contact : BaseObject {
         public string serialize() {
             string ret = "";
             foreach (NamedFlag flag in list) {
-                ret += flag.serialize() + " ";
+                ret += flag.serialise() + " ";
             }
 
             return ret.strip();
diff --git a/src/engine/api/geary-named-flag.vala b/src/engine/api/geary-named-flag.vala
index eefd8824a..7472de3ff 100644
--- a/src/engine/api/geary-named-flag.vala
+++ b/src/engine/api/geary-named-flag.vala
@@ -28,7 +28,7 @@ public class Geary.NamedFlag : BaseObject, Gee.Hashable<Geary.NamedFlag> {
         return name.down().hash();
     }
 
-    public string serialize() {
+    public string serialise() {
         return name;
     }
 
@@ -36,4 +36,3 @@ public class Geary.NamedFlag : BaseObject, Gee.Hashable<Geary.NamedFlag> {
         return name;
     }
 }
-
diff --git a/src/engine/api/geary-named-flags.vala b/src/engine/api/geary-named-flags.vala
index 56e486134..08fc1bad5 100644
--- a/src/engine/api/geary-named-flags.vala
+++ b/src/engine/api/geary-named-flags.vala
@@ -90,6 +90,17 @@ public class Geary.NamedFlags : BaseObject, Gee.Hashable<Geary.NamedFlags> {
         return Geary.String.stri_hash(to_string());
     }
 
+    /** Formats the flags for serialising in the database. */
+    public string serialise() {
+        var builder = new GLib.StringBuilder();
+        foreach (NamedFlag flag in this.list) {
+            builder.append(flag.serialise());
+            builder.append_c(' ');
+        }
+        return builder.str;
+    }
+
+    /** Formats the flags for debugging. */
     public string to_string() {
         string ret = "[";
         foreach (NamedFlag flag in list) {
@@ -99,4 +110,3 @@ public class Geary.NamedFlags : BaseObject, Gee.Hashable<Geary.NamedFlags> {
         return ret + "]";
     }
 }
-


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