enum country_code {
ISO3_AFG = 4, /* Afghanistan */
ISO3_ALB = 8, /* Albania */
ISO3_ATA = 10, /* Antarctica */
ISO3_DZA = 12, /* Algeria \*/
...
} ;
ENUM_DESCRIBE(country3, country_code)
void foo(enum country_code c)
{
printf("Called with C=%s\n", ENUM_LABEL_OF(country3, c)) ;
}
Sharing in the hope that other developer can use this code. Can be integrated into any code with files (".c" source, ".h" header and python code generator) - available on my GitHub (MIT License).
I wrote a small Python module called jsonfold, post processing the output of json.dump() (and other similar serializers). It will selectively fold short lines and small containers while still keeping the JSON readable.
It works as a lightweight wrapper for file-like objects, and it does NOT re-parse the JSON stream, so it can handle large documents with fixed memory usage and linear processing time.
Sample output (line width, level of folding, ... can be customized):
{ "a": { "b": { "c": "abc" } }, "x": { "y": { "z": "xyz" } } }