[libgxps] utils: Add gxps_value_get_double_non_negative()



commit b011d90cb202cfd1be99cb3e496f82b1b1833c49
Author: Carlos Garcia Campos <carlosgc gnome org>
Date:   Tue Nov 26 10:49:27 2013 +0100

    utils: Add gxps_value_get_double_non_negative()
    
    To parse non negative doubles.

 libgxps/gxps-parse-utils.c |   10 ++++++++
 libgxps/gxps-parse-utils.h |   52 ++++++++++++++++++++++---------------------
 2 files changed, 37 insertions(+), 25 deletions(-)
---
diff --git a/libgxps/gxps-parse-utils.c b/libgxps/gxps-parse-utils.c
index 18127d0..8a54111 100644
--- a/libgxps/gxps-parse-utils.c
+++ b/libgxps/gxps-parse-utils.c
@@ -321,6 +321,16 @@ gxps_value_get_double_positive (const gchar *value,
 }
 
 gboolean
+gxps_value_get_double_non_negative (const gchar *value,
+                                    gdouble     *double_value)
+{
+        if (!gxps_value_get_double (value, double_value))
+                return FALSE;
+
+        return *double_value >= 0;
+}
+
+gboolean
 gxps_point_parse (const gchar *point,
                   gdouble     *x,
                   gdouble     *y)
diff --git a/libgxps/gxps-parse-utils.h b/libgxps/gxps-parse-utils.h
index 9dbdefa..d5cb341 100644
--- a/libgxps/gxps-parse-utils.h
+++ b/libgxps/gxps-parse-utils.h
@@ -24,31 +24,33 @@
 
 G_BEGIN_DECLS
 
-gboolean gxps_parse_stream              (GMarkupParseContext  *context,
-                                         GInputStream         *stream,
-                                         GError              **error);
-void     gxps_parse_error               (GMarkupParseContext  *context,
-                                         const gchar          *source,
-                                         GMarkupError          error_type,
-                                         const gchar          *element_name,
-                                         const gchar          *attribute_name,
-                                         const gchar          *content,
-                                         GError              **error);
-gboolean gxps_value_get_int             (const gchar          *value,
-                                         gint                 *int_value);
-gboolean gxps_value_get_double          (const gchar          *value,
-                                         gdouble              *double_value);
-gboolean gxps_value_get_double_positive (const gchar          *value,
-                                         gdouble              *double_value);
-gboolean gxps_value_get_boolean         (const gchar          *value,
-                                         gboolean             *boolean_value);
-gboolean gxps_point_parse               (const gchar          *point,
-                                         gdouble              *x,
-                                         gdouble              *y);
-void     gxps_parse_skip_number         (gchar               **iter,
-                                         const gchar          *end);
-gchar   *gxps_resolve_relative_path     (const gchar          *source,
-                                         const gchar          *target);
+gboolean gxps_parse_stream                  (GMarkupParseContext  *context,
+                                             GInputStream         *stream,
+                                             GError              **error);
+void     gxps_parse_error                   (GMarkupParseContext  *context,
+                                             const gchar          *source,
+                                             GMarkupError          error_type,
+                                             const gchar          *element_name,
+                                             const gchar          *attribute_name,
+                                             const gchar          *content,
+                                             GError              **error);
+gboolean gxps_value_get_int                 (const gchar          *value,
+                                             gint                 *int_value);
+gboolean gxps_value_get_double              (const gchar          *value,
+                                             gdouble              *double_value);
+gboolean gxps_value_get_double_positive     (const gchar          *value,
+                                             gdouble              *double_value);
+gboolean gxps_value_get_double_non_negative (const gchar          *value,
+                                             gdouble              *double_value);
+gboolean gxps_value_get_boolean             (const gchar          *value,
+                                             gboolean             *boolean_value);
+gboolean gxps_point_parse                   (const gchar          *point,
+                                             gdouble              *x,
+                                             gdouble              *y);
+void     gxps_parse_skip_number             (gchar               **iter,
+                                             const gchar          *end);
+gchar   *gxps_resolve_relative_path         (const gchar          *source,
+                                             const gchar          *target);
 
 G_END_DECLS
 


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