[libgxps] Add gxps_value_get_double_positive() to parse positive real numbers
- From: Carlos Garcia Campos <carlosgc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgxps] Add gxps_value_get_double_positive() to parse positive real numbers
- Date: Sun, 6 Nov 2011 12:05:36 +0000 (UTC)
commit 45f5bb25dd38e6241ecd6d3e2daa78e6dd0fb585
Author: Carlos Garcia Campos <carlosgc gnome org>
Date: Sun Nov 6 12:47:19 2011 +0100
Add gxps_value_get_double_positive() to parse positive real numbers
It's the same than gxps_value_get_double() but this one fails if the
parsed number is not greater or equal than 1.
libgxps/gxps-parse-utils.c | 10 ++++++++++
libgxps/gxps-parse-utils.h | 34 ++++++++++++++++++----------------
2 files changed, 28 insertions(+), 16 deletions(-)
---
diff --git a/libgxps/gxps-parse-utils.c b/libgxps/gxps-parse-utils.c
index 23d048b..b509ee3 100644
--- a/libgxps/gxps-parse-utils.c
+++ b/libgxps/gxps-parse-utils.c
@@ -292,6 +292,16 @@ gxps_value_get_double (const gchar *value,
return TRUE;
}
+gboolean
+gxps_value_get_double_positive (const gchar *value,
+ gdouble *double_value)
+{
+ if (!gxps_value_get_double (value, double_value))
+ return FALSE;
+
+ return *double_value >= 1;
+}
+
gchar *
gxps_resolve_relative_path (const gchar *source,
const gchar *target)
diff --git a/libgxps/gxps-parse-utils.h b/libgxps/gxps-parse-utils.h
index 410076e..6c1e391 100644
--- a/libgxps/gxps-parse-utils.h
+++ b/libgxps/gxps-parse-utils.h
@@ -24,22 +24,24 @@
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);
-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);
+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]