[gst-cvs] gstreamer-sharp: Add a method to convert an integer value into the Flags/ EnumValues

Sebastian Dröge slomo at kemper.freedesktop.org
Thu May 14 08:16:04 PDT 2009


Module: gstreamer-sharp
Branch: master
Commit: 1811d89b6e6083407c028746b0669cdc37ca644a
URL:    http://cgit.freedesktop.org/gstreamer/gstreamer-sharp/commit/?id=1811d89b6e6083407c028746b0669cdc37ca644a

Author: Sebastian Dröge <sebastian.droege at collabora.co.uk>
Date:   Tue May 12 15:49:44 2009 +0200

Add a method to convert an integer value into the Flags/EnumValues

---

 gstreamer-sharp/EnumInfo.cs |   26 ++++++++++++++++++++++++++
 1 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/gstreamer-sharp/EnumInfo.cs b/gstreamer-sharp/EnumInfo.cs
index 4a6a4e4..e8348f6 100644
--- a/gstreamer-sharp/EnumInfo.cs
+++ b/gstreamer-sharp/EnumInfo.cs
@@ -101,6 +101,17 @@ namespace Gst {
       }
     }
 
+    public EnumValue this[int val] {
+      get {
+	foreach (EnumValue v in Values) {
+	  if (v.value == val)
+	    return v;
+	}
+
+	throw new Exception ();
+      }
+    }
+
     public static bool IsEnumType (GLib.GType gtype) {
       return (g_type_is_a (gtype.Val, GType.Enum.Val));
     }
@@ -176,6 +187,21 @@ namespace Gst {
       return (g_type_is_a (gtype.Val, GType.Flags.Val));
     }
 
+    public FlagsValue[] this[uint flags] {
+      get {
+        System.Collections.ArrayList ret = new System.Collections.ArrayList ();
+
+	foreach (FlagsValue v in Values) {
+	  if (flags == 0 && v.value == 0)
+	    ret.Add (v);
+	  else if ((v.value & flags) != 0)
+	    ret.Add (v);
+	}
+
+	return (FlagsValue[]) ret.ToArray (typeof (FlagsValue));
+      }
+    }
+
     public FlagsInfo (GLib.GType gtype) {
       if (!IsFlagsType (gtype))
         throw new ArgumentException ();





More information about the Gstreamer-commits mailing list