[rygel] core: Introduce SearchExpression.to_string ()



commit 80a0a1c8a4ff2872e7ff13df1d99f7c1c6949e71
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Tue Nov 3 18:09:58 2009 +0200

    core: Introduce SearchExpression.to_string ()

 src/rygel/rygel-search-criteria-parser.vala |   13 +++++++++++--
 src/rygel/rygel-search-expression.vala      |   16 ++++++++++++++--
 2 files changed, 25 insertions(+), 4 deletions(-)
---
diff --git a/src/rygel/rygel-search-criteria-parser.vala b/src/rygel/rygel-search-criteria-parser.vala
index 9788a17..4113441 100644
--- a/src/rygel/rygel-search-criteria-parser.vala
+++ b/src/rygel/rygel-search-criteria-parser.vala
@@ -149,8 +149,17 @@ internal class Rygel.SearchCriteriaParser : Object, StateMachine {
 // and braces.
 private class Rygel.OpenningBrace: Rygel.SearchExpression<void *,
                                                           void *,
-                                                          void *> {}
+                                                          void *> {
+    public override string to_string () {
+        assert_not_reached ();
+    }
+}
+
 private class Rygel.ClosingBrace: Rygel.SearchExpression<void *,
                                                          void *,
-                                                         void *> {}
+                                                         void *> {
+    public override string to_string () {
+        assert_not_reached ();
+    }
+}
 
diff --git a/src/rygel/rygel-search-expression.vala b/src/rygel/rygel-search-expression.vala
index e825a3e..193e6a5 100644
--- a/src/rygel/rygel-search-expression.vala
+++ b/src/rygel/rygel-search-expression.vala
@@ -39,12 +39,24 @@ public abstract class Rygel.SearchExpression<G,H,I> {
     public bool fullfills (MediaObject media_object) {
         return true;
     }
+
+    public abstract string to_string ();
 }
 
 public class Rygel.AtomicExpression :
-              Rygel.SearchExpression<SearchCriteriaOp,string,string> {}
+              Rygel.SearchExpression<SearchCriteriaOp,string,string> {
+    public override string to_string () {
+        return "%s %d %s".printf (this.operand1, this.op, this.operand2);
+    }
+}
 
 public class Rygel.LogicalExpression :
               Rygel.SearchExpression<LogicalOperator,
                                      SearchExpression,
-                                     SearchExpression> {}
+                                     SearchExpression> {
+    public override string to_string () {
+        return "(%s %d %s)".printf (this.operand1.to_string (),
+                                    this.op,
+                                    this.operand2.to_string ());
+    }
+}



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