libmm-glib,helpers: allow reading hex strings from match info

This commit is contained in:
Aleksander Morgado
2020-03-24 06:22:34 +01:00
parent 539562af01
commit 1c7304eb71
2 changed files with 31 additions and 0 deletions

View File

@@ -1491,6 +1491,31 @@ mm_get_u64_from_match_info (GMatchInfo *match_info,
return (s ? mm_get_u64_from_str (s, out) : FALSE); return (s ? mm_get_u64_from_str (s, out) : FALSE);
} }
gboolean
mm_get_uint_from_hex_match_info (GMatchInfo *match_info,
guint32 match_index,
guint *out)
{
guint64 num;
if (!mm_get_u64_from_hex_match_info (match_info, match_index, &num) || num > G_MAXUINT)
return FALSE;
*out = (guint)num;
return TRUE;
}
gboolean
mm_get_u64_from_hex_match_info (GMatchInfo *match_info,
guint32 match_index,
guint64 *out)
{
g_autofree gchar *s = NULL;
s = mm_get_string_unquoted_from_match_info (match_info, match_index);
return (s ? mm_get_u64_from_hex_str (s, out) : FALSE);
}
gboolean gboolean
mm_get_double_from_str (const gchar *str, mm_get_double_from_str (const gchar *str,
gdouble *out) gdouble *out)

View File

@@ -164,6 +164,12 @@ gboolean mm_get_uint_from_match_info (GMatchInfo *match_info,
gboolean mm_get_u64_from_match_info (GMatchInfo *match_info, gboolean mm_get_u64_from_match_info (GMatchInfo *match_info,
guint32 match_index, guint32 match_index,
guint64 *out); guint64 *out);
gboolean mm_get_uint_from_hex_match_info (GMatchInfo *match_info,
guint32 match_index,
guint *out);
gboolean mm_get_u64_from_hex_match_info (GMatchInfo *match_info,
guint32 match_index,
guint64 *out);
gboolean mm_get_double_from_str (const gchar *str, gboolean mm_get_double_from_str (const gchar *str,
gdouble *out); gdouble *out);
gboolean mm_get_double_from_match_info (GMatchInfo *match_info, gboolean mm_get_double_from_match_info (GMatchInfo *match_info,