[babl] babl: add babl_format_exists



commit 4500e4f9fa9030bebe1a0a65e2b3634b1122772b
Author: Øyvind Kolås <pippin gimp org>
Date:   Tue Oct 31 20:48:23 2017 +0100

    babl: add babl_format_exists
    
    A function to check if a specific format - by name - is already known by babl.
    Should be used in conjunction with babl_format() for user supplied format
    strings.

 babl/babl-format.c |    9 +++++++++
 babl/babl.h        |    9 +++++++++
 2 files changed, 18 insertions(+), 0 deletions(-)
---
diff --git a/babl/babl-format.c b/babl/babl-format.c
index 079272c..45c62b2 100644
--- a/babl/babl-format.c
+++ b/babl/babl-format.c
@@ -748,4 +748,13 @@ babl_format_with_space (const char *name, const Babl *space)
   return ret;
 }
 
+int
+babl_format_exists (const char *name)
+{
+  if (babl_db_exist_by_name (db, name))
+    return 1;
+  return 0;
+}
+
+
 
diff --git a/babl/babl.h b/babl/babl.h
index 5e299a7..a45de42 100644
--- a/babl/babl.h
+++ b/babl/babl.h
@@ -157,6 +157,15 @@ char *babl_icc_get_key (const char *icc_data,
 const Babl * babl_format            (const char *name);
 
 /**
+ * babl_format_exists:
+ *
+ * Returns 1 if the provided format name is known by babl or 0 if it is
+ * not. Can also be used to verify that specific extension formats are
+ * available (though this can also be inferred from the version of babl).
+ */
+int babl_format_exists              (const char *name);
+
+/**
  * babl_format_with_space:
  *
  * Returns the babl object representing the color format given by


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