On Thursday, 4 October 2018 14:03:48 CET Richard W.M. Jones wrote:
In some places when generating XML output in C code we use some
clever
macros:
start_element ("memory") {
attribute ("unit", "MiB");
string ("%d", g->memsize);
} end_element ();
This commit which is mostly refactoring moves the repeated definitions
of these macros into a common header file.
I also took this opportunity to change / clean up the macros:
- The macros are now documented properly.
- comment() and empty_element() macros are now available everywhere.
- Error handling has been made generic.
- Added do..while(0) around some of the macros to make them safe to
use in all contexts.
- Both string() and attribute() take a format string (previously
there were string_format() and attribute_format() variants).
I'd still keep these variants, as there is no need for a format string
in case there is already the final string to be used.
--
Pino Toscano