Does anyone have a completed version of a d analogue to php's var_dump?
Kevin Brogan via Digitalmars-d
digitalmars-d at puremagic.com
Fri Feb 24 22:22:02 PST 2017
I can dump a struct easily enough with the following. I'm
wondering if anyone else has done all the work to make it work
for every type? https://code.dlang.org/ is down at the moment so
I can't check there, and google hasn't been helpful.
========================================================================================
import std.traits;
void main()
{
WSADATA wsa;
dump!wsa;
}
void dump(alias variable)()
{
writeln("\nDumping ",typeid(typeof(variable)),":\n");
writeln(variable.stringof, " = \n{");
foreach(member; FieldNameTuple!(typeof(variable)))
{
writeln("\t", member, ": ", mixin("variable."~member) );
}
writeln("}\n");
}
========================================================================================
More information about the Digitalmars-d
mailing list