[glib/param-speedups2: 15/17] param: Add g_param_value_is_valid




commit 4af7b05c982d9008044a7702b2c17303a490ab1c
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri May 20 08:46:39 2022 -0400

    param: Add g_param_value_is_valid
    
    This is wrapper for the new value_is_valid vfunc.

 gobject/gparam.c | 27 +++++++++++++++++++++++++++
 gobject/gparam.h |  3 +++
 2 files changed, 30 insertions(+)
---
diff --git a/gobject/gparam.c b/gobject/gparam.c
index 4311dbbc68..85a91a5724 100644
--- a/gobject/gparam.c
+++ b/gobject/gparam.c
@@ -705,6 +705,33 @@ g_param_value_validate (GParamSpec *pspec,
   return FALSE;
 }
 
+/**
+ * g_param_value_is_valid:
+ * @pspec: a valid #GParamSpec
+ * @value: a #GValue of correct type for @pspec
+ *
+ * Return whether the contents of @value comply with the specifications
+ * set out by @pspec.
+ *
+ * Returns: whether the contents of @value comply with the specifications
+ * set out by @pspec.
+ *
+ * Since: 2.74
+ */
+gboolean
+g_param_value_is_valid (GParamSpec *pspec,
+                        const GValue *value)
+{
+  g_return_val_if_fail (G_IS_PARAM_SPEC (pspec), TRUE);
+  g_return_val_if_fail (G_IS_VALUE (value), TRUE);
+  g_return_val_if_fail (PSPEC_APPLIES_TO_VALUE (pspec, value), TRUE);
+
+  if (G_PARAM_SPEC_GET_CLASS (pspec)->value_is_valid)
+    return G_PARAM_SPEC_GET_CLASS (pspec)->value_is_valid (pspec, value);
+
+  return TRUE;
+}
+
 /**
  * g_param_value_convert:
  * @pspec: a valid #GParamSpec
diff --git a/gobject/gparam.h b/gobject/gparam.h
index 387201d934..5bb45ad3e2 100644
--- a/gobject/gparam.h
+++ b/gobject/gparam.h
@@ -326,6 +326,9 @@ gboolean    g_param_value_defaults          (GParamSpec    *pspec,
 GLIB_AVAILABLE_IN_ALL
 gboolean       g_param_value_validate          (GParamSpec    *pspec,
                                                 GValue        *value);
+GLIB_AVAILABLE_IN_2_74
+gboolean        g_param_value_is_valid          (GParamSpec    *pspec,
+                                                 const GValue  *value);
 GLIB_AVAILABLE_IN_ALL
 gboolean       g_param_value_convert           (GParamSpec    *pspec,
                                                 const GValue  *src_value,


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