adg: add adg_dim_get_text() helper method
commit444d4a4dd9335af028641999873b35e674ef8fbf
authorNicola Fontana <ntd@entidi.it>
Thu, 29 Dec 2016 19:09:18 +0000 (29 20:09 +0100)
committerNicola Fontana <ntd@entidi.it>
Thu, 29 Dec 2016 19:14:04 +0000 (29 20:14 +0100)
tree18eca6eb3c6ed1cb4a4c32071554adc87a733256
parentdd7242dfc9eaa9888ac82ae51e2563e9eba17435
adg: add adg_dim_get_text() helper method

A new API to help the common rendering of nominal values.

Originally I wanted to leverage printf and friends but this ended up
being impossible: I must compile the argument list at run-time (because
of AdgDimStyle:number-arguments) but I cannot build va_list dynamically.

So this is a quite hackish implementation that relies on a regex that
looks for printf directives inside AdgDimStyle:number-format and
repeatedly calls g_ascii_formatd() [1].

[1] https://developer.gnome.org/glib/stable/glib-String-Utility-Functions.html#g-ascii-formatd
src/adg/adg-dim-private.h
src/adg/adg-dim.c
src/adg/adg-dim.h
src/adg/tests/test-dim.c